diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-01-22 00:09:25 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-01-22 00:09:25 +0000 |
commit | 56493b0d54bf120651f1a95f1e4082377c3388da (patch) | |
tree | f2cab3a64be7a1f2a85e3b9661e756697b02909b /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 1019bdef0c724d0ea0d369a6f131b4b0260b367d (diff) | |
download | bcm5719-llvm-56493b0d54bf120651f1a95f1e4082377c3388da.tar.gz bcm5719-llvm-56493b0d54bf120651f1a95f1e4082377c3388da.zip |
Allow creation of "dummy" compile units for debug information.
- Although gross, this is needed currently to ensure that we produce
well formed debug information (to match pace with the assertions
being added to DebugInfo in LLVM).
llvm-svn: 62734
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index d3fee11e467..e0a52d61844 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -47,21 +47,24 @@ void CGDebugInfo::setLocation(SourceLocation Loc) { /// getOrCreateCompileUnit - Get the compile unit from the cache or create a new /// one if necessary. This returns null for invalid source locations. llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { - if (Loc.isInvalid()) - return llvm::DICompileUnit(); - - SourceManager &SM = M->getContext().getSourceManager(); - Loc = SM.getInstantiationLoc(Loc); - const FileEntry *FE = SM.getFileEntryForID(SM.getFileID(Loc)); - if (FE == 0) return llvm::DICompileUnit(); - + // FIXME: Until we do a complete job of emitting debug information, + // we need to support making dummy compile units so that we generate + // "well formed" debug info. + const FileEntry *FE = 0; + + if (Loc.isValid()) { + SourceManager &SM = M->getContext().getSourceManager(); + Loc = SM.getInstantiationLoc(Loc); + FE = SM.getFileEntryForID(SM.getFileID(Loc)); + } + // See if this compile unit has been used before. llvm::DICompileUnit &Unit = CompileUnitCache[FE]; if (!Unit.isNull()) return Unit; // Get source file information. - const char *FileName = FE->getName(); - const char *DirName = FE->getDir()->getName(); + const char *FileName = FE ? FE->getName() : "<unknown>"; + const char *DirName = FE ? FE->getDir()->getName() : ""; // Create new compile unit. // FIXME: Handle other language IDs as well. |