Index: lib/CodeGen/CGDebugInfo.h =================================================================== --- lib/CodeGen/CGDebugInfo.h +++ lib/CodeGen/CGDebugInfo.h @@ -499,8 +499,8 @@ std::string remapDIPath(StringRef) const; /// Compute the file checksum debug info for input file ID. - llvm::DIFile::ChecksumKind computeChecksum(FileID FID, - SmallString<32> &Checksum) const; + Optional + computeChecksum(FileID FID, SmallString<32> &Checksum) const; /// Get the file debug info descriptor for the input location. llvm::DIFile *getOrCreateFile(SourceLocation Loc); Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -361,19 +361,19 @@ return StringRef(); } -llvm::DIFile::ChecksumKind +Optional CGDebugInfo::computeChecksum(FileID FID, SmallString<32> &Checksum) const { Checksum.clear(); if (!CGM.getCodeGenOpts().EmitCodeView && CGM.getCodeGenOpts().DwarfVersion < 5) - return llvm::DIFile::CSK_None; + return None; SourceManager &SM = CGM.getContext().getSourceManager(); bool Invalid; llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, &Invalid); if (Invalid) - return llvm::DIFile::CSK_None; + return None; llvm::MD5 Hash; llvm::MD5::MD5Result Result; @@ -390,7 +390,6 @@ // If Location is not valid then use main input file. return DBuilder.createFile(remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()), - TheCU->getFile()->getChecksumKind(), TheCU->getFile()->getChecksum()); SourceManager &SM = CGM.getContext().getSourceManager(); @@ -400,7 +399,6 @@ // If the location is not valid then use main input file. return DBuilder.createFile(remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()), - TheCU->getFile()->getChecksumKind(), TheCU->getFile()->getChecksum()); // Cache the results. @@ -414,12 +412,15 @@ } SmallString<32> Checksum; - llvm::DIFile::ChecksumKind CSKind = + Optional CSKind = computeChecksum(SM.getFileID(Loc), Checksum); + Optional> CSInfo; + if (CSKind) + CSInfo.emplace(*CSKind, Checksum); llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), - CSKind, Checksum); + CSInfo); DIFileCache[fname].reset(F); return F; @@ -428,7 +429,6 @@ llvm::DIFile *CGDebugInfo::getOrCreateMainFile() { return DBuilder.createFile(remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()), - TheCU->getFile()->getChecksumKind(), TheCU->getFile()->getChecksum()); } @@ -473,7 +473,8 @@ void CGDebugInfo::CreateCompileUnit() { SmallString<32> Checksum; - llvm::DIFile::ChecksumKind CSKind = llvm::DIFile::CSK_None; + Optional CSKind; + Optional> CSInfo; // Should we be asking the SourceManager for the main file name, instead of // accepting it as an argument? This just causes the main file name to @@ -552,13 +553,16 @@ break; } + if (CSKind) + CSInfo.emplace(*CSKind, Checksum); + // Create new compile unit. // FIXME - Eliminate TheCU. auto &CGOpts = CGM.getCodeGenOpts(); TheCU = DBuilder.createCompileUnit( LangTag, DBuilder.createFile(remapDIPath(MainFileName), - remapDIPath(getCurrentDirname()), CSKind, Checksum), + remapDIPath(getCurrentDirname()), CSInfo), Producer, LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.EnableSplitDwarf ? "" : CGOpts.SplitDwarfFile, EmissionKind,