From: Daniel Dunbar Date: Fri, 24 Oct 2008 08:38:36 +0000 (+0000) Subject: Don't crash on invalid source locations in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25f51dda883d8b08d99e30fcec3b274599264712;p=clang Don't crash on invalid source locations in CGDebugInfo::getOrCreateCompileUnit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58081 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 89d00aee5e..4283dd4eaf 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -131,9 +131,12 @@ llvm::Value *CGDebugInfo::getValueFor(llvm::DebugInfoDesc *DD) { } /// getOrCreateCompileUnit - Get the compile unit from the cache or create a new -/// one if necessary. -llvm::CompileUnitDesc -*CGDebugInfo::getOrCreateCompileUnit(const SourceLocation Loc) { +/// one if necessary. This returns null for invalid source locations. +llvm::CompileUnitDesc* +CGDebugInfo::getOrCreateCompileUnit(const SourceLocation Loc) { + if (Loc.isInvalid()) + return NULL; + SourceManager &SM = M->getContext().getSourceManager(); const FileEntry *FE = SM.getFileEntryForLoc(Loc);