[cfe-commits] r153917 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGObjC.cpp test/CodeGenCXX/debug-info-artificial-arg.cpp test/CodeGenObjC/debug-info-block-helper.m test/CodeGenObjC/debug-info-synthesis.m test/CodeGenObjC/debug-property-synth.m

Eric Christopher echristo at apple.com
Mon Apr 2 17:44:15 PDT 2012


Author: echristo
Date: Mon Apr  2 19:44:15 2012
New Revision: 153917

URL: http://llvm.org/viewvc/llvm-project?rev=153917&view=rev
Log:
Change location information for synthesized properties to be at the
property file/line rather than the @synthesize file/line. Avoids
some nasty confusing-ness with conflating the file from the scope
and the line from the original declaration. Use    the current scope
location as a separate parameter so that we can    match it up
better in the line table with the beginning of the scope.

Update a couple of testcases accordingly since I had to change
that we actually use the passed in location in EmitFunctionStart
and for the new metadata parameter and add a new testcase to
make sure we've got the right line numbers for synthesized
properties.

Part of rdar://11026482

Added:
    cfe/trunk/test/CodeGenObjC/debug-info-synthesis.m
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGObjC.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp
    cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m
    cfe/trunk/test/CodeGenObjC/debug-property-synth.m

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=153917&r1=153916&r2=153917&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr  2 19:44:15 2012
@@ -1969,9 +1969,11 @@
   FnBeginRegionCount.push_back(LexicalBlockStack.size());
 
   const Decl *D = GD.getDecl();
+  // Use the location of the declaration.
+  SourceLocation Loc = D->getLocation();
   
   unsigned Flags = 0;
-  llvm::DIFile Unit = getOrCreateFile(CurLoc);
+  llvm::DIFile Unit = getOrCreateFile(Loc);
   llvm::DIDescriptor FDContext(Unit);
   llvm::DIArray TParamsArray;
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
@@ -2015,17 +2017,16 @@
   if (!Name.empty() && Name[0] == '\01')
     Name = Name.substr(1);
 
-  // It is expected that CurLoc is set before using EmitFunctionStart.
-  // Usually, CurLoc points to the left bracket location of compound
-  // statement representing function body.
-  unsigned LineNo = getLineNumber(CurLoc);
+  unsigned LineNo = getLineNumber(Loc);
   if (D->isImplicit())
     Flags |= llvm::DIDescriptor::FlagArtificial;
+
   llvm::DISubprogram SPDecl = getFunctionDeclaration(D);
   llvm::DISubprogram SP =
     DBuilder.createFunction(FDContext, Name, LinkageName, Unit,
                             LineNo, getOrCreateFunctionType(D, FnType, Unit),
                             Fn->hasInternalLinkage(), true/*definition*/,
+                            getLineNumber(CurLoc),
                             Flags, CGM.getLangOpts().Optimize, Fn,
                             TParamsArray, SPDecl);
 

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=153917&r1=153916&r2=153917&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Apr  2 19:44:15 2012
@@ -708,7 +708,7 @@
   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
   ObjCMethodDecl *OMD = PD->getGetterMethodDecl();
   assert(OMD && "Invalid call to generate getter (empty method)");
-  StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
+  StartObjCMethod(OMD, IMP->getClassInterface(), OMD->getLocStart());
 
   generateObjCGetterBody(IMP, PID, AtomicHelperFn);
 
@@ -1216,7 +1216,7 @@
   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
   ObjCMethodDecl *OMD = PD->getSetterMethodDecl();
   assert(OMD && "Invalid call to generate setter (empty method)");
-  StartObjCMethod(OMD, IMP->getClassInterface(), PID->getLocStart());
+  StartObjCMethod(OMD, IMP->getClassInterface(), OMD->getLocStart());
 
   generateObjCSetterBody(IMP, PID, AtomicHelperFn);
 

Modified: cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp?rev=153917&r1=153916&r2=153917&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-artificial-arg.cpp Mon Apr  2 19:44:15 2012
@@ -25,6 +25,6 @@
 // FIXME: The numbers are truly awful.
 // CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ]
 // CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ]
-// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47} ; [ DW_TAG_subprogram ]
+// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47, i32 12} ; [ DW_TAG_subprogram ]
 // CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
 // CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34}

Modified: cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m?rev=153917&r1=153916&r2=153917&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-info-block-helper.m Mon Apr  2 19:44:15 2012
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s
 extern void foo(void(^)(void));
 
-// CHECK: !40 = metadata !{i32 {{.*}}, i32 0, metadata !10, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !10, i32 24, metadata !41, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !43} ; [ DW_TAG_subprogram ]
+// CHECK: !40 = metadata !{i32 {{.*}}, i32 0, metadata !25, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !25, i32 24, metadata !41, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !43, i32 24} ; [ DW_TAG_subprogram ]
 
 @interface NSObject {
   struct objc_object *isa;

Added: cfe/trunk/test/CodeGenObjC/debug-info-synthesis.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-synthesis.m?rev=153917&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-synthesis.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-synthesis.m Mon Apr  2 19:44:15 2012
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -emit-llvm -g -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+# 1 "foo.m" 1
+# 1 "foo.m" 2
+# 1 "./foo.h" 1
+ at interface NSObject {
+  struct objc_object *isa;
+}
+ at end
+ at class NSDictionary;
+
+ at interface Foo : NSObject {}
+ at property (strong, nonatomic) NSDictionary *dict;
+ at end
+# 2 "foo.m" 2
+
+
+
+
+ at implementation Foo
+ at synthesize dict = _dict;
+
+- (void) bork {
+}
+ at end
+
+int main(int argc, char *argv[]) {
+  @autoreleasepool {
+    Foo *f = [Foo new];
+    [f bork];
+  }
+}
+
+// CHECK: !11 = metadata !{i32 {{.*}}, metadata !"./foo.h"
+// CHECK: !29 = metadata !{i32 {{.*}}, i32 0, metadata !11, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !11, i32 8, metadata !30, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !32, i32 8} ; [ DW_TAG_subprogram ]

Modified: cfe/trunk/test/CodeGenObjC/debug-property-synth.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-property-synth.m?rev=153917&r1=153916&r2=153917&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-property-synth.m (original)
+++ cfe/trunk/test/CodeGenObjC/debug-property-synth.m Mon Apr  2 19:44:15 2012
@@ -16,4 +16,5 @@
   return 0;
 }
 
-// CHECK:       .loc    2 10 0
+// FIXME: Make this test ir files.
+// CHECK:       .loc    2 6 0





More information about the cfe-commits mailing list