]> granicus.if.org Git - clang/commitdiff
Debug info: Implement a cleaner version of r198461. For symmetry with
authorAdrian Prantl <aprantl@apple.com>
Tue, 7 Jan 2014 19:24:24 +0000 (19:24 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 7 Jan 2014 19:24:24 +0000 (19:24 +0000)
C and C++ don't emit an extra lexical scope for the compound statement
that is the body of an Objective-C method.

rdar://problem/15010825

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198699 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGenObjC/arc-linetable-autorelease.m
test/CodeGenObjC/arc-linetable.m

index 3138d82fb8b590673b9783b67a353ad042f5277f..2977ed22230cd914e34e7e3d8bdfa6114a14f23c 100644 (file)
@@ -2537,8 +2537,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
 /// information in the source file. If the location is invalid, the
 /// previous location will be reused.
 void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-                               bool ForceColumnInfo,
-                               llvm::MDNode *ForceScope) {
+                               bool ForceColumnInfo) {
   // Update our current location
   setLocation(Loc);
 
@@ -2557,7 +2556,7 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
   // Update last state.
   PrevLoc = CurLoc;
 
-  llvm::MDNode *Scope = ForceScope ? ForceScope : &*LexicalBlockStack.back();
+  llvm::MDNode *Scope = LexicalBlockStack.back();
   Builder.SetCurrentDebugLocation(llvm::DebugLoc::get
                                   (getLineNumber(CurLoc),
                                    getColumnNumber(CurLoc, ForceColumnInfo),
index ac31bdf3f58c06a9b47164b5d3f09bce422d51a9..b38b9c338c9ef223987806c1190550c0964b0100 100644 (file)
@@ -211,17 +211,13 @@ public:
   /// getLocation - Return the current source location.
   SourceLocation getLocation() const { return CurLoc; }
 
-  /// getScope() - Return the current scope.
-  llvm::MDNode *getScope() const { return LexicalBlockStack.back(); }
-
   /// EmitLocation - Emit metadata to indicate a change in line/column
   /// information in the source file.
   /// \param ForceColumnInfo  Assume DebugColumnInfo option is true.
   /// \param ForceScope       Force the location to be in a specific lexical
   ///                         scope rather than the top of LexicalBlockStack.
   void EmitLocation(CGBuilderTy &Builder, SourceLocation Loc,
-                    bool ForceColumnInfo = false,
-                    llvm::MDNode *ForceScope = 0);
+                    bool ForceColumnInfo = false);
 
   /// EmitFunctionStart - Emit a call to llvm.dbg.function.start to indicate
   /// start of a new function.
index 058ce5686a3b6beccb8bbc781d0edbdd27c93aa2..aa990143ac23efc8411bbe011301c37bfcc7046e 100644 (file)
@@ -506,7 +506,8 @@ static llvm::Value *emitARCRetainLoadOfScalar(CodeGenFunction &CGF,
 /// its pointer, name, and types registered in the class struture.
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
   StartObjCMethod(OMD, OMD->getClassInterface(), OMD->getLocStart());
-  EmitStmt(OMD->getBody());
+  assert(isa<CompoundStmt>(OMD->getBody()));
+  EmitCompoundStmtWithoutScope(*cast<CompoundStmt>(OMD->getBody()));
   FinishFunction(OMD->getBodyRBrace());
 }
 
index 50882c8536bb4d78cb2138ba6d22bdc63702c517..b18ff09015aa8228ef8e1abed956b2c3d8ec4a9e 100644 (file)
@@ -37,7 +37,7 @@ void CodeGenFunction::EmitStopPoint(const Stmt *S) {
     Loc = S->getLocStart();
     DI->EmitLocation(Builder, Loc);
 
-    LastStopPoint = std::make_pair(Loc, DI->getScope());
+    LastStopPoint = Loc;
   }
 }
 
index fb668e4a168bb5d5d1e0c0a6d34b4a49eae17b5f..04c60f61f8838c797488614568d9e5dbe1559955 100644 (file)
@@ -209,10 +209,9 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
   // all will be fine.
   if (CGDebugInfo *DI = getDebugInfo()) {
     if (OnlySimpleReturnStmts)
-      DI->EmitLocation(Builder, LastStopPoint.first,
-                       false, LastStopPoint.second);
+      DI->EmitLocation(Builder, LastStopPoint, false);
     else
-      DI->EmitLocation(Builder, EndLoc, false, LastStopPoint.second);
+      DI->EmitLocation(Builder, EndLoc, false);
   }
 
   // Pop any cleanups that might have been associated with the
@@ -229,7 +228,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
 
     if (CGDebugInfo *DI = getDebugInfo())
       if (OnlySimpleReturnStmts)
-        DI->EmitLocation(Builder, EndLoc, false, LastStopPoint.second);
+        DI->EmitLocation(Builder, EndLoc, false);
   }
 
   // Emit function epilog (to return).
index c11f2c91729225bad842e52b7aa8f080a8c1e57c..37bbcf3f3422cce9e3584e124a3bdb73604c0051 100644 (file)
@@ -877,7 +877,7 @@ private:
   unsigned NumSimpleReturnExprs;
 
   /// The last regular (non-return) debug location (breakpoint) in the function.
-  std::pair<SourceLocation, llvm::MDNode*> LastStopPoint;
+  SourceLocation LastStopPoint;
 
 public:
   /// A scope within which we are constructing the fields of an object which
index be05ec2fcd8e941e8422a76378e1f3f72e0e9657..fa109154ce03bf70547d72a141a7938f8967d966 100644 (file)
@@ -29,12 +29,11 @@ NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h);
   CGFloat pattern[2];
   // CHECK: define {{.*}}_createBezierPathWithWidth
   // CHECK: load {{.*}} %path, align {{.*}}, !dbg ![[RET:[0-9]+]]
-  // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC1:[0-9]+]]
-  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC2:[0-9]+]]
-  // CHECK: ret {{.*}} !dbg ![[ARC2]]
+  // CHECK: call void @objc_storeStrong{{.*}} !dbg ![[ARC:[0-9]+]]
+  // CHECK: call {{.*}} @objc_autoreleaseReturnValue{{.*}} !dbg ![[ARC]]
+  // CHECK: ret {{.*}} !dbg ![[ARC]]
   // CHECK: ![[RET]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
   return path;
-  // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+2]], i32 0, metadata !{{.*}}, null}
-  // CHECK: ![[ARC2]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
+  // CHECK: ![[ARC]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
 }
 @end
index 34b7d7640fa9a98b0deb12b193f8fbb84a741847..7af02edc5b62b6329d83bbe9ef0a715113a28fbf 100644 (file)
@@ -49,9 +49,8 @@
 
 // CHECK: ![[TESTNOSIDEEFFECT:.*]] = {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+1]]] [local] [def] [-[AppDelegate testNoSideEffect:]]
 - (int)testNoSideEffect:(NSString *)foo {
-  // CHECK: ![[COMPOUND_STMT:.*]] = metadata !{i32 786443, metadata !{{.*}}, metadata ![[TESTNOSIDEEFFECT]], i32 [[@LINE-1]], i32 0, i32 0} ; [ DW_TAG_lexical_block ]
   int x = 1;
-  // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[COMPOUND_STMT]], null}
+  // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[TESTNOSIDEEFFECT]], null}
   return 1; // Return expression
   // CHECK: ![[RET1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null}
 }           // Cleanup + Ret