aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp5
1 files changed, 4 insertions, 1 deletions
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.