From 7782022c0c9c4721b097953f49378aa34358cea1 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 24 Feb 2009 23:16:03 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CGDebugInfo.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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. -- 2.50.1