aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authoryronglin <yronglin777@gmail.com>2025-04-17 22:40:47 +0800
committerGitHub <noreply@github.com>2025-04-17 22:40:47 +0800
commitd83b639b4c62924deef504f46e573e7d995ea10d (patch)
treefda59205ff14c0c04d49ec15db174456c5cb42fa /clang/lib/Lex/Preprocessor.cpp
parent78857e7263ba555fb40b286c6b40fcd35a85a65a (diff)
downloadllvm-d83b639b4c62924deef504f46e573e7d995ea10d.zip
llvm-d83b639b4c62924deef504f46e573e7d995ea10d.tar.gz
llvm-d83b639b4c62924deef504f46e573e7d995ea10d.tar.bz2
Reland [clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (#136077)
This PR reland https://github.com/llvm/llvm-project/pull/135808, fixed some missed changes in LLDB. I found this issue when I working on https://github.com/llvm/llvm-project/pull/107168. Currently we have many similiar data structures like: - std::pair<IdentifierInfo *, SourceLocation>. - Element type of ModuleIdPath. - IdentifierLocPair. - IdentifierLoc. This PR unify these data structures to IdentifierLoc, moved IdentifierLoc definition to SourceLocation.h, and deleted other similer data structures. --------- Signed-off-by: yronglin <yronglin777@gmail.com>
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index c25a3ef..4c050bf 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1159,8 +1159,8 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) {
if (Result.is(tok::colon) && ModuleDeclState.isNamedModule()) {
std::string Name = ModuleDeclState.getPrimaryName().str();
Name += ":";
- NamedModuleImportPath.push_back(
- {getIdentifierInfo(Name), Result.getLocation()});
+ NamedModuleImportPath.emplace_back(Result.getLocation(),
+ getIdentifierInfo(Name));
CurLexerCallback = CLK_LexAfterModuleImport;
return true;
}
@@ -1258,8 +1258,8 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) {
if (ModuleImportExpectsIdentifier && Result.getKind() == tok::identifier) {
// We expected to see an identifier here, and we did; continue handling
// identifiers.
- NamedModuleImportPath.push_back(
- std::make_pair(Result.getIdentifierInfo(), Result.getLocation()));
+ NamedModuleImportPath.emplace_back(Result.getLocation(),
+ Result.getIdentifierInfo());
ModuleImportExpectsIdentifier = false;
CurLexerCallback = CLK_LexAfterModuleImport;
return true;
@@ -1302,12 +1302,12 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) {
// If the FlatModuleName ends with colon, it implies it is a partition.
if (!FlatModuleName.empty() && FlatModuleName.back() != ':')
FlatModuleName += ".";
- FlatModuleName += Piece.first->getName();
+ FlatModuleName += Piece.getIdentifierInfo()->getName();
}
- SourceLocation FirstPathLoc = NamedModuleImportPath[0].second;
+ SourceLocation FirstPathLoc = NamedModuleImportPath[0].getLoc();
NamedModuleImportPath.clear();
- NamedModuleImportPath.push_back(
- std::make_pair(getIdentifierInfo(FlatModuleName), FirstPathLoc));
+ NamedModuleImportPath.emplace_back(FirstPathLoc,
+ getIdentifierInfo(FlatModuleName));
}
Module *Imported = nullptr;