diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-01-20 21:25:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-01-20 21:25:31 +0000 |
commit | 2d4bed140f65d713673d2d32ec3adadc960078c6 (patch) | |
tree | afc8b312473c41cd32fc2f8b2a73c47d378363d5 /test/SemaCXX/uninit-variables.cpp | |
parent | c32bb2affdd08fdec092e4374d0a184713c488d7 (diff) |
Relax CFG assertions in UninitializedValuesV2 when
handling pseudo-path sensitivity, and instead
use those assertion conditions as dynamic checks.
These assertions would be violated when analyzing
a CFG where some branches where optimized away
during CFG construction because their branch
conditions could be trivially determined.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123943 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/uninit-variables.cpp')
-rw-r--r-- | test/SemaCXX/uninit-variables.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp index e971357ca7..0d6920ceb3 100644 --- a/test/SemaCXX/uninit-variables.cpp +++ b/test/SemaCXX/uninit-variables.cpp @@ -13,3 +13,31 @@ int test2_aux() { return x; // no-warning } +// Handle cases where the CFG may constant fold some branches, thus +// mitigating the need for some path-sensitivity in the analysis. +unsigned test3_aux(); +unsigned test3() { + unsigned x = 0; + const bool flag = true; + if (flag && (x = test3_aux()) == 0) { + return x; + } + return x; +} +unsigned test3_b() { + unsigned x ; + const bool flag = true; + if (flag && (x = test3_aux()) == 0) { + x = 1; + } + return x; // no-warning +} +unsigned test3_c() { + unsigned x ; + const bool flag = false; + if (flag && (x = test3_aux()) == 0) { + x = 1; + } + return x; // expected-warning{{use of uninitialized variable 'x'}} +} + |