[cfe-commits] r70982 - /cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp

Mike Stump mrs at apple.com
Tue May 5 10:22:53 PDT 2009


Author: mrs
Date: Tue May  5 12:22:51 2009
New Revision: 70982

URL: http://llvm.org/viewvc/llvm-project?rev=70982&view=rev
Log:
Merge in 70965:

Fix generated debug info for decls with no location (which include self/_cmd
in ObjC) to not emit file/line location information.  Previously
we would output a file with bogus line information.  This fixes:
rdar://6852814 - Clang generates incorrect file & line info for automatic/understood formal parameters for objc-programs

Modified:
    cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp?rev=70982&r1=70981&r2=70982&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGDebugInfo.cpp Tue May  5 12:22:51 2009
@@ -742,17 +742,23 @@
   if (CO.OptimizationLevel)
     return;
 
+  llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
+  llvm::DIType Ty = getOrCreateType(Decl->getType(), Unit);
+
   // Get location information.
   SourceManager &SM = M->getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Decl->getLocation());
-  unsigned Line = PLoc.isInvalid() ? 0 : PLoc.getLine();
-  llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
+  unsigned Line = 0;
+  if (!PLoc.isInvalid())
+    Line = PLoc.getLine();
+  else
+    Unit = llvm::DICompileUnit();
+
   
   // Create the descriptor for the variable.
   llvm::DIVariable D = 
     DebugFactory.CreateVariable(Tag, RegionStack.back(),Decl->getNameAsString(),
-                                Unit, Line,
-                                getOrCreateType(Decl->getType(), Unit));
+                                Unit, Line, Ty);
   // Insert an llvm.dbg.declare into the current block.
   DebugFactory.InsertDeclare(Storage, D, Builder.GetInsertBlock());
 }





More information about the cfe-commits mailing list