summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/loop-block-counts.c2
-rw-r--r--clang/test/Analysis/loop-unrolling.cpp10
-rw-r--r--clang/test/Analysis/stack-frame-context-revision.cpp37
3 files changed, 43 insertions, 6 deletions
diff --git a/clang/test/Analysis/loop-block-counts.c b/clang/test/Analysis/loop-block-counts.c
index 04a3f747c2e..66bb850780c 100644
--- a/clang/test/Analysis/loop-block-counts.c
+++ b/clang/test/Analysis/loop-block-counts.c
@@ -12,7 +12,7 @@ void loop() {
for (int i = 0; i < 2; ++i)
callee(&arr[i]);
// FIXME: Should be UNKNOWN.
- clang_analyzer_eval(arr[0] == arr[1]); // expected-warning{{TRUE}}
+ clang_analyzer_eval(arr[0] == arr[1]); // expected-warning{{FALSE}}
}
void loopWithCall() {
diff --git a/clang/test/Analysis/loop-unrolling.cpp b/clang/test/Analysis/loop-unrolling.cpp
index b7375df38b6..761bf5af6a8 100644
--- a/clang/test/Analysis/loop-unrolling.cpp
+++ b/clang/test/Analysis/loop-unrolling.cpp
@@ -347,9 +347,9 @@ int simple_known_bound_loop() {
int simple_unknown_bound_loop() {
for (int i = 2; i < getNum(); i++) {
#ifdef DFS
- clang_analyzer_numTimesReached(); // expected-warning {{10}}
+ clang_analyzer_numTimesReached(); // expected-warning {{16}}
#else
- clang_analyzer_numTimesReached(); // expected-warning {{13}}
+ clang_analyzer_numTimesReached(); // expected-warning {{8}}
#endif
}
return 0;
@@ -368,10 +368,10 @@ int nested_inlined_unroll1() {
int nested_inlined_no_unroll1() {
int k;
for (int i = 0; i < 9; i++) {
-#ifdef ANALYZER_CM_Z3
- clang_analyzer_numTimesReached(); // expected-warning {{13}}
+#ifdef DFS
+ clang_analyzer_numTimesReached(); // expected-warning {{18}}
#else
- clang_analyzer_numTimesReached(); // expected-warning {{15}}
+ clang_analyzer_numTimesReached(); // expected-warning {{14}}
#endif
k = simple_unknown_bound_loop(); // reevaluation without inlining, splits the state as well
}
diff --git a/clang/test/Analysis/stack-frame-context-revision.cpp b/clang/test/Analysis/stack-frame-context-revision.cpp
new file mode 100644
index 00000000000..8c119f50c14
--- /dev/null
+++ b/clang/test/Analysis/stack-frame-context-revision.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -verify %s
+
+// expected-no-diagnostics:
+// From now the profile of the 'StackFrameContext' also contains the
+// 'NodeBuilderContext::blockCount()'. With this addition we can distinguish
+// between the 'StackArgumentsSpaceRegion' of the 'P' arguments being different
+// on every iteration.
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+template <typename PointerTy>
+struct SmarterPointer {
+ PointerTy getFromVoidPointer(void *P) const {
+ return static_cast<PointerTy>(P);
+ }
+
+ PointerTy getPointer() const {
+ return getFromVoidPointer(reinterpret_cast<void *>(Value));
+ }
+
+ intptr_t Value = 13;
+};
+
+struct Node {
+ SmarterPointer<Node *> Pred;
+};
+
+void test(Node *N) {
+ while (N) {
+ SmarterPointer<Node *> Next = N->Pred;
+ delete N;
+
+ N = Next.getPointer();
+ // no-warning: 'Use of memory after it is freed' was here as the same
+ // 'StackArgumentsSpaceRegion' purged out twice as 'P'.
+ }
+}
OpenPOWER on IntegriCloud