From 56741e29d42259599af4a54dfd7df672f77d3058 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 7 Jan 2014 22:05:55 +0000 Subject: [PATCH] Re-applying r198699 after reverting r198461. Debug info: Implement a cleaner version of r198461. For symmetry with C and C++ don't emit an extra lexical scope for the compound statement that is the body of an Objective-C method. llvm-svn: 198715 --- clang/lib/CodeGen/CGObjC.cpp | 3 ++- clang/test/CodeGenCXX/linetable-cleanup.cpp | 6 ++++-- clang/test/CodeGenObjC/arc-linetable-autorelease.m | 9 ++++----- clang/test/CodeGenObjC/arc-linetable.m | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 058ce56..aa99014 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -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(OMD->getBody())); + EmitCompoundStmtWithoutScope(*cast(OMD->getBody())); FinishFunction(OMD->getBodyRBrace()); } diff --git a/clang/test/CodeGenCXX/linetable-cleanup.cpp b/clang/test/CodeGenCXX/linetable-cleanup.cpp index 96b8572..ce7f2c6 100644 --- a/clang/test/CodeGenCXX/linetable-cleanup.cpp +++ b/clang/test/CodeGenCXX/linetable-cleanup.cpp @@ -46,12 +46,14 @@ void bar() void baz() { if (!foo()) - // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + // CHECK: ![[SCOPE1:.*]] = metadata !{{{.*}}, i32 [[@LINE-1]], {{.*}}} ; [ DW_TAG_lexical_block ] + // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata ![[SCOPE1]], null} return; if (foo()) { // no cleanup - // CHECK: {{.*}} = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + // CHECK: {{.*}} = metadata !{i32 [[@LINE+2]], i32 0, metadata ![[SCOPE2:.*]], null} + // CHECK: ![[SCOPE2]] = metadata !{{{.*}}, i32 [[@LINE-3]], {{.*}}} ; [ DW_TAG_lexical_block ] return; } // CHECK: ![[RETBAZ]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} diff --git a/clang/test/CodeGenObjC/arc-linetable-autorelease.m b/clang/test/CodeGenObjC/arc-linetable-autorelease.m index be05ec2..fa10915 100644 --- a/clang/test/CodeGenObjC/arc-linetable-autorelease.m +++ b/clang/test/CodeGenObjC/arc-linetable-autorelease.m @@ -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 diff --git a/clang/test/CodeGenObjC/arc-linetable.m b/clang/test/CodeGenObjC/arc-linetable.m index eac91f1..7af02ed 100644 --- a/clang/test/CodeGenObjC/arc-linetable.m +++ b/clang/test/CodeGenObjC/arc-linetable.m @@ -47,8 +47,10 @@ @implementation AppDelegate : NSObject +// CHECK: ![[TESTNOSIDEEFFECT:.*]] = {{.*}}[ DW_TAG_subprogram ] [line [[@LINE+1]]] [local] [def] [-[AppDelegate testNoSideEffect:]] - (int)testNoSideEffect:(NSString *)foo { - // CHECK: ![[ARC1]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + int x = 1; + // 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 -- 2.7.4