diff options
author | Paul Robinson <paul.robinson@sony.com> | 2018-05-25 20:59:29 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2018-05-25 20:59:29 +0000 |
commit | 638d606f83e7c12b5e3949ad5ad5757c603bd1b5 (patch) | |
tree | f301aaeafb027a0b73b8778e631ea86894e5b8a2 /clang/lib/CodeGen | |
parent | 11c1c266ccd06267516fdb0118513d3fe8cfaa52 (diff) | |
download | bcm5719-llvm-638d606f83e7c12b5e3949ad5ad5757c603bd1b5.tar.gz bcm5719-llvm-638d606f83e7c12b5e3949ad5ad5757c603bd1b5.zip |
[DebugInfo] Don't bother with MD5 checksums of preprocessed files.
The checksum will not reflect the real source, so there's no clear
reason to include them in the debug info. Also this was causing a
crash on the DWARF side.
Differential Revision: https://reviews.llvm.org/D47260
llvm-svn: 333311
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 16 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 1 |
2 files changed, 13 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; diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index a692babef53..ec7b046c8f3 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -57,6 +57,7 @@ class CGDebugInfo { CodeGenModule &CGM; const codegenoptions::DebugInfoKind DebugKind; bool DebugTypeExtRefs; + mutable bool EmitFileChecksums; llvm::DIBuilder DBuilder; llvm::DICompileUnit *TheCU = nullptr; ModuleMap *ClangModuleMap = nullptr; |