[cfe-commits] r100462 - in /cfe/trunk: lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGObjC.cpp test/CodeGenObjC/property-dbg.m

Devang Patel dpatel at apple.com
Mon Apr 5 14:09:15 PDT 2010


Author: dpatel
Date: Mon Apr  5 16:09:15 2010
New Revision: 100462

URL: http://llvm.org/viewvc/llvm-project?rev=100462&view=rev
Log:
Emit debug info for objc getters and setters.

Added:
    cfe/trunk/test/CodeGenObjC/property-dbg.m
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
    cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=100462&r1=100461&r2=100462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr  5 16:09:15 2010
@@ -1380,7 +1380,9 @@
        || (SM.getInstantiationLineNumber(CurLoc) ==
            SM.getInstantiationLineNumber(PrevLoc)
            && SM.isFromSameFile(CurLoc, PrevLoc)))
-    return;
+    // New Builder may not be in sync with CGDebugInfo.
+    if (!Builder.getCurrentDebugLocation().isUnknown())
+      return;
 
   // Update last state.
   PrevLoc = CurLoc;

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=100462&r1=100461&r2=100462&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Apr  5 16:09:15 2010
@@ -108,6 +108,10 @@
 void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
                                       const ObjCContainerDecl *CD) {
   FunctionArgList Args;
+  // Check if we should generate debug info for this method.
+  if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
+    DebugInfo = CGM.getDebugInfo();
+
   llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
 
   const CGFunctionInfo &FI = CGM.getTypes().getFunctionInfo(OMD);
@@ -128,9 +132,6 @@
 /// Generate an Objective-C method.  An Objective-C method is a C function with
 /// its pointer, name, and types registered in the class struture.
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
-  // Check if we should generate debug info for this method.
-  if (CGM.getDebugInfo() && !OMD->hasAttr<NoDebugAttr>())
-    DebugInfo = CGM.getDebugInfo();
   StartObjCMethod(OMD, OMD->getClassInterface());
   EmitStmt(OMD->getBody());
   FinishFunction(OMD->getBodyRBrace());

Added: cfe/trunk/test/CodeGenObjC/property-dbg.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/property-dbg.m?rev=100462&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/property-dbg.m (added)
+++ cfe/trunk/test/CodeGenObjC/property-dbg.m Mon Apr  5 16:09:15 2010
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -S -g -masm-verbose -x objective-c < %s | grep setI | grep DW_AT_name
+ at interface Foo {
+  int i;
+}
+ at property int i;
+ at end
+
+ at implementation Foo
+ at synthesize i;
+ at end
+
+int bar(Foo *f) {
+  int i = 1;
+  f.i = 2;
+  i = f.i;
+  return i;
+}





More information about the cfe-commits mailing list