aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-12-15 04:12:12 +0000
committerTed Kremenek <kremenek@apple.com>2009-12-15 04:12:12 +0000
commit43f19e3136a9610eeba3cdef9f9af70d93df2f7e (patch)
tree32bc0b7df4e25379dbf557a3561d3e4283323b9c /test
parentea5ae3170d8022c2007295ec794bdaf63f0273a1 (diff)
Until we can make the dead stores checker smarter, dont' emit dead store warnings for C++ objects (whose constructors/destructors have possible side-effects).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/dead-stores.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp
index 1bab9f4bad..363cfdd98c 100644
--- a/test/Analysis/dead-stores.cpp
+++ b/test/Analysis/dead-stores.cpp
@@ -4,6 +4,10 @@
// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -warn-dead-stores -verify %s
// RUN: clang -cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -warn-dead-stores -verify %s
+//===----------------------------------------------------------------------===//
+// Basic dead store checking (but in C++ mode).
+//===----------------------------------------------------------------------===//
+
int j;
void f1() {
int x = 4;
@@ -17,3 +21,19 @@ void f1() {
break;
}
}
+
+//===----------------------------------------------------------------------===//
+// Dead store checking involving constructors.
+//===----------------------------------------------------------------------===//
+
+class Test1 {
+ int &x;
+public:
+ Test1(int &y) : x(y) {}
+ ~Test1() { ++x; }
+};
+
+int test_ctor_1(int x) {
+ { Test1 a(x); } // no-warning
+ return x;
+}