summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 9e99a646b0b..8cf37f48a27 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -67,6 +67,8 @@ CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
DBuilder(CGM.getModule()) {
for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap)
DebugPrefixMap[KV.first] = KV.second;
+ EmitFileChecksums = CGM.getCodeGenOpts().EmitCodeView ||
+ CGM.getCodeGenOpts().DwarfVersion >= 5;
CreateCompileUnit();
}
@@ -365,15 +367,21 @@ Optional<llvm::DIFile::ChecksumKind>
CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const {
Checksum.clear();
- if (!CGM.getCodeGenOpts().EmitCodeView &&
- CGM.getCodeGenOpts().DwarfVersion < 5)
+ if (!EmitFileChecksums)
return None;
SourceManager &SM = CGM.getContext().getSourceManager();
bool Invalid;
- llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid);
- if (Invalid)
+ const SrcMgr::SLocEntry &Entry = SM.getSLocEntry(FID, &Invalid);
+ if (Invalid || !Entry.isFile())
return None;
+ if (Entry.getFile().hasLineDirectives()) {
+ // This must be a preprocessed file; its content won't match the original
+ // source; therefore checksumming the text we have is pointless or wrong.
+ EmitFileChecksums = false;
+ return None;
+ }
+ llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID);
llvm::MD5 Hash;
llvm::MD5::MD5Result Result;
OpenPOWER on IntegriCloud