Skip to content

Commit dce6577

Browse files
Handle invalid locations
1 parent 7ece9f5 commit dce6577

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,20 +563,18 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(const PresumedLoc &PLoc) {
563563
StringRef FileName;
564564
FileID FID;
565565
std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
566-
566+
SourceManager &SM = CGM.getContext().getSourceManager();
567567
if (PLoc.isInvalid()) {
568568
// The DIFile used by the CU is distinct from the main source file. Call
569569
// createFile() below for canonicalization if the source file was specified
570570
// with an absolute path.
571571
FileName = TheCU->getFile()->getFilename();
572572
CSInfo = TheCU->getFile()->getChecksum();
573+
FID = SM.getFileID(SourceLocation());
573574
} else {
574575
FileName = PLoc.getFilename();
575-
576576
if (FileName.empty()) {
577577
FileName = TheCU->getFile()->getFilename();
578-
} else {
579-
FileName = PLoc.getFilename();
580578
}
581579
FID = PLoc.getFileID();
582580
}
@@ -597,8 +595,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(const PresumedLoc &PLoc) {
597595
if (CSKind)
598596
CSInfo.emplace(*CSKind, Checksum);
599597
}
600-
SourceManager &SM = CGM.getContext().getSourceManager();
601-
return createFile(FileName, CSInfo, getSource(SM, PLoc.getFileID()));
598+
return createFile(FileName, CSInfo, getSource(SM, FID));
602599
}
603600

604601
llvm::DIFile *CGDebugInfo::createFile(

0 commit comments

Comments
 (0)