aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authoryronglin <yronglin777@gmail.com>2025-04-16 20:53:25 +0800
committerGitHub <noreply@github.com>2025-04-16 20:53:25 +0800
commitd3153ad66c539ad146062b6e65741901e5b5e1cc (patch)
tree2e2340c0ef9215149ec7f46256830437e5e547fb /clang/lib/Lex/Preprocessor.cpp
parentfe4a31d59db7b18dc45c3593bf100c101e725b79 (diff)
downloadllvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.zip
llvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.tar.gz
llvm-d3153ad66c539ad146062b6e65741901e5b5e1cc.tar.bz2
[clang] Unify `SourceLocation` and `IdentifierInfo*` pair-like data structures to `IdentifierLoc` (#135808)
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;