Skip to content

Conversation

@SergejSalnikov
Copy link
Contributor

It's a non-functional change.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. debuginfo labels Nov 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2025

@llvm/pr-subscribers-clang-codegen
@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-clang

Author: SKill (SergejSalnikov)

Changes

It's a non-functional change.


Full diff: https://github.com/llvm/llvm-project/pull/166530.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+6-7)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index ca579c915f49d..8a3180a099d17 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -565,20 +565,20 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
   FileID FID;
   std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
 
+  llvm::DIFile *CUFile = TheCU->getFile();
   if (Loc.isInvalid()) {
     // The DIFile used by the CU is distinct from the main source file. Call
     // createFile() below for canonicalization if the source file was specified
     // with an absolute path.
-    FileName = TheCU->getFile()->getFilename();
-    CSInfo = TheCU->getFile()->getChecksum();
+    FileName = CUFile->getFilename();
+    CSInfo = CUFile->getChecksum();
+    FID = SM.getFileID(Loc);
   } else {
     PresumedLoc PLoc = SM.getPresumedLoc(SM.getFileLoc(Loc));
     FileName = PLoc.getFilename();
 
     if (FileName.empty()) {
-      FileName = TheCU->getFile()->getFilename();
-    } else {
-      FileName = PLoc.getFilename();
+      FileName = CUFile->getFilename();
     }
     FID = PLoc.getFileID();
   }
@@ -599,8 +599,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(

@SergejSalnikov
Copy link
Contributor Author

This PR also contains #166530, which I was hoping to merge before that one goes in.

@SergejSalnikov SergejSalnikov changed the title Slight refactoring of CGDebugInfo::getOrCreateFile. [clang] Slight refactoring of CGDebugInfo::getOrCreateFile Nov 5, 2025
@SergejSalnikov SergejSalnikov changed the title [clang] Slight refactoring of CGDebugInfo::getOrCreateFile [clang][DebugInfo] Slight refactoring of CGDebugInfo::getOrCreateFile Nov 5, 2025
@SergejSalnikov SergejSalnikov changed the title [clang][DebugInfo] Slight refactoring of CGDebugInfo::getOrCreateFile [clang][DebugInfo] Slight refactoring of getOrCreateFile Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category debuginfo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants