From ac91b4c7063615da6797031f5ac46a906e6b8166 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 18 Mar 2010 23:46:43 +0000 Subject: [PATCH] For debug information, get the main file name from the source manager rather than from the -main-file-name flag, since the source manager has proper path information. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98898 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 60aa4e784e..323c458842 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -104,9 +104,14 @@ llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) { void CGDebugInfo::CreateCompileUnit() { // Get absolute path name. - std::string MainFileName = CGM.getCodeGenOpts().MainFileName; - if (MainFileName.empty()) + SourceManager &SM = CGM.getContext().getSourceManager(); + std::string MainFileName; + if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) + MainFileName = MainFile->getName(); + else if (CGM.getCodeGenOpts().MainFileName.empty()) MainFileName = ""; + else + MainFileName = CGM.getCodeGenOpts().MainFileName; llvm::sys::Path AbsFileName(MainFileName); AbsFileName.makeAbsolute(); -- 2.40.0