[cfe-commits] r158791 - in /cfe/trunk/test/Analysis: new-fail.cpp new.cpp
Jordan Rose
jordan_rose at apple.com
Tue Jun 19 22:34:32 PDT 2012
Author: jrose
Date: Wed Jun 20 00:34:32 2012
New Revision: 158791
URL: http://llvm.org/viewvc/llvm-project?rev=158791&view=rev
Log:
[analyzer] Move failing 'new' test cases back into new.cpp instead of XFAILing.
Per Anna's comment, this is a better way to handle "to-do list"-type failures.
This way we'll know if any of the features get fixed; in an XFAIL file, /all/
the cases have to be fixed before lit would tell us anything.
Removed:
cfe/trunk/test/Analysis/new-fail.cpp
Modified:
cfe/trunk/test/Analysis/new.cpp
Removed: cfe/trunk/test/Analysis/new-fail.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/new-fail.cpp?rev=158790&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/new-fail.cpp (original)
+++ cfe/trunk/test/Analysis/new-fail.cpp (removed)
@@ -1,21 +0,0 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store region -verify %s
-// XFAIL: *
-
-void f1() {
- int *n = new int;
- if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}}
- }
-}
-
-void f2() {
- int *n = new int(3);
- if (*n) { // no-warning
- }
-}
-
-void *operator new(size_t, void *, void *);
-void *testCustomNew() {
- int *x = (int *)malloc(sizeof(int));
- void *y = new (0, x) int;
- return y; // no-warning (placement new could have freed x)
-}
Modified: cfe/trunk/test/Analysis/new.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/new.cpp?rev=158791&r1=158790&r2=158791&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/new.cpp (original)
+++ cfe/trunk/test/Analysis/new.cpp Wed Jun 20 00:34:32 2012
@@ -34,3 +34,34 @@
return y; // no-warning
}
+
+//--------------------------------
+// Incorrectly-modelled behavior
+//--------------------------------
+
+void testZeroInitialization() {
+ int *n = new int;
+
+ // Should warn that *n is uninitialized.
+ if (*n) { // no-warning
+ }
+}
+
+void testValueInitialization() {
+ int *n = new int(3);
+
+ // Should be TRUE (and have no uninitialized variable warning)
+ clang_analyzer_eval(*n == 3); // expected-warning{{UNKNOWN}}
+}
+
+
+void *operator new(size_t, void *, void *);
+void *testCustomNewMalloc() {
+ int *x = (int *)malloc(sizeof(int));
+
+ // Should be no-warning (the custom allocator could have freed x).
+ void *y = new (0, x) int; // expected-warning{{leak of memory pointed to by 'x'}}
+
+ return y;
+}
+
More information about the cfe-commits
mailing list