git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166280 91177308-0d34-0410-b5e6-96231b3b80d8
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/exprs1.c
// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/exprs2.c
// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues -triple x86_64-apple-darwin -verify %s
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFArray * CFArrayRef;
// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-constraints=range -analyzer-store=region
typedef struct objc_selector *SEL;
typedef signed char BOOL;
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.osx.cocoa.Dealloc %s -verify
@protocol NSObject
- (BOOL)isEqual:(id)object;
// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-objc-root-class %s
// BEGIN delta-debugging reduced header stuff
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify %s
#include <stdarg.h>
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
// Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we
// do a forced load and binding to the environment on an expression that would regularly
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -Wno-objc-root-class %s -verify
// The point of this test cases is to exercise properties in the static
// analyzer
// RUN: %clang_cc1 -cc1 -std=c++11 -Wuninitialized -verify %s
void f() {
int a[] = { 1, 2, 3 };
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
// Test if the 'storage' region gets properly initialized after it is cast to
// 'struct sockaddr *'.
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
// Test function pointer casts. Currently we track function addresses using
// loc::FunctionVal. Because casts can be arbitrary, do we need to model
// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-constraints=range -verify %s
typedef unsigned char Boolean;
typedef signed long CFIndex;
// This test case was reported in <rdar:problem/6080742>.
// It tests path-sensitivity with respect to '!(cfstring != 0)' (negation of inequality).
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s
// Do not crash on initialization to complex numbers.
void init_complex() {
void foo() {
int *p = (int*) 0x10000; // Should not crash here.
// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -verify %s
// Ensure we don't crash on C++ declarations with special names.
struct X {
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,osx,alpha.unix,alpha.security.taint -analyzer-store region -verify %s
class Evil {
public:
// RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -verify %s
// radar://11485149, PR12871
class PlotPoint {
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core -analyzer-checker=deadcode.DeadStores,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s
typedef unsigned int NSUInteger;
// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -Wno-objc-root-class -verify %s
//===----------------------------------------------------------------------===//
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
typedef struct {
char I[4];
// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=alpha.deadcode.IdempotentOperations,osx.cocoa.RetainCount -verify %s
typedef unsigned long NSUInteger;
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
// Test parameter 'a' is registered to LiveVariables analysis data although it
// is not referenced in the function body.
// Test when entering f1(), we set the right AnalysisDeclContext to Environment.
// Otherwise, block-level expr '1 && a' would not be block-level.
int g(int a) {
return a;
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -analyzer-config objc-inlining=false -verify %s
typedef struct objc_class *Class;
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
int f1() {
int x = 0, y = 1;
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.MallocOverflow -verify %s
class A {
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
// Intra-procedural C++ tests.
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s
// <rdar://problem/6440393> - A bunch of misc. failures involving evaluating
// these expressions and building CFGs. These tests are here to prevent
// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
// <rdar://problem/11405978> - Handle casts of vectors to structs, and loading
// a value.
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -fblocks %s -analyzer-eagerly-assume
// Delta-reduced header stuff (needed for test cases).
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
// Here is a case where a pointer is treated as integer, invalidated as an
// integer, and then used again as a pointer. This test just makes sure
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks %s
// 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
//===------------------------------------------------------------------------------------------===//
// This files tests our path-sensitive handling of Objective-c++ files.
// This is a test case for the issue reported in PR 2819:
// http://llvm.org/bugs/show_bug.cgi?id=2819
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -std=gnu99 -analyzer-store=region -verify %s
// The store for 'a[1]' should not be removed mistakenly. SymbolicRegions may
// RUN: %clang --analyze %s -o %t -Xclang -verify
// Test handling of ObjC bool literals.
// PR 4164: http://llvm.org/bugs/show_bug.cgi?id=4164
//
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core %s -analyzer-store=region -verify
typedef int bar_return_t;
// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-constraints=range -analyzer-store=region -verify %s
// This test case mainly checks that the retain/release checker doesn't crash
// on this file.
// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -verify -Wno-objc-root-class %s
typedef struct Foo { int x; } Bar;
// RUN: %clang_cc1 -analyze -analyzer-checker=unix,core,alpha.security.taint -w -verify %s
// Make sure we don't crash when someone redefines a system function we reason about.
// This test case simply should not crash. It evaluates the logic of not
// using MemRegion::getRValueType in incorrect places.
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s
int printf(const char *restrict,...);
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=security.insecureAPI,security.FloatLoopCounter %s -verify
// This file complements 'security-syntax-checks.m', but tests that we omit
// specific checks on platforms where they don't make sense.
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -Wno-objc-root-class %s
// Test reasoning about static locals in ObjCMethods.
int *getValidPtr();
// Testing core functionality of the SValBuilder.
// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify
typedef struct _FILE FILE;
typedef __typeof(sizeof(int)) size_t;
#import <stdarg.h>
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -analyzer-constraints=range %s -verify
//===-- unions-region.m ---------------------------------------------------===//
// RUN: %clang_cc1 -analyze -analyzer-checker=core %s -verify
namespace PR14054_reduced {
struct Definition;
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace N1 {
struct X { };
// C++0x [basic.lookup.classref]p3:
// If the unqualified-id is ~type-name, the type-name is looked up in the
// RUN: %clang_cc1 -std=c++11 %s -verify
struct A { void f(); };
struct C { void f(); };
// This is basically paraphrased from the standard.
namespace A {
int a;
// When looking up a namespace-name in a using-directive or
// namespace-alias-definition, only namespace names are considered.
struct S {};
S E0;
struct S {
static const int f0 = 0;
// C++0x [basic.lookup.unqual]p14:
// If a variable member of a namespace is defined outside of the
typedef int f;
// Template type parameters.
typedef unsigned char T;
typedef int Int;
typedef char Char;
int main() {
}
int main(int argc, const char* const* argv) {
int *use_new(int N) {
return new int [N];
namespace std {
class bad_alloc { };
// PR12497
namespace test0 {
// RUN: %clang_cc1 %s -fsyntax-only -verify
// "During the lookup for a base class name, non-type names are ignored"
namespace PR5840 {
// Make sure that friend declarations don't introduce ambiguous
// declarations.
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
class AInner {
// C++0x [class.nest] p3:
// If class X is defined in a namespace scope, a nested class Y may be
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
namespace Test1 {
class A final { };
class Trivial { int n; void f(); };
class NonTrivial1 { NonTrivial1(const NonTrivial1 &); };
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding -fshort-wchar %s
#include <stdint.h>
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
enum X : short { A, B };
extern decltype(+A) x;
namespace pr7801 {
extern void* x[];
bool is_char_ptr( const char* );
// PR8430
namespace N {
namespace ns0 {
// C++03 [namespace.udecl]p3:
// For the purpose of overload resolution, the functions which are
// <rdar://problem/8296180>
typedef int pid_t;
// PR5787
class C {
int g(int);
int i;
char x1[]("hello");
extern char x1[6];
void point(int = 3, int = 4);
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
template<typename T> struct identity;
template<typename ...Types> struct tuple;
template<typename T, typename U>
struct is_same {
namespace pr6200 {
struct v {};
void f() &;
// PR10087: Make sure that we don't conflate exception specifications
// from different functions in the canonical type system.
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
// This is the "let the user shoot himself in the foot" clause.
void f() noexcept {
struct Y : X { };
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-c++11-narrowing -verify %s
// <rdar://problem/11121178>
void f(int x) {
// The result of the expression const_cast<T>(v) is of type T. If T is
// an lvalue reference to object type, the result is an lvalue; if T
// RUN: %clang_cc1 -verify -fsyntax-only %s
template<typename T> struct Node {
int lhs;
// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to
// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3).