[cfe-commits] r171493 - in /cfe/trunk: lib/CodeGen/CGBlocks.cpp test/CodeGenObjC/debug-info-block-line.m

Manman Ren mren at apple.com
Fri Jan 4 10:51:35 PST 2013


Author: mren
Date: Fri Jan  4 12:51:35 2013
New Revision: 171493

URL: http://llvm.org/viewvc/llvm-project?rev=171493&view=rev
Log:
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

Added:
    cfe/trunk/test/CodeGenObjC/debug-info-block-line.m
Modified:
    cfe/trunk/lib/CodeGen/CGBlocks.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=171493&r1=171492&r2=171493&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Fri Jan  4 12:51:35 2013
@@ -1176,6 +1176,9 @@
                                               Builder, blockInfo);
       }
     }
+    // Recover location if it was changed in the above loop.
+    DI->EmitLocation(Builder,
+        cast<CompoundStmt>(blockDecl->getBody())->getRBracLoc());
   }
 
   // And resume where we left off.

Added: cfe/trunk/test/CodeGenObjC/debug-info-block-line.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/debug-info-block-line.m?rev=171493&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/debug-info-block-line.m (added)
+++ cfe/trunk/test/CodeGenObjC/debug-info-block-line.m Fri Jan  4 12:51:35 2013
@@ -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)
+
+ at interface NSObject
+- (id)init;
+ at end
+
+ at interface NSError : NSObject
+ at end
+
+ at interface NSString : NSObject
+ at end
+
+ at interface NSString (NSStringExtensionMethods)
+- (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))block;
+ at end
+
+ at interface NSData : NSObject
+ at end
+
+ at interface NSData (ASBase64)
+- (NSString *)encodedString:(NSInteger)position;
+- (NSData *)compressedData;
+ at end
+
+typedef void (^TDataCompletionBlock)(NSData *data, NSError *error);
+ at interface TMap : NSObject
+- (NSString *)identifier;
+- (NSString *)name;
++ (TMap *)mapForID:(NSString *)identifier;
+- (void)dataWithCompletionBlock:(TDataCompletionBlock)block;
+ at end
+
+typedef enum : NSUInteger {
+    TOK                = 100,
+    TError = 125,
+} TResponseCode;
+
+ at interface TConnection : NSObject
+- (void)sendString:(NSString *)string;
+- (void)sendFormat:(NSString *)format, ...;
+- (void)sendResponseCode:(TResponseCode)responseCode dataFollows:(BOOL)flag
+                         format:(NSString *)format, ...;
+ at end
+
+ at interface TServer : NSObject
+ at end
+
+ at 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]];
+        }
+    }];
+}
+ at end





More information about the cfe-commits mailing list