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);
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);
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,
/// 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();
// CHECK-REL-NODIR: !DICompileUnit(
// CHECK-REL-NODIR-SAME: file: ![[PCH:[0-9]+]]
// CHECK-REL-NODIR-SAME: splitDebugFilename: "prefix.pch"
-// CHECK-REL-NODIR: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]"
+// CHECK-REL-NODIR: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]
// ---------------------------------------------------------------------
// Relative PCH in a subdirectory.
// CHECK-ABS: !DICompileUnit(
// CHECK-ABS-SAME: file: ![[PCH:[0-9]+]]
// CHECK-ABS-SAME: splitDebugFilename: "prefix.pch"
-// CHECK-ABS: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]"
+// CHECK-ABS: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]