summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-04-23 18:09:16 +0000
committerDevang Patel <dpatel@apple.com>2009-04-23 18:09:16 +0000
commita6acb390e70453fd129cdaa19bdf8b0e206081f5 (patch)
treee1d52250bf2e2be4d890b81cba27d750a80e3010 /clang/lib/CodeGen/CGDebugInfo.cpp
parent466af3eb461b017b731df1cf743a8d7fd9a168aa (diff)
downloadbcm5719-llvm-a6acb390e70453fd129cdaa19bdf8b0e206081f5.tar.gz
bcm5719-llvm-a6acb390e70453fd129cdaa19bdf8b0e206081f5.zip
Handle corner case where clang-cc is invoked directly to compile preprocessed source file without -main-file-name. In this case, CDDebugInfo is not able identify correct main source file becase SM.isFromMainFile() returns true for locations from header files as well as locations from main source file.
This patch takes conservative approach by not emitting more then one compile unit with isMain bit set. llvm-svn: 69902
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp22
1 files changed, 14 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;
OpenPOWER on IntegriCloud