summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/lambdas.cpp
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
commita565a7b9b835656746d82425721d0f0eb69e3113 (patch)
treef2f16b43610a7e4858779a17f1a1662068c4e65a /clang/test/Analysis/lambdas.cpp
parent569e53b0f63001284a521a7a91c9cb189b3bdc7f (diff)
downloadbcm5719-llvm-a565a7b9b835656746d82425721d0f0eb69e3113.tar.gz
bcm5719-llvm-a565a7b9b835656746d82425721d0f0eb69e3113.zip
[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 llvm-svn: 319638
Diffstat (limited to 'clang/test/Analysis/lambdas.cpp')
-rw-r--r--clang/test/Analysis/lambdas.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/Analysis/lambdas.cpp b/clang/test/Analysis/lambdas.cpp
index f3ff9b95393..38a2e3a84fb 100644
--- a/clang/test/Analysis/lambdas.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud