diff options
author | Tom Care <tom.care@uqconnect.edu.au> | 2010-08-12 22:45:47 +0000 |
---|---|---|
committer | Tom Care <tom.care@uqconnect.edu.au> | 2010-08-12 22:45:47 +0000 |
commit | f8a9863df942e69d58e34432da3532a4ead650ad (patch) | |
tree | 33e95eec6ee0e8fc7f6fccec372afa66834ab9d7 /clang/test/Analysis/idempotent-operations.c | |
parent | b5a6246b91cc4240b2b5113aaf2d181021f64ba7 (diff) | |
download | bcm5719-llvm-f8a9863df942e69d58e34432da3532a4ead650ad.tar.gz bcm5719-llvm-f8a9863df942e69d58e34432da3532a4ead650ad.zip |
Improved IdempotentOperationChecker false positives and false negatives.
- Unfinished analysis may still report valid warnings if the path was completely analyzed
- New 'CanVary' heuristic to recursively determine if a subexpression has a varying element
- Updated test cases, including one known bug
- Exposed GRCoreEngine through GRExprEngine
llvm-svn: 110970
Diffstat (limited to 'clang/test/Analysis/idempotent-operations.c')
-rw-r--r-- | clang/test/Analysis/idempotent-operations.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/clang/test/Analysis/idempotent-operations.c b/clang/test/Analysis/idempotent-operations.c index 2543b1a0068..23401e8cdb8 100644 --- a/clang/test/Analysis/idempotent-operations.c +++ b/clang/test/Analysis/idempotent-operations.c @@ -53,20 +53,33 @@ void basic() { } void floats(float x) { - test_f(x * 1.0); // no-warning + test_f(x * 1.0); // no-warning test_f(x * 1.0F); // no-warning } -// Ensure that we don't report false poitives on complex loops +// Ensure that we don't report false poitives in complex loops void bailout() { - int unused, result = 4; - int numbers[5] = { 0, 32, 'x', 128, 255 }; + int unused = 0, result = 4; + result = result; // expected-warning {{Assigned value is always the same as the existing value}} - for (int bg = 0; bg < 5; bg ++) { - result += numbers[bg]; // no-warning + for (unsigned bg = 0; bg < 1024; bg ++) { + result = bg * result; // no-warning for (int i = 0; i < 256; i++) { - unused = i; + unused *= i; // no-warning } } } + +// False positive tests + +unsigned false1() { + return (5 - 2 - 3); // no-warning +} + +enum testenum { enum1 = 0, enum2 }; +unsigned false2() { + return enum1; // no-warning +} + +extern unsigned foo(); |