Ted Kremenek | ade3195 | 2011-03-12 06:14:28 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=deadcode.IdempotentOperations -verify %s |
Tom Care | ef52bcb | 2010-08-24 21:09:07 +0000 | [diff] [blame] | 2 | |
| 3 | // C++ specific false positives |
| 4 | |
| 5 | extern void test(int i); |
| 6 | extern void test_ref(int &i); |
| 7 | |
| 8 | // Test references affecting pseudoconstants |
| 9 | void false1() { |
| 10 | int a = 0; |
| 11 | int five = 5; |
| 12 | int &b = a; |
| 13 | test(five * a); // expected-warning {{The right operand to '*' is always 0}} |
| 14 | b = 4; |
| 15 | } |
Ted Kremenek | 422ab7a | 2011-04-02 02:56:23 +0000 | [diff] [blame^] | 16 | |
| 17 | // Test not flagging idempotent operations because we aborted the analysis |
| 18 | // of a path because of an unsupported construct. |
| 19 | struct RDar9219143_Foo { |
| 20 | ~RDar9219143_Foo(); |
| 21 | operator bool() const; |
| 22 | }; |
| 23 | |
| 24 | RDar9219143_Foo foo(); |
| 25 | unsigned RDar9219143_bar(); |
| 26 | void RDar9219143_test() { |
| 27 | unsigned i, e; |
| 28 | for (i = 0, e = RDar9219143_bar(); i != e; ++i) |
| 29 | if (foo()) |
| 30 | break; |
| 31 | if (i == e) // no-warning |
| 32 | return; |
| 33 | } |
| 34 | |