aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-02-24 23:16:03 +0000
committerDevang Patel <dpatel@apple.com>2009-02-24 23:16:03 +0000
commit7782022c0c9c4721b097953f49378aa34358cea1 (patch)
treee3b928975600e05076d71e083d8ed15439256abd /lib/CodeGen/CGDebugInfo.cpp
parent79e079d3caecc0ddd7128dc038d3f8960bbab62e (diff)
If Loc is invalid (e.g. "self" in Objective-C) then use MainFileID's compile unit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index a48c247239..53e28729cb 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -52,10 +52,13 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
// "well formed" debug info.
const FileEntry *FE = 0;
+ SourceManager &SM = M->getContext().getSourceManager();
if (Loc.isValid()) {
- SourceManager &SM = M->getContext().getSourceManager();
Loc = SM.getInstantiationLoc(Loc);
FE = SM.getFileEntryForID(SM.getFileID(Loc));
+ } else {
+ // If Loc is not valid then use main file id.
+ FE = SM.getFileEntryForID(SM.getMainFileID());
}
// See if this compile unit has been used before.