From: Devang Patel Date: Tue, 24 Feb 2009 23:16:03 +0000 (+0000) Subject: If Loc is invalid (e.g. "self" in Objective-C) then use MainFileID's compile unit. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7782022c0c9c4721b097953f49378aa34358cea1;p=clang 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 --- 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.