summaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorDevin Coughlin <dcoughlin@apple.com>2017-12-04 04:46:47 +0000
committerDevin Coughlin <dcoughlin@apple.com>2017-12-04 04:46:47 +0000
commit6a217e4c25e66055338c0c58d33d8a7e793f8b28 (patch)
tree5642f63e217316bdc9c975651fa9f7fd3b4ed298 /test/Analysis
parent008134d00bbe515d1d885aa2e021d698d3d41a04 (diff)
[analyzer] Don't treat lambda-captures float constexprs as undefined
RegionStore has special logic to evaluate captured constexpr variables. However, if the constexpr initializer cannot be evaluated as an integer, the value is treated as undefined. This leads to false positives when, for example, a constexpr float is captured by a lambda. To fix this, treat a constexpr capture that cannot be evaluated as unknown rather than undefined. rdar://problem/35784662 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319638 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/lambdas.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp
index f3ff9b9539..38a2e3a84f 100644
--- a/test/Analysis/lambdas.cpp
+++ b/test/Analysis/lambdas.cpp
@@ -337,6 +337,16 @@ void captureByReference() {
lambda2();
}
+void testCapturedConstExprFloat() {
+ constexpr float localConstant = 4.0;
+ auto lambda = []{
+ // Don't treat localConstant as containing a garbage value
+ float copy = localConstant; // no-warning
+ (void)copy;
+ };
+
+ lambda();
+}
// CHECK: [B2 (ENTRY)]
// CHECK: Succs (1): B1