diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 22 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 1 |
2 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index f2ca2e7c589..a652ede1c1f 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -34,7 +34,7 @@ using namespace clang; using namespace clang::CodeGen; CGDebugInfo::CGDebugInfo(CodeGenModule *m) - : M(m), DebugFactory(M->getModule()) { + : M(m), isMainCompileUnitCreated(false), DebugFactory(M->getModule()) { } CGDebugInfo::~CGDebugInfo() { @@ -71,16 +71,22 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { AbsFileName = tmp; } - // See if thie compile unit is represnting main source file. + // See if thie compile unit is representing main source file. Each source + // file has corresponding compile unit. There is only one main source + // file at a time. bool isMain = false; const LangOptions &LO = M->getLangOptions(); const char *MainFileName = LO.getMainFileName(); - if (MainFileName) { - if (!strcmp(AbsFileName.getLast().c_str(), MainFileName)) - isMain = true; - } else { - if (Loc.isValid() && SM.isFromMainFile(Loc)) - isMain = true; + if (isMainCompileUnitCreated == false) { + if (MainFileName) { + if (!strcmp(AbsFileName.getLast().c_str(), MainFileName)) + isMain = true; + } else { + if (Loc.isValid() && SM.isFromMainFile(Loc)) + isMain = true; + } + if (isMain) + isMainCompileUnitCreated = true; } unsigned LangTag; diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 4a59ecaaa57..1581637f4a3 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -34,6 +34,7 @@ namespace CodeGen { /// the backend. class CGDebugInfo { CodeGenModule *M; + bool isMainCompileUnitCreated; llvm::DIFactory DebugFactory; SourceLocation CurLoc, PrevLoc; |