diff options
| author | Adrian Prantl <aprantl@apple.com> | 2018-12-11 16:58:43 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2018-12-11 16:58:43 +0000 |
| commit | aa5bad449bec3b8b5aafca96e3d6daaac9be86a5 (patch) | |
| tree | 4d87d9f6828499b46a78bd819669bb472bf05394 /clang/lib | |
| parent | 743ae6045d41318149bc8d1bdaf8ce4f48792c90 (diff) | |
| download | bcm5719-llvm-aa5bad449bec3b8b5aafca96e3d6daaac9be86a5.tar.gz bcm5719-llvm-aa5bad449bec3b8b5aafca96e3d6daaac9be86a5.zip | |
Reuse code from CGDebugInfo::getOrCreateFile() when creating the file
for the DICompileUnit.
This addresses post-commit feedback for D55085. Without this patch, a
main source file with an absolute paths may appear in different
DIFiles, once with the absolute path and once with the common prefix
between the absolute path and the current working directory.
Differential Revision: https://reviews.llvm.org/D55519
llvm-svn: 348865
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 17 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 9 |
2 files changed, 17 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 9a6204b5bda..d9c184c209d 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -429,7 +429,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) { Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo; if (CSKind) CSInfo.emplace(*CSKind, Checksum); + return createFile(FileName, CSInfo, getSource(SM, SM.getFileID(Loc))); +} +llvm::DIFile * +CGDebugInfo::createFile(StringRef FileName, + Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo, + Optional<StringRef> Source) { StringRef Dir; StringRef File; std::string RemappedFile = remapDIPath(FileName); @@ -460,16 +466,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) { Dir = CurDir; File = RemappedFile; } - llvm::DIFile *F = - DBuilder.createFile(File, Dir, CSInfo, - getSource(SM, SM.getFileID(Loc))); - + llvm::DIFile *F = DBuilder.createFile(File, Dir, CSInfo, Source); DIFileCache[FileName.data()].reset(F); return F; } llvm::DIFile *CGDebugInfo::getOrCreateMainFile() { - return DBuilder.createFile( + return createFile( remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()), TheCU->getFile()->getChecksum(), CGM.getCodeGenOpts().EmbedSource ? TheCU->getSource() : None); @@ -607,9 +610,7 @@ void CGDebugInfo::CreateCompileUnit() { auto &CGOpts = CGM.getCodeGenOpts(); TheCU = DBuilder.createCompileUnit( LangTag, - DBuilder.createFile(remapDIPath(MainFileName), - remapDIPath(getCurrentDirname()), CSInfo, - getSource(SM, SM.getMainFileID())), + createFile(MainFileName, CSInfo, getSource(SM, SM.getMainFileID())), CGOpts.EmitVersionIdentMetadata ? Producer : "", LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO, CGOpts.DwarfDebugFlags, RuntimeVers, diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 8f29e27e605..5b0d2d7fc90 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -538,9 +538,16 @@ private: /// Get the source of the given file ID. Optional<StringRef> getSource(const SourceManager &SM, FileID FID); - /// Get the file debug info descriptor for the input location. + /// Convenience function to get the file debug info descriptor for the input + /// location. llvm::DIFile *getOrCreateFile(SourceLocation Loc); + /// Create a file debug info descriptor for a source file. + llvm::DIFile * + createFile(StringRef FileName, + Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo, + Optional<StringRef> Source); + /// Get the file info for main compile unit. llvm::DIFile *getOrCreateMainFile(); |

