If Loc is invalid (e.g. "self" in Objective-C) then use MainFileID's compile unit.
llvm-svn: 65403
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index a48c247..53e2872 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -52,10 +52,13 @@
// "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.