summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/lambdas.mm
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2015-11-15 17:48:22 +0000
committerDevin Coughlin <dcoughlin@apple.com>2015-11-15 17:48:22 +0000
commit1d4058322dfa18210cfb51d9b53139bdbea7c242 (patch)
tree7e06df9be32fca95ffe9f0b9ee70fb9202633193 /clang/test/Analysis/lambdas.mm
parent121262604158e8ad2fd5958044024246b6d326bb (diff)
downloadbcm5719-llvm-1d4058322dfa18210cfb51d9b53139bdbea7c242.tar.gz
bcm5719-llvm-1d4058322dfa18210cfb51d9b53139bdbea7c242.zip
[analyzer] Handle calling ObjC super method from inside C++ lambda.
When calling a ObjC method on super from inside a C++ lambda, look at the captures to find "self". This mirrors how the analyzer handles calling super in an ObjC block and fixes an assertion failure. rdar://problem/23550077 llvm-svn: 253176
Diffstat (limited to 'clang/test/Analysis/lambdas.mm')
-rw-r--r--clang/test/Analysis/lambdas.mm46
1 files changed, 46 insertions, 0 deletions
diff --git a/clang/test/Analysis/lambdas.mm b/clang/test/Analysis/lambdas.mm
new file mode 100644
index 00000000000..f2cd5aefffe
--- /dev/null
+++ b/clang/test/Analysis/lambdas.mm
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wno-objc-root-class -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s
+
+int clang_analyzer_eval(int);
+
+@interface Super
+- (void)superMethod;
+@end
+
+@interface Sub : Super {
+ int _ivar1;
+ int _ivar2;
+}
+@end
+
+
+@implementation Sub
+- (void)callMethodOnSuperInCXXLambda; {
+ // Explicit capture.
+ [self]() {
+ [super superMethod];
+ }();
+
+ // Implicit capture.
+ [=]() {
+ [super superMethod];
+ }();
+}
+
+- (void)swapIvars {
+ int tmp = _ivar1;
+ _ivar1 = _ivar2;
+ _ivar2 = tmp;
+}
+
+- (void)callMethodOnSelfInCXXLambda; {
+ _ivar1 = 7;
+ _ivar2 = 8;
+ [self]() {
+ [self swapIvars];
+ }();
+
+ clang_analyzer_eval(_ivar1 == 8); // expected-warning{{TRUE}}
+ clang_analyzer_eval(_ivar2 == 7); // expected-warning{{TRUE}}
+}
+
+@end
OpenPOWER on IntegriCloud