diff options
| author | Tom Care <tom.care@uqconnect.edu.au> | 2010-08-23 19:51:57 +0000 |
|---|---|---|
| committer | Tom Care <tom.care@uqconnect.edu.au> | 2010-08-23 19:51:57 +0000 |
| commit | e332c3b762790241706215bb84a787acb42a949e (patch) | |
| tree | f0fc278eef94e0fd7838bdadce0be642bceda972 /clang/test | |
| parent | 58bd73a5a7b60becc487bf373bb1660e3b18c92d (diff) | |
| download | bcm5719-llvm-e332c3b762790241706215bb84a787acb42a949e.tar.gz bcm5719-llvm-e332c3b762790241706215bb84a787acb42a949e.zip | |
Several small changes to PseudoConstantAnalysis and the way IdempotentOperationChecker uses it.
- Psuedo -> Pseudo (doh...)
- C++ reference support
- Added pseudoconstant test case for __block vars
- Separated out static local checking from pseudoconstant analysis and generalized to non-local checking
- Added missing test cases for storage false positives
llvm-svn: 111832
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/idempotent-operations.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/clang/test/Analysis/idempotent-operations.c b/clang/test/Analysis/idempotent-operations.c index abf67103c11..179c7a4da3f 100644 --- a/clang/test/Analysis/idempotent-operations.c +++ b/clang/test/Analysis/idempotent-operations.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -verify -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s // Basic tests @@ -51,7 +51,7 @@ unsigned basic() { test(zero << x); // expected-warning {{The left operand to '<<' is always 0}} test(zero >> x); // expected-warning {{The left operand to '>>' is always 0}} - // Overwrite the values so these aren't marked as psuedoconstants + // Overwrite the values so these aren't marked as Pseudoconstants x = 1; zero = 2; one = 3; @@ -102,12 +102,38 @@ unsigned false3(int param) { return nonparam; } -// Psuedo-constants (vars only read) and constants should not be reported +// Pseudo-constants (vars only read) and constants should not be reported unsigned false4() { // Trivial constant - const int height = 1; // no-warning - // Psuedo-constant (never changes after decl) - int width = height; // no-warning + const int height = 1; + + // Pseudo-constant (never changes after decl) + int width = height; + + // Pseudo-constant (blockvar) + __block int a = 0; + int b = 10; + a *= b; // no-warning + test(a); return width * 10; // no-warning } + +// Static vars are common false positives +int false5() { + static int test = 0; + int a = 56; + a *= test; // no-warning + test++; + return a; +} + +// Non-local storage vars are considered false positives +int globalInt = 1; +int false6() { + int localInt = 23; + + localInt /= globalInt; + + return localInt; +} |

