From: Manman Ren Date: Fri, 4 Jan 2013 18:51:35 +0000 (+0000) Subject: Debug Info: fix the line location for cleanup code of a block function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c7a0e1a75ebe13366a646a9eb8c4aa61e4728d3;p=clang Debug Info: fix the line location for cleanup code of a block function The line information was changed when emitting debug information for all the DeclRefExprs and we should change it back to get ready for PopClenupBlocks called from FinishFunction. rdar://11562117 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171493 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 68958522d8..54bcb88ce3 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -1176,6 +1176,9 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD, Builder, blockInfo); } } + // Recover location if it was changed in the above loop. + DI->EmitLocation(Builder, + cast(blockDecl->getBody())->getRBracLoc()); } // And resume where we left off. diff --git a/test/CodeGenObjC/debug-info-block-line.m b/test/CodeGenObjC/debug-info-block-line.m new file mode 100644 index 0000000000..f050bb7da6 --- /dev/null +++ b/test/CodeGenObjC/debug-info-block-line.m @@ -0,0 +1,85 @@ +// REQUIRES: x86-64-registered-target +// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-default-synthesize-properties -fobjc-arc -O0 -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s + +// rdar://11562117 +typedef unsigned int NSUInteger; +typedef long NSInteger; +typedef signed char BOOL; + +#define nil ((void*) 0) +#define YES ((BOOL)1) +#define NO ((BOOL)0) + +@interface NSObject +- (id)init; +@end + +@interface NSError : NSObject +@end + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) +- (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block; +@end + +@interface NSData : NSObject +@end + +@interface NSData (ASBase64) +- (NSString *)encodedString:(NSInteger)position; +- (NSData *)compressedData; +@end + +typedef void (^TDataCompletionBlock)(NSData *data, NSError *error); +@interface TMap : NSObject +- (NSString *)identifier; +- (NSString *)name; ++ (TMap *)mapForID:(NSString *)identifier; +- (void)dataWithCompletionBlock:(TDataCompletionBlock)block; +@end + +typedef enum : NSUInteger { + TOK = 100, + TError = 125, +} TResponseCode; + +@interface TConnection : NSObject +- (void)sendString:(NSString *)string; +- (void)sendFormat:(NSString *)format, ...; +- (void)sendResponseCode:(TResponseCode)responseCode dataFollows:(BOOL)flag + format:(NSString *)format, ...; +@end + +@interface TServer : NSObject +@end + +@implementation TServer +- (void)serverConnection:(TConnection *)connection getCommand:(NSString *)str +{ + NSString *mapID = nil; + TMap *map = [TMap mapForID:mapID]; +// Make sure we do not map code generated for the block to the above line. +// CHECK: define internal void @"__39-[TServer serverConnection:getCommand:]_block_invoke" +// CHECK: if.end: +// CHECK: call void @objc_storeStrong(i8** [[VAL1:%.*]], i8* null) nounwind, !dbg ![[MD1:.*]] +// CHECK: call void @objc_storeStrong(i8** [[VAL2:%.*]], i8* null) nounwind, !dbg ![[MD1]] +// CHECK-NEXT: ret +// CHECK: ![[MD1]] = metadata !{i32 83 + [map dataWithCompletionBlock:^(NSData *data, NSError *error) { + if (data) { + NSString *encoded = [[data compressedData] encodedString:18]; + [connection sendResponseCode:TOK dataFollows:YES + format:@"Sending \"%@\" (%@)", [map name], [map identifier]]; + [encoded enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) { + [connection sendFormat:@"%@\r\n", line]; + }]; + [connection sendString:@".\r\n"]; + } else { + [connection sendResponseCode:TError dataFollows:NO + format:@"Failed \"%@\" (%@)", [map name], [map identifier]]; + } + }]; +} +@end