]> granicus.if.org Git - clang/commitdiff
Use current location as the location of compiler generated arguments, e.g. self,...
authorDevang Patel <dpatel@apple.com>
Wed, 10 Feb 2010 01:09:50 +0000 (01:09 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 10 Feb 2010 01:09:50 +0000 (01:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95743 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/2010-02-09-DbgSelf.m [new file with mode: 0644]

index 6f84add037285db72be3f2a2a999ce9f3c3a5ee6..7138bc05190eba21cb4ceda8cba54d8d153de8f2 100644 (file)
@@ -91,16 +91,15 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
   // 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 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
     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 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag,
   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();
   }
diff --git a/test/CodeGen/2010-02-09-DbgSelf.m b/test/CodeGen/2010-02-09-DbgSelf.m
new file mode 100644 (file)
index 0000000..e09adac
--- /dev/null
@@ -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.
+
+@interface Foo 
+-(void) Bar: (int)x ;
+@end
+
+
+@implementation Foo
+-(void) Bar: (int)x 
+{
+}
+@end
+