Don't crash on invalid source locations in
CGDebugInfo::getOrCreateCompileUnit.
llvm-svn: 58081
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 89d00ae..4283dd4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -131,9 +131,12 @@
}
/// 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);