diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
commit | 7442d6faa2719e4e7d33a7021c406c5a4facd74d (patch) | |
tree | c72b9241553fc9966179aba84f90f17bfa9235c3 /test/Analysis | |
parent | b52119637f743680a99710ce5fdb6646da2772af (diff) | |
download | src-7442d6faa2719e4e7d33a7021c406c5a4facd74d.tar.gz src-7442d6faa2719e4e7d33a7021c406c5a4facd74d.zip |
Vendor import of clang trunk r300422:vendor/clang/clang-trunk-r300422
Notes
Notes:
svn path=/vendor/clang/dist/; revision=317019
svn path=/vendor/clang/clang-trunk-r300422/; revision=317020; tag=vendor/clang/clang-trunk-r300422
Diffstat (limited to 'test/Analysis')
417 files changed, 2060 insertions, 914 deletions
diff --git a/test/Analysis/CFContainers-invalid.c b/test/Analysis/CFContainers-invalid.c index 3268e1eae253..ce1284f75da7 100644 --- a/test/Analysis/CFContainers-invalid.c +++ b/test/Analysis/CFContainers-invalid.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues -triple x86_64-apple-darwin -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues -triple x86_64-apple-darwin -verify %s // expected-no-diagnostics typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/CFContainers.mm b/test/Analysis/CFContainers.mm index f315bc9f045c..0a45bffe5acf 100644 --- a/test/Analysis/CFContainers.mm +++ b/test/Analysis/CFContainers.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s typedef const struct __CFAllocator * CFAllocatorRef; typedef const struct __CFString * CFStringRef; diff --git a/test/Analysis/CFDateGC.m b/test/Analysis/CFDateGC.m index fae144f859a8..714e213f9577 100644 --- a/test/Analysis/CFDateGC.m +++ b/test/Analysis/CFDateGC.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/CFNumber.c b/test/Analysis/CFNumber.c index d7dd951b93ce..7ac65cc1d2b2 100644 --- a/test/Analysis/CFNumber.c +++ b/test/Analysis/CFNumber.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s typedef signed long CFIndex; typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/CFRetainRelease_NSAssertionHandler.m b/test/Analysis/CFRetainRelease_NSAssertionHandler.m index be1f20de762c..f358ee64ceb4 100644 --- a/test/Analysis/CFRetainRelease_NSAssertionHandler.m +++ b/test/Analysis/CFRetainRelease_NSAssertionHandler.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-store=region +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-store=region // expected-no-diagnostics typedef struct objc_selector *SEL; diff --git a/test/Analysis/CGColorSpace.c b/test/Analysis/CGColorSpace.c index 8681e15d39e5..38f0512b0063 100644 --- a/test/Analysis/CGColorSpace.c +++ b/test/Analysis/CGColorSpace.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s typedef struct CGColorSpace *CGColorSpaceRef; extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); diff --git a/test/Analysis/CheckNSError.m b/test/Analysis/CheckNSError.m index d126d29157b8..6de98e85efe3 100644 --- a/test/Analysis/CheckNSError.m +++ b/test/Analysis/CheckNSError.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s typedef signed char BOOL; diff --git a/test/Analysis/DeallocMissingRelease.m b/test/Analysis/DeallocMissingRelease.m index 651f20a13621..91af2bd0a231 100644 --- a/test/Analysis/DeallocMissingRelease.m +++ b/test/Analysis/DeallocMissingRelease.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-ios4.0 -DMACOS=0 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-macosx10.6.0 -DMACOS=1 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-ios4.0 -DMACOS=0 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-macosx10.6.0 -DMACOS=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s #include "Inputs/system-header-simulator-for-objc-dealloc.h" diff --git a/test/Analysis/DeallocUseAfterFreeErrors.m b/test/Analysis/DeallocUseAfterFreeErrors.m index c131e71f44a1..2e1bdc41bb6e 100644 --- a/test/Analysis/DeallocUseAfterFreeErrors.m +++ b/test/Analysis/DeallocUseAfterFreeErrors.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/DynamicTypePropagation.m b/test/Analysis/DynamicTypePropagation.m index 79ef37c794d0..25a0ae35fd32 100644 --- a/test/Analysis/DynamicTypePropagation.m +++ b/test/Analysis/DynamicTypePropagation.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.ObjCGenerics -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.ObjCGenerics -verify %s #if !__has_feature(objc_generics) # error Compiler does not support Objective-C generics? diff --git a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp index 6fab8bb668e8..b5e47b3355da 100644 --- a/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp +++ b/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s #include "Inputs/system-header-simulator-for-malloc.h" diff --git a/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp b/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp index bca223b6e04a..88435b866acd 100644 --- a/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp +++ b/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s // expected-no-diagnostics typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/Malloc+NewDelete_intersections.cpp b/test/Analysis/Malloc+NewDelete_intersections.cpp index d10020dc8e66..9140e1f4a372 100644 --- a/test/Analysis/Malloc+NewDelete_intersections.cpp +++ b/test/Analysis/Malloc+NewDelete_intersections.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); diff --git a/test/Analysis/MemRegion.cpp b/test/Analysis/MemRegion.cpp index 992b7f1f9767..b8f079a773df 100644 --- a/test/Analysis/MemRegion.cpp +++ b/test/Analysis/MemRegion.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -verify %s #include "MPIMock.h" diff --git a/test/Analysis/MismatchedDeallocator-checker-test.mm b/test/Analysis/MismatchedDeallocator-checker-test.mm index 3cc3e18c7c7c..b80f7df233dd 100644 --- a/test/Analysis/MismatchedDeallocator-checker-test.mm +++ b/test/Analysis/MismatchedDeallocator-checker-test.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -fblocks -verify %s #include "Inputs/system-header-simulator-objc.h" #include "Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/MismatchedDeallocator-path-notes.cpp b/test/Analysis/MismatchedDeallocator-path-notes.cpp index 1c8c80cf21b9..118f23bca114 100644 --- a/test/Analysis/MismatchedDeallocator-path-notes.cpp +++ b/test/Analysis/MismatchedDeallocator-path-notes.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void changePointee(int *p); diff --git a/test/Analysis/MissingDealloc.m b/test/Analysis/MissingDealloc.m index 248dc514c876..bedd1e7fc25a 100644 --- a/test/Analysis/MissingDealloc.m +++ b/test/Analysis/MissingDealloc.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify -triple x86_64-apple-darwin10 -fobjc-arc %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify -triple x86_64-apple-darwin10 -fobjc-arc %s #define NON_ARC !__has_feature(objc_arc) diff --git a/test/Analysis/MisusedMovedObject.cpp b/test/Analysis/MisusedMovedObject.cpp new file mode 100644 index 000000000000..44e055fd407b --- /dev/null +++ b/test/Analysis/MisusedMovedObject.cpp @@ -0,0 +1,619 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify -analyzer-output=text %s + +namespace std { + +template <typename> +struct remove_reference; + +template <typename _Tp> +struct remove_reference { typedef _Tp type; }; + +template <typename _Tp> +struct remove_reference<_Tp &> { typedef _Tp type; }; + +template <typename _Tp> +struct remove_reference<_Tp &&> { typedef _Tp type; }; + +template <typename _Tp> +typename remove_reference<_Tp>::type &&move(_Tp &&__t) { + return static_cast<typename remove_reference<_Tp>::type &&>(__t); +} + +template <typename _Tp> +_Tp &&forward(typename remove_reference<_Tp>::type &__t) noexcept { + return static_cast<_Tp &&>(__t); +} + +template <class T> +void swap(T &a, T &b) { + T c(std::move(a)); + a = std::move(b); + b = std::move(c); +} + +} // namespace std + +class B { +public: + B() = default; + B(const B &) = default; + B(B &&) = default; + void operator=(B &&b) { + return; + } + void foo() { return; } +}; + +class A { + int i; + double d; + +public: + B b; + A(int ii = 42, double dd = 1.0) : d(dd), i(ii), b(B()) {} + void moveconstruct(A &&other) { + std::swap(b, other.b); + std::swap(d, other.d); + std::swap(i, other.i); + return; + } + static A get() { + A v(12, 13); + return v; + } + A(A *a) { + moveconstruct(std::move(*a)); + } + A(const A &other) : i(other.i), d(other.d), b(other.b) {} + A(A &&other) : i(other.i), d(other.d), b(std::move(other.b)) { // expected-note {{'b' became 'moved-from' here}} + } + A(A &&other, char *k) { + moveconstruct(std::move(other)); + } + void operator=(A &&other) { + moveconstruct(std::move(other)); + return; + } + int getI() { return i; } + int foo() const; + void bar() const; + void reset(); + void destroy(); + void clear(); + bool empty() const; + bool isEmpty() const; + operator bool() const; +}; + +int bignum(); + +void moveInsideFunctionCall(A a) { + A b = std::move(a); +} +void leftRefCall(A &a) { + a.foo(); +} +void rightRefCall(A &&a) { + a.foo(); +} +void constCopyOrMoveCall(const A a) { + a.foo(); +} + +void copyOrMoveCall(A a) { + a.foo(); +} + +void simpleMoveCtorTest() { + A a; + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} +} + +void simpleMoveAssignementTest() { + A a; + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} +} + +void moveInInitListTest() { + struct S { + A a; + }; + A a; + S s{std::move(a)}; // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} +} + +// Don't report a bug if the variable was assigned to in the meantime. +void reinitializationTest(int i) { + { + A a; + A b; + b = std::move(a); + a = A(); + a.foo(); + } + { + A a; + if (i == 1) { // expected-note {{Assuming 'i' is not equal to 1}} expected-note {{Taking false branch}} + // expected-note@-1 {{Assuming 'i' is not equal to 1}} expected-note@-1 {{Taking false branch}} + A b; + b = std::move(a); + a = A(); + } + if (i == 2) { // expected-note {{Assuming 'i' is not equal to 2}} expected-note {{Taking false branch}} + //expected-note@-1 {{Assuming 'i' is not equal to 2}} expected-note@-1 {{Taking false branch}} + a.foo(); // no-warning + } + } + { + A a; + if (i == 1) { // expected-note {{Taking false branch}} expected-note {{Taking false branch}} + std::move(a); + } + if (i == 2) { // expected-note {{Taking false branch}} expected-note {{Taking false branch}} + a = A(); + a.foo(); + } + } + // The built-in assignment operator should also be recognized as a + // reinitialization. (std::move() may be called on built-in types in template + // code.) + { + int a1 = 1, a2 = 2; + std::swap(a1, a2); + } + // A std::move() after the assignment makes the variable invalid again. + { + A a; + A b; + b = std::move(a); + a = A(); + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + } + // If a path exist where we not reinitialize the variable we report a bug. + { + A a; + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + if (i < 10) { // expected-note {{Assuming 'i' is >= 10}} expected-note {{Taking false branch}} + a = A(); + } + if (i > 5) { // expected-note {{Taking true branch}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + } + } +} + +// Using decltype on an expression is not a use. +void decltypeIsNotUseTest() { + A a; + // A b(std::move(a)); + decltype(a) other_a; // no-warning +} + +void loopTest() { + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is false. Execution jumps to the end of the function}} + rightRefCall(std::move(a)); // no-warning + } + } + { + A a; + for (int i = 0; i < 2; i++) { // expected-note {{Loop condition is true. Entering loop body}} + //expected-note@-1 {{Loop condition is true. Entering loop body}} + //expected-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} + rightRefCall(std::move(a)); // no-warning + } + } + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is false. Execution jumps to the end of the function}} + leftRefCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < 2; i++) { // expected-note {{Loop condition is true. Entering loop body}} + //expected-note@-1 {{Loop condition is true. Entering loop body}} + //expected-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} + leftRefCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is false. Execution jumps to the end of the function}} + constCopyOrMoveCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < 2; i++) { // expected-note {{Loop condition is true. Entering loop body}} + //expected-note@-1 {{Loop condition is true. Entering loop body}} + //expected-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} + constCopyOrMoveCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is false. Execution jumps to the end of the function}} + moveInsideFunctionCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < 2; i++) { // expected-note {{Loop condition is true. Entering loop body}} + //expected-note@-1 {{Loop condition is true. Entering loop body}} + //expected-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} + moveInsideFunctionCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is false. Execution jumps to the end of the function}} + copyOrMoveCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < 2; i++) { // expected-note {{Loop condition is true.}} + //expected-note@-1 {{Loop condition is true. Entering loop body}} + //expected-note@-2 {{Loop condition is false. Execution jumps to the end of the function}} + copyOrMoveCall(a); // no-warning + } + } + { + A a; + for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is true. Entering loop body}} expected-note {{Loop condition is true. Entering loop body}} + constCopyOrMoveCall(std::move(a)); // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}} + // expected-note@-1 {{'a' became 'moved-from' here}} + } + } + + // Don't warn if we return after the move. + { + A a; + for (int i = 0; i < 3; ++i) { + a.bar(); + if (a.foo() > 0) { + A b; + b = std::move(a); // no-warning + return; + } + } + } +} + +//report a usage of a moved-from object only at the first use +void uniqueTest(bool cond) { + A a(42, 42.0); + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + + if (cond) { // expected-note {{Assuming 'cond' is not equal to 0}} expected-note {{Taking true branch}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + } + if (cond) { + a.bar(); // no-warning + } + + a.bar(); // no-warning +} + +void uniqueTest2() { + A a; + A a1 = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + + A a2 = std::move(a); // no-warning + a.foo(); // no-warning +} + +// There are exceptions where we assume in general that the method works fine +//even on moved-from objects. +void moveSafeFunctionsTest() { + A a; + A b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.empty(); // no-warning + a.isEmpty(); // no-warning + (void)a; // no-warning + (bool)a; // expected-warning {{expression result unused}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} +} + +void moveStateResetFunctionsTest() { + { + A a; + A b = std::move(a); + a.reset(); // no-warning + a.foo(); // no-warning + } + { + A a; + A b = std::move(a); + a.destroy(); // no-warning + a.foo(); // no-warning + } + { + A a; + A b = std::move(a); + a.clear(); // no-warning + a.foo(); // no-warning + } +} + +// Moves or uses that occur as part of template arguments. +template <int> +class ClassTemplate { +public: + void foo(A a); +}; + +template <int> +void functionTemplate(A a); + +void templateArgIsNotUseTest() { + { + // A pattern like this occurs in the EXPECT_EQ and ASSERT_EQ macros in + // Google Test. + A a; + ClassTemplate<sizeof(A(std::move(a)))>().foo(std::move(a)); // no-warning + } + { + A a; + functionTemplate<sizeof(A(std::move(a)))>(std::move(a)); // no-warning + } +} + +// Moves of global variables are not reported. +A global_a; +void globalVariablesTest() { + std::move(global_a); + global_a.foo(); // no-warning +} + +// Moves of member variables. +class memberVariablesTest { + A a; + static A static_a; + + void f() { + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object 'a'}} + + b = std::move(static_a); // expected-note {{'static_a' became 'moved-from' here}} + static_a.foo(); // expected-warning {{Method call on a 'moved-from' object 'static_a'}} expected-note {{Method call on a 'moved-from' object 'static_a'}} + } +}; + +void PtrAndArrayTest() { + A *Ptr = new A(1, 1.5); + A Arr[10]; + Arr[2] = std::move(*Ptr); // expected-note {{Became 'moved-from' here}} + (*Ptr).foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}} + + Ptr = &Arr[1]; + Arr[3] = std::move(Arr[1]); // expected-note {{Became 'moved-from' here}} + Ptr->foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}} + + Arr[3] = std::move(Arr[2]); // expected-note {{Became 'moved-from' here}} + Arr[2].foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object}} + + Arr[2] = std::move(Arr[3]); // reinitialization + Arr[2].foo(); // no-warning +} + +void exclusiveConditionsTest(bool cond) { + A a; + if (cond) { + A b; + b = std::move(a); + } + if (!cond) { + a.bar(); // no-warning + } +} + +void differentBranchesTest(int i) { + // Don't warn if the use is in a different branch from the move. + { + A a; + if (i > 0) { // expected-note {{Assuming 'i' is > 0}} expected-note {{Taking true branch}} + A b; + b = std::move(a); + } else { + a.foo(); // no-warning + } + } + // Same thing, but with a ternary operator. + { + A a, b; + i > 0 ? (void)(b = std::move(a)) : a.bar(); // no-warning // expected-note {{'?' condition is true}} + } + // A variation on the theme above. + { + A a; + a.foo() > 0 ? a.foo() : A(std::move(a)).foo(); // expected-note {{Assuming the condition is false}} expected-note {{'?' condition is false}} + } + // Same thing, but with a switch statement. + { + A a, b; + switch (i) { // expected-note {{Control jumps to 'case 1:' at line 448}} + case 1: + b = std::move(a); // no-warning + break; // expected-note {{Execution jumps to the end of the function}} + case 2: + a.foo(); // no-warning + break; + } + } + // However, if there's a fallthrough, we do warn. + { + A a, b; + switch (i) { // expected-note {{Control jumps to 'case 1:' at line 460}} + case 1: + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + case 2: + a.foo(); // expected-warning {{Method call on a 'moved-from' object}} expected-note {{Method call on a 'moved-from' object 'a'}} + break; + } + } +} + +void tempTest() { + A a = A::get(); + A::get().foo(); // no-warning + for (int i = 0; i < bignum(); i++) { + A::get().foo(); // no-warning + } +} + +void interFunTest1(A &a) { + a.bar(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} +} + +void interFunTest2() { + A a; + A b; + b = std::move(a); // expected-note {{'a' became 'moved-from' here}} + interFunTest1(a); // expected-note {{Calling 'interFunTest1'}} +} + +void foobar(A a, int i); +void foobar(int i, A a); + +void paramEvaluateOrderTest() { + A a; + foobar(std::move(a), a.getI()); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + // expected-note@-1 {{'a' became 'moved-from' here}} + + //FALSE NEGATIVE since parameters evaluate order is undefined + foobar(a.getI(), std::move(a)); //no-warning +} + +void not_known(A &a); +void not_known(A *a); + +void regionAndPointerEscapeTest() { + { + A a; + A b; + b = std::move(a); + not_known(a); + a.foo(); //no-warning + } + { + A a; + A b; + b = std::move(a); + not_known(&a); + a.foo(); // no-warning + } +} + +// A declaration statement containing multiple declarations sequences the +// initializer expressions. +void declarationSequenceTest() { + { + A a; + A a1 = a, a2 = std::move(a); // no-warning + } + { + A a; + A a1 = std::move(a), a2 = a; // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}} + // expected-note@-1 {{'a' became 'moved-from' here}} + } +} + +// The logical operators && and || sequence their operands. +void logicalOperatorsSequenceTest() { + { + A a; + if (a.foo() > 0 && A(std::move(a)).foo() > 0) { // expected-note {{Assuming the condition is false}} expected-note {{Assuming the condition is false}} + // expected-note@-1 {{Left side of '&&' is false}} expected-note@-1 {{Left side of '&&' is false}} + //expected-note@-2 {{Taking false branch}} expected-note@-2 {{Taking false branch}} + A().bar(); + } + } + // A variation: Negate the result of the && (which pushes the && further down + // into the AST). + { + A a; + if (!(a.foo() > 0 && A(std::move(a)).foo() > 0)) { // expected-note {{Assuming the condition is false}} expected-note {{Assuming the condition is false}} + // expected-note@-1 {{Left side of '&&' is false}} expected-note@-1 {{Left side of '&&' is false}} + // expected-note@-2 {{Taking true branch}} expected-note@-2 {{Taking true branch}} + A().bar(); + } + } + { + A a; + if (A(std::move(a)).foo() > 0 && a.foo() > 0) { // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + // expected-note@-1 {{'a' became 'moved-from' here}} expected-note@-1 {{Assuming the condition is true}} expected-note@-1 {{Assuming the condition is false}} + // expected-note@-2 {{Left side of '&&' is false}} expected-note@-2 {{Left side of '&&' is true}} + // expected-note@-3 {{Taking false branch}} + A().bar(); + } + } + { + A a; + if (a.foo() > 0 || A(std::move(a)).foo() > 0) { // expected-note {{Assuming the condition is true}} + //expected-note@-1 {{Left side of '||' is true}} + //expected-note@-2 {{Taking true branch}} + A().bar(); + } + } + { + A a; + if (A(std::move(a)).foo() > 0 || a.foo() > 0) { // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + // expected-note@-1 {{'a' became 'moved-from' here}} expected-note@-1 {{Assuming the condition is false}} expected-note@-1 {{Left side of '||' is false}} + A().bar(); + } + } +} + +// A range-based for sequences the loop variable declaration before the body. +void forRangeSequencesTest() { + A v[2] = {A(), A()}; + for (A &a : v) { + A b; + b = std::move(a); // no-warning + } +} + +// If a variable is declared in an if statement, the declaration of the variable +// (which is treated like a reinitialization by the check) is sequenced before +// the evaluation of the condition (which constitutes a use). +void ifStmtSequencesDeclAndConditionTest() { + for (int i = 0; i < 3; ++i) { + if (A a = A()) { + A b; + b = std::move(a); // no-warning + } + } +} + +void subRegionMoveTest() { + { + A a; + B b = std::move(a.b); // expected-note {{'b' became 'moved-from' here}} + a.b.foo(); // expected-warning {{Method call on a 'moved-from' object 'b'}} expected-note {{Method call on a 'moved-from' object 'b'}} + } + { + A a; + A a1 = std::move(a); // expected-note {{Calling move constructor for 'A'}} expected-note {{Returning from move constructor for 'A'}} + a.b.foo(); // expected-warning {{Method call on a 'moved-from' object 'b'}} expected-note {{Method call on a 'moved-from' object 'b'}} + } + // Don't report a misuse if any SuperRegion is already reported. + { + A a; + A a1 = std::move(a); // expected-note {{'a' became 'moved-from' here}} + a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + a.b.foo(); // no-warning + } +} diff --git a/test/Analysis/NSContainers.m b/test/Analysis/NSContainers.m index c868459999da..ac33efc1174a 100644 --- a/test/Analysis/NSContainers.m +++ b/test/Analysis/NSContainers.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-objc-literal-conversion -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s void clang_analyzer_eval(int); diff --git a/test/Analysis/NSPanel.m b/test/Analysis/NSPanel.m index 53b18c205ef8..e65b0715a15f 100644 --- a/test/Analysis/NSPanel.m +++ b/test/Analysis/NSPanel.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s // expected-no-diagnostics // BEGIN delta-debugging reduced header stuff diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m index 1123d80ab2e8..a53fc1e56624 100644 --- a/test/Analysis/NSString.m +++ b/test/Analysis/NSString.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-config mode=shallow -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -DOSATOMIC_USE_INLINED -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-config mode=shallow -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -DOSATOMIC_USE_INLINED -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/NSWindow.m b/test/Analysis/NSWindow.m index 44a97e42d6c4..e247ff18ceb0 100644 --- a/test/Analysis/NSWindow.m +++ b/test/Analysis/NSWindow.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -analyzer-store=region -verify %s // These declarations were reduced using Delta-Debugging from Foundation.h // on Mac OS X. The test cases are below. diff --git a/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp index 49358f6a2aba..987ed6a31fa8 100644 --- a/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp +++ b/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s // expected-no-diagnostics typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/NewDelete-checker-test.cpp b/test/Analysis/NewDelete-checker-test.cpp index 78a0015ca532..66e837572bb0 100644 --- a/test/Analysis/NewDelete-checker-test.cpp +++ b/test/Analysis/NewDelete-checker-test.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" typedef __typeof__(sizeof(int)) size_t; @@ -244,7 +244,7 @@ void testUninitDeleteArray() { void testUninitFree() { int *x; - free(x); // expected-warning{{Function call argument is an uninitialized value}} + free(x); // expected-warning{{1st function call argument is an uninitialized value}} } void testUninitDeleteSink() { diff --git a/test/Analysis/NewDelete-custom.cpp b/test/Analysis/NewDelete-custom.cpp index d368889c968e..f06ff4a858e5 100644 --- a/test/Analysis/NewDelete-custom.cpp +++ b/test/Analysis/NewDelete-custom.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" #ifndef LEAKS diff --git a/test/Analysis/NewDelete-intersections.mm b/test/Analysis/NewDelete-intersections.mm index cde8122b7274..aa52c7902888 100644 --- a/test/Analysis/NewDelete-intersections.mm +++ b/test/Analysis/NewDelete-intersections.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s #include "Inputs/system-header-simulator-cxx.h" #include "Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/NewDelete-path-notes.cpp b/test/Analysis/NewDelete-path-notes.cpp index 64b15b88dfe8..115a4addcaa8 100644 --- a/test/Analysis/NewDelete-path-notes.cpp +++ b/test/Analysis/NewDelete-path-notes.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void test() { diff --git a/test/Analysis/NewDelete-variadic.cpp b/test/Analysis/NewDelete-variadic.cpp index f9ef079bfe80..523785a70415 100644 --- a/test/Analysis/NewDelete-variadic.cpp +++ b/test/Analysis/NewDelete-variadic.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s // expected-no-diagnostics namespace std { diff --git a/test/Analysis/NewDeleteLeaks-PR18394.cpp b/test/Analysis/NewDeleteLeaks-PR18394.cpp index d0d70375f5a2..5a5b82cf609c 100644 --- a/test/Analysis/NewDeleteLeaks-PR18394.cpp +++ b/test/Analysis/NewDeleteLeaks-PR18394.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s // expected-no-diagnostics class A { diff --git a/test/Analysis/NewDeleteLeaks-PR19102.cpp b/test/Analysis/NewDeleteLeaks-PR19102.cpp index b141301e456f..502db6122f5c 100644 --- a/test/Analysis/NewDeleteLeaks-PR19102.cpp +++ b/test/Analysis/NewDeleteLeaks-PR19102.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s class A0 {}; diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m index 5ed92dfe5d4e..c08fd0dc5156 100644 --- a/test/Analysis/NoReturn.m +++ b/test/Analysis/NoReturn.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s #include <stdarg.h> diff --git a/test/Analysis/OSAtomic_mac.cpp b/test/Analysis/OSAtomic_mac.cpp index f93895893c59..e45f236b2f03 100644 --- a/test/Analysis/OSAtomic_mac.cpp +++ b/test/Analysis/OSAtomic_mac.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s // expected-no-diagnostics // Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we diff --git a/test/Analysis/ObjCProperties.m b/test/Analysis/ObjCProperties.m index 201e3e165d87..1a112ec2b128 100644 --- a/test/Analysis/ObjCProperties.m +++ b/test/Analysis/ObjCProperties.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s -verify // expected-no-diagnostics // The point of this test cases is to exercise properties in the static diff --git a/test/Analysis/ObjCPropertiesSyntaxChecks.m b/test/Analysis/ObjCPropertiesSyntaxChecks.m index 5c642c581736..5a25896c8aef 100644 --- a/test/Analysis/ObjCPropertiesSyntaxChecks.m +++ b/test/Analysis/ObjCPropertiesSyntaxChecks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify +// RUN: %clang_analyze_cc1 -w -fblocks -analyzer-checker=osx.ObjCProperty %s -verify #include "Inputs/system-header-simulator-objc.h" @@ -59,3 +59,10 @@ @interface IWithoutImpl : NSObject {} @property(copy) NSMutableString *mutableStr; // no-warning @end + +@protocol SomeProtocol +// Don't warn on protocol properties because it is possible to +// conform to them correctly; it is only synthesized setters that +// that are definitely incorrect. +@property (copy) NSMutableString *myProp; // no-crash // no-warning +@end diff --git a/test/Analysis/ObjCRetSigs.m b/test/Analysis/ObjCRetSigs.m index 6ee83ec4d105..97d33f9f5467 100644 --- a/test/Analysis/ObjCRetSigs.m +++ b/test/Analysis/ObjCRetSigs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s int printf(const char *, ...); diff --git a/test/Analysis/PR12905.c b/test/Analysis/PR12905.c index 8f678d114472..f36b93aacf90 100644 --- a/test/Analysis/PR12905.c +++ b/test/Analysis/PR12905.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core %s // PR12905 void C(void); diff --git a/test/Analysis/PR24184.cpp b/test/Analysis/PR24184.cpp index 54eae563e7da..1280334d4d6a 100644 --- a/test/Analysis/PR24184.cpp +++ b/test/Analysis/PR24184.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -w -analyze -analyzer-eagerly-assume -fcxx-exceptions -analyzer-checker=core -analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 64 -verify %s -// RUN: %clang_cc1 -w -analyze -analyzer-checker=core -analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify %s +// RUN: %clang_analyze_cc1 -w -analyzer-eagerly-assume -fcxx-exceptions -analyzer-checker=core -analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 64 -verify %s +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify %s // These tests used to hit an assertion in the bug report. Test case from http://llvm.org/PR24184. typedef struct { diff --git a/test/Analysis/PR2599.m b/test/Analysis/PR2599.m index ac552ee613bd..1c2270e6aa66 100644 --- a/test/Analysis/PR2599.m +++ b/test/Analysis/PR2599.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify %s +// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify %s typedef const void * CFTypeRef; typedef const struct __CFString * CFStringRef; diff --git a/test/Analysis/PR2978.m b/test/Analysis/PR2978.m index b609da5aac24..8b7effc66a1e 100644 --- a/test/Analysis/PR2978.m +++ b/test/Analysis/PR2978.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify // Tests for the checker which checks missing/extra ivar 'release' calls // in dealloc. diff --git a/test/Analysis/PR3991.m b/test/Analysis/PR3991.m index 68d5660287da..ffdb7b4a6e44 100644 --- a/test/Analysis/PR3991.m +++ b/test/Analysis/PR3991.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-incomplete-implementation %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-incomplete-implementation %s // expected-no-diagnostics //===----------------------------------------------------------------------===// diff --git a/test/Analysis/PR7218.c b/test/Analysis/PR7218.c index 1775e057f4db..10a75c98e515 100644 --- a/test/Analysis/PR7218.c +++ b/test/Analysis/PR7218.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store region -verify %s char PR7218(char a) { char buf[2]; buf[0] = a; diff --git a/test/Analysis/additive-folding-range-constraints.c b/test/Analysis/additive-folding-range-constraints.c index 4baada8bf98a..87d1b1cd8958 100644 --- a/test/Analysis/additive-folding-range-constraints.c +++ b/test/Analysis/additive-folding-range-constraints.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/additive-folding.cpp b/test/Analysis/additive-folding.cpp index 6ae025bbac2e..823b17600428 100644 --- a/test/Analysis/additive-folding.cpp +++ b/test/Analysis/additive-folding.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -Wno-tautological-compare %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -Wno-tautological-compare %s void clang_analyzer_eval(bool); @@ -205,3 +205,12 @@ void multiplicativeSanityTest(int x) { clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}} } + +void additiveSymSymFolding(int x, int y) { + // We should simplify 'x - 1' to '0' and handle the comparison, + // despite both sides being complicated symbols. + int z = x - 1; + if (x == 1) + if (y >= 0) + clang_analyzer_eval(z <= y); // expected-warning{{TRUE}} +} diff --git a/test/Analysis/analyzeOneFunction.m b/test/Analysis/analyzeOneFunction.m index e70b2d7d5fbc..a77abe1246b8 100644 --- a/test/Analysis/analyzeOneFunction.m +++ b/test/Analysis/analyzeOneFunction.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyze-function="-[Test1 myMethodWithY:withX:]" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyze-function="-[Test1 myMethodWithY:withX:]" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s typedef signed char BOOL; typedef unsigned int NSUInteger; diff --git a/test/Analysis/analyzer-checker-config.c b/test/Analysis/analyzer-checker-config.c index 642c96c996d5..34e339963f3c 100644 --- a/test/Analysis/analyzer-checker-config.c +++ b/test/Analysis/analyzer-checker-config.c @@ -1,10 +1,10 @@ -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.Malloc:Optimistic=true +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.Malloc:Optimistic=true // Just to test clang is working. # foo diff --git a/test/Analysis/analyzer-config.c b/test/Analysis/analyzer-config.c index 6faeeb3bf733..c0153a50532a 100644 --- a/test/Analysis/analyzer-config.c +++ b/test/Analysis/analyzer-config.c @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1 +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core,osx.cocoa,debug.ConfigDumper -analyzer-max-loop 34 > %t 2>&1 // RUN: FileCheck --input-file=%t %s void bar() {} diff --git a/test/Analysis/analyzer-config.cpp b/test/Analysis/analyzer-config.cpp index 23f08286eb7e..f84be1781160 100644 --- a/test/Analysis/analyzer-config.cpp +++ b/test/Analysis/analyzer-config.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1 +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core,osx.cocoa,debug.ConfigDumper -analyzer-max-loop 34 > %t 2>&1 // RUN: FileCheck --input-file=%t %s void bar() {} diff --git a/test/Analysis/analyzer-display-progress.cpp b/test/Analysis/analyzer-display-progress.cpp index 5d9f5e5b28f0..b54044a0a361 100644 --- a/test/Analysis/analyzer-display-progress.cpp +++ b/test/Analysis/analyzer-display-progress.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-display-progress %s 2>&1 | FileCheck %s void f() {}; void g() {}; diff --git a/test/Analysis/analyzer-display-progress.m b/test/Analysis/analyzer-display-progress.m index cc43cf36d60e..8d0b3d6d5679 100644 --- a/test/Analysis/analyzer-display-progress.m +++ b/test/Analysis/analyzer-display-progress.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-display-progress %s 2>&1 | FileCheck %s #include "Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/analyzer-enabled-checkers.c b/test/Analysis/analyzer-enabled-checkers.c index e60de05d47a3..0ea01a010af6 100644 --- a/test/Analysis/analyzer-enabled-checkers.c +++ b/test/Analysis/analyzer-enabled-checkers.c @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=core -Xclang -analyzer-list-enabled-checkers > %t 2>&1 +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core -analyzer-list-enabled-checkers > %t 2>&1 // RUN: FileCheck --input-file=%t %s // CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List diff --git a/test/Analysis/analyzer-stats.c b/test/Analysis/analyzer-stats.c index a0a50cbc9343..5a40d196bb1f 100644 --- a/test/Analysis/analyzer-stats.c +++ b/test/Analysis/analyzer-stats.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s int foo(); diff --git a/test/Analysis/analyzer_test.py b/test/Analysis/analyzer_test.py new file mode 100644 index 000000000000..58df11a4ba47 --- /dev/null +++ b/test/Analysis/analyzer_test.py @@ -0,0 +1,28 @@ +import lit.formats +import lit.TestRunner + +# Custom format class for static analyzer tests +class AnalyzerTest(lit.formats.ShTest): + + def execute(self, test, litConfig): + result = self.executeWithAnalyzeSubstitution( + test, litConfig, '-analyzer-constraints=range') + + if result.code == lit.Test.FAIL: + return result + + # If z3 backend available, add an additional run line for it + if test.config.clang_staticanalyzer_z3 == '1': + result = self.executeWithAnalyzeSubstitution( + test, litConfig, '-analyzer-constraints=z3 -DANALYZER_CM_Z3') + + return result + + def executeWithAnalyzeSubstitution(self, test, litConfig, substitution): + saved_substitutions = list(test.config.substitutions) + test.config.substitutions.append(('%analyze', substitution)) + result = lit.TestRunner.executeShTest(test, litConfig, + self.execute_external) + test.config.substitutions = saved_substitutions + + return result diff --git a/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c index a41d04018458..cdfec456cdae 100644 --- a/test/Analysis/array-struct-region.c +++ b/test/Analysis/array-struct-region.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/array-struct-region.cpp b/test/Analysis/array-struct-region.cpp index 47776863d6a2..48a05fd4057d 100644 --- a/test/Analysis/array-struct-region.cpp +++ b/test/Analysis/array-struct-region.cpp @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c++ -analyzer-config c++-inlining=constructors %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -DINLINE -verify -x c %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -DINLINE -verify -x c++ -analyzer-config c++-inlining=constructors %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify -x c++ -analyzer-config c++-inlining=constructors %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -DINLINE -verify -x c %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -DINLINE -verify -x c++ -analyzer-config c++-inlining=constructors %s void clang_analyzer_eval(int); diff --git a/test/Analysis/array-struct.c b/test/Analysis/array-struct.c index 34bdc58ab5ae..45c4c9d4ad17 100644 --- a/test/Analysis/array-struct.c +++ b/test/Analysis/array-struct.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.CastToStruct -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.CastToStruct -analyzer-store=region -verify %s struct s { int data; diff --git a/test/Analysis/atomics.c b/test/Analysis/atomics.c index f0f5ff076842..6fe4ec580b86 100644 --- a/test/Analysis/atomics.c +++ b/test/Analysis/atomics.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s // Tests for c11 atomics. Many of these tests currently yield unknown // because we don't fully model the atomics and instead imprecisely diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp index 0b4454fbd958..cc47c92360a5 100644 --- a/test/Analysis/auto-obj-dtors-cfg-output.cpp +++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -analyzer-checker=debug.DumpCFG %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s class A { diff --git a/test/Analysis/base-init.cpp b/test/Analysis/base-init.cpp index 3c870e1ccf88..1f59303789b3 100644 --- a/test/Analysis/base-init.cpp +++ b/test/Analysis/base-init.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=constructors -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=constructors -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/bitwise-ops.c b/test/Analysis/bitwise-ops.c index 01daf4229625..407aa19289c5 100644 --- a/test/Analysis/bitwise-ops.c +++ b/test/Analysis/bitwise-ops.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -triple x86_64-apple-darwin13 -Wno-shift-count-overflow -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-apple-darwin13 -Wno-shift-count-overflow -verify %s void clang_analyzer_eval(int); #define CHECK(expr) if (!(expr)) return; clang_analyzer_eval(expr) diff --git a/test/Analysis/block-in-critical-section.cpp b/test/Analysis/block-in-critical-section.cpp index 93c0b6dba665..c65cc612cf73 100644 --- a/test/Analysis/block-in-critical-section.cpp +++ b/test/Analysis/block-in-critical-section.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.BlockInCriticalSection -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.BlockInCriticalSection -std=c++11 -verify %s void sleep(int x) {} @@ -9,29 +9,91 @@ struct mutex { }; } -void testBlockInCriticalSection() { +void getc() {} +void fgets() {} +void read() {} +void recv() {} + +void pthread_mutex_lock() {} +void pthread_mutex_trylock() {} +void pthread_mutex_unlock() {} + +void mtx_lock() {} +void mtx_timedlock() {} +void mtx_trylock() {} +void mtx_unlock() {} + +void testBlockInCriticalSectionWithStdMutex() { std::mutex m; m.lock(); - sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} m.unlock(); } +void testBlockInCriticalSectionWithPthreadMutex() { + pthread_mutex_lock(); + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} + pthread_mutex_unlock(); + + pthread_mutex_trylock(); + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} + pthread_mutex_unlock(); +} + +void testBlockInCriticalSectionC11Locks() { + mtx_lock(); + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} + mtx_unlock(); + + mtx_timedlock(); + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} + mtx_unlock(); + + mtx_trylock(); + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} + getc(); // expected-warning {{Call to blocking function 'getc' inside of critical section}} + fgets(); // expected-warning {{Call to blocking function 'fgets' inside of critical section}} + read(); // expected-warning {{Call to blocking function 'read' inside of critical section}} + recv(); // expected-warning {{Call to blocking function 'recv' inside of critical section}} + mtx_unlock(); +} + void testBlockInCriticalSectionWithNestedMutexes() { std::mutex m, n, k; m.lock(); n.lock(); k.lock(); - sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} k.unlock(); - sleep(5); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(5); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} n.unlock(); - sleep(3); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(3); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} m.unlock(); sleep(3); // no-warning } void f() { - sleep(1000); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(1000); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} } void testBlockInCriticalSectionInterProcedural() { @@ -46,5 +108,5 @@ void testBlockInCriticalSectionUnexpectedUnlock() { m.unlock(); sleep(1); // no-warning m.lock(); - sleep(1); // expected-warning {{A blocking function %s is called inside a critical section}} + sleep(1); // expected-warning {{Call to blocking function 'sleep' inside of critical section}} } diff --git a/test/Analysis/blocks-no-inline.c b/test/Analysis/blocks-no-inline.c index de6f959b9d8c..859eedfbc3af 100644 --- a/test/Analysis/blocks-no-inline.c +++ b/test/Analysis/blocks-no-inline.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify -x c++ %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -fblocks -verify -x c++ %s void clang_analyzer_eval(int); diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index bf10c61d3a21..98d0f8a2ebaa 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify -x objective-c++ %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core -analyzer-store=region -fblocks -analyzer-opt-analyze-nested-blocks -verify -x objective-c++ %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from Mac OS X headers: diff --git a/test/Analysis/blocks.mm b/test/Analysis/blocks.mm index 5f93888d45d0..6cff9b47f169 100644 --- a/test/Analysis/blocks.mm +++ b/test/Analysis/blocks.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -fblocks -analyzer-opt-analyze-nested-blocks -verify -x objective-c++ %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core,debug.DumpCFG -fblocks -analyzer-opt-analyze-nested-blocks %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core -fblocks -analyzer-opt-analyze-nested-blocks -verify -x objective-c++ %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,debug.DumpCFG -fblocks -analyzer-opt-analyze-nested-blocks %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s // expected-no-diagnostics diff --git a/test/Analysis/bool-assignment.c b/test/Analysis/bool-assignment.c index 285569ee11bb..57a7f0b5dc1b 100644 --- a/test/Analysis/bool-assignment.c +++ b/test/Analysis/bool-assignment.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.BoolAssignment -analyzer-store=region -verify -std=c99 -Dbool=_Bool %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.BoolAssignment -analyzer-store=region -verify -x c++ %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.BoolAssignment -analyzer-store=region -verify -std=c99 -Dbool=_Bool %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.BoolAssignment -analyzer-store=region -verify -x c++ %s // Test C++'s bool and C's _Bool. // FIXME: We stopped warning on these when SValBuilder got smarter about @@ -43,8 +43,11 @@ void test_BOOL_initialization(int y) { return; } if (y > 200 && y < 250) { - // FIXME: Currently we are loosing this warning due to a SymbolCast in RHS. +#ifdef ANALYZER_CM_Z3 + BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}} +#else BOOL x = y; // no-warning +#endif return; } if (y >= 127 && y < 150) { diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c index 824aa7c063b7..a671d9ee8d4e 100644 --- a/test/Analysis/bstring.c +++ b/test/Analysis/bstring.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s //===----------------------------------------------------------------------=== // Declarations diff --git a/test/Analysis/bstring.cpp b/test/Analysis/bstring.cpp index 0b4e7e94f00b..a6d7b4016277 100644 --- a/test/Analysis/bstring.cpp +++ b/test/Analysis/bstring.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s #include "Inputs/system-header-simulator-cxx.h" #include "Inputs/system-header-simulator-for-malloc.h" diff --git a/test/Analysis/bug_hash_test.cpp b/test/Analysis/bug_hash_test.cpp index b73528e88d2f..0efcb5f7cdcd 100644 --- a/test/Analysis/bug_hash_test.cpp +++ b/test/Analysis/bug_hash_test.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,debug.DumpBugHash -analyzer-output=plist %s -o %t.plist +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,debug.DumpBugHash -analyzer-output=plist %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s int function(int p) { diff --git a/test/Analysis/bug_hash_test.m b/test/Analysis/bug_hash_test.m index debed329bdde..1e99d3c0b9ac 100644 --- a/test/Analysis/bug_hash_test.m +++ b/test/Analysis/bug_hash_test.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,debug.DumpBugHash -analyzer-output=plist %s -o %t.plist +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,debug.DumpBugHash -analyzer-output=plist %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s @protocol NSObject diff --git a/test/Analysis/builtin-functions.cpp b/test/Analysis/builtin-functions.cpp index d3afab5bd615..4e9859754d62 100644 --- a/test/Analysis/builtin-functions.cpp +++ b/test/Analysis/builtin-functions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection %s -std=c++11 -verify +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,debug.ExprInspection %s -std=c++11 -verify void clang_analyzer_eval(bool); diff --git a/test/Analysis/call-invalidation.cpp b/test/Analysis/call-invalidation.cpp index 80323ffcf18e..d3b5fca9cd5b 100644 --- a/test/Analysis/call-invalidation.cpp +++ b/test/Analysis/call-invalidation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/cast-to-struct.cpp b/test/Analysis/cast-to-struct.cpp index 45d55947c937..c3aba023c56e 100644 --- a/test/Analysis/cast-to-struct.cpp +++ b/test/Analysis/cast-to-struct.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core.CastToStruct,core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.CastToStruct,core -verify %s struct AB { int A; @@ -65,3 +65,17 @@ void intToStruct(int *P) { void *VP = P; Abc = (struct ABC *)VP; } + +// https://llvm.org/bugs/show_bug.cgi?id=31173 +void dontCrash1(struct AB X) { + struct UndefS *S = (struct UndefS *)&X; +} + +struct S; +struct T { + struct S *P; +}; +extern struct S Var1, Var2; +void dontCrash2() { + ((struct T *) &Var1)->P = &Var2; +} diff --git a/test/Analysis/castexpr-callback.c b/test/Analysis/castexpr-callback.c index 73fa17a134a8..3b46093db9ae 100644 --- a/test/Analysis/castexpr-callback.c +++ b/test/Analysis/castexpr-callback.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:PreStmtCastExpr=true,debug.AnalysisOrder:PostStmtCastExpr=true %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:PreStmtCastExpr=true,debug.AnalysisOrder:PostStmtCastExpr=true %s 2>&1 | FileCheck %s void test(char c) { int i = (int)c; diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c index b5e6e2784c8d..3ba12e4318de 100644 --- a/test/Analysis/casts.c +++ b/test/Analysis/casts.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s extern void clang_analyzer_eval(_Bool); @@ -118,3 +118,8 @@ void castsToBool() { extern float globalFloat; clang_analyzer_eval(globalFloat); // expected-warning{{UNKNOWN}} } + +void locAsIntegerCasts(void *p) { + int x = (int) p; + clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}} +} diff --git a/test/Analysis/casts.cpp b/test/Analysis/casts.cpp index 53e1cd085acd..f96f19b0ac33 100644 --- a/test/Analysis/casts.cpp +++ b/test/Analysis/casts.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify %s bool PR14634(int x) { double y = (double)x; diff --git a/test/Analysis/casts.m b/test/Analysis/casts.m index 895c8119c180..5c81ae6ffbe6 100644 --- a/test/Analysis/casts.m +++ b/test/Analysis/casts.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // Test function pointer casts. diff --git a/test/Analysis/cfg.cpp b/test/Analysis/cfg.cpp index 3e34a0fac6af..208277343cdc 100644 --- a/test/Analysis/cfg.cpp +++ b/test/Analysis/cfg.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s // CHECK-LABEL: void checkWrap(int i) diff --git a/test/Analysis/cfref_PR2519.c b/test/Analysis/cfref_PR2519.c index d9642e5197d1..5636737ffe0e 100644 --- a/test/Analysis/cfref_PR2519.c +++ b/test/Analysis/cfref_PR2519.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics typedef unsigned char Boolean; diff --git a/test/Analysis/cfref_rdar6080742.c b/test/Analysis/cfref_rdar6080742.c index 7094660a352d..2f7403658e8a 100644 --- a/test/Analysis/cfref_rdar6080742.c +++ b/test/Analysis/cfref_rdar6080742.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // This test case was reported in <rdar:problem/6080742>. diff --git a/test/Analysis/check-deserialization.cpp b/test/Analysis/check-deserialization.cpp index 2b0bce2b9ad5..9e4e47194c24 100644 --- a/test/Analysis/check-deserialization.cpp +++ b/test/Analysis/check-deserialization.cpp @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -emit-pch -o %t %s -// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyze -analyzer-checker=core %s -// RUN: %clang_cc1 -include-pch %t -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyzer-checker=core %s +// RUN: %clang_analyze_cc1 -include-pch %t -analyzer-checker=core -verify %s #ifndef HEADER #define HEADER diff --git a/test/Analysis/checker-plugins.c b/test/Analysis/checker-plugins.c index 3882ba6661b4..ee60ec6e2192 100644 --- a/test/Analysis/checker-plugins.c +++ b/test/Analysis/checker-plugins.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext -analyze -analyzer-checker='example.MainCallChecker' -verify %s +// RUN: %clang_analyze_cc1 -load %llvmshlibdir/SampleAnalyzerPlugin%pluginext -analyzer-checker='example.MainCallChecker' -verify %s // REQUIRES: plugins, examples // Test that the MainCallChecker example analyzer plugin loads and runs. diff --git a/test/Analysis/chroot.c b/test/Analysis/chroot.c index 1b818a8e6322..7e514f744000 100644 --- a/test/Analysis/chroot.c +++ b/test/Analysis/chroot.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.Chroot -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Chroot -analyzer-store region -verify %s extern int chroot(const char* path); extern int chdir(const char* path); diff --git a/test/Analysis/comparison-implicit-casts.cpp b/test/Analysis/comparison-implicit-casts.cpp index a991d438cb4c..fe5254c0a53b 100644 --- a/test/Analysis/comparison-implicit-casts.cpp +++ b/test/Analysis/comparison-implicit-casts.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple i386-apple-darwin9 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple x86_64-apple-darwin9 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple i386-apple-darwin9 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,debug.ExprInspection -triple x86_64-apple-darwin9 -verify %s // This file runs in C++ mode so that the comparison type is 'bool', not 'int'. void clang_analyzer_eval(int); diff --git a/test/Analysis/complex-init-list.cpp b/test/Analysis/complex-init-list.cpp index bbff64b7a13f..299f362ffd8a 100644 --- a/test/Analysis/complex-init-list.cpp +++ b/test/Analysis/complex-init-list.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s // expected-no-diagnostics // Do not crash on initialization to complex numbers. diff --git a/test/Analysis/complex.c b/test/Analysis/complex.c index 6aca58948339..1f61b141cb31 100644 --- a/test/Analysis/complex.c +++ b/test/Analysis/complex.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify -Wno-unreachable-code -ffreestanding %s #include <stdint.h> diff --git a/test/Analysis/concrete-address.c b/test/Analysis/concrete-address.c index 819afca967c9..f1608f8a801c 100644 --- a/test/Analysis/concrete-address.c +++ b/test/Analysis/concrete-address.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics void foo() { diff --git a/test/Analysis/conditional-operator.cpp b/test/Analysis/conditional-operator.cpp index 137dc3987755..32978c66fa14 100644 --- a/test/Analysis/conditional-operator.cpp +++ b/test/Analysis/conditional-operator.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -analyzer-output=text -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection %s -analyzer-output=text -verify void clang_analyzer_eval(bool); diff --git a/test/Analysis/conditional-path-notes.c b/test/Analysis/conditional-path-notes.c index 448af7f97fae..d842b7fc6eef 100644 --- a/test/Analysis/conditional-path-notes.c +++ b/test/Analysis/conditional-path-notes.c @@ -1,5 +1,5 @@ -// RUN: %clang --analyze %s -Xanalyzer -analyzer-output=text -Xclang -verify -// RUN: %clang --analyze %s -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=text -verify +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t // RUN: FileCheck --input-file=%t %s void testCondOp(int *p) { diff --git a/test/Analysis/const-method-call.cpp b/test/Analysis/const-method-call.cpp index b8aaeea6c3eb..17df2a016b89 100644 --- a/test/Analysis/const-method-call.cpp +++ b/test/Analysis/const-method-call.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index 81d119392658..a6d2b749427c 100644 --- a/test/Analysis/constant-folding.c +++ b/test/Analysis/constant-folding.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/conversion.c b/test/Analysis/conversion.c index f202696dc623..a22a56765407 100644 --- a/test/Analysis/conversion.c +++ b/test/Analysis/conversion.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-conversion -analyze -analyzer-checker=core,alpha.core.Conversion -verify %s +// RUN: %clang_analyze_cc1 -Wno-conversion -analyzer-checker=core,alpha.core.Conversion -verify %s unsigned char U8; signed char S8; @@ -9,9 +9,67 @@ void assign(unsigned U, signed S) { if (U > 300) S8 = U; // expected-warning {{Loss of precision in implicit conversion}} if (S > 10) - U8 = S; + U8 = S; // no-warning if (U < 200) - S8 = U; + S8 = U; // no-warning +} + +void addAssign() { + unsigned long L = 1000; + int I = -100; + U8 += L; // expected-warning {{Loss of precision in implicit conversion}} + L += I; // no-warning +} + +void subAssign() { + unsigned long L = 1000; + int I = -100; + U8 -= L; // expected-warning {{Loss of precision in implicit conversion}} + L -= I; // no-warning +} + +void mulAssign() { + unsigned long L = 1000; + int I = -1; + U8 *= L; // expected-warning {{Loss of precision in implicit conversion}} + L *= I; // expected-warning {{Loss of sign in implicit conversion}} + I = 10; + L *= I; // no-warning +} + +void divAssign() { + unsigned long L = 1000; + int I = -1; + U8 /= L; // no-warning + L /= I; // expected-warning {{Loss of sign in implicit conversion}} +} + +void remAssign() { + unsigned long L = 1000; + int I = -1; + U8 %= L; // no-warning + L %= I; // expected-warning {{Loss of sign in implicit conversion}} +} + +void andAssign() { + unsigned long L = 1000; + int I = -1; + U8 &= L; // no-warning + L &= I; // expected-warning {{Loss of sign in implicit conversion}} +} + +void orAssign() { + unsigned long L = 1000; + int I = -1; + U8 |= L; // expected-warning {{Loss of precision in implicit conversion}} + L |= I; // expected-warning {{Loss of sign in implicit conversion}} +} + +void xorAssign() { + unsigned long L = 1000; + int I = -1; + U8 ^= L; // expected-warning {{Loss of precision in implicit conversion}} + L ^= I; // expected-warning {{Loss of sign in implicit conversion}} } void init1() { @@ -21,7 +79,7 @@ void init1() { void relational(unsigned U, signed S) { if (S > 10) { - if (U < S) { + if (U < S) { // no-warning } } if (S < -10) { @@ -32,14 +90,14 @@ void relational(unsigned U, signed S) { void multiplication(unsigned U, signed S) { if (S > 5) - S = U * S; + S = U * S; // no-warning if (S < -10) S = U * S; // expected-warning {{Loss of sign}} } void division(unsigned U, signed S) { if (S > 5) - S = U / S; + S = U / S; // no-warning if (S < -10) S = U / S; // expected-warning {{Loss of sign}} } diff --git a/test/Analysis/copypaste/asm.cpp b/test/Analysis/copypaste/asm.cpp index e93f119198a3..2e3613dfca4b 100644 --- a/test/Analysis/copypaste/asm.cpp +++ b/test/Analysis/copypaste/asm.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/attributes.cpp b/test/Analysis/copypaste/attributes.cpp index 72d654c6e060..083be74436df 100644 --- a/test/Analysis/copypaste/attributes.cpp +++ b/test/Analysis/copypaste/attributes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/blocks.cpp b/test/Analysis/copypaste/blocks.cpp index 133b5cbcd6ac..10467b7248c1 100644 --- a/test/Analysis/copypaste/blocks.cpp +++ b/test/Analysis/copypaste/blocks.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fblocks -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -fblocks -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // This tests if we search for clones in blocks. diff --git a/test/Analysis/copypaste/call.cpp b/test/Analysis/copypaste/call.cpp index 8e95f7cb304a..046229a30a4a 100644 --- a/test/Analysis/copypaste/call.cpp +++ b/test/Analysis/copypaste/call.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/catch.cpp b/test/Analysis/copypaste/catch.cpp index 590ce8f223f9..cf3e8076bd54 100644 --- a/test/Analysis/copypaste/catch.cpp +++ b/test/Analysis/copypaste/catch.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/delete.cpp b/test/Analysis/copypaste/delete.cpp index dc42c9c0595b..394226bedf1b 100644 --- a/test/Analysis/copypaste/delete.cpp +++ b/test/Analysis/copypaste/delete.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/dependent-exist.cpp b/test/Analysis/copypaste/dependent-exist.cpp index 5182ba61c9dc..9046353d0f07 100644 --- a/test/Analysis/copypaste/dependent-exist.cpp +++ b/test/Analysis/copypaste/dependent-exist.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fms-extensions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -fms-extensions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/expr-types.cpp b/test/Analysis/copypaste/expr-types.cpp index 14eef6eac636..601f0b192ac5 100644 --- a/test/Analysis/copypaste/expr-types.cpp +++ b/test/Analysis/copypaste/expr-types.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/fold.cpp b/test/Analysis/copypaste/fold.cpp index 548dfb19af56..0aed11bcf070 100644 --- a/test/Analysis/copypaste/fold.cpp +++ b/test/Analysis/copypaste/fold.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/function-try-block.cpp b/test/Analysis/copypaste/function-try-block.cpp index 7a69097579ab..d77714591b91 100644 --- a/test/Analysis/copypaste/function-try-block.cpp +++ b/test/Analysis/copypaste/function-try-block.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -fcxx-exceptions -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s // Tests if function try blocks are correctly handled. diff --git a/test/Analysis/copypaste/functions.cpp b/test/Analysis/copypaste/functions.cpp index c95443de72d1..d2c607b2171e 100644 --- a/test/Analysis/copypaste/functions.cpp +++ b/test/Analysis/copypaste/functions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // This tests if we search for clones in functions. diff --git a/test/Analysis/copypaste/generic.c b/test/Analysis/copypaste/generic.c index 9d8392139b39..d4d456473621 100644 --- a/test/Analysis/copypaste/generic.c +++ b/test/Analysis/copypaste/generic.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/labels.cpp b/test/Analysis/copypaste/labels.cpp index 26318ac40510..eff3330a0f39 100644 --- a/test/Analysis/copypaste/labels.cpp +++ b/test/Analysis/copypaste/labels.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/lambda.cpp b/test/Analysis/copypaste/lambda.cpp index c13c56f6671d..17c874894319 100644 --- a/test/Analysis/copypaste/lambda.cpp +++ b/test/Analysis/copypaste/lambda.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // expected-no-diagnostics diff --git a/test/Analysis/copypaste/macro-complexity.cpp b/test/Analysis/copypaste/macro-complexity.cpp index aca4df1d025c..70d3f0c74820 100644 --- a/test/Analysis/copypaste/macro-complexity.cpp +++ b/test/Analysis/copypaste/macro-complexity.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s // Tests that the complexity value of a macro expansion is about the same as // the complexity value of a normal function call and the the macro body doesn't diff --git a/test/Analysis/copypaste/macros.cpp b/test/Analysis/copypaste/macros.cpp index db9b4c6ee2e4..bdacd4839a67 100644 --- a/test/Analysis/copypaste/macros.cpp +++ b/test/Analysis/copypaste/macros.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // Tests that macros and non-macro clones aren't mixed into the same hash // group. This is currently necessary as all clones in a hash group need diff --git a/test/Analysis/copypaste/objc-methods.m b/test/Analysis/copypaste/objc-methods.m index 9b8002c003a2..e63c7f6288bc 100644 --- a/test/Analysis/copypaste/objc-methods.m +++ b/test/Analysis/copypaste/objc-methods.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -Wno-objc-root-class -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -Wno-objc-root-class -analyzer-checker=alpha.clone.CloneChecker -verify %s // This tests if we search for clones in Objective-C methods. diff --git a/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp b/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp index 1180d447a7a3..7c4f35525fea 100644 --- a/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp +++ b/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-output=plist -analyzer-config notes-as-events=true -o %t.plist -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-output=plist -analyzer-config notes-as-events=true -o %t.plist -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // RUN: FileCheck --input-file=%t.plist %s void log(); diff --git a/test/Analysis/copypaste/plist-diagnostics.cpp b/test/Analysis/copypaste/plist-diagnostics.cpp index 109d8e4fc71f..e2fa7597caf6 100644 --- a/test/Analysis/copypaste/plist-diagnostics.cpp +++ b/test/Analysis/copypaste/plist-diagnostics.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-output=plist -o %t.plist -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-output=plist -o %t.plist -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // RUN: FileCheck --input-file=%t.plist %s void log(); diff --git a/test/Analysis/copypaste/sub-sequences.cpp b/test/Analysis/copypaste/sub-sequences.cpp index ff73632e4353..798662d25663 100644 --- a/test/Analysis/copypaste/sub-sequences.cpp +++ b/test/Analysis/copypaste/sub-sequences.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s // This tests if sub-sequences can match with normal sequences. diff --git a/test/Analysis/copypaste/suspicious-clones.cpp b/test/Analysis/copypaste/suspicious-clones.cpp index c64a1dc8b8ff..3a760e256279 100644 --- a/test/Analysis/copypaste/suspicious-clones.cpp +++ b/test/Analysis/copypaste/suspicious-clones.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:ReportSuspiciousClones=true -analyzer-config alpha.clone.CloneChecker:ReportNormalClones=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:ReportSuspiciousClones=true -analyzer-config alpha.clone.CloneChecker:ReportNormalClones=false -verify %s // Tests finding a suspicious clone that references local variables. diff --git a/test/Analysis/copypaste/text-diagnostics.cpp b/test/Analysis/copypaste/text-diagnostics.cpp index a80afdb1eaf8..a6e358cc8535 100644 --- a/test/Analysis/copypaste/text-diagnostics.cpp +++ b/test/Analysis/copypaste/text-diagnostics.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-output=text -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-output=text -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s void log(); diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c index 9e437d218272..b819f10edc13 100644 --- a/test/Analysis/coverage.c +++ b/test/Analysis/coverage.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -analyzer-max-loop 4 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-store=region -analyzer-max-loop 4 -verify %s #include "Inputs/system-header-simulator.h" typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/crash-trace.c b/test/Analysis/crash-trace.c index bac74476ed9f..b79dd02e6b43 100644 --- a/test/Analysis/crash-trace.c +++ b/test/Analysis/crash-trace.c @@ -1,4 +1,4 @@ -// RUN: not --crash %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s +// RUN: not --crash %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s // REQUIRES: crash-recovery // FIXME: CHECKs might be incompatible to win32. diff --git a/test/Analysis/cstring-syntax-cxx.cpp b/test/Analysis/cstring-syntax-cxx.cpp index 39c978ab600f..b2adef8e1ece 100644 --- a/test/Analysis/cstring-syntax-cxx.cpp +++ b/test/Analysis/cstring-syntax-cxx.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s // expected-no-diagnostics // Ensure we don't crash on C++ declarations with special names. diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c index 4aa88ed3b7ed..313ac5449540 100644 --- a/test/Analysis/cstring-syntax.c +++ b/test/Analysis/cstring-syntax.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s typedef __SIZE_TYPE__ size_t; char *strncat(char *, const char *, size_t); @@ -10,4 +10,6 @@ void testStrncat(const char *src) { strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning {{Potential buffer overflow. Replace with}} strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning {{Potential buffer overflow. Replace with}} strncat(dest, src, sizeof(src)); // expected-warning {{Potential buffer overflow. Replace with}} + // Should not crash when sizeof has a type argument. + strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(char)); } diff --git a/test/Analysis/ctor.mm b/test/Analysis/ctor.mm index e7c0c6cac630..646229aac989 100644 --- a/test/Analysis/ctor.mm +++ b/test/Analysis/ctor.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -fobjc-arc -analyzer-config c++-inlining=constructors -Wno-null-dereference -std=c++11 -verify %s #include "Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp index e3f812540d0b..f8234c99ef5e 100644 --- a/test/Analysis/cxx-crashes.cpp +++ b/test/Analysis/cxx-crashes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s // REQUIRES: LP64 void clang_analyzer_eval(bool); diff --git a/test/Analysis/cxx-for-range.cpp b/test/Analysis/cxx-for-range.cpp index 6be8b78ee816..bf3cfbff1231 100644 --- a/test/Analysis/cxx-for-range.cpp +++ b/test/Analysis/cxx-for-range.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core -analyzer-config path-diagnostics-alternate=true -analyzer-output=plist-multi-file -o %t.plist -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core -analyzer-config path-diagnostics-alternate=true -analyzer-output=plist-multi-file -o %t.plist -verify %s // RUN: FileCheck --input-file=%t.plist %s extern void work(); diff --git a/test/Analysis/cxx-method-names.cpp b/test/Analysis/cxx-method-names.cpp index 21be5e4bd3f4..e57e72df840e 100644 --- a/test/Analysis/cxx-method-names.cpp +++ b/test/Analysis/cxx-method-names.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,osx,alpha.unix,alpha.security.taint -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,osx,alpha.unix,alpha.security.taint -analyzer-store region -verify %s // expected-no-diagnostics class Evil { diff --git a/test/Analysis/cxx11-crashes.cpp b/test/Analysis/cxx11-crashes.cpp index c6034e6480ee..8905d1c87b82 100644 --- a/test/Analysis/cxx11-crashes.cpp +++ b/test/Analysis/cxx11-crashes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -verify %s // radar://11485149, PR12871 class PlotPoint { diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index c55b34ff2112..05bc64af7a37 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core,deadcode.DeadStores -analyzer-store=region -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -Wunused-variable -analyzer-checker=core,deadcode.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -Wunused-variable -analyzer-checker=core,deadcode.DeadStores -analyzer-store=region -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s void f1() { int k, y; // expected-warning{{unused variable 'k'}} expected-warning{{unused variable 'y'}} diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index 77b349edd091..d926ccf5ecf6 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyze -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyze -analyzer-store=region -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyzer-store=region -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s //===----------------------------------------------------------------------===// // Basic dead store checking (but in C++ mode). diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 8bc6b2e84d01..9f91f393a116 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s // expected-no-diagnostics typedef signed char BOOL; diff --git a/test/Analysis/debug-CallGraph.c b/test/Analysis/debug-CallGraph.c index 64259e2069a4..9f3865b35a4e 100644 --- a/test/Analysis/debug-CallGraph.c +++ b/test/Analysis/debug-CallGraph.c @@ -1,4 +1,16 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s + +int get5() { + return 5; +} + +int add(int val1, int val2) { + return val1 + val2; +} + +int test_add() { + return add(10, get5()); +} static void mmm(int y) { if (y != 0) @@ -31,8 +43,18 @@ void eee(); void eee() {} void fff() { eee(); } +// This test case tests that forward declaration for the top-level function +// does not affect call graph construction. +void do_nothing() {} +void test_single_call(); +void test_single_call() { + do_nothing(); +} + // CHECK:--- Call graph Dump --- -// CHECK-NEXT: {{Function: < root > calls: mmm foo aaa < > bbb ccc ddd eee fff $}} +// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call $}} +// CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}} +// CHECK-NEXT: {{Function: do_nothing calls: $}} // CHECK-NEXT: {{Function: fff calls: eee $}} // CHECK-NEXT: {{Function: eee calls: $}} // CHECK-NEXT: {{Function: ddd calls: ccc $}} @@ -42,3 +64,6 @@ void fff() { eee(); } // CHECK-NEXT: {{Function: aaa calls: foo $}} // CHECK-NEXT: {{Function: foo calls: mmm $}} // CHECK-NEXT: {{Function: mmm calls: $}} +// CHECK-NEXT: {{Function: test_add calls: add get5 $}} +// CHECK-NEXT: {{Function: add calls: $}} +// CHECK-NEXT: {{Function: get5 calls: $}} diff --git a/test/Analysis/default-analyze.m b/test/Analysis/default-analyze.m index 5fbaa2f98c65..e2f7297884d7 100644 --- a/test/Analysis/default-analyze.m +++ b/test/Analysis/default-analyze.m @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -o %t +// RUN: %clang_analyze_cc1 %s -o %t // Tests that some specific checkers are enabled by default. diff --git a/test/Analysis/default-diagnostic-visitors.c b/test/Analysis/default-diagnostic-visitors.c index 0bc6a033ac09..c8f64bc6d7f4 100644 --- a/test/Analysis/default-diagnostic-visitors.c +++ b/test/Analysis/default-diagnostic-visitors.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core -analyzer-store=region -analyzer-output=text -verify %s // This file is for testing enhanced diagnostics produced by the default BugReporterVisitors. diff --git a/test/Analysis/delayed-template-parsing-crash.cpp b/test/Analysis/delayed-template-parsing-crash.cpp index 94a143b0c066..6d189afb455a 100644 --- a/test/Analysis/delayed-template-parsing-crash.cpp +++ b/test/Analysis/delayed-template-parsing-crash.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -fdelayed-template-parsing -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -std=c++11 -fdelayed-template-parsing -verify %s // expected-no-diagnostics template <class T> struct remove_reference {typedef T type;}; diff --git a/test/Analysis/delegates.m b/test/Analysis/delegates.m index 28e9006c18e5..23028054517e 100644 --- a/test/Analysis/delegates.m +++ b/test/Analysis/delegates.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -Wno-objc-root-class -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -Wno-objc-root-class -verify %s // expected-no-diagnostics diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp index e9c7ca8f731f..b9851fd3e404 100644 --- a/test/Analysis/derived-to-base.cpp +++ b/test/Analysis/derived-to-base.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -DCONSTRUCTORS=1 -analyzer-config c++-inlining=constructors -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DCONSTRUCTORS=1 -analyzer-config c++-inlining=constructors -verify %s void clang_analyzer_eval(bool); void clang_analyzer_checkInlined(bool); diff --git a/test/Analysis/designated-initializer.c b/test/Analysis/designated-initializer.c index b601f872571f..920b2f08d7e7 100644 --- a/test/Analysis/designated-initializer.c +++ b/test/Analysis/designated-initializer.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 \ +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 \ // RUN: | FileCheck %s struct Q { int a, b, c; }; diff --git a/test/Analysis/diagnostics/deref-track-symbolic-region.c b/test/Analysis/diagnostics/deref-track-symbolic-region.c index 42060ccd9260..179e736ee18b 100644 --- a/test/Analysis/diagnostics/deref-track-symbolic-region.c +++ b/test/Analysis/diagnostics/deref-track-symbolic-region.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s struct S { diff --git a/test/Analysis/diagnostics/deref-track-symbolic-region.cpp b/test/Analysis/diagnostics/deref-track-symbolic-region.cpp index 6d348415aaf3..61993f0872f4 100644 --- a/test/Analysis/diagnostics/deref-track-symbolic-region.cpp +++ b/test/Analysis/diagnostics/deref-track-symbolic-region.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s struct S { int *x; diff --git a/test/Analysis/diagnostics/diag-cross-file-boundaries.c b/test/Analysis/diagnostics/diag-cross-file-boundaries.c index 270163e85607..b975af3fb29f 100644 --- a/test/Analysis/diagnostics/diag-cross-file-boundaries.c +++ b/test/Analysis/diagnostics/diag-cross-file-boundaries.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=html -o PR12421.html %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=html -o PR12421.html %s 2>&1 | FileCheck %s // Test for PR12421 #include "diag-cross-file-boundaries.h" diff --git a/test/Analysis/diagnostics/explicit-suppression.cpp b/test/Analysis/diagnostics/explicit-suppression.cpp index d36def20f25f..193846c082bc 100644 --- a/test/Analysis/diagnostics/explicit-suppression.cpp +++ b/test/Analysis/diagnostics/explicit-suppression.cpp @@ -1,5 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=true -DSUPPRESSED=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=true -DSUPPRESSED=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DSUPPRESSED=1 -verify %s #ifdef SUPPRESSED // expected-no-diagnostics diff --git a/test/Analysis/diagnostics/false-positive-suppression.c b/test/Analysis/diagnostics/false-positive-suppression.c index cdcd7cc77798..87c04cbcdc07 100644 --- a/test/Analysis/diagnostics/false-positive-suppression.c +++ b/test/Analysis/diagnostics/false-positive-suppression.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -I %S/Inputs -analyze -analyzer-checker=core,unix -verify %s +// RUN: %clang_analyze_cc1 -I %S/Inputs -analyzer-checker=core,unix -verify %s // expected-no-diagnostics #include "include/sys/queue.h" diff --git a/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp b/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp index 143cbbeeac20..197fad5d0b7d 100644 --- a/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp +++ b/test/Analysis/diagnostics/implicit-cxx-std-suppression.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -verify %s // expected-no-diagnostics diff --git a/test/Analysis/diagnostics/macros.cpp b/test/Analysis/diagnostics/macros.cpp index 8d7fccde1c61..5aa2c03ab0ed 100644 --- a/test/Analysis/diagnostics/macros.cpp +++ b/test/Analysis/diagnostics/macros.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core,osx -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,osx -analyzer-output=text -verify %s #include "../Inputs/system-header-simulator.h" #include "../Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/diagnostics/macros.m b/test/Analysis/diagnostics/macros.m index 7ef80b302dd9..b45997486214 100644 --- a/test/Analysis/diagnostics/macros.m +++ b/test/Analysis/diagnostics/macros.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx -fblocks -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -fblocks -analyzer-output=text -verify %s #include "../Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/diagnostics/no-prune-paths.c b/test/Analysis/diagnostics/no-prune-paths.c index fab5cf82059b..6e9e45766bf5 100644 --- a/test/Analysis/diagnostics/no-prune-paths.c +++ b/test/Analysis/diagnostics/no-prune-paths.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config prune-paths=false -DNPRUNE=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config prune-paths=false -DNPRUNE=1 -verify %s // "prune-paths" is a debug option only; this is just a simple test to see that // it's being honored. diff --git a/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp b/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp index 6ed39451a8bc..8c66b96007eb 100644 --- a/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp +++ b/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -analyzer-output=plist-multi-file %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s #include "Inputs/include/plist-diagnostics-include-check-macro.h" diff --git a/test/Analysis/diagnostics/report-issues-within-main-file.cpp b/test/Analysis/diagnostics/report-issues-within-main-file.cpp index 5fd7abd03c4a..784fdba972df 100644 --- a/test/Analysis/diagnostics/report-issues-within-main-file.cpp +++ b/test/Analysis/diagnostics/report-issues-within-main-file.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -analyzer-output=plist-multi-file -analyzer-config report-in-main-source-file=true -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-output=plist-multi-file -analyzer-config report-in-main-source-file=true -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s #include "Inputs/include/report-issues-within-main-file.h" diff --git a/test/Analysis/diagnostics/shortest-path-suppression.c b/test/Analysis/diagnostics/shortest-path-suppression.c index 4f648b986b25..d0fa4b51ef44 100644 --- a/test/Analysis/diagnostics/shortest-path-suppression.c +++ b/test/Analysis/diagnostics/shortest-path-suppression.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s // expected-no-diagnostics int *returnNull() { return 0; } diff --git a/test/Analysis/diagnostics/text-diagnostics.c b/test/Analysis/diagnostics/text-diagnostics.c index 592521672ff4..01946476e099 100644 --- a/test/Analysis/diagnostics/text-diagnostics.c +++ b/test/Analysis/diagnostics/text-diagnostics.c @@ -1,4 +1,4 @@ -// RUN: %clang --analyze -Xanalyzer -analyzer-output=text -fno-caret-diagnostics %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.NullDereference -analyzer-output=text -fno-caret-diagnostics %s 2>&1 | FileCheck %s void testA() { int *p = 0; diff --git a/test/Analysis/diagnostics/undef-value-caller.c b/test/Analysis/diagnostics/undef-value-caller.c index dc19e0a2b856..4f273bd9a72d 100644 --- a/test/Analysis/diagnostics/undef-value-caller.c +++ b/test/Analysis/diagnostics/undef-value-caller.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s // RUN: FileCheck --input-file %t %s #include "undef-value-callee.h" diff --git a/test/Analysis/diagnostics/undef-value-param.c b/test/Analysis/diagnostics/undef-value-param.c index 8ebf0daf2b49..837b0419ef20 100644 --- a/test/Analysis/diagnostics/undef-value-param.c +++ b/test/Analysis/diagnostics/undef-value-param.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void foo_irrelevant(int c) { diff --git a/test/Analysis/diagnostics/undef-value-param.m b/test/Analysis/diagnostics/undef-value-param.m index b9947d8ce019..f8212e0b9df3 100644 --- a/test/Analysis/diagnostics/undef-value-param.m +++ b/test/Analysis/diagnostics/undef-value-param.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s typedef signed char BOOL; @@ -45,8 +45,8 @@ SCDynamicStoreRef anotherCreateRef(unsigned *err, unsigned x); CreateRefUndef(&storeRef, 4); //expected-note@-1{{Calling 'CreateRefUndef'}} //expected-note@-2{{Returning from 'CreateRefUndef'}} - CFRelease(storeRef); //expected-warning {{Function call argument is an uninitialized value}} - //expected-note@-1{{Function call argument is an uninitialized value}} + CFRelease(storeRef); //expected-warning {{1st function call argument is an uninitialized value}} + //expected-note@-1{{1st function call argument is an uninitialized value}} } @end @@ -918,12 +918,12 @@ static void CreateRefUndef(SCDynamicStoreRef *storeRef, unsigned x) { // CHECK-NEXT: </array> // CHECK-NEXT: <key>depth</key><integer>0</integer> // CHECK-NEXT: <key>extended_message</key> -// CHECK-NEXT: <string>Function call argument is an uninitialized value</string> +// CHECK-NEXT: <string>1st function call argument is an uninitialized value</string> // CHECK-NEXT: <key>message</key> -// CHECK-NEXT: <string>Function call argument is an uninitialized value</string> +// CHECK-NEXT: <string>1st function call argument is an uninitialized value</string> // CHECK-NEXT: </dict> // CHECK-NEXT: </array> -// CHECK-NEXT: <key>description</key><string>Function call argument is an uninitialized value</string> +// CHECK-NEXT: <key>description</key><string>1st function call argument is an uninitialized value</string> // CHECK-NEXT: <key>category</key><string>Logic error</string> // CHECK-NEXT: <key>type</key><string>Uninitialized argument value</string> // CHECK-NEXT: <key>check_name</key><string>core.CallAndMessage</string> diff --git a/test/Analysis/disable-all-checks.c b/test/Analysis/disable-all-checks.c index 461e6d9bf94a..eb55799c259f 100644 --- a/test/Analysis/disable-all-checks.c +++ b/test/Analysis/disable-all-checks.c @@ -1,11 +1,11 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-disable-all-checks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-disable-all-checks -analyzer-checker=core -analyzer-store=region -verify %s -// RUN: %clang --analyze -Xanalyzer -analyzer-disable-all-checks -Xclang -verify %s -// RUN: not %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-disable-checker -verify %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -analyzer-disable-all-checks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-disable-all-checks -analyzer-checker=core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-disable-all-checks -verify %s +// RUN: not %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -analyzer-disable-checker -verify %s 2>&1 | FileCheck %s // expected-no-diagnostics // CHECK: use -analyzer-disable-all-checks to disable all static analyzer checkers int buggy() { int x = 0; return 5/x; // no warning -}
\ No newline at end of file +} diff --git a/test/Analysis/dispatch-once.m b/test/Analysis/dispatch-once.m index 2f82718663e5..7314dc96d541 100644 --- a/test/Analysis/dispatch-once.m +++ b/test/Analysis/dispatch-once.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s -// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s +// RUN: %clang_analyze_cc1 -w -fblocks -analyzer-checker=core,osx.API,unix.Malloc -verify %s +// RUN: %clang_analyze_cc1 -w -fblocks -fobjc-arc -analyzer-checker=core,osx.API,unix.Malloc -verify %s #include "Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/div-zero.cpp b/test/Analysis/div-zero.cpp index d1261dc57335..063450d8883b 100644 --- a/test/Analysis/div-zero.cpp +++ b/test/Analysis/div-zero.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core.DivideZero -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero -verify %s int fooPR10616 (int qX ) { int a, c, d; diff --git a/test/Analysis/division-by-zero.c b/test/Analysis/division-by-zero.c index d3c228e6c97d..33bb6fa3a6f5 100644 --- a/test/Analysis/division-by-zero.c +++ b/test/Analysis/division-by-zero.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc %s // Do not crash due to division by zero int f(unsigned int a) { diff --git a/test/Analysis/domtest.c b/test/Analysis/domtest.c index dd72117f8c95..e957c8d70e02 100644 --- a/test/Analysis/domtest.c +++ b/test/Analysis/domtest.c @@ -1,5 +1,5 @@ // RUN: rm -f %t -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpDominators %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpDominators %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s // Test the DominatorsTree implementation with various control flows diff --git a/test/Analysis/dtor-cxx11.cpp b/test/Analysis/dtor-cxx11.cpp index 7d2e87e44e4b..76d5e6c5065d 100644 --- a/test/Analysis/dtor-cxx11.cpp +++ b/test/Analysis/dtor-cxx11.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true -Wno-null-dereference -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true -Wno-null-dereference -verify %s // expected-no-diagnostics #include "Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp index c67722283ff8..bc74130b2fdf 100644 --- a/test/Analysis/dtor.cpp +++ b/test/Analysis/dtor.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus -analyzer-config c++-inlining=destructors,cfg-temporary-dtors=true -Wno-null-dereference -Wno-inaccessible-base -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection,cplusplus -analyzer-config c++-inlining=destructors,cfg-temporary-dtors=true -Wno-null-dereference -Wno-inaccessible-base -verify %s void clang_analyzer_eval(bool); void clang_analyzer_checkInlined(bool); diff --git a/test/Analysis/dtors-in-dtor-cfg-output.cpp b/test/Analysis/dtors-in-dtor-cfg-output.cpp index ceda58c8566c..4c1c8dd91da7 100644 --- a/test/Analysis/dtors-in-dtor-cfg-output.cpp +++ b/test/Analysis/dtors-in-dtor-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s class A { public: diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp index b48ee5b8efad..0c86f81cb819 100644 --- a/test/Analysis/dynamic-cast.cpp +++ b/test/Analysis/dynamic-cast.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=none -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/dynamic_type_check.m b/test/Analysis/dynamic_type_check.m index f9b181e308a9..3dc9465cfedf 100644 --- a/test/Analysis/dynamic_type_check.m +++ b/test/Analysis/dynamic_type_check.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.DynamicTypeChecker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.DynamicTypeChecker -verify %s #define nil 0 diff --git a/test/Analysis/edges-new.mm b/test/Analysis/edges-new.mm index 5cc21e04ece0..217cd4aa467f 100644 --- a/test/Analysis/edges-new.mm +++ b/test/Analysis/edges-new.mm @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-apple-darwin10 --analyze -Xclang -analyzer-config -Xclang path-diagnostics-alternate=true -Xclang -analyzer-output=plist -o %t %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,deadcode.DeadStores,osx.cocoa.RetainCount,unix.Malloc,unix.MismatchedDeallocator -analyzer-eagerly-assume -analyzer-config path-diagnostics-alternate=true -analyzer-output=plist -o %t -w %s // RUN: FileCheck --input-file %t %s //===----------------------------------------------------------------------===// @@ -230,7 +230,7 @@ void test_do_while() { p = 0; } while (i< 2); - + *p = 0xDEADBEEF; } diff --git a/test/Analysis/elementtype.c b/test/Analysis/elementtype.c index 1b2681181b40..7eba8e14b3a7 100644 --- a/test/Analysis/elementtype.c +++ b/test/Analysis/elementtype.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region %s typedef struct added_obj_st { int type; diff --git a/test/Analysis/engine/replay-without-inlining.c b/test/Analysis/engine/replay-without-inlining.c index 14b2b819b9e6..0b9820eba698 100644 --- a/test/Analysis/engine/replay-without-inlining.c +++ b/test/Analysis/engine/replay-without-inlining.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s // expected-no-diagnostics typedef struct { diff --git a/test/Analysis/enum.cpp b/test/Analysis/enum.cpp index 571fa7ba228d..e26b8f00d98c 100644 --- a/test/Analysis/enum.cpp +++ b/test/Analysis/enum.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=debug.ExprInspection %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=debug.ExprInspection %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/exceptions.mm b/test/Analysis/exceptions.mm index dab1b5e8c9c8..0e776373b62a 100644 --- a/test/Analysis/exceptions.mm +++ b/test/Analysis/exceptions.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fexceptions -fobjc-exceptions -fcxx-exceptions -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -fexceptions -fobjc-exceptions -fcxx-exceptions -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s void clang_analyzer_checkInlined(bool); diff --git a/test/Analysis/exercise-ps.c b/test/Analysis/exercise-ps.c index 03b6874b68ee..577b88bf837f 100644 --- a/test/Analysis/exercise-ps.c +++ b/test/Analysis/exercise-ps.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // // Just exercise the analyzer on code that has at one point caused issues // (i.e., no assertions or crashes). diff --git a/test/Analysis/explain-svals.c b/test/Analysis/explain-svals.c new file mode 100644 index 000000000000..f1540bbe2de8 --- /dev/null +++ b/test/Analysis/explain-svals.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s + +struct S { + int z; +}; + +void clang_analyzer_explain_int(int); +void clang_analyzer_explain_voidp(void *); +void clang_analyzer_explain_S(struct S); + +int glob; + +void test_1(int param, void *ptr) { + clang_analyzer_explain_voidp(&glob); // expected-warning-re{{{{^pointer to global variable 'glob'$}}}} + clang_analyzer_explain_int(param); // expected-warning-re{{{{^argument 'param'$}}}} + clang_analyzer_explain_voidp(ptr); // expected-warning-re{{{{^argument 'ptr'$}}}} + if (param == 42) + clang_analyzer_explain_int(param); // expected-warning-re{{{{^signed 32-bit integer '42'$}}}} +} + +void test_2(struct S s) { + clang_analyzer_explain_S(s); //expected-warning-re{{{{^lazily frozen compound value of parameter 's'$}}}} + clang_analyzer_explain_voidp(&s); // expected-warning-re{{{{^pointer to parameter 's'$}}}} + clang_analyzer_explain_int(s.z); // expected-warning-re{{{{^initial value of field 'z' of parameter 's'$}}}} +} diff --git a/test/Analysis/explain-svals.cpp b/test/Analysis/explain-svals.cpp index be2f83037051..d4b56a348252 100644 --- a/test/Analysis/explain-svals.cpp +++ b/test/Analysis/explain-svals.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core.builtin,debug.ExprInspection,unix.cstring -verify %s typedef unsigned long size_t; diff --git a/test/Analysis/explain-svals.m b/test/Analysis/explain-svals.m index 34cdacfa282c..dd40946c8432 100644 --- a/test/Analysis/explain-svals.m +++ b/test/Analysis/explain-svals.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -w -triple i386-apple-darwin10 -fblocks -analyze -analyzer-checker=core.builtin,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -w -triple i386-apple-darwin10 -fblocks -analyzer-checker=core.builtin,debug.ExprInspection -verify %s #include "Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/expr-inspection.c b/test/Analysis/expr-inspection.c index 69e18cb1e686..59406cd420ad 100644 --- a/test/Analysis/expr-inspection.c +++ b/test/Analysis/expr-inspection.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s 2>&1 | FileCheck %s // Self-tests for the debug.ExprInspection checker. @@ -19,4 +19,4 @@ void foo(int x) { // CHECK: Expressions: // CHECK-NEXT: clang_analyzer_printState : &code{clang_analyzer_printState} -// CHECK-NEXT: Ranges are empty. +// CHECK-NEXT: {{(Ranges are empty.)|(Constraints:[[:space:]]*$)}} diff --git a/test/Analysis/fields.c b/test/Analysis/fields.c index a670c50434e3..1aa484074208 100644 --- a/test/Analysis/fields.c +++ b/test/Analysis/fields.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection %s -analyzer-store=region -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection %s -analyzer-store=region -verify void clang_analyzer_eval(int); diff --git a/test/Analysis/free.c b/test/Analysis/free.c index 3746bf11c04e..acdb2820d328 100644 --- a/test/Analysis/free.c +++ b/test/Analysis/free.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify -analyzer-config unix.Malloc:Optimistic=true %s +// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core,unix.Malloc -fblocks -verify -analyzer-config unix.Malloc:Optimistic=true %s typedef __typeof(sizeof(int)) size_t; void free(void *); void *alloca(size_t); diff --git a/test/Analysis/func.c b/test/Analysis/func.c index 78afb45da696..58d4f45eeb50 100644 --- a/test/Analysis/func.c +++ b/test/Analysis/func.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s void clang_analyzer_eval(int); void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/generics.m b/test/Analysis/generics.m index da5c5126566c..dac148d42e8e 100644 --- a/test/Analysis/generics.m +++ b/test/Analysis/generics.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist // RUN: FileCheck --input-file %t.plist %s #if !__has_feature(objc_generics) diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c index bff22012c0c7..83df292f5885 100644 --- a/test/Analysis/global-region-invalidation.c +++ b/test/Analysis/global-region-invalidation.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,alpha.security.taint,debug.TaintTest,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,alpha.security.taint,debug.TaintTest,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/global_region_invalidation.mm b/test/Analysis/global_region_invalidation.mm index 2369c09d22f1..aee3b66a63d3 100644 --- a/test/Analysis/global_region_invalidation.mm +++ b/test/Analysis/global_region_invalidation.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/gmalloc.c b/test/Analysis/gmalloc.c new file mode 100644 index 000000000000..10c4fe284054 --- /dev/null +++ b/test/Analysis/gmalloc.c @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s + +#include "Inputs/system-header-simulator.h" + +typedef void* gpointer; +typedef const void* gconstpointer; +typedef unsigned long gsize; +typedef unsigned int guint; + +gpointer g_malloc(gsize n_bytes); +gpointer g_malloc0(gsize n_bytes); +gpointer g_realloc(gpointer mem, gsize n_bytes); +gpointer g_try_malloc(gsize n_bytes); +gpointer g_try_malloc0(gsize n_bytes); +gpointer g_try_realloc(gpointer mem, gsize n_bytes); +void g_free(gpointer mem); +gpointer g_memdup(gconstpointer mem, guint byte_size); + +static const gsize n_bytes = 1024; + +void f1() { + gpointer g1 = g_malloc(n_bytes); + gpointer g2 = g_malloc0(n_bytes); + g1 = g_realloc(g1, n_bytes * 2); + gpointer g3 = g_try_malloc(n_bytes); + gpointer g4 = g_try_malloc0(n_bytes); + g3 = g_try_realloc(g3, n_bytes * 2); + + g_free(g1); + g_free(g2); + g_free(g2); // expected-warning{{Attempt to free released memory}} +} + +void f2() { + gpointer g1 = g_malloc(n_bytes); + gpointer g2 = g_malloc0(n_bytes); + g1 = g_realloc(g1, n_bytes * 2); + gpointer g3 = g_try_malloc(n_bytes); + gpointer g4 = g_try_malloc0(n_bytes); + g3 = g_try_realloc(g3, n_bytes * 2); + + g_free(g1); + g_free(g2); + g_free(g3); + g3 = g_memdup(g3, n_bytes); // expected-warning{{Use of memory after it is freed}} +} + +void f3() { + gpointer g1 = g_malloc(n_bytes); + gpointer g2 = g_malloc0(n_bytes); + g1 = g_realloc(g1, n_bytes * 2); + gpointer g3 = g_try_malloc(n_bytes); + gpointer g4 = g_try_malloc0(n_bytes); + g3 = g_try_realloc(g3, n_bytes * 2); // expected-warning{{Potential leak of memory pointed to by 'g4'}} + + g_free(g1); + g_free(g2); + g_free(g3); +} diff --git a/test/Analysis/gtest.cpp b/test/Analysis/gtest.cpp index f33569598e1e..5797a773b423 100644 --- a/test/Analysis/gtest.cpp +++ b/test/Analysis/gtest.cpp @@ -1,6 +1,6 @@ -//RUN: %clang_cc1 -cc1 -std=c++11 -analyze -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume %s -verify -//RUN: %clang_cc1 -cc1 -std=c++11 -analyze -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume -DGTEST_VERSION_1_8_AND_LATER=1 %s -verify -//RUN: %clang_cc1 -cc1 -std=c++11 -analyze -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume -analyzer-config cfg-temporary-dtors=true %s -verify +//RUN: %clang_analyze_cc1 -cc1 -std=c++11 -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume %s -verify +//RUN: %clang_analyze_cc1 -cc1 -std=c++11 -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume -DGTEST_VERSION_1_8_AND_LATER=1 %s -verify +//RUN: %clang_analyze_cc1 -cc1 -std=c++11 -analyzer-checker=core,apiModeling.google.GTest,debug.ExprInspection -analyzer-eagerly-assume -analyzer-config cfg-temporary-dtors=true %s -verify void clang_analyzer_eval(int); void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/html-diags-multifile.c b/test/Analysis/html-diags-multifile.c index bb769283bba9..ce1f72b6bb1a 100644 --- a/test/Analysis/html-diags-multifile.c +++ b/test/Analysis/html-diags-multifile.c @@ -1,5 +1,5 @@ // RUN: mkdir -p %t.dir -// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir %s +// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %t.dir %s // RUN: ls %t.dir | not grep report // RUN: rm -fR %t.dir diff --git a/test/Analysis/html-diags.c b/test/Analysis/html-diags.c index e998020f4cfa..182bcfbdfa12 100644 --- a/test/Analysis/html-diags.c +++ b/test/Analysis/html-diags.c @@ -1,11 +1,11 @@ // RUN: rm -fR %T/dir // RUN: mkdir %T/dir -// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T/dir %s +// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o %T/dir %s // RUN: ls %T/dir | grep report // PR16547: Test relative paths // RUN: cd %T/dir -// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o testrelative %s +// RUN: %clang_analyze_cc1 -analyzer-output=html -analyzer-checker=core -o testrelative %s // RUN: ls %T/dir/testrelative | grep report // Currently this test mainly checks that the HTML diagnostics doesn't crash diff --git a/test/Analysis/identical-expressions.cpp b/test/Analysis/identical-expressions.cpp index 138cd7ce9887..8bb82372b534 100644 --- a/test/Analysis/identical-expressions.cpp +++ b/test/Analysis/identical-expressions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core.IdenticalExpr -w -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core.IdenticalExpr -w -verify %s /* Only one expected warning per function allowed at the very end. */ diff --git a/test/Analysis/index-type.c b/test/Analysis/index-type.c index fc638dfe7417..b86913b996f6 100644 --- a/test/Analysis/index-type.c +++ b/test/Analysis/index-type.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,alpha.security.ArrayBoundV2 -DM32 -verify %s // expected-no-diagnostics #define UINT_MAX (~0u) diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index 09509271dae0..c73635686d83 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=constructors -std=c++11 -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp index deefbef07738..ccf4db519d79 100644 --- a/test/Analysis/initializers-cfg-output.cpp +++ b/test/Analysis/initializers-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s class A { public: diff --git a/test/Analysis/inline-not-supported.c b/test/Analysis/inline-not-supported.c index 756d5d8b8dbf..c5f4c74952cc 100644 --- a/test/Analysis/inline-not-supported.c +++ b/test/Analysis/inline-not-supported.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core -verify %s // For now, don't inline varargs. void foo(int *x, ...) { diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c index bccf219d31e5..441bb48b1055 100644 --- a/test/Analysis/inline-plist.c +++ b/test/Analysis/inline-plist.c @@ -1,5 +1,5 @@ -// RUN: %clang --analyze %s -fblocks -Xanalyzer -analyzer-output=text -Xanalyzer -analyzer-config -Xanalyzer suppress-null-return-paths=false -Xclang -verify %s -// RUN: %clang --analyze %s -fblocks -Xanalyzer -analyzer-config -Xanalyzer suppress-null-return-paths=false -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference,core.DivideZero -fblocks -analyzer-output=text -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference,core.DivideZero -fblocks -analyzer-output=plist -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false -o %t // RUN: FileCheck -input-file %t %s // <rdar://problem/10967815> @@ -41,7 +41,7 @@ void bar(int *p) { // expected-note@-2 {{Taking false branch}} return; } - + if (p == 0) { // expected-note@-1 {{Taking true branch}} triggers_bug(p); @@ -59,7 +59,7 @@ void test_block__capture_null() { ^(){ // expected-note {{Calling anonymous block}} *p = 1; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} expected-note{{Dereference of null pointer (loaded from variable 'p')}} }(); - + } void test_block_ret() { @@ -550,12 +550,12 @@ void test_block_arg() { // CHECK-NEXT: <array> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: </array> @@ -567,7 +567,7 @@ void test_block_arg() { // CHECK-NEXT: <key>location</key> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: <key>ranges</key> @@ -575,7 +575,7 @@ void test_block_arg() { // CHECK-NEXT: <array> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: <dict> @@ -600,12 +600,12 @@ void test_block_arg() { // CHECK-NEXT: <array> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: <dict> // CHECK-NEXT: <key>line</key><integer>39</integer> -// CHECK-NEXT: <key>col</key><integer>8</integer> +// CHECK-NEXT: <key>col</key><integer>7</integer> // CHECK-NEXT: <key>file</key><integer>0</integer> // CHECK-NEXT: </dict> // CHECK-NEXT: </array> diff --git a/test/Analysis/inline-unique-reports.c b/test/Analysis/inline-unique-reports.c index 4b3c2fecca1e..f827f88deb1d 100644 --- a/test/Analysis/inline-unique-reports.c +++ b/test/Analysis/inline-unique-reports.c @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t > /dev/null 2>&1 +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t > /dev/null 2>&1 // RUN: FileCheck -input-file %t %s static inline bug(int *p) { diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 03c4ea832581..8fce0fb176ea 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); void clang_analyzer_checkInlined(int); diff --git a/test/Analysis/inline.cpp b/test/Analysis/inline.cpp index 9fc4f81c05b6..76eee5beffac 100644 --- a/test/Analysis/inline.cpp +++ b/test/Analysis/inline.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config ipa=inlining -analyzer-config c++-allocator-inlining=true -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config ipa=inlining -analyzer-config c++-allocator-inlining=true -verify %s void clang_analyzer_eval(bool); void clang_analyzer_checkInlined(bool); diff --git a/test/Analysis/inline2.c b/test/Analysis/inline2.c index bae7434518e2..39e6d16cc4fd 100644 --- a/test/Analysis/inline2.c +++ b/test/Analysis/inline2.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // expected-no-diagnostics // Test parameter 'a' is registered to LiveVariables analysis data although it diff --git a/test/Analysis/inline3.c b/test/Analysis/inline3.c index e7f4775925a1..2c70fb21aa2b 100644 --- a/test/Analysis/inline3.c +++ b/test/Analysis/inline3.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // expected-no-diagnostics // Test when entering f1(), we set the right AnalysisDeclContext to Environment. diff --git a/test/Analysis/inline4.c b/test/Analysis/inline4.c index 71a379a02c75..a1aac1dec686 100644 --- a/test/Analysis/inline4.c +++ b/test/Analysis/inline4.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // expected-no-diagnostics int g(int a) { diff --git a/test/Analysis/inlining/DynDispatchBifurcate.m b/test/Analysis/inlining/DynDispatchBifurcate.m index 0ce079654e98..a41a5e3a858d 100644 --- a/test/Analysis/inlining/DynDispatchBifurcate.m +++ b/test/Analysis/inlining/DynDispatchBifurcate.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -analyzer-config ipa=dynamic-bifurcate -verify %s #include "InlineObjCInstanceMethod.h" diff --git a/test/Analysis/inlining/InlineObjCClassMethod.m b/test/Analysis/inlining/InlineObjCClassMethod.m index c9cc90ba27c0..bb869c5e5297 100644 --- a/test/Analysis/inlining/InlineObjCClassMethod.m +++ b/test/Analysis/inlining/InlineObjCClassMethod.m @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s void clang_analyzer_checkInlined(int); +void clang_analyzer_eval(int); // Test inlining of ObjC class methods. @@ -194,7 +195,9 @@ int foo2() { @implementation SelfUsedInParent + (int)getNum {return 5;} + (int)foo { - return [self getNum]; + int r = [self getNum]; + clang_analyzer_eval(r == 5); // expected-warning{{TRUE}} + return r; } @end @interface SelfUsedInParentChild : SelfUsedInParent @@ -229,8 +232,80 @@ void rdar15037033() { + (void)forwardDeclaredVariadicMethod:(int)x, ... { clang_analyzer_checkInlined(0); // no-warning } +@end +@interface SelfClassTestParent : NSObject +-(unsigned)returns10; ++(unsigned)returns20; ++(unsigned)returns30; @end +@implementation SelfClassTestParent +-(unsigned)returns10 { return 100; } ++(unsigned)returns20 { return 100; } ++(unsigned)returns30 { return 100; } +@end +@interface SelfClassTest : SelfClassTestParent +-(unsigned)returns10; ++(unsigned)returns20; ++(unsigned)returns30; +@end + +@implementation SelfClassTest +-(unsigned)returns10 { return 10; } ++(unsigned)returns20 { return 20; } ++(unsigned)returns30 { return 30; } ++(void)classMethod { + unsigned result1 = [self returns20]; + clang_analyzer_eval(result1 == 20); // expected-warning{{TRUE}} + unsigned result2 = [[self class] returns30]; + clang_analyzer_eval(result2 == 30); // expected-warning{{TRUE}} + unsigned result3 = [[super class] returns30]; + clang_analyzer_eval(result3 == 100); // expected-warning{{UNKNOWN}} +} +-(void)instanceMethod { + unsigned result0 = [self returns10]; + clang_analyzer_eval(result0 == 10); // expected-warning{{TRUE}} + unsigned result2 = [[self class] returns30]; + clang_analyzer_eval(result2 == 30); // expected-warning{{TRUE}} + unsigned result3 = [[super class] returns30]; + clang_analyzer_eval(result3 == 100); // expected-warning{{UNKNOWN}} +} +@end +@interface Parent : NSObject ++ (int)a; ++ (int)b; +@end +@interface Child : Parent +@end +@interface Other : NSObject ++(void)run; +@end +int main(int argc, const char * argv[]) { + @autoreleasepool { + [Other run]; + } + return 0; +} +@implementation Other ++(void)run { + int result = [Child a]; + // TODO: This should return 100. + clang_analyzer_eval(result == 12); // expected-warning{{TRUE}} +} +@end +@implementation Parent ++ (int)a; { + return [self b]; +} ++ (int)b; { + return 12; +} +@end +@implementation Child ++ (int)b; { + return 100; +} +@end diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.m b/test/Analysis/inlining/InlineObjCInstanceMethod.m index f6aa50a24802..4578a55c7a07 100644 --- a/test/Analysis/inlining/InlineObjCInstanceMethod.m +++ b/test/Analysis/inlining/InlineObjCInstanceMethod.m @@ -1,4 +1,4 @@ -// RUN: %clang --analyze -Xanalyzer -analyzer-checker=osx.cocoa.IncompatibleMethodTypes,osx.coreFoundation.CFRetainRelease -Xclang -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.DivideZero,core.DynamicTypePropagation,osx.cocoa.IncompatibleMethodTypes -w -verify %s #include "InlineObjCInstanceMethod.h" diff --git a/test/Analysis/inlining/ObjCDynTypePopagation.m b/test/Analysis/inlining/ObjCDynTypePopagation.m index ccc24713782a..0c1d4f2a31cb 100644 --- a/test/Analysis/inlining/ObjCDynTypePopagation.m +++ b/test/Analysis/inlining/ObjCDynTypePopagation.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s #include "InlineObjCInstanceMethod.h" diff --git a/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m index 06b271ad4b36..d787c7e9e17b 100644 --- a/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m +++ b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify %s typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @end diff --git a/test/Analysis/inlining/RetainCountExamples.m b/test/Analysis/inlining/RetainCountExamples.m index 41479af0a096..938d3e2bfb62 100644 --- a/test/Analysis/inlining/RetainCountExamples.m +++ b/test/Analysis/inlining/RetainCountExamples.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-config ipa=dynamic-bifurcate -verify %s typedef signed char BOOL; typedef struct objc_class *Class; diff --git a/test/Analysis/inlining/analysis-order.c b/test/Analysis/inlining/analysis-order.c index 5149818c74fd..620732c68542 100644 --- a/test/Analysis/inlining/analysis-order.c +++ b/test/Analysis/inlining/analysis-order.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s // Do not analyze test1() again because it was inlined void test1(); diff --git a/test/Analysis/inlining/assume-super-init-does-not-return-nil.m b/test/Analysis/inlining/assume-super-init-does-not-return-nil.m index fba3e2d1b54b..be46776b37d4 100644 --- a/test/Analysis/inlining/assume-super-init-does-not-return-nil.m +++ b/test/Analysis/inlining/assume-super-init-does-not-return-nil.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx -verify %s typedef signed char BOOL; diff --git a/test/Analysis/inlining/containers.cpp b/test/Analysis/inlining/containers.cpp index c757da66bedb..16e006b345f2 100644 --- a/test/Analysis/inlining/containers.cpp +++ b/test/Analysis/inlining/containers.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=false -verify %s -// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=true -DINLINE=1 -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=false -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=true -DINLINE=1 -verify %s #ifndef HEADER diff --git a/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp b/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp index e23d4e23a48f..02084839c55b 100644 --- a/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp +++ b/test/Analysis/inlining/dyn-dispatch-bifurcate.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify -Wno-reinterpret-base-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config ipa=dynamic-bifurcate -verify -Wno-reinterpret-base-class %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/inlining/eager-reclamation-path-notes.c b/test/Analysis/inlining/eager-reclamation-path-notes.c index cd16eb3af930..7c0f0ec8f52e 100644 --- a/test/Analysis/inlining/eager-reclamation-path-notes.c +++ b/test/Analysis/inlining/eager-reclamation-path-notes.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void use(int *ptr, int val) { diff --git a/test/Analysis/inlining/eager-reclamation-path-notes.cpp b/test/Analysis/inlining/eager-reclamation-path-notes.cpp index 8d5e85a6394f..f77a19f9965f 100644 --- a/test/Analysis/inlining/eager-reclamation-path-notes.cpp +++ b/test/Analysis/inlining/eager-reclamation-path-notes.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s typedef struct { diff --git a/test/Analysis/inlining/false-positive-suppression.c b/test/Analysis/inlining/false-positive-suppression.c index a0bc3611fe97..4931695ef127 100644 --- a/test/Analysis/inlining/false-positive-suppression.c +++ b/test/Analysis/inlining/false-positive-suppression.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-eagerly-assume -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-eagerly-assume -analyzer-checker=core -verify -DSUPPRESSED=1 %s -// RUN: %clang_cc1 -analyze -analyzer-eagerly-assume -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-eagerly-assume -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-eagerly-assume -analyzer-checker=core -verify -DSUPPRESSED=1 %s +// RUN: %clang_analyze_cc1 -analyzer-eagerly-assume -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s int opaquePropertyCheck(void *object); int coin(); diff --git a/test/Analysis/inlining/false-positive-suppression.cpp b/test/Analysis/inlining/false-positive-suppression.cpp index bff6907809c1..56659b4a1941 100644 --- a/test/Analysis/inlining/false-positive-suppression.cpp +++ b/test/Analysis/inlining/false-positive-suppression.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -DSUPPRESSED=1 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -DSUPPRESSED=1 %s namespace rdar12676053 { // Delta-reduced from a preprocessed file. diff --git a/test/Analysis/inlining/false-positive-suppression.m b/test/Analysis/inlining/false-positive-suppression.m index 685e29e23131..f3532e5d6640 100644 --- a/test/Analysis/inlining/false-positive-suppression.m +++ b/test/Analysis/inlining/false-positive-suppression.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -DSUPPRESSED=1 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -fobjc-arc -verify -DSUPPRESSED=1 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -DSUPPRESSED=1 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -fobjc-arc -verify -DSUPPRESSED=1 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s #define ARC __has_feature(objc_arc) diff --git a/test/Analysis/inlining/inline-defensive-checks.c b/test/Analysis/inlining/inline-defensive-checks.c index 4ce783c852fe..4029da651b65 100644 --- a/test/Analysis/inlining/inline-defensive-checks.c +++ b/test/Analysis/inlining/inline-defensive-checks.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s // Perform inline defensive checks. void idc(int *p) { diff --git a/test/Analysis/inlining/inline-defensive-checks.cpp b/test/Analysis/inlining/inline-defensive-checks.cpp index b69c53565784..6a803fa695c6 100644 --- a/test/Analysis/inlining/inline-defensive-checks.cpp +++ b/test/Analysis/inlining/inline-defensive-checks.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // expected-no-diagnostics extern void __assert_fail (__const char *__assertion, __const char *__file, diff --git a/test/Analysis/inlining/inline-defensive-checks.m b/test/Analysis/inlining/inline-defensive-checks.m index 0404ee6df813..38e5446ecd39 100644 --- a/test/Analysis/inlining/inline-defensive-checks.m +++ b/test/Analysis/inlining/inline-defensive-checks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s typedef signed char BOOL; typedef struct objc_class *Class; diff --git a/test/Analysis/inlining/path-notes.c b/test/Analysis/inlining/path-notes.c index 403d33db4851..95adee30a9af 100644 --- a/test/Analysis/inlining/path-notes.c +++ b/test/Analysis/inlining/path-notes.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config suppress-null-return-paths=false -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config suppress-null-return-paths=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void zero(int **p) { diff --git a/test/Analysis/inlining/path-notes.cpp b/test/Analysis/inlining/path-notes.cpp index 2d6886f9a77f..4d0b899e7cf7 100644 --- a/test/Analysis/inlining/path-notes.cpp +++ b/test/Analysis/inlining/path-notes.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config c++-inlining=destructors -std=c++11 -verify -Wno-tautological-undefined-compare %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config c++-inlining=destructors -std=c++11 -analyzer-config path-diagnostics-alternate=false %s -o %t.plist -Wno-tautological-undefined-compare +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config c++-inlining=destructors -std=c++11 -verify -Wno-tautological-undefined-compare %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config c++-inlining=destructors -std=c++11 -analyzer-config path-diagnostics-alternate=false %s -o %t.plist -Wno-tautological-undefined-compare // RUN: FileCheck --input-file=%t.plist %s class Foo { diff --git a/test/Analysis/inlining/path-notes.m b/test/Analysis/inlining/path-notes.m index d9b5a5820fe5..7f60ff8e3200 100644 --- a/test/Analysis/inlining/path-notes.m +++ b/test/Analysis/inlining/path-notes.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount -analyzer-output=text -analyzer-config suppress-null-return-paths=false -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount -analyzer-output=plist-multi-file -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false -fblocks %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount -analyzer-output=text -analyzer-config suppress-null-return-paths=false -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount -analyzer-output=plist-multi-file -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false -fblocks %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s typedef struct dispatch_queue_s *dispatch_queue_t; diff --git a/test/Analysis/inlining/retain-count-self-init.m b/test/Analysis/inlining/retain-count-self-init.m index 97379dbc7a88..208197381f60 100644 --- a/test/Analysis/inlining/retain-count-self-init.m +++ b/test/Analysis/inlining/retain-count-self-init.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.SelfInit -analyzer-config ipa=dynamic-bifurcate -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.SelfInit -analyzer-config ipa=dynamic-bifurcate -verify %s typedef signed char BOOL; typedef struct objc_class *Class; diff --git a/test/Analysis/inlining/stl.cpp b/test/Analysis/inlining/stl.cpp index d89a10983041..b672be2ba245 100644 --- a/test/Analysis/inlining/stl.cpp +++ b/test/Analysis/inlining/stl.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -DINLINE=1 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -DINLINE=1 -verify %s #include "../Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/inlining/test-always-inline-size-option.c b/test/Analysis/inlining/test-always-inline-size-option.c index 6b3c13d2b672..85fc8a16cc75 100644 --- a/test/Analysis/inlining/test-always-inline-size-option.c +++ b/test/Analysis/inlining/test-always-inline-size-option.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-inline-max-stack-depth=3 -analyzer-config ipa-always-inline-size=3 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-inline-max-stack-depth=3 -analyzer-config ipa-always-inline-size=3 -verify %s void clang_analyzer_eval(int); int nested5() { diff --git a/test/Analysis/inlining/test_objc_inlining_option.m b/test/Analysis/inlining/test_objc_inlining_option.m index 61408c1f3d42..f3a9417dac31 100644 --- a/test/Analysis/inlining/test_objc_inlining_option.m +++ b/test/Analysis/inlining/test_objc_inlining_option.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config ipa=dynamic-bifurcate -analyzer-config objc-inlining=false -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config ipa=dynamic-bifurcate -analyzer-config objc-inlining=false -verify %s // expected-no-diagnostics typedef signed char BOOL; diff --git a/test/Analysis/iterator-past-end.cpp b/test/Analysis/iterator-past-end.cpp index 4d9ed0cf9816..252d1044bd16 100644 --- a/test/Analysis/iterator-past-end.cpp +++ b/test/Analysis/iterator-past-end.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify #include "Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/ivars.m b/test/Analysis/ivars.m index c717da63ee61..11514d2f8309 100644 --- a/test/Analysis/ivars.m +++ b/test/Analysis/ivars.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s void clang_analyzer_eval(int); diff --git a/test/Analysis/keychainAPI-diagnostic-visitor.m b/test/Analysis/keychainAPI-diagnostic-visitor.m index a78b114a00fb..d8da697a41e8 100644 --- a/test/Analysis/keychainAPI-diagnostic-visitor.m +++ b/test/Analysis/keychainAPI-diagnostic-visitor.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=osx.SecKeychainAPI -analyzer-store=region -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=osx.SecKeychainAPI -analyzer-store=region -analyzer-output=text -verify %s // This file is for testing enhanced diagnostics produced by the default SecKeychainAPI checker. diff --git a/test/Analysis/keychainAPI.m b/test/Analysis/keychainAPI.m index 4fc48c066f9d..1725ce15f0e6 100644 --- a/test/Analysis/keychainAPI.m +++ b/test/Analysis/keychainAPI.m @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.SecKeychainAPI %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.SecKeychainAPI -fblocks %s -verify + +#include "Inputs/system-header-simulator-objc.h" // Fake typedefs. typedef unsigned int OSStatus; @@ -6,8 +8,6 @@ typedef unsigned int SecKeychainAttributeList; typedef unsigned int SecKeychainItemRef; typedef unsigned int SecItemClass; typedef unsigned int UInt32; -typedef unsigned int CFTypeRef; -typedef unsigned int UInt16; typedef unsigned int SecProtocolType; typedef unsigned int SecAuthenticationType; typedef unsigned int SecKeychainAttributeInfo; @@ -77,7 +77,7 @@ void errRetVal() { void *outData; st = SecKeychainItemCopyContent(2, ptr, ptr, &length, &outData); if (st == GenericError) - SecKeychainItemFreeContent(ptr, outData); // expected-warning{{Only call free if a valid (non-NULL) buffer was returned}} + SecKeychainItemFreeContent(ptr, outData); } // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'}} // If null is passed in, the data is not allocated, so no need for the matching free. @@ -101,14 +101,6 @@ void doubleAlloc() { SecKeychainItemFreeContent(ptr, outData); } -void fooOnlyFree() { - unsigned int *ptr = 0; - OSStatus st = 0; - UInt32 length; - void *outData = &length; - SecKeychainItemFreeContent(ptr, outData);// expected-warning{{Trying to free data which has not been allocated}} -} - // Do not warn if undefined value is passed to a function. void fooOnlyFreeUndef() { unsigned int *ptr = 0; @@ -220,11 +212,27 @@ int foo(CFTypeRef keychainOrArray, SecProtocolType protocol, if (st == noErr) SecKeychainItemFreeContent(ptr, outData[3]); } - if (length) { // expected-warning{{Allocated data is not released: missing a call to 'SecKeychainItemFreeContent'}} + if (length) { // TODO: We do not report a warning here since the symbol is no longer live, but it's not marked as dead. length++; } return 0; -}// no-warning +} + +int testErrorCodeAsLHS(CFTypeRef keychainOrArray, SecProtocolType protocol, + SecAuthenticationType authenticationType, SecKeychainItemRef *itemRef) { + unsigned int *ptr = 0; + OSStatus st = 0; + UInt32 length; + void *outData; + st = SecKeychainFindInternetPassword(keychainOrArray, + 16, "server", 16, "domain", 16, "account", + 16, "path", 222, protocol, authenticationType, + &length, &outData, itemRef); + if (noErr == st) + SecKeychainItemFreeContent(ptr, outData); + + return 0; +} void free(void *ptr); void deallocateWithFree() { @@ -251,7 +259,6 @@ extern const CFAllocatorRef kCFAllocatorMallocZone; extern const CFAllocatorRef kCFAllocatorNull; extern const CFAllocatorRef kCFAllocatorUseContext; CFStringRef CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const uint8_t *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator); -extern void CFRelease(CFStringRef cf); void DellocWithCFStringCreate1(CFAllocatorRef alloc) { unsigned int *ptr = 0; @@ -333,11 +340,11 @@ void radar10508828() { SecKeychainItemFreeContent(0, pwdBytes); } -void radar10508828_2() { +void radar10508828_20092614() { UInt32 pwdLen = 0; void* pwdBytes = 0; OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0); - SecKeychainItemFreeContent(0, pwdBytes); // expected-warning {{Only call free if a valid (non-NULL) buffer was returned}} + SecKeychainItemFreeContent(0, pwdBytes); } //Example from bug 10797. @@ -426,3 +433,24 @@ void allocAndFree3(void *attrList) { SecKeychainItemFreeContent(attrList, outData); } +typedef struct AuthorizationValue { + int length; + void *data; +} AuthorizationValue; +typedef struct AuthorizationCallback { + OSStatus (*SetContextVal)(AuthorizationValue *inValue); +} AuthorizationCallback; +static AuthorizationCallback cb; +int radar_19196494() { + @autoreleasepool { + AuthorizationValue login_password = {}; + UInt32 passwordLength; + void *passwordData = 0; + OSStatus err = SecKeychainFindGenericPassword(0, 0, "", 0, "", (UInt32 *)&login_password.length, (void**)&login_password.data, 0); + cb.SetContextVal(&login_password); + if (err == noErr) { + SecKeychainItemFreeContent(0, login_password.data); + } + } + return 0; +} diff --git a/test/Analysis/kmalloc-linux.c b/test/Analysis/kmalloc-linux.c index 87c1107a102e..bac71388a7a8 100644 --- a/test/Analysis/kmalloc-linux.c +++ b/test/Analysis/kmalloc-linux.c @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-unknown-linux --analyze %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux %s #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/lambda-notes.cpp b/test/Analysis/lambda-notes.cpp index 661fd052c87d..7abff35df124 100644 --- a/test/Analysis/lambda-notes.cpp +++ b/test/Analysis/lambda-notes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core.DivideZero -analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t // RUN: FileCheck --input-file=%t %s diff --git a/test/Analysis/lambdas-generalized-capture.cpp b/test/Analysis/lambdas-generalized-capture.cpp index 790e15e8ccc3..feaf55d6c84e 100644 --- a/test/Analysis/lambdas-generalized-capture.cpp +++ b/test/Analysis/lambdas-generalized-capture.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -fsyntax-only -analyze -analyzer-checker=core,deadcode,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core,deadcode,debug.ExprInspection -verify %s int clang_analyzer_eval(int); diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp index 0b66e6b92fa6..f3ff9b953938 100644 --- a/test/Analysis/lambdas.cpp +++ b/test/Analysis/lambdas.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -analyze -analyzer-checker=core,debug.DumpCFG -analyzer-config inline-lambdas=true %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,debug.DumpCFG -analyzer-config inline-lambdas=true %s > %t 2>&1 // RUN: FileCheck --input-file=%t %s void clang_analyzer_warnIfReached(); @@ -212,7 +212,7 @@ struct DontCrash { callLambda([&](){ ++x; }); callLambdaFromStatic([&](){ ++x; }); } - + template<typename T> static void callLambdaFromStatic(T t) { t(); diff --git a/test/Analysis/lambdas.mm b/test/Analysis/lambdas.mm index dc1a13e8b69d..d2b8e7b35356 100644 --- a/test/Analysis/lambdas.mm +++ b/test/Analysis/lambdas.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fblocks -Wno-objc-root-class -analyze -analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -fblocks -Wno-objc-root-class -analyzer-checker=core,deadcode,debug.ExprInspection -analyzer-config inline-lambdas=true -verify %s int clang_analyzer_eval(int); diff --git a/test/Analysis/lifetime-extension.cpp b/test/Analysis/lifetime-extension.cpp index 124eef32fde3..5e3c5dde0a8b 100644 --- a/test/Analysis/lifetime-extension.cpp +++ b/test/Analysis/lifetime-extension.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-unused -std=c++11 -analyze -analyzer-checker=debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=debug.ExprInspection -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/lit.local.cfg b/test/Analysis/lit.local.cfg index da2a68b378cc..a594c5dada58 100644 --- a/test/Analysis/lit.local.cfg +++ b/test/Analysis/lit.local.cfg @@ -1,2 +1,13 @@ -if config.root.clang_staticanalyzer == 0: +# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: + +import site + +# Load the custom analyzer test format, which runs the test again with Z3 if it +# is available. +site.addsitedir(os.path.dirname(__file__)) +import analyzer_test +config.test_format = analyzer_test.AnalyzerTest( + config.test_format.execute_external) + +if not config.root.clang_staticanalyzer: config.unsupported = True diff --git a/test/Analysis/live-variables.cpp b/test/Analysis/live-variables.cpp index 0cfaa1b41f52..2c38b8bd7134 100644 --- a/test/Analysis/live-variables.cpp +++ b/test/Analysis/live-variables.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // expected-no-diagnostics class B { public: diff --git a/test/Analysis/live-variables.m b/test/Analysis/live-variables.m index eefd292bf79b..d2390f3f8787 100644 --- a/test/Analysis/live-variables.m +++ b/test/Analysis/live-variables.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -fobjc-arc -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -fobjc-arc -verify %s // expected-no-diagnostics @interface NSObject @end diff --git a/test/Analysis/localization-aggressive.m b/test/Analysis/localization-aggressive.m index 89950d4eed74..346cf3ef22e2 100644 --- a/test/Analysis/localization-aggressive.m +++ b/test/Analysis/localization-aggressive.m @@ -1,6 +1,6 @@ // RUN: %clang_cc1 -fblocks -x objective-c-header -emit-pch -o %t.pch %S/Inputs/localization-pch.h -// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker -include-pch %t.pch -verify -analyzer-config AggressiveReport=true %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-store=region -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker -include-pch %t.pch -verify -analyzer-config AggressiveReport=true %s // These declarations were reduced using Delta-Debugging from Foundation.h // on Mac OS X. diff --git a/test/Analysis/localization.m b/test/Analysis/localization.m index 200eac3f037e..3a6a0d707373 100644 --- a/test/Analysis/localization.m +++ b/test/Analysis/localization.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region -analyzer-output=text -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.localizability.PluralMisuseChecker -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-store=region -analyzer-output=text -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.localizability.PluralMisuseChecker -verify %s // The larger set of tests in located in localization.m. These are tests // specific for non-aggressive reporting. diff --git a/test/Analysis/logical-ops.c b/test/Analysis/logical-ops.c index 0b63bc9ec835..553050173b02 100644 --- a/test/Analysis/logical-ops.c +++ b/test/Analysis/logical-ops.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-pointer-bool-conversion -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -Wno-pointer-bool-conversion -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/loop-widening.c b/test/Analysis/loop-widening.c index 0b9bf7080873..de17951d180f 100644 --- a/test/Analysis/loop-widening.c +++ b/test/Analysis/loop-widening.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s void clang_analyzer_eval(int); void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/lvalue.cpp b/test/Analysis/lvalue.cpp index 9a6bd5939743..762113987663 100644 --- a/test/Analysis/lvalue.cpp +++ b/test/Analysis/lvalue.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify %s // expected-no-diagnostics int f1() { diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c index 3119cb7e9744..21eaab72b766 100644 --- a/test/Analysis/malloc-annotations.c +++ b/test/Analysis/malloc-annotations.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc -analyzer-store=region -verify -analyzer-config unix.Malloc:Optimistic=true %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc -analyzer-store=region -verify -analyzer-config unix.Malloc:Optimistic=true %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void free(void *); diff --git a/test/Analysis/malloc-custom.c b/test/Analysis/malloc-custom.c index 3c16bbd17e68..f33b150de678 100644 --- a/test/Analysis/malloc-custom.c +++ b/test/Analysis/malloc-custom.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -Wno-incompatible-library-redeclaration -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -Wno-incompatible-library-redeclaration -verify %s // Various tests to make the the analyzer is robust against custom // redeclarations of memory routines. diff --git a/test/Analysis/malloc-interprocedural.c b/test/Analysis/malloc-interprocedural.c index c78cc6c6aae4..4f7daec1b5bc 100644 --- a/test/Analysis/malloc-interprocedural.c +++ b/test/Analysis/malloc-interprocedural.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc -analyzer-inline-max-stack-depth=5 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc -analyzer-inline-max-stack-depth=5 -verify %s #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/malloc-overflow.c b/test/Analysis/malloc-overflow.c index 99e05adab6fb..d8ad062840d5 100644 --- a/test/Analysis/malloc-overflow.c +++ b/test/Analysis/malloc-overflow.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.MallocOverflow -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.MallocOverflow -verify %s #define NULL ((void *) 0) typedef __typeof__(sizeof(int)) size_t; diff --git a/test/Analysis/malloc-overflow.cpp b/test/Analysis/malloc-overflow.cpp index e3a0408863e6..e070217cf7d8 100644 --- a/test/Analysis/malloc-overflow.cpp +++ b/test/Analysis/malloc-overflow.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.MallocOverflow -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.MallocOverflow -verify %s // expected-no-diagnostics class A { diff --git a/test/Analysis/malloc-overflow2.c b/test/Analysis/malloc-overflow2.c index 83a2c02213b2..2e1b1d4d2b24 100644 --- a/test/Analysis/malloc-overflow2.c +++ b/test/Analysis/malloc-overflow2.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -analyze -analyzer-checker=alpha.security.MallocOverflow,unix -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -analyzer-checker=alpha.security.MallocOverflow,unix -verify %s typedef __typeof__(sizeof(int)) size_t; extern void *malloc(size_t); diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c index d6c4f39103fa..26aea1604517 100644 --- a/test/Analysis/malloc-plist.c +++ b/test/Analysis/malloc-plist.c @@ -1,5 +1,5 @@ // RUN: rm -f %t -// RUN: %clang_cc1 -analyze -fblocks -analyzer-checker=core,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s // RUN: FileCheck -input-file %t %s typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/malloc-protoype.c b/test/Analysis/malloc-protoype.c index f056f0f2855d..0b8c0f9f28df 100644 --- a/test/Analysis/malloc-protoype.c +++ b/test/Analysis/malloc-protoype.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -w -analyze -analyzer-checker=core,unix.Malloc -verify %s +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,unix.Malloc -verify %s // expected-no-diagnostics // Test that strange prototypes doesn't crash the analyzer diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c index 7a8585fa8442..ee104245b819 100644 --- a/test/Analysis/malloc-sizeof.c +++ b/test/Analysis/malloc-sizeof.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.MallocSizeof -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.MallocSizeof -verify %s #include <stddef.h> diff --git a/test/Analysis/malloc-sizeof.cpp b/test/Analysis/malloc-sizeof.cpp index 8589975f8fc2..30227a9cbc80 100644 --- a/test/Analysis/malloc-sizeof.cpp +++ b/test/Analysis/malloc-sizeof.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.MallocSizeof -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.MallocSizeof -verify %s #include <stddef.h> diff --git a/test/Analysis/malloc-three-arg.c b/test/Analysis/malloc-three-arg.c index 01b08aeda51a..a2103376e348 100644 --- a/test/Analysis/malloc-three-arg.c +++ b/test/Analysis/malloc-three-arg.c @@ -1,4 +1,4 @@ -// RUN: %clang -target x86_64-unknown-freebsd --analyze %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-freebsd %s #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index d5bc6571e42a..d5f2cfedd185 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp index a8a79cac868b..c323754bb467 100644 --- a/test/Analysis/malloc.cpp +++ b/test/Analysis/malloc.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -w -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s -// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -w -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple i386-unknown-linux-gnu -w -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s #include "Inputs/system-header-simulator-cxx.h" diff --git a/test/Analysis/malloc.m b/test/Analysis/malloc.m index 9201c2b75fe6..1f67daba55ec 100644 --- a/test/Analysis/malloc.m +++ b/test/Analysis/malloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class -fblocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class -fblocks %s #include "Inputs/system-header-simulator-objc.h" @class NSString; @@ -29,7 +29,7 @@ void rdar10579586(char x); if (error != ((void*)0)) return error; - rdar10579586(buffer->str_c); // expected-warning {{Function call argument is an uninitialized value}} + rdar10579586(buffer->str_c); // expected-warning {{1st function call argument is an uninitialized value}} free(buffer); return ((void*)0); } diff --git a/test/Analysis/malloc.mm b/test/Analysis/malloc.mm index c7fe86bf0bcc..f8a43b3b6a99 100644 --- a/test/Analysis/malloc.mm +++ b/test/Analysis/malloc.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -fblocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -fblocks %s #import "Inputs/system-header-simulator-objc.h" #import "Inputs/system-header-simulator-for-malloc.h" diff --git a/test/Analysis/max-nodes-suppress-on-sink.c b/test/Analysis/max-nodes-suppress-on-sink.c index c45bee8203df..8d955b91c1e3 100644 --- a/test/Analysis/max-nodes-suppress-on-sink.c +++ b/test/Analysis/max-nodes-suppress-on-sink.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config max-nodes=12 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config max-nodes=12 -verify %s // Here we test how "suppress on sink" feature of certain bugtypes interacts // with reaching analysis limits. diff --git a/test/Analysis/member-expr.cpp b/test/Analysis/member-expr.cpp index f8dd324e9857..9951943e3060 100644 --- a/test/Analysis/member-expr.cpp +++ b/test/Analysis/member-expr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection %s -verify void clang_analyzer_checkInlined(bool); void clang_analyzer_eval(int); diff --git a/test/Analysis/method-call-intra-p.cpp b/test/Analysis/method-call-intra-p.cpp index a1709428402c..bead20fecd54 100644 --- a/test/Analysis/method-call-intra-p.cpp +++ b/test/Analysis/method-call-intra-p.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store region -verify %s // expected-no-diagnostics // Intra-procedural C++ tests. diff --git a/test/Analysis/method-call-path-notes.cpp b/test/Analysis/method-call-path-notes.cpp index 8eb07d550a61..e6253d4f89c3 100644 --- a/test/Analysis/method-call-path-notes.cpp +++ b/test/Analysis/method-call-path-notes.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s // Test warning about null or uninitialized pointer values used as instance member diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp index 95db452aec6a..4f6a9a430a78 100644 --- a/test/Analysis/method-call.cpp +++ b/test/Analysis/method-call.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=constructors -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=constructors -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/misc-ps-64.m b/test/Analysis/misc-ps-64.m index be50d4606d4f..50c0e9795d86 100644 --- a/test/Analysis/misc-ps-64.m +++ b/test/Analysis/misc-ps-64.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s // expected-no-diagnostics // <rdar://problem/6440393> - A bunch of misc. failures involving evaluating diff --git a/test/Analysis/misc-ps-arm.m b/test/Analysis/misc-ps-arm.m index a9ea3274ae4b..9cb7bb202fef 100644 --- a/test/Analysis/misc-ps-arm.m +++ b/test/Analysis/misc-ps-arm.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -target-feature +neon -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple thumbv7-apple-ios0.0.0 -target-feature +neon -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s // expected-no-diagnostics // <rdar://problem/11405978> - Handle casts of vectors to structs, and loading diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp index 164af5dc3dfe..1b4516af7880 100644 --- a/test/Analysis/misc-ps-cxx0x.cpp +++ b/test/Analysis/misc-ps-cxx0x.cpp @@ -1,4 +1,4 @@ -// RUN: %clang --analyze -std=c++11 %s -Xclang -verify -o /dev/null +// RUN: %clang_analyze_cc1 -analyzer-checker=core.NullDereference,core.uninitialized.UndefReturn -std=c++11 %s -verify -o /dev/null void test_static_assert() { static_assert(sizeof(void *) == sizeof(void*), "test_static_assert"); diff --git a/test/Analysis/misc-ps-eager-assume.m b/test/Analysis/misc-ps-eager-assume.m index ca056d8fff9e..dbeecf235f9f 100644 --- a/test/Analysis/misc-ps-eager-assume.m +++ b/test/Analysis/misc-ps-eager-assume.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s -analyzer-eagerly-assume +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s -analyzer-eagerly-assume // expected-no-diagnostics // Delta-reduced header stuff (needed for test cases). diff --git a/test/Analysis/misc-ps-ranges.m b/test/Analysis/misc-ps-ranges.m index d8720e9a377c..161d9817bcf1 100644 --- a/test/Analysis/misc-ps-ranges.m +++ b/test/Analysis/misc-ps-ranges.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s // <rdar://problem/6776949> // main's 'argc' argument is always > 0 diff --git a/test/Analysis/misc-ps-region-store-i386.m b/test/Analysis/misc-ps-region-store-i386.m index bed6fc30d315..269a8155b12a 100644 --- a/test/Analysis/misc-ps-region-store-i386.m +++ b/test/Analysis/misc-ps-region-store-i386.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s // expected-no-diagnostics // Here is a case where a pointer is treated as integer, invalidated as an diff --git a/test/Analysis/misc-ps-region-store-x86_64.m b/test/Analysis/misc-ps-region-store-x86_64.m index 4575ad44977b..0bdc5a2b6a26 100644 --- a/test/Analysis/misc-ps-region-store-x86_64.m +++ b/test/Analysis/misc-ps-region-store-x86_64.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s // expected-no-diagnostics // Here is a case where a pointer is treated as integer, invalidated as an diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index daa6d64f2bd5..c6dad5dd9d6e 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions -Wno-tautological-undefined-compare -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions -Wno-tautological-undefined-compare +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions -Wno-tautological-undefined-compare +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -fexceptions -fcxx-exceptions -Wno-tautological-undefined-compare void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index 58166484b822..9bd207326350 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyze -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -DTEST_64 -analyzer-checker=core,alpha.core.CastToStruct,alpha.security.ReturnPtrRange,alpha.security.ArrayBound -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s typedef long unsigned int size_t; void *memcpy(void *, const void *, size_t); @@ -396,7 +396,7 @@ void rdar_7332673_test1() { int rdar_7332673_test2_aux(char *x); void rdar_7332673_test2() { char *value; - if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{Function call argument is an uninitialized value}} + if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{1st function call argument is an uninitialized value}} } //===----------------------------------------------------------------------===// @@ -673,7 +673,7 @@ typedef void (^RDar_7462324_Callback)(id obj); builder = ^(id object) { id x; if (object) { - builder(x); // expected-warning{{Block call argument is an uninitialized value}} + builder(x); // expected-warning{{1st block call argument is an uninitialized value}} } }; builder(target); diff --git a/test/Analysis/misc-ps-region-store.mm b/test/Analysis/misc-ps-region-store.mm index c19a90f011c8..4b271c4512dc 100644 --- a/test/Analysis/misc-ps-region-store.mm +++ b/test/Analysis/misc-ps-region-store.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s // expected-no-diagnostics //===------------------------------------------------------------------------------------------===// diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c index ad65437e4c1d..3044dc98d3c7 100644 --- a/test/Analysis/misc-ps.c +++ b/test/Analysis/misc-ps.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index f979cf3eed82..9a75cfd87b62 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1,6 +1,6 @@ // NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued. -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -analyzer-store=region -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s #ifndef __clang_analyzer__ #error __clang_analyzer__ not defined @@ -796,7 +796,7 @@ int test_uninit_branch_c(void) { void test_bad_call_aux(int x); void test_bad_call(void) { int y; - test_bad_call_aux(y); // expected-warning{{Function call argument is an uninitialized value}} + test_bad_call_aux(y); // expected-warning{{1st function call argument is an uninitialized value}} } @interface TestBadArg {} @@ -805,7 +805,7 @@ void test_bad_call(void) { void test_bad_msg(TestBadArg *p) { int y; - [p testBadArg:y]; // expected-warning{{Argument in message expression is an uninitialized value}} + [p testBadArg:y]; // expected-warning{{1st argument in message expression is an uninitialized value}} } //===----------------------------------------------------------------------===// diff --git a/test/Analysis/model-file.cpp b/test/Analysis/model-file.cpp index 41cdf7fef48c..de5a888ab223 100644 --- a/test/Analysis/model-file.cpp +++ b/test/Analysis/model-file.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config faux-bodies=true,model-path=%S/Inputs/Models -analyzer-output=plist-multi-file -verify %s -o %t +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config faux-bodies=true,model-path=%S/Inputs/Models -analyzer-output=plist-multi-file -verify %s -o %t // RUN: FileCheck --input-file=%t %s typedef int* intptr; diff --git a/test/Analysis/mpichecker.cpp b/test/Analysis/mpichecker.cpp index b7a1e00e00b4..f7644520ebcf 100644 --- a/test/Analysis/mpichecker.cpp +++ b/test/Analysis/mpichecker.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -verify %s #include "MPIMock.h" diff --git a/test/Analysis/mpicheckernotes.cpp b/test/Analysis/mpicheckernotes.cpp index be312fdf5fda..994ce8e302dd 100644 --- a/test/Analysis/mpicheckernotes.cpp +++ b/test/Analysis/mpicheckernotes.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -analyzer-output=text -verify %s // MPI-Checker test file to test note diagnostics. diff --git a/test/Analysis/new-with-exceptions.cpp b/test/Analysis/new-with-exceptions.cpp index 84d77c22302c..9d02574229c1 100644 --- a/test/Analysis/new-with-exceptions.cpp +++ b/test/Analysis/new-with-exceptions.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -std=c++11 -fexceptions -fcxx-exceptions -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store region -std=c++11 -fexceptions -fcxx-exceptions -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp index e262aa727e2b..6cfcb1d92719 100644 --- a/test/Analysis/new.cpp +++ b/test/Analysis/new.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s #include "Inputs/system-header-simulator-cxx.h" void clang_analyzer_eval(bool); diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m index e63e2cafaf42..cbfc266b7bee 100644 --- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m +++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin8 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s // <rdar://problem/6888289> - This test case shows that a nil instance // variable can possibly be initialized by a method. diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m index 4f9939040446..d4a478d327e3 100644 --- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m +++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.1 2>&1 +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin8 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.1 2>&1 // RUN: FileCheck -input-file=%t.1 -check-prefix=CHECK-darwin8 %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.2 2>&1 +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.2 2>&1 // RUN: FileCheck -input-file=%t.2 -check-prefix=CHECK-darwin9 %s -// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.3 2>&1 +// RUN: %clang_analyze_cc1 -triple thumbv6-apple-ios4.0 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s > %t.3 2>&1 // RUN: FileCheck -input-file=%t.3 -check-prefix=CHECK-darwin9 %s @interface MyClass {} diff --git a/test/Analysis/no-exit-cfg.c b/test/Analysis/no-exit-cfg.c index b3c3fbcc6241..7575152295eb 100644 --- a/test/Analysis/no-exit-cfg.c +++ b/test/Analysis/no-exit-cfg.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // This is a test case for the issue reported in PR 2819: diff --git a/test/Analysis/no-outofbounds.c b/test/Analysis/no-outofbounds.c index d4012794d5c7..ae534a94a241 100644 --- a/test/Analysis/no-outofbounds.c +++ b/test/Analysis/no-outofbounds.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,alpha.unix,alpha.security.ArrayBound -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,alpha.unix,alpha.security.ArrayBound -analyzer-store=region -verify %s // expected-no-diagnostics //===----------------------------------------------------------------------===// diff --git a/test/Analysis/no-unreachable-dtors.cpp b/test/Analysis/no-unreachable-dtors.cpp index e0893b3f4e62..1675542d9ac7 100644 --- a/test/Analysis/no-unreachable-dtors.cpp +++ b/test/Analysis/no-unreachable-dtors.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.Stats -verify -Wno-unreachable-code %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.Stats -verify -Wno-unreachable-code %s struct S { ~S(); diff --git a/test/Analysis/non-diagnosable-assumptions.c b/test/Analysis/non-diagnosable-assumptions.c index 50cc8d603b95..44b69bed7c27 100644 --- a/test/Analysis/non-diagnosable-assumptions.c +++ b/test/Analysis/non-diagnosable-assumptions.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -w -analyze -analyzer-checker=core.DivideZero -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core.DivideZero -analyzer-output=text -verify %s // This test file verifies the "Assuming..." diagnostic pieces that are being // reported when the branch condition was too complicated to explain. diff --git a/test/Analysis/nonnull.m b/test/Analysis/nonnull.m index c21360ded8d1..6db7cfaf4917 100644 --- a/test/Analysis/nonnull.m +++ b/test/Analysis/nonnull.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -w -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -w -verify %s @interface MyObject - (void)takePointer:(void *)ptr __attribute__((nonnull(1))); diff --git a/test/Analysis/null-deref-path-notes.m b/test/Analysis/null-deref-path-notes.m index 9e5cab6e7430..242b5daa9bfc 100644 --- a/test/Analysis/null-deref-path-notes.m +++ b/test/Analysis/null-deref-path-notes.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-output=text -fblocks -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false -fblocks -Wno-objc-root-class %s -o %t +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -analyzer-output=text -fblocks -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false -fblocks -Wno-objc-root-class %s -o %t // RUN: FileCheck --input-file=%t %s @interface Root { diff --git a/test/Analysis/null-deref-ps-region.c b/test/Analysis/null-deref-ps-region.c index 5bb945486fbc..6ef99ae473ca 100644 --- a/test/Analysis/null-deref-ps-region.c +++ b/test/Analysis/null-deref-ps-region.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-store=region -verify %s // expected-no-diagnostics diff --git a/test/Analysis/null-deref-ps.c b/test/Analysis/null-deref-ps.c index b0d2292547f6..5dee308a003d 100644 --- a/test/Analysis/null-deref-ps.c +++ b/test/Analysis/null-deref-ps.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s -Wno-error=return-type -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -analyzer-purge=none -verify %s -Wno-error=return-type +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-store=region -verify %s -Wno-error=return-type typedef unsigned uintptr_t; @@ -286,7 +286,7 @@ void pr4759_aux(int *p) __attribute__((nonnull)); void pr4759() { int *p; - pr4759_aux(p); // expected-warning{{Function call argument is an uninitialized value}} + pr4759_aux(p); // expected-warning{{1st function call argument is an uninitialized value}} } // Relax function call arguments invalidation to be aware of const diff --git a/test/Analysis/nullability-no-arc.mm b/test/Analysis/nullability-no-arc.mm index e872266d2770..0760186f4243 100644 --- a/test/Analysis/nullability-no-arc.mm +++ b/test/Analysis/nullability-no-arc.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,nullability -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,nullability -verify %s #define nil 0 diff --git a/test/Analysis/nullability.c b/test/Analysis/nullability.c index a282969e03d4..e0836c6798bb 100644 --- a/test/Analysis/nullability.c +++ b/test/Analysis/nullability.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,nullability -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability -verify %s void it_takes_two(int a, int b); void function_pointer_arity_mismatch() { diff --git a/test/Analysis/nullability.mm b/test/Analysis/nullability.mm index e4f13c6162cb..ddfede53b59d 100644 --- a/test/Analysis/nullability.mm +++ b/test/Analysis/nullability.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -DNOSYSTEMHEADERS=0 -verify %s -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -DNOSYSTEMHEADERS=1 -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -DNOSYSTEMHEADERS=0 -verify %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -DNOSYSTEMHEADERS=1 -verify %s #include "Inputs/system-header-simulator-for-nullability.h" diff --git a/test/Analysis/nullability_nullonly.mm b/test/Analysis/nullability_nullonly.mm index 359841d97a62..18225391ee87 100644 --- a/test/Analysis/nullability_nullonly.mm +++ b/test/Analysis/nullability_nullonly.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -fobjc-arc -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull -DNOSYSTEMHEADERS=0 -verify %s -// RUN: %clang_cc1 -analyze -fobjc-arc -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -DNOSYSTEMHEADERS=1 -verify %s +// RUN: %clang_analyze_cc1 -fobjc-arc -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull -DNOSYSTEMHEADERS=0 -verify %s +// RUN: %clang_analyze_cc1 -fobjc-arc -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull -analyzer-config nullability:NoDiagnoseCallsToSystemHeaders=true -DNOSYSTEMHEADERS=1 -verify %s #include "Inputs/system-header-simulator-for-nullability.h" diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index acc525e9fef7..229ad7bbb555 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -Wno-conversion-null -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -Wno-conversion-null -analyzer-checker=core,debug.ExprInspection -analyzer-store region -verify %s void clang_analyzer_eval(int); @@ -107,7 +107,7 @@ struct Type { void shouldNotCrash() { decltype(nullptr) p; if (getSymbol()) - invokeF(p); // expected-warning{{Function call argument is an uninit}} + invokeF(p); // expected-warning{{1st function call argument is an uninit}} if (getSymbol()) invokeF(nullptr); if (getSymbol()) { diff --git a/test/Analysis/number-object-conversion.c b/test/Analysis/number-object-conversion.c index c4ffaaffef12..8f1e67217974 100644 --- a/test/Analysis/number-object-conversion.c +++ b/test/Analysis/number-object-conversion.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -analyzer-checker=osx.NumberObjectConversion %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify #define NULL ((void *)0) diff --git a/test/Analysis/number-object-conversion.cpp b/test/Analysis/number-object-conversion.cpp index 9dea7b067d08..7e46a2bee85a 100644 --- a/test/Analysis/number-object-conversion.cpp +++ b/test/Analysis/number-object-conversion.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyzer-checker=osx.NumberObjectConversion %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -std=c++11 -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify #define NULL ((void *)0) #include "Inputs/system-header-simulator-cxx.h" // for nullptr diff --git a/test/Analysis/number-object-conversion.m b/test/Analysis/number-object-conversion.m index 08d4a195431d..8bc03320e6d6 100644 --- a/test/Analysis/number-object-conversion.m +++ b/test/Analysis/number-object-conversion.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyze -analyzer-checker=osx.NumberObjectConversion %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyze -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -analyzer-checker=osx.NumberObjectConversion %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyzer-checker=osx.NumberObjectConversion %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify #include "Inputs/system-header-simulator-objc.h" diff --git a/test/Analysis/objc-arc.m b/test/Analysis/objc-arc.m index 2d47c18ba46e..4b446abc906f 100644 --- a/test/Analysis/objc-arc.m +++ b/test/Analysis/objc-arc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -analyzer-opt-analyze-nested-blocks -fobjc-arc -analyzer-config path-diagnostics-alternate=true -analyzer-output=plist-multi-file -o %t.plist %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount,deadcode -verify -fblocks -analyzer-opt-analyze-nested-blocks -fobjc-arc -analyzer-config path-diagnostics-alternate=true -analyzer-output=plist-multi-file -o %t.plist %s // RUN: FileCheck --input-file=%t.plist %s typedef signed char BOOL; diff --git a/test/Analysis/objc-bool.m b/test/Analysis/objc-bool.m index a2d10cc3bade..98d0cb2773f6 100644 --- a/test/Analysis/objc-bool.m +++ b/test/Analysis/objc-bool.m @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -o %t -Xclang -verify +// RUN: %clang_analyze_cc1 %s -o %t -verify // expected-no-diagnostics // Test handling of ObjC bool literals. diff --git a/test/Analysis/objc-boxing.m b/test/Analysis/objc-boxing.m index 73386f463bc8..963374b3ef3c 100644 --- a/test/Analysis/objc-boxing.m +++ b/test/Analysis/objc-boxing.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-objc-literal-conversion -analyze -analyzer-checker=core,unix.Malloc,osx.cocoa.NonNilReturnValue,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -analyzer-checker=core,unix.Malloc,osx.cocoa.NonNilReturnValue,debug.ExprInspection -analyzer-store=region -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/objc-for.m b/test/Analysis/objc-for.m index d1e044a6513b..41709bee359e 100644 --- a/test/Analysis/objc-for.m +++ b/test/Analysis/objc-for.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.Loops,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.Loops,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/objc-message.m b/test/Analysis/objc-message.m index dc0fd1f4c5c9..f525ce7968dd 100644 --- a/test/Analysis/objc-message.m +++ b/test/Analysis/objc-message.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s extern void clang_analyzer_warnIfReached(); void clang_analyzer_eval(int); diff --git a/test/Analysis/objc-method-coverage.m b/test/Analysis/objc-method-coverage.m index 489c19ba6c62..1915586de93a 100644 --- a/test/Analysis/objc-method-coverage.m +++ b/test/Analysis/objc-method-coverage.m @@ -1,5 +1,5 @@ // REQUIRES: asserts -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-stats -fblocks %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-stats -fblocks %s 2>&1 | FileCheck %s @interface I int f() { return 0; diff --git a/test/Analysis/objc-properties.m b/test/Analysis/objc-properties.m index f6ed3e5ef043..88a19a13c514 100644 --- a/test/Analysis/objc-properties.m +++ b/test/Analysis/objc-properties.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignment -verify -fblocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignment -verify -fblocks %s typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @end diff --git a/test/Analysis/objc-radar17039661.m b/test/Analysis/objc-radar17039661.m index fc55ab1daeb4..bfb8ef02306b 100644 --- a/test/Analysis/objc-radar17039661.m +++ b/test/Analysis/objc-radar17039661.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t // RUN: FileCheck --input-file=%t %s @class NSString; typedef long NSInteger; diff --git a/test/Analysis/objc-string.mm b/test/Analysis/objc-string.mm index a32b740bba02..53f3c3736261 100644 --- a/test/Analysis/objc-string.mm +++ b/test/Analysis/objc-string.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -Wno-objc-literal-conversion %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -Wno-objc-literal-conversion %s void clang_analyzer_eval(bool); @class NSString; diff --git a/test/Analysis/objc-subscript.m b/test/Analysis/objc-subscript.m index ae621c982873..155fbb7b6268 100644 --- a/test/Analysis/objc-subscript.m +++ b/test/Analysis/objc-subscript.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s typedef signed char BOOL; typedef unsigned int NSUInteger; diff --git a/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m b/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m index 4777aed99d91..1603a57fea40 100644 --- a/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m +++ b/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions -verify -fblocks %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions -verify -fblocks %s typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @end diff --git a/test/Analysis/objc_invalidation.m b/test/Analysis/objc_invalidation.m index cd66444f4010..52a79d8f34ba 100644 --- a/test/Analysis/objc_invalidation.m +++ b/test/Analysis/objc_invalidation.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.InstanceVariableInvalidation -DRUN_IVAR_INVALIDATION -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.MissingInvalidationMethod -DRUN_MISSING_INVALIDATION_METHOD -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.osx.cocoa.InstanceVariableInvalidation -DRUN_IVAR_INVALIDATION -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.osx.cocoa.MissingInvalidationMethod -DRUN_MISSING_INVALIDATION_METHOD -verify %s extern void __assert_fail (__const char *__assertion, __const char *__file, unsigned int __line, __const char *__function) __attribute__ ((__noreturn__)); diff --git a/test/Analysis/openmp-unsupported.c b/test/Analysis/openmp-unsupported.c new file mode 100644 index 000000000000..7e363eecbaa0 --- /dev/null +++ b/test/Analysis/openmp-unsupported.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin -fopenmp -verify %s +// expected-no-diagnostics + +void openmp_parallel_crash_test() { +#pragma omp parallel + ; +} diff --git a/test/Analysis/operator-calls.cpp b/test/Analysis/operator-calls.cpp index 4bd7c12fad32..310722965965 100644 --- a/test/Analysis/operator-calls.cpp +++ b/test/Analysis/operator-calls.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s void clang_analyzer_eval(bool); struct X0 { }; diff --git a/test/Analysis/out-of-bounds-new.cpp b/test/Analysis/out-of-bounds-new.cpp index ee7bb1ec444b..b7ceea72a270 100644 --- a/test/Analysis/out-of-bounds-new.cpp +++ b/test/Analysis/out-of-bounds-new.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -Wno-array-bounds -analyze -analyzer-checker=unix,core,alpha.security.ArrayBoundV2 -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -analyzer-checker=unix,core,alpha.security.ArrayBoundV2 -verify %s // Tests doing an out-of-bounds access after the end of an array using: // - constant integer index diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c index ca1e0d05006a..1970cd658c42 100644 --- a/test/Analysis/out-of-bounds.c +++ b/test/Analysis/out-of-bounds.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/outofbound-notwork.c b/test/Analysis/outofbound-notwork.c index 68b01e0f79c6..22ccd9e2c913 100644 --- a/test/Analysis/outofbound-notwork.c +++ b/test/Analysis/outofbound-notwork.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBound -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,alpha.security.ArrayBound -analyzer-store=region -verify %s // XFAIL: * // Once we better handle modeling of sizes of VLAs, we can pull this back diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 81ed7ac00b39..35672c0c448b 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,unix,alpha.security.ArrayBound -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s +// RUN: %clang_analyze_cc1 -Wno-array-bounds -analyzer-checker=core,unix,alpha.security.ArrayBound -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); diff --git a/test/Analysis/override-werror.c b/test/Analysis/override-werror.c index a68ee1ed0a30..7dc09f518627 100644 --- a/test/Analysis/override-werror.c +++ b/test/Analysis/override-werror.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -Werror %s -analyzer-store=region -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -Werror %s -analyzer-store=region -verify // This test case illustrates that using '-analyze' overrides the effect of // -Werror. This allows basic warnings not to interfere with producing diff --git a/test/Analysis/padding_c.c b/test/Analysis/padding_c.c index 93cefcad8930..f4178f545791 100644 --- a/test/Analysis/padding_c.c +++ b/test/Analysis/padding_c.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s #if __has_include(<stdalign.h>) #include <stdalign.h> diff --git a/test/Analysis/padding_cpp.cpp b/test/Analysis/padding_cpp.cpp index df2f2a82d35c..ee49aea0c2be 100644 --- a/test/Analysis/padding_cpp.cpp +++ b/test/Analysis/padding_cpp.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++14 -analyze -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s +// RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s // Make sure that the C cases still work fine, even when compiled as C++. #include "padding_c.c" diff --git a/test/Analysis/padding_message.cpp b/test/Analysis/padding_message.cpp index bbfa45394d85..4c7e06108154 100644 --- a/test/Analysis/padding_message.cpp +++ b/test/Analysis/padding_message.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -std=c++14 -analyze -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -std=c++14 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s // expected-warning@+7{{\ Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal). \ diff --git a/test/Analysis/plist-html-macros.c b/test/Analysis/plist-html-macros.c index dbdbb30c4b2f..c25346d99a6d 100644 --- a/test/Analysis/plist-html-macros.c +++ b/test/Analysis/plist-html-macros.c @@ -1,9 +1,9 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // (sanity check) // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-html -o %t.dir/index.plist %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html -o %t.dir/index.plist %s // RUN: ls %t.dir | grep '\.html' | count 1 // RUN: grep '\.html' %t.dir/index.plist | count 1 diff --git a/test/Analysis/plist-macros.cpp b/test/Analysis/plist-macros.cpp index 09ad15e5a570..594cfdc6efc5 100644 --- a/test/Analysis/plist-macros.cpp +++ b/test/Analysis/plist-macros.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -analyzer-eagerly-assume -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=ture %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m index 7c8e51385777..03f3393af8a7 100644 --- a/test/Analysis/plist-output-alternate.m +++ b/test/Analysis/plist-output-alternate.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -fblocks -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -fblocks -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s // RUN: FileCheck --input-file %t %s void test_null_init(void) { diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index affbb5d14d9c..a80ab5c31c66 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -Xanalyzer -analyzer-checker=osx.cocoa.RetainCount -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t.plist +// RUN: %clang_analyze_cc1 %s -analyzer-checker=osx.cocoa.RetainCount,deadcode.DeadStores,core -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t.plist // RUN: FileCheck --input-file=%t.plist %s void test_null_init(void) { @@ -24,7 +24,7 @@ void test_null_cond(int *p) { *p = 0xDEADBEEF; } } - + void test_null_cond_transitive(int *q) { if (!q) { int *p = q; @@ -51,7 +51,7 @@ void test_assumptions(int a, int b) } int *bar_cond_assign(); -int test_cond_assign() { +int test_cond_assign() { int *p; if (p = bar_cond_assign()) return 1; @@ -138,7 +138,7 @@ void test_loop_diagnostics() { void test_loop_diagnostics_2() { int *p = 0; - for (int i = 0; i < 2; ) { + for (int i = 0; i < 2; ) { ++i; p = 0; } @@ -166,9 +166,9 @@ void test_loop_fast_enumeration(id arr) { @interface RDar12114812 { char *p; } @end -@implementation RDar12114812 +@implementation RDar12114812 - (void)test { - p = 0; + p = 0; *p = 1; } @end @@ -2686,103 +2686,6 @@ int testFoo(Foo *x) { // CHECK-NEXT: </array> // CHECK-NEXT: </dict> // CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>control</string> -// CHECK-NEXT: <key>edges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>start</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>3</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>5</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>end</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>event</string> -// CHECK-NEXT: <key>location</key> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <key>ranges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>28</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>depth</key><integer>0</integer> -// CHECK-NEXT: <key>extended_message</key> -// CHECK-NEXT: <string>Assuming 'i' is >= 'x'</string> -// CHECK-NEXT: <key>message</key> -// CHECK-NEXT: <string>Assuming 'i' is >= 'x'</string> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>control</string> -// CHECK-NEXT: <key>edges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>start</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>24</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>end</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>3</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>108</integer> -// CHECK-NEXT: <key>col</key><integer>5</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> // CHECK-NEXT: <key>kind</key><string>event</string> // CHECK-NEXT: <key>location</key> // CHECK-NEXT: <dict> @@ -2992,103 +2895,6 @@ int testFoo(Foo *x) { // CHECK-NEXT: </array> // CHECK-NEXT: </dict> // CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>control</string> -// CHECK-NEXT: <key>edges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>start</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>3</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>5</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>end</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>event</string> -// CHECK-NEXT: <key>location</key> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <key>ranges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>15</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>depth</key><integer>0</integer> -// CHECK-NEXT: <key>extended_message</key> -// CHECK-NEXT: <string>Assuming 'i' is >= 'x'</string> -// CHECK-NEXT: <key>message</key> -// CHECK-NEXT: <string>Assuming 'i' is >= 'x'</string> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>kind</key><string>control</string> -// CHECK-NEXT: <key>edges</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>start</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>11</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: <key>end</key> -// CHECK-NEXT: <array> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>3</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> -// CHECK-NEXT: <key>line</key><integer>117</integer> -// CHECK-NEXT: <key>col</key><integer>5</integer> -// CHECK-NEXT: <key>file</key><integer>0</integer> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: </array> -// CHECK-NEXT: </dict> -// CHECK-NEXT: <dict> // CHECK-NEXT: <key>kind</key><string>event</string> // CHECK-NEXT: <key>location</key> // CHECK-NEXT: <dict> diff --git a/test/Analysis/pointer-to-member.cpp b/test/Analysis/pointer-to-member.cpp index 039782b44b74..0fbb992dd82a 100644 --- a/test/Analysis/pointer-to-member.cpp +++ b/test/Analysis/pointer-to-member.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/pr22954.c b/test/Analysis/pr22954.c index 01aa5b34a7eb..64a00c5ec087 100644 --- a/test/Analysis/pr22954.c +++ b/test/Analysis/pr22954.c @@ -3,7 +3,7 @@ // At the moment the whole of the destination array content is invalidated. // If a.s1 region has a symbolic offset, the whole region of 'a' is invalidated. // Specific triple set to test structures of size 0. -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/pr4209.m b/test/Analysis/pr4209.m index 29abe94441da..8b0eacad9694 100644 --- a/test/Analysis/pr4209.m +++ b/test/Analysis/pr4209.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-incomplete-implementation -verify %s +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-incomplete-implementation -verify %s // This test case was crashing due to how CFRefCount.cpp resolved the // ObjCInterfaceDecl* and ClassName in EvalObjCMessageExpr. diff --git a/test/Analysis/pr_2542_rdar_6793404.m b/test/Analysis/pr_2542_rdar_6793404.m index 6f1ebf962594..5df40e88fcb4 100644 --- a/test/Analysis/pr_2542_rdar_6793404.m +++ b/test/Analysis/pr_2542_rdar_6793404.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -pedantic -analyzer-store=region -verify -Wno-objc-root-class %s // BEGIN delta-debugging reduced header stuff diff --git a/test/Analysis/pr_4164.c b/test/Analysis/pr_4164.c index 0d2ca41b32e1..02c1f41ebbd5 100644 --- a/test/Analysis/pr_4164.c +++ b/test/Analysis/pr_4164.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // PR 4164: http://llvm.org/bugs/show_bug.cgi?id=4164 diff --git a/test/Analysis/properties.m b/test/Analysis/properties.m index 235a9687821d..e792bb2e6bad 100644 --- a/test/Analysis/properties.m +++ b/test/Analysis/properties.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.Dealloc,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s void clang_analyzer_eval(int); @@ -987,5 +987,21 @@ void testOpaqueConsistency(OpaqueIntWrapper *w) { } @end + +@interface Wrapper +@property(nonatomic, readonly) int value; +@end + +@implementation Wrapper +@synthesize value; +@end + +void testNoCrashWhenAccessPropertyAndThereAreNoDirectBindingsAtAll() { + union { + Wrapper *wrapper; + } u = { 0 }; + [u.wrapper value]; +} + #endif // non-ARC diff --git a/test/Analysis/properties.mm b/test/Analysis/properties.mm index e49d034f2651..2d93d6dc6385 100644 --- a/test/Analysis/properties.mm +++ b/test/Analysis/properties.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class -fobjc-arc %s void clang_analyzer_eval(bool); void clang_analyzer_checkInlined(bool); diff --git a/test/Analysis/pthreadlock.c b/test/Analysis/pthreadlock.c index a6e29e78ff38..98868172523d 100644 --- a/test/Analysis/pthreadlock.c +++ b/test/Analysis/pthreadlock.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.PthreadLock -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.PthreadLock -verify %s // Tests performing normal locking patterns and wrong locking orders diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index 2b15badf4274..b78ec503a1ca 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-tautological-pointer-compare %s -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple i686-apple-darwin9 -Wno-tautological-pointer-compare %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-tautological-pointer-compare %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple i686-apple-darwin9 -Wno-tautological-pointer-compare %s void clang_analyzer_eval(int); @@ -213,7 +213,12 @@ void comparisons_imply_size(int *lhs, int *rhs) { } clang_analyzer_eval(lhs <= rhs); // expected-warning{{TRUE}} +// FIXME: In Z3ConstraintManager, ptrdiff_t is mapped to signed bitvector. However, this does not directly imply the unsigned comparison. +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval((rhs - lhs) >= 0); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval((rhs - lhs) >= 0); // expected-warning{{TRUE}} +#endif clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{UNKNOWN}} if (lhs >= rhs) { @@ -223,7 +228,11 @@ void comparisons_imply_size(int *lhs, int *rhs) { clang_analyzer_eval(lhs == rhs); // expected-warning{{FALSE}} clang_analyzer_eval(lhs < rhs); // expected-warning{{TRUE}} +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{TRUE}} +#endif } void size_implies_comparison(int *lhs, int *rhs) { @@ -234,7 +243,11 @@ void size_implies_comparison(int *lhs, int *rhs) { return; } +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(lhs <= rhs); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval(lhs <= rhs); // expected-warning{{TRUE}} +#endif clang_analyzer_eval((rhs - lhs) >= 0); // expected-warning{{TRUE}} clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{UNKNOWN}} @@ -244,7 +257,11 @@ void size_implies_comparison(int *lhs, int *rhs) { } clang_analyzer_eval(lhs == rhs); // expected-warning{{FALSE}} +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(lhs < rhs); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval(lhs < rhs); // expected-warning{{TRUE}} +#endif clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{TRUE}} } @@ -255,30 +272,42 @@ void size_implies_comparison(int *lhs, int *rhs) { void zero_implies_reversed_equal(int *lhs, int *rhs) { clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{UNKNOWN}} if ((rhs - lhs) == 0) { - // FIXME: Should be FALSE. +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(rhs != lhs); // expected-warning{{FALSE}} + clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}} +#else clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}} - // FIXME: Should be TRUE. clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} +#endif return; } clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{FALSE}} - // FIXME: Should be FALSE. +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}} + clang_analyzer_eval(rhs != lhs); // expected-warning{{TRUE}} +#else clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} - // FIXME: Should be TRUE. clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}} +#endif } void canonical_equal(int *lhs, int *rhs) { clang_analyzer_eval(lhs == rhs); // expected-warning{{UNKNOWN}} if (lhs == rhs) { - // FIXME: Should be TRUE. +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}} +#else clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} +#endif return; } clang_analyzer_eval(lhs == rhs); // expected-warning{{FALSE}} - // FIXME: Should be FALSE. +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}} +#else clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}} +#endif } void compare_element_region_and_base(int *p) { diff --git a/test/Analysis/ptr-arith.cpp b/test/Analysis/ptr-arith.cpp index 07ddec30af56..e1860f4268e0 100644 --- a/test/Analysis/ptr-arith.cpp +++ b/test/Analysis/ptr-arith.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-unused-value -std=c++14 -analyze -analyzer-checker=core,debug.ExprInspection,alpha.core.PointerArithm -verify %s +// RUN: %clang_analyze_cc1 -Wno-unused-value -std=c++14 -analyzer-checker=core,debug.ExprInspection,alpha.core.PointerArithm -verify %s struct X { int *p; int zero; diff --git a/test/Analysis/qt_malloc.cpp b/test/Analysis/qt_malloc.cpp index 200556ea306d..ad25634d87b0 100644 --- a/test/Analysis/qt_malloc.cpp +++ b/test/Analysis/qt_malloc.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus -analyzer-store=region -verify %s // expected-no-diagnostics #include "Inputs/qt-simulator.h" diff --git a/test/Analysis/range_casts.c b/test/Analysis/range_casts.c index 682369cce66f..a01ab5d52097 100644 --- a/test/Analysis/range_casts.c +++ b/test/Analysis/range_casts.c @@ -1,5 +1,5 @@ // This test checks that intersecting ranges does not cause 'system is over constrained' assertions in the case of eg: 32 bits unsigned integers getting their range from 64 bits signed integers. -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/rdar-6442306-1.m b/test/Analysis/rdar-6442306-1.m index 31a300c1f66f..d84000076d79 100644 --- a/test/Analysis/rdar-6442306-1.m +++ b/test/Analysis/rdar-6442306-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-disable-checker=alpha.core.PointerArithm %s -analyzer-store=region -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-disable-checker=alpha.core.PointerArithm %s -analyzer-store=region -verify // expected-no-diagnostics typedef int bar_return_t; diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m index 2119df5b9ef5..da7d42c3722e 100644 --- a/test/Analysis/rdar-6540084.m +++ b/test/Analysis/rdar-6540084.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-checker=deadcode.DeadStores -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-checker=deadcode.DeadStores -verify %s // // This test exercises the live variables analysis (LiveVariables.cpp). // The case originally identified a non-termination bug. diff --git a/test/Analysis/rdar-6541136-region.c b/test/Analysis/rdar-6541136-region.c index 83b7605b9511..dc75af43e491 100644 --- a/test/Analysis/rdar-6541136-region.c +++ b/test/Analysis/rdar-6541136-region.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -analyze -analyzer-checker=core,alpha.security.ArrayBound -analyzer-store=region %s +// RUN: %clang_analyze_cc1 -verify -analyzer-checker=core,alpha.security.ArrayBound -analyzer-store=region %s struct tea_cheese { unsigned magic; }; typedef struct tea_cheese kernel_tea_cheese_t; diff --git a/test/Analysis/rdar-6562655.m b/test/Analysis/rdar-6562655.m index 9591f551f3d9..8794cacb74a0 100644 --- a/test/Analysis/rdar-6562655.m +++ b/test/Analysis/rdar-6562655.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // // This test case mainly checks that the retain/release checker doesn't crash diff --git a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m index e9809db50119..72dbe422b63a 100644 --- a/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m +++ b/test/Analysis/rdar-6600344-nil-receiver-undefined-struct-ret.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s // expected-no-diagnostics typedef struct Foo { int x; } Bar; diff --git a/test/Analysis/rdar-7168531.m b/test/Analysis/rdar-7168531.m index b128d32bfdea..b2b1511dd2ab 100644 --- a/test/Analysis/rdar-7168531.m +++ b/test/Analysis/rdar-7168531.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -analyzer-store=region %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -analyzer-store=region %s // Note that the target triple is important for this test case. It specifies that we use the // fragile Objective-C ABI. diff --git a/test/Analysis/redefined_system.c b/test/Analysis/redefined_system.c index 16f03abe12e5..4901b3ae616f 100644 --- a/test/Analysis/redefined_system.c +++ b/test/Analysis/redefined_system.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx,unix,core,alpha.security.taint -w -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx,unix,core,alpha.security.taint -w -verify %s // expected-no-diagnostics // Make sure we don't crash when someone redefines a system function we reason about. diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m index cff5970b315a..c77909a0c277 100644 --- a/test/Analysis/refcnt_naming.m +++ b/test/Analysis/refcnt_naming.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-config ipa=none -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-config ipa=none -analyzer-store=region -verify %s typedef const struct __CFString * CFStringRef; typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp index 951079d43e47..b323b966610a 100644 --- a/test/Analysis/reference.cpp +++ b/test/Analysis/reference.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -Wno-null-dereference -Wno-tautological-undefined-compare %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -Wno-null-dereference -Wno-tautological-undefined-compare %s void clang_analyzer_eval(bool); @@ -118,16 +118,30 @@ void testRetroactiveNullReference(int *x) { } void testReferenceAddress(int &x) { +// FIXME: Move non-zero reference assumption out of RangeConstraintManager.cpp:422 +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(&x != 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&ref() != 0); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval(&x != 0); // expected-warning{{TRUE}} clang_analyzer_eval(&ref() != 0); // expected-warning{{TRUE}} +#endif struct S { int &x; }; extern S getS(); +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(&getS().x != 0); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval(&getS().x != 0); // expected-warning{{TRUE}} +#endif extern S *getSP(); +#ifdef ANALYZER_CM_Z3 + clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{UNKNOWN}} +#else clang_analyzer_eval(&getSP()->x != 0); // expected-warning{{TRUE}} +#endif } diff --git a/test/Analysis/reference.mm b/test/Analysis/reference.mm index c5546aac5fcd..1d73ccd6ead3 100644 --- a/test/Analysis/reference.mm +++ b/test/Analysis/reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -Wno-null-dereference %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -Wno-null-dereference %s @interface Foo - (int &)ref; diff --git a/test/Analysis/region-1.m b/test/Analysis/region-1.m index 6940c69dc1bc..3245bd4cf744 100644 --- a/test/Analysis/region-1.m +++ b/test/Analysis/region-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s // expected-no-diagnostics // // This test case simply should not crash. It evaluates the logic of not diff --git a/test/Analysis/region-store.c b/test/Analysis/region-store.c index 70bda1117b0e..673baafa0959 100644 --- a/test/Analysis/region-store.c +++ b/test/Analysis/region-store.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection -verify %s int printf(const char *restrict,...); diff --git a/test/Analysis/region-store.cpp b/test/Analysis/region-store.cpp index 5ea5c3f82fd6..cb49f4837d81 100644 --- a/test/Analysis/region-store.cpp +++ b/test/Analysis/region-store.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s // expected-no-diagnostics class Loc { diff --git a/test/Analysis/reinterpret-cast.cpp b/test/Analysis/reinterpret-cast.cpp index f3b0a7b257b6..7b8c2f3ee9a4 100644 --- a/test/Analysis/reinterpret-cast.cpp +++ b/test/Analysis/reinterpret-cast.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/retain-release-arc.m b/test/Analysis/retain-release-arc.m index 6f3cbfbe5a9f..78115ac5bde0 100644 --- a/test/Analysis/retain-release-arc.m +++ b/test/Analysis/retain-release-arc.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fobjc-arc -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fobjc-arc -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text typedef __typeof(sizeof(int)) size_t; diff --git a/test/Analysis/retain-release-cache-out.m b/test/Analysis/retain-release-cache-out.m index 54573a460638..5e9ebc4ad661 100644 --- a/test/Analysis/retain-release-cache-out.m +++ b/test/Analysis/retain-release-cache-out.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze %s -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -verify +// RUN: %clang_analyze_cc1 %s -analyzer-checker=core,osx.cocoa.RetainCount -fblocks -verify // This test is checking behavior when a single checker runs only with the core // checkers, testing that the traversal order in the CFG does not affect the diff --git a/test/Analysis/retain-release-cf-audited.m b/test/Analysis/retain-release-cf-audited.m index c89172f70bef..414ccd53b309 100644 --- a/test/Analysis/retain-release-cf-audited.m +++ b/test/Analysis/retain-release-cf-audited.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -verify %s -x objective-c++ +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.RetainCount -verify %s -x objective-c++ // The special thing about this file is that CFRetain and CFRelease are marked // as cf_audited_transfer. diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index 26eb6e12be20..6305942ac20a 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount,osx.cocoa.NSAutoreleasePool -analyzer-store=region -fobjc-gc-only -fblocks -verify -Wno-objc-root-class %s //===----------------------------------------------------------------------===// // Header stuff. diff --git a/test/Analysis/retain-release-inline.m b/test/Analysis/retain-release-inline.m index 8809c8c84446..0cde2c1cf5af 100644 --- a/test/Analysis/retain-release-inline.m +++ b/test/Analysis/retain-release-inline.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fblocks -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fblocks -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from Mac OS X headers: diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m index 5b5558215060..04f991263c00 100644 --- a/test/Analysis/retain-release-path-notes-gc.m +++ b/test/Analysis/retain-release-path-notes-gc.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=text -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s /*** diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m index 23347bc3aa73..f44d40fa495b 100644 --- a/test/Analysis/retain-release-path-notes.m +++ b/test/Analysis/retain-release-path-notes.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=plist-multi-file -analyzer-config path-diagnostics-alternate=false %s -o %t // RUN: FileCheck --input-file=%t %s /*** diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m index 3f83fb582834..65a31cc91ada 100644 --- a/test/Analysis/retain-release-region-store.m +++ b/test/Analysis/retain-release-region-store.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-max-loop 6 -verify %s +// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -analyzer-max-loop 6 -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index b883a86602ba..39a3baa8960c 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1,6 +1,6 @@ // RUN: rm -f %t.objc.plist %t.objcpp.plist -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s -analyzer-output=plist -o %t.objc.plist -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -std=gnu++98 -Wno-objc-root-class %s -analyzer-output=plist -o %t.objcpp.plist +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s -analyzer-output=plist -o %t.objc.plist +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify -x objective-c++ -std=gnu++98 -Wno-objc-root-class %s -analyzer-output=plist -o %t.objcpp.plist // FIXLATER: cat %t.objc.plist ; FileCheck --input-file=%t.objc.plist %s // FIXLATER: cat %t.objcpp.plist ; FileCheck --input-file=%t.objcpp.plist %s diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm index 3650d887244b..c9817005c2c5 100644 --- a/test/Analysis/retain-release.mm +++ b/test/Analysis/retain-release.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fblocks -verify %s #if __has_feature(attribute_ns_returns_retained) #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) diff --git a/test/Analysis/return-ptr-range.cpp b/test/Analysis/return-ptr-range.cpp index 0cc17b05042b..dd5dcd5d5d19 100644 --- a/test/Analysis/return-ptr-range.cpp +++ b/test/Analysis/return-ptr-range.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.ReturnPtrRange -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange -verify %s int arr[10]; int *ptr; diff --git a/test/Analysis/security-syntax-checks-no-emit.c b/test/Analysis/security-syntax-checks-no-emit.c index 7759aa73b33b..29dd2017745e 100644 --- a/test/Analysis/security-syntax-checks-no-emit.c +++ b/test/Analysis/security-syntax-checks-no-emit.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple i686-pc-linux-gnu -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify // expected-no-diagnostics // This file complements 'security-syntax-checks.m', but tests that we omit diff --git a/test/Analysis/security-syntax-checks.m b/test/Analysis/security-syntax-checks.m index 9b7fb25edb19..04a4c7d86655 100644 --- a/test/Analysis/security-syntax-checks.m +++ b/test/Analysis/security-syntax-checks.m @@ -1,11 +1,11 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple x86_64-unknown-cloudabi -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple x86_64-unknown-cloudabi -analyze -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple x86_64-unknown-cloudabi -analyze -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify -// RUN: %clang_cc1 -triple x86_64-unknown-cloudabi -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi -DUSE_BUILTINS -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-cloudabi -DUSE_BUILTINS -DVARIANT -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify #ifdef USE_BUILTINS # define BUILTIN(f) __builtin_ ## f diff --git a/test/Analysis/self-assign.cpp b/test/Analysis/self-assign.cpp index 74fb0fea2476..580a3ab00ead 100644 --- a/test/Analysis/self-assign.cpp +++ b/test/Analysis/self-assign.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify -analyzer-output=text +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection %s -verify -analyzer-output=text extern "C" char *strdup(const char* s); extern "C" void free(void* ptr); diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m index d1fb88de5410..cb1a321e8bbb 100644 --- a/test/Analysis/self-init.m +++ b/test/Analysis/self-init.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -analyzer-config ipa=dynamic -fno-builtin %s -verify -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fno-builtin %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.SelfInit -analyzer-config ipa=dynamic -fno-builtin %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.SelfInit -fno-builtin %s -verify @class NSZone, NSCoder; @protocol NSObject diff --git a/test/Analysis/shallow-mode.m b/test/Analysis/shallow-mode.m index 23df6990d49d..1c71e1b38fce 100644 --- a/test/Analysis/shallow-mode.m +++ b/test/Analysis/shallow-mode.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config mode=shallow -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config mode=shallow -verify %s // expected-no-diagnostics void clang_analyzer_checkInlined(unsigned); diff --git a/test/Analysis/simple-stream-checks.c b/test/Analysis/simple-stream-checks.c index 2f725745a5ba..ca1c78157547 100644 --- a/test/Analysis/simple-stream-checks.c +++ b/test/Analysis/simple-stream-checks.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.unix.SimpleStream -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.unix.SimpleStream -verify %s #include "Inputs/system-header-simulator-for-simple-stream.h" @@ -65,7 +65,7 @@ void SymbolEscapedThroughFunctionCall() { } FILE *GlobalF; -void SymbolEscapedThroughAssignmentToGloabl() { +void SymbolEscapedThroughAssignmentToGlobal() { FILE *F = fopen("myfile.txt", "w"); GlobalF = F; return; // no warning diff --git a/test/Analysis/sizeofpointer.c b/test/Analysis/sizeofpointer.c index a9e045b4af53..14ddbd1a8b10 100644 --- a/test/Analysis/sizeofpointer.c +++ b/test/Analysis/sizeofpointer.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core.SizeofPtr -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.SizeofPtr -verify %s struct s { }; diff --git a/test/Analysis/stack-addr-ps.c b/test/Analysis/stack-addr-ps.c index d668f8fbee2d..4026cee90b04 100644 --- a/test/Analysis/stack-addr-ps.c +++ b/test/Analysis/stack-addr-ps.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -fblocks -verify %s int* f1() { int x = 0; diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index a4ab2f3985c6..79afd18e1889 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s -Wno-undefined-bool-conversion +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify %s -Wno-undefined-bool-conversion typedef __INTPTR_TYPE__ intptr_t; diff --git a/test/Analysis/stack-block-returned.cpp b/test/Analysis/stack-block-returned.cpp index af2cec776697..b45cf6335b90 100644 --- a/test/Analysis/stack-block-returned.cpp +++ b/test/Analysis/stack-block-returned.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -fblocks -verify %s typedef void (^bptr)(void); diff --git a/test/Analysis/stackaddrleak.c b/test/Analysis/stackaddrleak.c index 717f30964acd..a037d12fe40c 100644 --- a/test/Analysis/stackaddrleak.c +++ b/test/Analysis/stackaddrleak.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -std=c99 -Dbool=_Bool -Wno-bool-conversion %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -x c++ -Wno-bool-conversion %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -std=c99 -Dbool=_Bool -Wno-bool-conversion %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -x c++ -Wno-bool-conversion %s typedef __INTPTR_TYPE__ intptr_t; char const *p; diff --git a/test/Analysis/static_local.m b/test/Analysis/static_local.m index dcd49e11a16c..daa7ef54c9f8 100644 --- a/test/Analysis/static_local.m +++ b/test/Analysis/static_local.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -Wno-objc-root-class %s // expected-no-diagnostics // Test reasoning about static locals in ObjCMethods. diff --git a/test/Analysis/stats.c b/test/Analysis/stats.c index 5701dc71f5fa..eca83c0ad96e 100644 --- a/test/Analysis/stats.c +++ b/test/Analysis/stats.c @@ -1,5 +1,5 @@ // REQUIRES: asserts -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s void foo() { int x; diff --git a/test/Analysis/std-c-library-functions.c b/test/Analysis/std-c-library-functions.c index 6b78a26d44bb..042b035f8bdf 100644 --- a/test/Analysis/std-c-library-functions.c +++ b/test/Analysis/std-c-library-functions.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s -// RUN: %clang_cc1 -triple i686-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s -// RUN: %clang_cc1 -triple armv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s -// RUN: %clang_cc1 -triple thumbv7-a15-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s void clang_analyzer_eval(int); diff --git a/test/Analysis/std-c-library-functions.cpp b/test/Analysis/std-c-library-functions.cpp index e6ac66bc81a3..00b341af5f92 100644 --- a/test/Analysis/std-c-library-functions.cpp +++ b/test/Analysis/std-c-library-functions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-linux -analyze -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s // Test that we don't model functions with broken prototypes. // Because they probably work differently as well. diff --git a/test/Analysis/stream.c b/test/Analysis/stream.c index 329a7823f2e5..7adf14be34d9 100644 --- a/test/Analysis/stream.c +++ b/test/Analysis/stream.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.Stream -analyzer-store region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -verify %s typedef __typeof__(sizeof(int)) size_t; typedef struct _IO_FILE FILE; diff --git a/test/Analysis/string-fail.c b/test/Analysis/string-fail.c index ac5c6d057235..ff95ea9ee28f 100644 --- a/test/Analysis/string-fail.c +++ b/test/Analysis/string-fail.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s // XFAIL: * // This file is for tests that may eventually go into string.c, or may be diff --git a/test/Analysis/string.c b/test/Analysis/string.c index e541219d05a2..8ea2068c5613 100644 --- a/test/Analysis/string.c +++ b/test/Analysis/string.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s //===----------------------------------------------------------------------=== // Declarations diff --git a/test/Analysis/superclass.m b/test/Analysis/superclass.m index 3102d1f35a7c..172935995389 100644 --- a/test/Analysis/superclass.m +++ b/test/Analysis/superclass.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.MissingSuperCall -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=osx.cocoa.MissingSuperCall -verify -Wno-objc-root-class %s // Define used Classes @protocol NSObject diff --git a/test/Analysis/svalbuilder-logic.c b/test/Analysis/svalbuilder-logic.c index 9cf3f964bc0a..1595acb93569 100644 --- a/test/Analysis/svalbuilder-logic.c +++ b/test/Analysis/svalbuilder-logic.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s // expected-no-diagnostics // Testing core functionality of the SValBuilder. diff --git a/test/Analysis/switch-case.c b/test/Analysis/switch-case.c index 08a61a07be26..08403937e019 100644 --- a/test/Analysis/switch-case.c +++ b/test/Analysis/switch-case.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s void clang_analyzer_eval(int); void clang_analyzer_warnIfReached(); diff --git a/test/Analysis/symbol-reaper.c b/test/Analysis/symbol-reaper.c index 362a22d4caf3..72fcc7e2b9df 100644 --- a/test/Analysis/symbol-reaper.c +++ b/test/Analysis/symbol-reaper.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s void clang_analyzer_eval(int); void clang_analyzer_warnOnDeadSymbol(int); diff --git a/test/Analysis/taint-diagnostic-visitor.c b/test/Analysis/taint-diagnostic-visitor.c new file mode 100644 index 000000000000..50fc0b6a4e26 --- /dev/null +++ b/test/Analysis/taint-diagnostic-visitor.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core -analyzer-output=text -verify %s + +// This file is for testing enhanced diagnostics produced by the GenericTaintChecker + +int scanf(const char *restrict format, ...); +int system(const char *command); + +void taintDiagnostic() +{ + char buf[128]; + scanf("%s", buf); // expected-note {{Taint originated here}} + system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}} +} diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c index fe27070026bd..8efed66dacbf 100644 --- a/test/Analysis/taint-generic.c +++ b/test/Analysis/taint-generic.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -Wno-format-security -verify %s int scanf(const char *restrict format, ...); int getchar(void); @@ -169,6 +169,43 @@ void testSocket() { sock = socket(AF_LOCAL, SOCK_STREAM, 0); read(sock, buffer, 100); execl(buffer, "filename", 0); // no-warning + + sock = socket(AF_INET, SOCK_STREAM, 0); + // References to both buffer and &buffer as an argument should taint the argument + read(sock, &buffer, 100); + execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}} +} + +void testStruct() { + struct { + char buf[16]; + int length; + } tainted; + + char buffer[16]; + int sock; + + sock = socket(AF_INET, SOCK_STREAM, 0); + read(sock, &tainted, sizeof(tainted)); + __builtin_memcpy(buffer, tainted.buf, tainted.length); // expected-warning {{Untrusted data is used to specify the buffer size}} +} + +void testStructArray() { + struct { + char buf[16]; + struct { + int length; + } st[1]; + } tainted; + + char buffer[16]; + int sock; + + sock = socket(AF_INET, SOCK_STREAM, 0); + read(sock, &tainted.buf[0], sizeof(tainted.buf)); + read(sock, &tainted.st[0], sizeof(tainted.st)); + // FIXME: tainted.st[0].length should be marked tainted + __builtin_memcpy(buffer, tainted.buf, tainted.st[0].length); // no-warning } int testDivByZero() { diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c index 6287198eda45..1b59e7bc8e90 100644 --- a/test/Analysis/taint-tester.c +++ b/test/Analysis/taint-tester.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-int-to-pointer-cast -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify +// RUN: %clang_analyze_cc1 -Wno-int-to-pointer-cast -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/taint-tester.cpp b/test/Analysis/taint-tester.cpp index ca7b729f2691..23a92cc56d24 100644 --- a/test/Analysis/taint-tester.cpp +++ b/test/Analysis/taint-tester.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify // expected-no-diagnostics typedef struct _FILE FILE; diff --git a/test/Analysis/taint-tester.m b/test/Analysis/taint-tester.m index b5663ca02777..531c21b5faf8 100644 --- a/test/Analysis/taint-tester.m +++ b/test/Analysis/taint-tester.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify // expected-no-diagnostics #import <stdarg.h> diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp index a9e455625957..372443bedffa 100644 --- a/test/Analysis/temp-obj-dtors-cfg-output.cpp +++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp @@ -1,7 +1,7 @@ // RUN: rm -f %t -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-temporary-dtors=true -std=c++98 %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config cfg-temporary-dtors=true -std=c++98 %s > %t 2>&1 // RUN: FileCheck --input-file=%t -check-prefix=CXX98 -check-prefix=CHECK %s -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1 +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1 // RUN: FileCheck --input-file=%t -check-prefix=CXX11 -check-prefix=CHECK %s class A { diff --git a/test/Analysis/templates.cpp b/test/Analysis/templates.cpp index 131794a7c931..c1631e0db90c 100644 --- a/test/Analysis/templates.cpp +++ b/test/Analysis/templates.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fblocks -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fblocks -analyzer-config c++-template-inlining=false -DNO_INLINE -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -fblocks -analyzer-config c++-template-inlining=false -DNO_INLINE -verify %s void clang_analyzer_eval(bool); diff --git a/test/Analysis/temporaries-callback-order.cpp b/test/Analysis/temporaries-callback-order.cpp new file mode 100644 index 000000000000..df916cc4e767 --- /dev/null +++ b/test/Analysis/temporaries-callback-order.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:Bind=true -analyzer-config debug.AnalysisOrder:RegionChanges=true %s 2>&1 | FileCheck %s + +struct Super { + virtual void m(); +}; +struct Sub : Super { + virtual void m() {} +}; + +void testTemporaries() { + // This triggers RegionChanges twice: + // - Once for zero-initialization of the structure. + // - Once for creating a temporary region and copying the structure there. + // FIXME: This code shouldn't really produce the extra temporary, however + // that's how we behave for now. + Sub().m(); +} + +void seeIfCheckBindWorks() { + // This should trigger checkBind. The rest of the code shouldn't. + // This also triggers checkRegionChanges after that. + // Note that this function is analyzed first, so the messages would be on top. + int x = 1; +} + +// seeIfCheckBindWorks(): +// CHECK: Bind +// CHECK-NEXT: RegionChanges + +// testTemporaries(): +// CHECK-NEXT: RegionChanges +// CHECK-NEXT: RegionChanges + +// Make sure there's no further output. +// CHECK-NOT: Bind +// CHECK-NOT: RegionChanges diff --git a/test/Analysis/temporaries.cpp b/test/Analysis/temporaries.cpp index 49cf070177fc..99851dd68539 100644 --- a/test/Analysis/temporaries.cpp +++ b/test/Analysis/temporaries.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++03 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++11 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s -std=c++11 +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++03 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -w -std=c++11 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -DTEMPORARY_DTORS -verify -w -analyzer-config cfg-temporary-dtors=true %s -std=c++11 extern bool clang_analyzer_eval(bool); extern bool clang_analyzer_warnIfReached(); @@ -493,3 +493,40 @@ namespace PR16629 { clang_analyzer_eval(x == 47); // expected-warning{{TRUE}} } } + +namespace PR32088 { + void testReturnFromStmtExprInitializer() { + // We shouldn't try to destroy the object pointed to by `obj' upon return. + const NonTrivial &obj = ({ + return; // no-crash + NonTrivial(42); + }); + } +} + +namespace CopyToTemporaryCorrectly { +class Super { +public: + void m() { + mImpl(); + } + virtual void mImpl() = 0; +}; +class Sub : public Super { +public: + Sub(const int &p) : j(p) {} + virtual void mImpl() override { + // Used to be undefined pointer dereference because we didn't copy + // the subclass data (j) to the temporary object properly. + (void)(j + 1); // no-warning + if (j != 22) { + clang_analyzer_warnIfReached(); // no-warning + } + } + const int &j; +}; +void run() { + int i = 22; + Sub(i).m(); +} +} diff --git a/test/Analysis/test-after-div-zero.c b/test/Analysis/test-after-div-zero.c index f34c4f7a3661..159c80c11d86 100644 --- a/test/Analysis/test-after-div-zero.c +++ b/test/Analysis/test-after-div-zero.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -std=c99 -Dbool=_Bool -analyze -analyzer-checker=core,alpha.core.TestAfterDivZero -analyzer-output=text -verify %s -// RUN: %clang_cc1 -x c++ -analyze -analyzer-checker=core,alpha.core.TestAfterDivZero -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -std=c99 -Dbool=_Bool -analyzer-checker=core,alpha.core.TestAfterDivZero -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=core,alpha.core.TestAfterDivZero -analyzer-output=text -verify %s int var; diff --git a/test/Analysis/test-include-cpp.cpp b/test/Analysis/test-include-cpp.cpp index 2ac5e11c997e..6998e3ccd669 100644 --- a/test/Analysis/test-include-cpp.cpp +++ b/test/Analysis/test-include-cpp.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s #include "test-include-cpp.h" diff --git a/test/Analysis/test-include.c b/test/Analysis/test-include.c index 6aa80b96426c..20aa2447850b 100644 --- a/test/Analysis/test-include.c +++ b/test/Analysis/test-include.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s #include "test-include.h" #define DIVYX(X,Y) Y/X diff --git a/test/Analysis/test-objc-non-nil-return-value-checker.m b/test/Analysis/test-objc-non-nil-return-value-checker.m index 8b1e6a5054a5..2a9063624639 100644 --- a/test/Analysis/test-objc-non-nil-return-value-checker.m +++ b/test/Analysis/test-objc-non-nil-return-value-checker.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.NonNilReturnValue,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.NonNilReturnValue,debug.ExprInspection -verify %s typedef unsigned int NSUInteger; typedef signed char BOOL; diff --git a/test/Analysis/test-variably-modified-types.c b/test/Analysis/test-variably-modified-types.c index a833434228d1..1df57affad41 100644 --- a/test/Analysis/test-variably-modified-types.c +++ b/test/Analysis/test-variably-modified-types.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyze-function=testVariablyModifiedTypes -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyze-function=testVariablyModifiedTypes -verify %s // Test that we process variably modified type correctly - the call graph construction should pick up function_with_bug while recursively visiting test_variably_modifiable_types. unsigned getArraySize(int *x) { diff --git a/test/Analysis/traversal-algorithm.mm b/test/Analysis/traversal-algorithm.mm index 8a3dc8b3a222..bdf576063d65 100644 --- a/test/Analysis/traversal-algorithm.mm +++ b/test/Analysis/traversal-algorithm.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpTraversal -analyzer-max-loop 4 -std=c++11 %s | FileCheck -check-prefix=DFS %s +// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpTraversal -analyzer-max-loop 4 -std=c++11 %s | FileCheck -check-prefix=DFS %s int a(); int b(); diff --git a/test/Analysis/traversal-begin-end-function.c b/test/Analysis/traversal-begin-end-function.c index 810ce1d2a529..9d46f26ce8f9 100644 --- a/test/Analysis/traversal-begin-end-function.c +++ b/test/Analysis/traversal-begin-end-function.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s void inline_callee(int i); diff --git a/test/Analysis/traversal-path-unification.c b/test/Analysis/traversal-path-unification.c index 3bf6df731c22..28a15110f903 100644 --- a/test/Analysis/traversal-path-unification.c +++ b/test/Analysis/traversal-path-unification.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal -DUSE_EXPR %s | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpTraversal -DUSE_EXPR %s | FileCheck %s int a(); int b(); diff --git a/test/Analysis/ubigraph-viz.cpp b/test/Analysis/ubigraph-viz.cpp index 0cb9bd6d8929..228dd660c7ff 100644 --- a/test/Analysis/ubigraph-viz.cpp +++ b/test/Analysis/ubigraph-viz.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -analyzer-viz-egraph-ubigraph -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -analyzer-viz-egraph-ubigraph -verify %s // expected-no-diagnostics int f(int x) { diff --git a/test/Analysis/undef-buffers.c b/test/Analysis/undef-buffers.c index 1581b2b8cbb2..d5802fb8c640 100644 --- a/test/Analysis/undef-buffers.c +++ b/test/Analysis/undef-buffers.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,core.uninitialized -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,core.uninitialized -analyzer-store=region -verify -analyzer-config unix:Optimistic=true %s typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void free(void *); diff --git a/test/Analysis/uninit-const.c b/test/Analysis/uninit-const.c index 9e42d23214de..9a6529a772a7 100644 --- a/test/Analysis/uninit-const.c +++ b/test/Analysis/uninit-const.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.Malloc,core,alpha.core.CallAndMessageUnInitRefArg -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=unix.Malloc,core,alpha.core.CallAndMessageUnInitRefArg -analyzer-output=text -verify %s // Passing uninitialized const data to function #include "Inputs/system-header-simulator.h" @@ -24,16 +24,16 @@ void doStuff_variadic(const int *u, ...){}; void f_1(void) { int t; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_1_1(void) { int t; int* tp1 = &t; int* tp2 = tp1; // expected-note {{'tp2' initialized here}} - doStuff_pointerToConstInt(tp2); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp2); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } @@ -45,8 +45,8 @@ void f_2(void) { int t; int* p = f_2_sub(&t); int* tp = p; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } int z; @@ -62,14 +62,14 @@ void f_4(void) { void f_5(void) { int ta[5]; int* tp = ta; // expected-note {{'tp' initialized here}} - doStuff_pointerToConstInt(tp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_5_1(void) { int ta[5]; // expected-note {{'ta' initialized here}} - doStuff_pointerToConstInt(ta); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(ta); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_6(void) { @@ -92,27 +92,27 @@ void f_7(void) { void f_8(void) { int g; // expected-note {{'g' declared without an initial value}} - doStuff2(g); // expected-warning {{Function call argument is an uninitialized value}} - // expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff2(g); // expected-warning {{1st function call argument is an uninitialized value}} + // expected-note@-1 {{1st function call argument is an uninitialized value}} } void f_9(void) { int a[6]; int const *ptau = a; // expected-note {{'ptau' initialized here}} - doStuff_arrayOfConstInt(ptau); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_arrayOfConstInt(ptau); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_10(void) { int a[6]; // expected-note {{'a' initialized here}} - doStuff_arrayOfConstInt(a); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_arrayOfConstInt(a); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_11(void) { int t[10]; //expected-note {{'t' initialized here}} - doStuff_constStaticSizedArray(t); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_constStaticSizedArray(t); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f_12(void) { @@ -126,8 +126,8 @@ int f_malloc_1(void) { ptr = (int *)malloc(sizeof(int)); // expected-note {{Value assigned to 'ptr'}} - doStuff_pointerToConstInt(ptr); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_pointerToConstInt(ptr); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} free(ptr); return 0; } @@ -148,16 +148,16 @@ void f_variadic_unp_unv(void) { int t; int v; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } // uninit pointer, init val void f_variadic_unp_inv(void) { int t; int v = 3; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,v); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,v); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } // init pointer, uninit val @@ -165,8 +165,8 @@ void f_variadic_inp_unv(void) { int t=5; int v; // expected-note {{'v' declared without an initial value}} int* tp = &t; - doStuff_variadic(tp,v);// expected-warning {{Function call argument is an uninitialized value}} - // expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff_variadic(tp,v);// expected-warning {{2nd function call argument is an uninitialized value}} + // expected-note@-1 {{2nd function call argument is an uninitialized value}} } // init pointer, init val @@ -192,8 +192,8 @@ void f_variadic_unp_inp(void) { int u=3; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } //init pointer, uninit pointer @@ -211,6 +211,6 @@ void f_variadic_unp_unp(void) { int u; int *vp = &u ; int *tp = &t; // expected-note {{'tp' initialized here}} - doStuff_variadic(tp,vp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_variadic(tp,vp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } diff --git a/test/Analysis/uninit-const.cpp b/test/Analysis/uninit-const.cpp index 56bfa08e4176..75e932a77ced 100644 --- a/test/Analysis/uninit-const.cpp +++ b/test/Analysis/uninit-const.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,core,alpha.core.CallAndMessageUnInitRefArg -analyzer-output=text -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,core,alpha.core.CallAndMessageUnInitRefArg -analyzer-output=text -verify %s // Passing uninitialized const data to unknown function #include "Inputs/system-header-simulator-cxx.h" @@ -66,8 +66,8 @@ void f6_2(void) { int &p = t; int &s = p; int &q = s; //expected-note {{'q' initialized here}} - doStuff6(q); //expected-warning {{Function call argument is an uninitialized value}} - //expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}} + //expected-note@-1 {{1st function call argument is an uninitialized value}} } void doStuff6_3(int& q_, int *ptr_) {} @@ -78,15 +78,15 @@ void f6_3(void) { int &p = t; int &s = p; int &q = s; - doStuff6_3(q,ptr); //expected-warning {{Function call argument is an uninitialized value}} - //expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff6_3(q,ptr); //expected-warning {{2nd function call argument is an uninitialized value}} + //expected-note@-1 {{2nd function call argument is an uninitialized value}} } void f6(void) { int k; // expected-note {{'k' declared without an initial value}} - doStuff6(k); // expected-warning {{Function call argument is an uninitialized value}} - // expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff6(k); // expected-warning {{1st function call argument is an uninitialized value}} + // expected-note@-1 {{1st function call argument is an uninitialized value}} } @@ -95,15 +95,15 @@ void f6(void) { void f5(void) { int t; int* tp = &t; // expected-note {{'tp' initialized here}} - doStuff_uninit(tp); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_uninit(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } void f4(void) { int y; // expected-note {{'y' declared without an initial value}} - doStuff4(y); // expected-warning {{Function call argument is an uninitialized value}} - // expected-note@-1 {{Function call argument is an uninitialized value}} + doStuff4(y); // expected-warning {{1st function call argument is an uninitialized value}} + // expected-note@-1 {{1st function call argument is an uninitialized value}} } void f3(void) { @@ -123,6 +123,6 @@ void f1(void) { void f_uninit(void) { int x; - doStuff_uninit(&x); // expected-warning {{Function call argument is a pointer to uninitialized value}} - // expected-note@-1 {{Function call argument is a pointer to uninitialized value}} + doStuff_uninit(&x); // expected-warning {{1st function call argument is a pointer to uninitialized value}} + // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}} } diff --git a/test/Analysis/uninit-msg-expr.m b/test/Analysis/uninit-msg-expr.m index 19fdf611c865..8454137967f6 100644 --- a/test/Analysis/uninit-msg-expr.m +++ b/test/Analysis/uninit-msg-expr.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from @@ -52,5 +52,5 @@ unsigned f2() { void f3() { NSMutableArray *aArray = [NSArray array]; NSString *aString; - [aArray addObject:aString]; // expected-warning {{Argument in message expression is an uninitialized value}} + [aArray addObject:aString]; // expected-warning {{1st argument in message expression is an uninitialized value}} } diff --git a/test/Analysis/uninit-ps-rdar6145427.m b/test/Analysis/uninit-ps-rdar6145427.m index c18116f21ae5..d735f17317cf 100644 --- a/test/Analysis/uninit-ps-rdar6145427.m +++ b/test/Analysis/uninit-ps-rdar6145427.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -analyzer-store=region %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -analyzer-store=region %s // Delta-Debugging reduced preamble. typedef signed char BOOL; diff --git a/test/Analysis/uninit-vals-ps-region.m b/test/Analysis/uninit-vals-ps-region.m index 87256b3b4b1b..18010f240d3d 100644 --- a/test/Analysis/uninit-vals-ps-region.m +++ b/test/Analysis/uninit-vals-ps-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-store=region -analyzer-checker=core -verify %s struct s { int data; diff --git a/test/Analysis/uninit-vals-ps.c b/test/Analysis/uninit-vals-ps.c index ad40b15502e4..ee25d9d9a602 100644 --- a/test/Analysis/uninit-vals-ps.c +++ b/test/Analysis/uninit-vals-ps.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -fblocks -verify %s struct FPRec { void (*my_func)(int * x); @@ -14,7 +14,7 @@ int f1_a(struct FPRec* foo) { int f1_b() { int x; - return bar(x)+1; // expected-warning{{Function call argument is an uninitialized value}} + return bar(x)+1; // expected-warning{{1st function call argument is an uninitialized value}} } int f2() { @@ -57,6 +57,12 @@ int f5(void) { return s.x; // no-warning } +void f6(int x) { + int a[20]; + if (x == 25) {} + if (a[x] == 123) {} // expected-warning{{The left operand of '==' is a garbage value due to array index out of bounds}} +} + int ret_uninit() { int i; int *p = &i; diff --git a/test/Analysis/uninit-vals-union.c b/test/Analysis/uninit-vals-union.c index 927dfa2e5979..b433e7b0ef62 100644 --- a/test/Analysis/uninit-vals-union.c +++ b/test/Analysis/uninit-vals-union.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -analyzer-store=region -verify -Wno-unused %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.builtin -analyzer-store=region -verify -Wno-unused %s typedef union { int y; diff --git a/test/Analysis/uninit-vals.cpp b/test/Analysis/uninit-vals.cpp index 387c3754dae4..5ab1348ae5c0 100644 --- a/test/Analysis/uninit-vals.cpp +++ b/test/Analysis/uninit-vals.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin -verify -DCHECK_FOR_CRASH %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core.builtin -verify -DCHECK_FOR_CRASH %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s #ifdef CHECK_FOR_CRASH // expected-no-diagnostics @@ -27,7 +27,7 @@ void foo() { // case with undefined values, too. c1.b.a = c2->b.a; #else - c1.b.a = c2->b.a; // expected-warning{{Function call argument is an uninitialized value}} + c1.b.a = c2->b.a; // expected-warning{{1st function call argument is an uninitialized value}} #endif } } diff --git a/test/Analysis/uninit-vals.m b/test/Analysis/uninit-vals.m index 72b673980017..7c18dee97606 100644 --- a/test/Analysis/uninit-vals.m +++ b/test/Analysis/uninit-vals.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s typedef unsigned int NSUInteger; typedef __typeof__(sizeof(int)) size_t; diff --git a/test/Analysis/unions-region.m b/test/Analysis/unions-region.m index 636198ad0594..bad159fe8123 100644 --- a/test/Analysis/unions-region.m +++ b/test/Analysis/unions-region.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region %s -verify // expected-no-diagnostics //===-- unions-region.m ---------------------------------------------------===// diff --git a/test/Analysis/unions.cpp b/test/Analysis/unions.cpp index f363ab81ae72..2758cdaa26b3 100644 --- a/test/Analysis/unions.cpp +++ b/test/Analysis/unions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection %s -verify +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection %s -verify extern void clang_analyzer_eval(bool); extern "C" char *strdup(const char *s); diff --git a/test/Analysis/unix-api.c b/test/Analysis/unix-api.c index 24b145d3d3d9..64ff3c0fccf4 100644 --- a/test/Analysis/unix-api.c +++ b/test/Analysis/unix-api.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -verify %s #ifndef O_RDONLY #define O_RDONLY 0 diff --git a/test/Analysis/unix-api.cpp b/test/Analysis/unix-api.cpp index 1c8f99632c07..2b07d8807c1f 100644 --- a/test/Analysis/unix-api.cpp +++ b/test/Analysis/unix-api.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -verify %s extern "C" { #ifndef O_RDONLY #define O_RDONLY 0 diff --git a/test/Analysis/unix-fns.c b/test/Analysis/unix-fns.c index b14457845895..3eccd51d2c60 100644 --- a/test/Analysis/unix-fns.c +++ b/test/Analysis/unix-fns.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,unix.API,osx.API %s -analyzer-store=region -analyzer-output=plist -analyzer-eagerly-assume -analyzer-config faux-bodies=true -analyzer-config path-diagnostics-alternate=false -fblocks -verify -o %t.plist +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,unix.API,osx.API %s -analyzer-store=region -analyzer-output=plist -analyzer-eagerly-assume -analyzer-config faux-bodies=true -analyzer-config path-diagnostics-alternate=false -fblocks -verify -o %t.plist // RUN: FileCheck --input-file=%t.plist %s // RUN: mkdir -p %t.dir -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API,osx.API -analyzer-output=html -analyzer-config faux-bodies=true -fblocks -o %t.dir %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API,osx.API -analyzer-output=html -analyzer-config faux-bodies=true -fblocks -o %t.dir %s // RUN: rm -fR %t.dir struct _opaque_pthread_once_t { long __sig; diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c index 4ddfb21f0a0f..ff58587be2da 100644 --- a/test/Analysis/unreachable-code-path.c +++ b/test/Analysis/unreachable-code-path.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,alpha.deadcode.UnreachableCode -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s extern void foo(int a); diff --git a/test/Analysis/unsupported-types.c b/test/Analysis/unsupported-types.c new file mode 100644 index 000000000000..9233095e4211 --- /dev/null +++ b/test/Analysis/unsupported-types.c @@ -0,0 +1,31 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple x86_64-unknown-linux -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -triple powerpc64-linux-gnu -verify %s + +#define _Complex_I (__extension__ 1.0iF) + +void clang_analyzer_eval(int); + +void complex_float(double _Complex x, double _Complex y) { + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I) + return + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}} +} + +void complex_int(int _Complex x, int _Complex y) { + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + if (x != 1.0 + 3.0 * _Complex_I && y != 1.0 - 4.0 * _Complex_I) + return + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(x + y == 2.0 - 1.0 * _Complex_I); // expected-warning{{UNKNOWN}} +} + +void longdouble_float(long double x, long double y) { + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + if (x != 0.0L && y != 1.0L) + return + clang_analyzer_eval(x == y); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(x + y == 1.0L); // expected-warning{{UNKNOWN}} +} diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index f04132ba4570..8f12d9b18a7d 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -analyze -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s +// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=osx.cocoa.UnusedIvars -verify -Wno-objc-root-class %s //===--- BEGIN: Delta-debugging reduced headers. --------------------------===// diff --git a/test/Analysis/valist-as-lazycompound.c b/test/Analysis/valist-as-lazycompound.c new file mode 100644 index 000000000000..2fbd4cb76f48 --- /dev/null +++ b/test/Analysis/valist-as-lazycompound.c @@ -0,0 +1,21 @@ +// RUN: %clang_analyze_cc1 -triple gcc-linaro-arm-linux-gnueabihf -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s +// expected-no-diagnostics + +typedef unsigned int size_t; +typedef __builtin_va_list __gnuc_va_list; +typedef __gnuc_va_list va_list; + +extern int vsprintf(char *__restrict __s, + const char *__restrict __format, __gnuc_va_list + __arg); + +void _dprintf(const char *function, int flen, int line, int level, + const char *prefix, const char *fmt, ...) { + char raw[10]; + int err; + va_list ap; + + __builtin_va_start(ap, fmt); + err = vsprintf(raw, fmt, ap); + __builtin_va_end(ap); +} diff --git a/test/Analysis/valist-uninitialized-no-undef.c b/test/Analysis/valist-uninitialized-no-undef.c new file mode 100644 index 000000000000..528ac86c1421 --- /dev/null +++ b/test/Analysis/valist-uninitialized-no-undef.c @@ -0,0 +1,40 @@ +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s + +#include "Inputs/system-header-simulator-for-valist.h" + +// This is called in call_inlined_uses_arg(), +// and the warning is generated during the analysis of call_inlined_uses_arg(). +void inlined_uses_arg(va_list arg) { + (void)va_arg(arg, int); // expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} +} + +void call_inlined_uses_arg(int fst, ...) { + va_list va; + inlined_uses_arg(va); // expected-note{{Calling 'inlined_uses_arg'}} +} + +void f6(va_list *fst, ...) { + va_start(*fst, fst); + // FIXME: There should be no warning for this. + (void)va_arg(*fst, int); // expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} + va_end(*fst); +} + +void call_vprintf_bad(int isstring, ...) { + va_list va; + vprintf(isstring ? "%s" : "%d", va); // expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}} + // expected-note@-1{{Function 'vprintf' is called with an uninitialized va_list argument}} + // expected-note@-2{{Assuming 'isstring' is 0}} + // expected-note@-3{{'?' condition is false}} +} + +void call_vsprintf_bad(char *buffer, ...) { + va_list va; + va_start(va, buffer); // expected-note{{Initialized va_list}} + va_end(va); // expected-note{{Ended va_list}} + vsprintf(buffer, "%s %d %d %lf %03d", va); // expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}} + // expected-note@-1{{Function 'vsprintf' is called with an uninitialized va_list argument}} +} + diff --git a/test/Analysis/valist-uninitialized.c b/test/Analysis/valist-uninitialized.c index b1f11d138fec..19308537e02c 100644 --- a/test/Analysis/valist-uninitialized.c +++ b/test/Analysis/valist-uninitialized.c @@ -1,17 +1,20 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Uninitialized,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple hexagon-unknown-linux -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Uninitialized,valist.CopyToSelf -analyzer-disable-checker=core.CallAndMessage -analyzer-output=text -analyzer-store=region -verify %s #include "Inputs/system-header-simulator-for-valist.h" void f1(int fst, ...) { va_list va; - (void)va_arg(va, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} + (void)va_arg(va, int); // expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} } int f2(int fst, ...) { va_list va; va_start(va, fst); // expected-note{{Initialized va_list}} va_end(va); // expected-note{{Ended va_list}} - return va_arg(va, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} + return va_arg(va, int); // expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} } void f3(int fst, ...) { @@ -25,11 +28,13 @@ void f3(int fst, ...) { void f4(int cond, ...) { va_list va; - if (cond) { // expected-note{{Assuming 'cond' is 0}} expected-note{{Taking false branch}} + if (cond) { // expected-note{{Assuming 'cond' is 0}} + // expected-note@-1{{Taking false branch}} va_start(va, cond); (void)va_arg(va,int); } - va_end(va); //expected-warning{{va_end() is called on an uninitialized va_list}} expected-note{{va_end() is called on an uninitialized va_list}} + va_end(va); //expected-warning{{va_end() is called on an uninitialized va_list}} + // expected-note@-1{{va_end() is called on an uninitialized va_list}} } void f5(va_list fst, ...) { @@ -38,13 +43,6 @@ void f5(va_list fst, ...) { va_end(fst); } // no-warning -//FIXME: this should not cause a warning -void f6(va_list *fst, ...) { - va_start(*fst, fst); - (void)va_arg(*fst, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} - va_end(*fst); -} - void f7(int *fst, ...) { va_list x; va_list *y = &x; @@ -58,8 +56,9 @@ void f8(int *fst, ...) { va_list *y = &x; va_start(*y,fst); // expected-note{{Initialized va_list}} va_end(x); // expected-note{{Ended va_list}} - (void)va_arg(*y, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} -} // no-warning + (void)va_arg(*y, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} +} // This only contains problems which are handled by varargs.Unterminated. void reinit(int *fst, ...) { @@ -87,48 +86,56 @@ void reinit3(int *fst, ...) { va_start(va, fst); // expected-note{{Initialized va_list}} (void)va_arg(va, int); va_end(va); // expected-note{{Ended va_list}} - (void)va_arg(va, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} + (void)va_arg(va, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} + // expected-note@-1{{va_arg() is called on an uninitialized va_list}} } void copyself(int fst, ...) { va_list va; va_start(va, fst); // expected-note{{Initialized va_list}} - va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}} + va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} + // expected-note@-1{{va_list 'va' is copied onto itself}} va_end(va); -} // no-warning +} void copyselfUninit(int fst, ...) { va_list va; - va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}} -} // no-warning + va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} + // expected-note@-1{{va_list 'va' is copied onto itself}} +} void copyOverwrite(int fst, ...) { va_list va, va2; va_start(va, fst); // expected-note{{Initialized va_list}} - va_copy(va, va2); // expected-warning{{Initialized va_list 'va' is overwritten by an uninitialized one}} expected-note{{Initialized va_list 'va' is overwritten by an uninitialized one}} -} // no-warning + va_copy(va, va2); // expected-warning{{Initialized va_list 'va' is overwritten by an uninitialized one}} + // expected-note@-1{{Initialized va_list 'va' is overwritten by an uninitialized one}} +} void copyUnint(int fst, ...) { va_list va, va2; - va_copy(va, va2); // expected-warning{{Uninitialized va_list is copied}} expected-note{{Uninitialized va_list is copied}} + va_copy(va, va2); // expected-warning{{Uninitialized va_list is copied}} + // expected-note@-1{{Uninitialized va_list is copied}} } void g1(int fst, ...) { va_list va; - va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} expected-note{{va_end() is called on an uninitialized va_list}} + va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} + // expected-note@-1{{va_end() is called on an uninitialized va_list}} } void g2(int fst, ...) { va_list va; va_start(va, fst); // expected-note{{Initialized va_list}} va_end(va); // expected-note{{Ended va_list}} - va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} expected-note{{va_end() is called on an uninitialized va_list}} + va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} + // expected-note@-1{{va_end() is called on an uninitialized va_list}} } void is_sink(int fst, ...) { va_list va; - va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} expected-note{{va_end() is called on an uninitialized va_list}} - *((volatile int *)0) = 1; //no-warning + va_end(va); // expected-warning{{va_end() is called on an uninitialized va_list}} + // expected-note@-1{{va_end() is called on an uninitialized va_list}} + *((volatile int *)0) = 1; } // NOTE: this is invalid, as the man page of va_end requires that "Each invocation of va_start() @@ -141,17 +148,6 @@ void uses_arg(va_list arg) { (void)va_arg(arg, int); } //no-warning -// This is the same function as the previous one, but it is called in call_uses_arg2(), -// and the warning is generated during the analysis of call_uses_arg2(). -void inlined_uses_arg(va_list arg) { - (void)va_arg(arg, int); //expected-warning{{va_arg() is called on an uninitialized va_list}} expected-note{{va_arg() is called on an uninitialized va_list}} -} - -void call_inlined_uses_arg(int fst, ...) { - va_list va; - inlined_uses_arg(va); // expected-note{{Calling 'inlined_uses_arg'}} -} - void call_vprintf_ok(int isstring, ...) { va_list va; va_start(va, isstring); @@ -159,20 +155,24 @@ void call_vprintf_ok(int isstring, ...) { va_end(va); } //no-warning -void call_vprintf_bad(int isstring, ...) { +void call_some_other_func(int n, ...) { va_list va; - vprintf(isstring ? "%s" : "%d", va); //expected-warning{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vprintf' is called with an uninitialized va_list argument}} expected-note{{Assuming 'isstring' is 0}} expected-note{{'?' condition is false}} -} + some_library_function(n, va); +} //no-warning -void call_vsprintf_bad(char *buffer, ...) { - va_list va; - va_start(va, buffer); // expected-note{{Initialized va_list}} - va_end(va); // expected-note{{Ended va_list}} - vsprintf(buffer, "%s %d %d %lf %03d", va); //expected-warning{{Function 'vsprintf' is called with an uninitialized va_list argument}} expected-note{{Function 'vsprintf' is called with an uninitialized va_list argument}} +void inlined_uses_arg_good(va_list arg) { + (void)va_arg(arg, int); } -void call_some_other_func(int n, ...) { +void call_inlined_uses_arg_good(int fst, ...) { va_list va; - some_library_function(n, va); -} //no-warning + va_start(va, fst); + inlined_uses_arg_good(va); + va_end(va); +} +void va_copy_test(va_list arg) { + va_list dst; + va_copy(dst, arg); + va_end(dst); +} diff --git a/test/Analysis/valist-unterminated.c b/test/Analysis/valist-unterminated.c index 63ee992b2894..e19c6761784c 100644 --- a/test/Analysis/valist-unterminated.c +++ b/test/Analysis/valist-unterminated.c @@ -1,11 +1,13 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple hexagon-unknown-linux -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,valist.Unterminated,valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s #include "Inputs/system-header-simulator-for-valist.h" void f1(int fst, ...) { va_list va; va_start(va, fst); // expected-note{{Initialized va_list}} - return; // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}} + return; // expected-warning{{Initialized va_list 'va' is leaked}} + // expected-note@-1{{Initialized va_list 'va' is leaked}} } void f2(int fst, ...) { @@ -13,37 +15,42 @@ void f2(int fst, ...) { va_start(va, fst); // expected-note{{Initialized va_list}} va_end(va); // expected-note{{Ended va_list}} va_start(va, fst); // expected-note{{Initialized va_list}} -} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}} +} // expected-warning{{Initialized va_list 'va' is leaked}} + // expected-note@-1{{Initialized va_list 'va' is leaked}} void f3(int fst, ...) { va_list va, va2; va_start(va, fst); va_copy(va2, va); // expected-note{{Initialized va_list}} - va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list 'va2' is leaked}} + va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}} + // expected-note@-1{{Initialized va_list 'va2' is leaked}} } void f4(va_list *fst, ...) { va_start(*fst, fst); // expected-note{{Initialized va_list}} - return; // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}} + return; // expected-warning{{Initialized va_list is leaked}} + // expected-note@-1{{Initialized va_list is leaked}} } void f5(va_list fst, ...) { - va_start(fst, fst); - //FIXME: this should cause a warning -} // no-warning + va_start(fst, fst); // expected-note{{Initialized va_list}} +} // expected-warning{{Initialized va_list}} + // expected-note@-1{{Initialized va_list}} void f6(va_list *fst, ...) { va_start(*fst, fst); // expected-note{{Initialized va_list}} (void)va_arg(*fst, int); //FIXME: this should NOT cause a warning - va_end(*fst); // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}} + va_end(*fst); // expected-warning{{Initialized va_list is leaked}} + // expected-note@-1{{Initialized va_list is leaked}} } void f7(int *fst, ...) { va_list x; va_list *y = &x; va_start(*y,fst); // expected-note{{Initialized va_list}} -} // expected-warning{{Initialized va_list 'x' is leaked}} expected-note{{Initialized va_list 'x' is leaked}} +} // expected-warning{{Initialized va_list 'x' is leaked}} + // expected-note@-1{{Initialized va_list 'x' is leaked}} void f8(int *fst, ...) { va_list x; @@ -54,9 +61,12 @@ void f8(int *fst, ...) { void reinit(int *fst, ...) { va_list va; - va_start(va, fst); // expected-note{{Initialized va_list}} expected-note{{Initialized va_list}} - va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}} expected-note{{Initialized va_list 'va' is initialized again}} -} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}} + va_start(va, fst); // expected-note{{Initialized va_list}} + // expected-note@-1{{Initialized va_list}} + va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}} + // expected-note@-1{{Initialized va_list 'va' is initialized again}} +} // expected-warning{{Initialized va_list 'va' is leaked}} + // expected-note@-1{{Initialized va_list 'va' is leaked}} void reinitOk(int *fst, ...) { va_list va; @@ -69,20 +79,23 @@ void reinitOk(int *fst, ...) { void copyself(int fst, ...) { va_list va; va_start(va, fst); // expected-note{{Initialized va_list}} - va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}} + va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} + // expected-note@-1{{va_list 'va' is copied onto itself}} va_end(va); -} // no-warning +} void copyselfUninit(int fst, ...) { va_list va; - va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} expected-note{{va_list 'va' is copied onto itself}} -} // no-warning + va_copy(va, va); // expected-warning{{va_list 'va' is copied onto itself}} + // expected-note@-1{{va_list 'va' is copied onto itself}} +} void copyOverwrite(int fst, ...) { va_list va, va2; va_start(va, fst); // expected-note{{Initialized va_list}} - va_copy(va, va2); // expected-warning{{Initialized va_list 'va' is overwritten by an uninitialized one}} expected-note{{Initialized va_list 'va' is overwritten by an uninitialized one}} -} // no-warning + va_copy(va, va2); // expected-warning{{Initialized va_list 'va' is overwritten by an uninitialized one}} + // expected-note@-1{{Initialized va_list 'va' is overwritten by an uninitialized one}} +} //This only generates a warning for the valist.Uninitialized checker void copyUnint(int fst, ...) { @@ -94,20 +107,27 @@ void recopy(int fst, ...) { va_list va, va2; va_start(va, fst); va_copy(va2, va); // expected-note{{Initialized va_list}} - va_copy(va2, va); // expected-warning{{Initialized va_list 'va2' is initialized again}} expected-note{{Initialized va_list 'va2' is initialized again}} + va_copy(va2, va); // expected-warning{{Initialized va_list 'va2' is initialized again}} + // expected-note@-1{{Initialized va_list 'va2' is initialized again}} va_end(va); va_end(va2); -} //no-warning +} void doublemsg(int fst, ...) { va_list va, va2; - va_start(va, fst), va_start(va2, fst); // expected-warning{{Initialized va_list 'va' is leaked}} expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list}} expected-note{{Initialized va_list 'va' is leaked}} + va_start(va, fst), va_start(va2, fst); // expected-warning{{Initialized va_list 'va' is leaked}} + // expected-warning@-1{{Initialized va_list 'va2' is leaked}} + // expected-note@-2{{Initialized va_list}} + // expected-note@-3{{Initialized va_list}} + // expected-note@-4{{Initialized va_list}} + // expected-note@-5{{Initialized va_list 'va' is leaked}} } void in_array(int fst, ...) { va_list va_array[8]; va_start(va_array[3], fst); // expected-note{{Initialized va_list}} -} // expected-warning{{Initialized va_list 'va_array[3]' is leaked}} expected-note{{Initialized va_list 'va_array[3]' is leaked}} +} // expected-warning{{Initialized va_list 'va_array[3]' is leaked}} + // expected-note@-1{{Initialized va_list 'va_array[3]' is leaked}} struct containing_a_valist { va_list vafield; @@ -117,12 +137,14 @@ struct containing_a_valist { void in_struct(int fst, ...) { struct containing_a_valist s; va_start(s.vafield, fst); // expected-note{{Initialized va_list}} -} // expected-warning{{Initialized va_list 's.vafield' is leaked}} expected-note{{Initialized va_list 's.vafield' is leaked}} +} // expected-warning{{Initialized va_list 's.vafield' is leaked}} + // expected-note@-1{{Initialized va_list 's.vafield' is leaked}} void casting(int fst, ...) { char mem[sizeof(va_list)]; va_start(*(va_list *) mem, fst); // expected-note{{Initialized va_list}} -} // expected-warning{{Initialized va_list 'mem[0]' is leaked}} expected-note{{Initialized va_list 'mem[0]' is leaked}} +} // expected-warning{{Initialized va_list 'mem[0]' is leaked}} + // expected-note@-1{{Initialized va_list 'mem[0]' is leaked}} void castingOk(int fst, ...) { diff --git a/test/Analysis/variadic-method-types.m b/test/Analysis/variadic-method-types.m index 9f90e5ff343d..6db93ac032e6 100644 --- a/test/Analysis/variadic-method-types.m +++ b/test/Analysis/variadic-method-types.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.VariadicMethodTypes -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.VariadicMethodTypes -analyzer-store=region -fblocks -verify %s //===----------------------------------------------------------------------===// // The following code is reduced using delta-debugging from diff --git a/test/Analysis/vfork.c b/test/Analysis/vfork.c index c7a02fa65c44..da1b5da40665 100644 --- a/test/Analysis/vfork.c +++ b/test/Analysis/vfork.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify -x c++ %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,security.insecureAPI.vfork,unix.Vfork -verify -x c++ %s #include "Inputs/system-header-simulator.h" diff --git a/test/Analysis/virtualcall.cpp b/test/Analysis/virtualcall.cpp index 311f0a137c6f..56bd32446ee7 100644 --- a/test/Analysis/virtualcall.cpp +++ b/test/Analysis/virtualcall.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -verify -std=c++11 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:Interprocedural=true -DINTERPROCEDURAL=1 -verify -std=c++11 %s +// RUN: %clang_analyze_cc1 -analyzer-checker=optin.cplusplus.VirtualCall -analyzer-store region -analyzer-config optin.cplusplus.VirtualCall:PureOnly=true -DPUREONLY=1 -verify -std=c++11 %s /* When INTERPROCEDURAL is set, we expect diagnostics in all functions reachable from a constructor or destructor. If it is not set, we expect diagnostics diff --git a/test/Analysis/vla.c b/test/Analysis/vla.c index f94bea96e8f6..eb06c24246a7 100644 --- a/test/Analysis/vla.c +++ b/test/Analysis/vla.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s // Zero-sized VLAs. void check_zero_sized_VLA(int x) { diff --git a/test/Analysis/weak-functions.c b/test/Analysis/weak-functions.c index a983f92f81aa..514a94388722 100644 --- a/test/Analysis/weak-functions.c +++ b/test/Analysis/weak-functions.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection,unix.Malloc,unix.cstring,alpha.unix.cstring,unix.API,osx.API,osx.cocoa.RetainCount -Wno-null-dereference -Wno-tautological-compare -analyzer-store=region -fblocks -verify %s +// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection,unix.Malloc,unix.cstring,alpha.unix.cstring,unix.API,osx.API,osx.cocoa.RetainCount -Wno-null-dereference -Wno-tautological-compare -analyzer-store=region -fblocks -verify %s #define NULL 0 void clang_analyzer_eval(int); void myFunc(); |