diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-05-02 19:51:20 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-05-02 19:51:20 +0000 |
commit | 4b75085f5669efc6407c662b5686361624c3ff2f (patch) | |
tree | 959f9cebb4a939a426b72fd52f2aa66605c048fc /test/Analysis | |
parent | 4e3b54b4acb4dd926ca50d7f06c8265d1d24ba79 (diff) |
[analyzer] Don't try to evaluate MaterializeTemporaryExpr as a constant.
...and don't consider '0' to be a null pointer constant if it's the
initializer for a float!
Apparently null pointer constant evaluation looks through both
MaterializeTemporaryExpr and ImplicitCastExpr, so we have to be more
careful about types in the callers. For RegionStore this just means giving
up a little more; for ExprEngine this means handling the
MaterializeTemporaryExpr case explicitly.
Follow-up to r180894.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180944 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/inline.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/test/Analysis/inline.cpp b/test/Analysis/inline.cpp index 62bce28472..909e18017b 100644 --- a/test/Analysis/inline.cpp +++ b/test/Analysis/inline.cpp @@ -262,12 +262,33 @@ namespace DefaultArgs { } int defaultReference(const int &input = 42) { - return input; + return -input; + } + int defaultReferenceZero(const int &input = 0) { + return -input; } void testReference() { - clang_analyzer_eval(defaultReference(1) == 1); // expected-warning{{TRUE}} - clang_analyzer_eval(defaultReference() == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(defaultReference(1) == -1); // expected-warning{{TRUE}} + clang_analyzer_eval(defaultReference() == -42); // expected-warning{{TRUE}} + + clang_analyzer_eval(defaultReferenceZero(1) == -1); // expected-warning{{TRUE}} + clang_analyzer_eval(defaultReferenceZero() == 0); // expected-warning{{TRUE}} +} + + double defaultFloatReference(const double &i = 42) { + return -i; + } + double defaultFloatReferenceZero(const double &i = 0) { + return -i; + } + + void testFloatReference() { + clang_analyzer_eval(defaultFloatReference(1) == -1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(defaultFloatReference() == -42); // expected-warning{{UNKNOWN}} + + clang_analyzer_eval(defaultFloatReferenceZero(1) == -1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(defaultFloatReferenceZero() == 0); // expected-warning{{UNKNOWN}} } } |