[cfe-commits] r95743 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp test/CodeGen/2010-02-09-DbgSelf.m

Devang Patel dpatel at apple.com
Tue Feb 9 17:09:50 PST 2010


Author: dpatel
Date: Tue Feb  9 19:09:50 2010
New Revision: 95743

URL: http://llvm.org/viewvc/llvm-project?rev=95743&view=rev
Log:
Use current location as the location of compiler generated arguments, e.g. self, _cmd etc.

Added:
    cfe/trunk/test/CodeGen/2010-02-09-DbgSelf.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=95743&r1=95742&r2=95743&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Feb  9 19:09:50 2010
@@ -91,16 +91,15 @@
   // Get source file information.
   const char *FileName =  "<unknown>";
   SourceManager &SM = CGM.getContext().getSourceManager();
-  unsigned FID = 0;
   if (Loc.isValid()) {
     PresumedLoc PLoc = SM.getPresumedLoc(Loc);
     FileName = PLoc.getFilename();
-    FID = PLoc.getIncludeLoc().getRawEncoding();
-  }
+    unsigned FID = PLoc.getIncludeLoc().getRawEncoding();
 
-  // See if this compile unit has been used before.
-  llvm::DICompileUnit &Unit = CompileUnitCache[FID];
-  if (!Unit.isNull()) return Unit;
+    // See if this compile unit has been used before for this valid location.
+    llvm::DICompileUnit &Unit = CompileUnitCache[FID];
+    if (!Unit.isNull()) return Unit;
+  }
 
   // Get absolute path name.
   llvm::sys::Path AbsFileName(FileName);
@@ -150,7 +149,7 @@
     RuntimeVers = LO.ObjCNonFragileABI ? 2 : 1;
 
   // Create new compile unit.
-  return Unit = DebugFactory.CreateCompileUnit(
+  return DebugFactory.CreateCompileUnit(
     LangTag, AbsFileName.getLast(), AbsFileName.getDirname(), Producer, isMain,
     LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers);
 }
@@ -1515,9 +1514,12 @@
   PresumedLoc PLoc = SM.getPresumedLoc(VD->getLocation());
   unsigned Line = 0;
   unsigned Column = 0;
-  if (!PLoc.isInvalid()) {
+  if (PLoc.isInvalid())
+    PLoc = SM.getPresumedLoc(CurLoc);
+  if (PLoc.isValid()) {
     Line = PLoc.getLine();
     Column = PLoc.getColumn();
+    Unit = getOrCreateCompileUnit(CurLoc);
   } else {
     Unit = llvm::DICompileUnit();
   }

Added: cfe/trunk/test/CodeGen/2010-02-09-DbgSelf.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/2010-02-09-DbgSelf.m?rev=95743&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/2010-02-09-DbgSelf.m (added)
+++ cfe/trunk/test/CodeGen/2010-02-09-DbgSelf.m Tue Feb  9 19:09:50 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | grep  "\"self\", metadata" 
+// Test to check that "self" argument is assigned a location.
+
+ at interface Foo 
+-(void) Bar: (int)x ;
+ at end
+
+
+ at implementation Foo
+-(void) Bar: (int)x 
+{
+}
+ at end
+





More information about the cfe-commits mailing list