summaryrefslogtreecommitdiff
path: root/test/Analysis/lambdas.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /test/Analysis/lambdas.cpp
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'test/Analysis/lambdas.cpp')
-rw-r--r--test/Analysis/lambdas.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp
index 320ba2aabc227..fdd1c61164f4c 100644
--- a/test/Analysis/lambdas.cpp
+++ b/test/Analysis/lambdas.cpp
@@ -1,10 +1,26 @@
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core -analyzer-config inline-lambdas=false -DNO_INLINING=1 -verify %s
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,debug.DumpCFG -analyzer-config inline-lambdas=true %s > %t 2>&1
// RUN: FileCheck --input-file=%t %s
void clang_analyzer_warnIfReached();
void clang_analyzer_eval(int);
+#ifdef NO_INLINING
+
+// expected-no-diagnostics
+
+int& invalidate_static_on_unknown_lambda() {
+ static int* z;
+ auto f = [] {
+ z = nullptr;
+ }; // should invalidate "z" when inlining is disabled.
+ f();
+ return *z; // no-warning
+}
+
+#else
+
struct X { X(const X&); };
void f(X x) { (void) [x]{}; }
@@ -348,6 +364,18 @@ void testCapturedConstExprFloat() {
lambda();
}
+void escape(void*);
+
+int& invalidate_static_on_unknown_lambda() {
+ static int* z;
+ auto lambda = [] {
+ static float zz;
+ z = new int(120);
+ };
+ escape(&lambda);
+ return *z; // no-warning
+}
+
static int b = 0;
@@ -365,6 +393,8 @@ int f() {
return 0;
}
+#endif
+
// CHECK: [B2 (ENTRY)]
// CHECK: Succs (1): B1
// CHECK: [B1]