[cfe-commits] r62734 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/2009-01-21-invalid-debug-info.m
Daniel Dunbar
daniel at zuster.org
Wed Jan 21 16:09:27 PST 2009
Author: ddunbar
Date: Wed Jan 21 18:09:25 2009
New Revision: 62734
URL: http://llvm.org/viewvc/llvm-project?rev=62734&view=rev
Log:
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).
Added:
cfe/trunk/test/CodeGen/2009-01-21-invalid-debug-info.m
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=62734&r1=62733&r2=62734&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Jan 21 18:09:25 2009
@@ -47,21 +47,24 @@
/// 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.
Added: cfe/trunk/test/CodeGen/2009-01-21-invalid-debug-info.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2009-01-21-invalid-debug-info.m?rev=62734&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/2009-01-21-invalid-debug-info.m (added)
+++ cfe/trunk/test/CodeGen/2009-01-21-invalid-debug-info.m Wed Jan 21 18:09:25 2009
@@ -0,0 +1,16 @@
+// RUN: clang -S -g -o %t.s %s
+
+// FIXME: This test case can be removed at some point (since it will
+// no longer effectively test anything). The reason it was causing
+// trouble was the synthesized self decl in im1 was causing the debug
+// info for I1* to be generated, but referring to an invalid compile
+// unit. This was later referred to by f1 and created ill formed debug
+// information.
+
+ at interface I1 @end
+
+ at implementation I1
+-im0 {}
+ at end
+
+I1 *f1(void) { return 0; }
More information about the cfe-commits
mailing list