[clang] [clang][DebugInfo] Remove unnessesary call to `SM.getFileLoc` when calling `SM.getPresumedLoc` (PR #166544)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 17 04:55:20 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-clang
Author: Sergej Salnikov (SergejSalnikov)
<details>
<summary>Changes</summary>
This is no longer required after #<!-- -->166255
---
Full diff: https://github.com/llvm/llvm-project/pull/166544.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+7-8)
``````````diff
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ca579c915f49d..6c1e0038a4316 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -345,7 +345,7 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
if (Loc.isInvalid())
return;
- CurLoc = CGM.getContext().getSourceManager().getFileLoc(Loc);
+ CurLoc = Loc;
// If we've changed files in the middle of a lexical scope go ahead
// and create a new lexical scope with file node if it's different
@@ -571,8 +571,9 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
// with an absolute path.
FileName = TheCU->getFile()->getFilename();
CSInfo = TheCU->getFile()->getChecksum();
+ FID = SM.getFileID(Loc);
} else {
- PresumedLoc PLoc = SM.getPresumedLoc(SM.getFileLoc(Loc));
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc);
FileName = PLoc.getFilename();
if (FileName.empty()) {
@@ -599,8 +600,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
}
- return createFile(FileName, CSInfo,
- getSource(SM, SM.getFileID(SM.getFileLoc(Loc))));
+ return createFile(FileName, CSInfo, getSource(SM, FID));
}
llvm::DIFile *CGDebugInfo::createFile(
@@ -655,7 +655,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
if (Loc.isInvalid())
return 0;
SourceManager &SM = CGM.getContext().getSourceManager();
- return SM.getPresumedLoc(SM.getFileLoc(Loc)).getLine();
+ return SM.getPresumedLoc(Loc).getLine();
}
unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
@@ -667,8 +667,7 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
if (Loc.isInvalid() && CurLoc.isInvalid())
return 0;
SourceManager &SM = CGM.getContext().getSourceManager();
- PresumedLoc PLoc =
- SM.getPresumedLoc(Loc.isValid() ? SM.getFileLoc(Loc) : CurLoc);
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc);
return PLoc.isValid() ? PLoc.getColumn() : 0;
}
@@ -6281,7 +6280,7 @@ void CGDebugInfo::AddStringLiteralDebugInfo(llvm::GlobalVariable *GV,
const StringLiteral *S) {
SourceLocation Loc = S->getStrTokenLoc(0);
SourceManager &SM = CGM.getContext().getSourceManager();
- PresumedLoc PLoc = SM.getPresumedLoc(SM.getFileLoc(Loc));
+ PresumedLoc PLoc = SM.getPresumedLoc(Loc);
if (!PLoc.isValid())
return;
``````````
</details>
https://github.com/llvm/llvm-project/pull/166544
More information about the cfe-commits
mailing list