]> granicus.if.org Git - clang/commitdiff
If Loc is invalid (e.g. "self" in Objective-C) then use MainFileID's compile unit.
authorDevang Patel <dpatel@apple.com>
Tue, 24 Feb 2009 23:16:03 +0000 (23:16 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 24 Feb 2009 23:16:03 +0000 (23:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65403 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index a48c24723903d464371978cf5639ff50b3b30846..53e28729cbb2dc763cd102511e5c272748d30c3e 100644 (file)
@@ -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.