diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-05-04 18:07:20 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-05-04 18:07:20 +0000 |
commit | 4f53cbe431f529fc2bd62c2c8020791eb85d0d4d (patch) | |
tree | 990c4fbf58ba6ae543e19c5a4d0f0633b1ec8a10 /test/SemaObjCXX | |
parent | 1f8b3b7a73ee410006e3dc2fbf8546b9aa48a696 (diff) |
[ObjC] Enter a new evaluation context before calling
BuildBlockForLambdaConversion.
Previously, clang would build an incorrect AST for the following code:
id test() {
return @{@"a": [](){}, @"b": [](){}};
}
ReturnStmt 0x10d080448
`-ExprWithCleanups 0x10d080428
|-cleanup Block 0x10d0801f0 // points to the second BlockDecl
...
-BlockDecl 0x10d07f150 // First block
...
-BlockDecl 0x10d0801f0 // Second block
...
`-ExprWithCleanups 0x10d0801d0
|-cleanup Block 0x10d07f150 // points to the first BlockDecl
To fix the bug, this commit enters a new evaluation context to reset
ExprNeedsCleanups before each block is parsed.
rdar://problem/16879958
Differential Revision: http://reviews.llvm.org/D18815
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r-- | test/SemaObjCXX/block-cleanup.mm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/SemaObjCXX/block-cleanup.mm b/test/SemaObjCXX/block-cleanup.mm new file mode 100644 index 0000000000..0c6a6d8c26 --- /dev/null +++ b/test/SemaObjCXX/block-cleanup.mm @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s + +// CHECK: -FunctionDecl {{.*}} test 'id (void)' +// CHECK-NEXT: -CompoundStmt +// CHECK-NEXT: -ReturnStmt +// CHECK-NEXT: -ExprWithCleanups +// CHECK-NEXT: -cleanup Block +// CHECK-NEXT: -cleanup Block + +@interface NSDictionary ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +@end + +id test() { + return @{@"a": [](){}, @"b": [](){}}; +} |