[clang] b7c4ac2 - NFC, use structured binding to simplify the code.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 7 08:08:10 PDT 2025
Author: Haojian Wu
Date: 2025-07-07T17:07:37+02:00
New Revision: b7c4ac2db4cdd99203b836bd94b3392fd7536de5
URL: https://github.com/llvm/llvm-project/commit/b7c4ac2db4cdd99203b836bd94b3392fd7536de5
DIFF: https://github.com/llvm/llvm-project/commit/b7c4ac2db4cdd99203b836bd94b3392fd7536de5.diff
LOG: NFC, use structured binding to simplify the code.
Added:
Modified:
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/Indexing.cpp
clang/unittests/Index/IndexTests.cpp
Removed:
################################################################################
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 3beff3d6d849f..4ebec8e074330 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -2466,9 +2466,7 @@ void ASTUnit::addFileLevelDecl(Decl *D) {
SourceLocation FileLoc = SM.getFileLoc(Loc);
assert(SM.isLocalSourceLocation(FileLoc));
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedLoc(FileLoc);
+ auto [FID, Offset] = SM.getDecomposedLoc(FileLoc);
if (FID.isInvalid())
return;
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 30ac48b8010b8..46b04420eb627 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -929,9 +929,7 @@ static CharSourceRange makeRangeFromFileLocs(CharSourceRange Range,
}
// Break down the source locations.
- FileID FID;
- unsigned BeginOffs;
- std::tie(FID, BeginOffs) = SM.getDecomposedLoc(Begin);
+ auto [FID, BeginOffs] = SM.getDecomposedLoc(Begin);
if (FID.isInvalid())
return {};
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 2bd9ae50b72e7..5086f8f5be63b 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -6968,9 +6968,7 @@ void ASTWriter::associateDeclWithFile(const Decl *D, LocalDeclID ID) {
SourceManager &SM = PP->getSourceManager();
SourceLocation FileLoc = SM.getFileLoc(Loc);
assert(SM.isLocalSourceLocation(FileLoc));
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedLoc(FileLoc);
+ auto [FID, Offset] = SM.getDecomposedLoc(FileLoc);
if (FID.isInvalid())
return;
assert(SM.getSLocEntry(FID).isFile());
diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp
index 3cd49bf90235b..32a7147af3382 100644
--- a/clang/tools/libclang/Indexing.cpp
+++ b/clang/tools/libclang/Indexing.cpp
@@ -389,9 +389,7 @@ class IndexingFrontendAction : public ASTFrontendAction {
if (SM.isInSystemHeader(Loc))
return true; // always skip bodies from system headers.
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedLoc(Loc);
+ auto [FID, Offset] = SM.getDecomposedLoc(Loc);
// Don't skip bodies from main files; this may be revisited.
if (SM.getMainFileID() == FID)
return false;
diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp
index 8e9a1c6bf8824..05ce448237fdf 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -35,9 +35,7 @@ struct Position {
static Position fromSourceLocation(SourceLocation Loc,
const SourceManager &SM) {
- FileID FID;
- unsigned Offset;
- std::tie(FID, Offset) = SM.getDecomposedSpellingLoc(Loc);
+ auto [FID, Offset] = SM.getDecomposedSpellingLoc(Loc);
Position P;
P.Line = SM.getLineNumber(FID, Offset);
P.Column = SM.getColumnNumber(FID, Offset);
More information about the cfe-commits
mailing list