A significant number of our tests in C accidentally use functions

without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the ninth batch of tests being updated (there are a
significant number of other tests left to be updated).
This commit is contained in:
Aaron Ballman 2022-02-13 08:02:46 -05:00
parent d462e64754
commit 1ea584377e
365 changed files with 1906 additions and 1906 deletions

View File

@ -561,7 +561,7 @@
<key>type</key><string>Improper use of &apos;dispatch_once&apos;</string>
<key>check_name</key><string>osx.API</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>173fbcac3fc64dbaec32768d4cfda250</string>
<key>issue_hash_content_of_line_in_context</key><string>3c7c4524233ba46b615e7c4c2ce7c20d</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test_dispatch_once</string>
<key>issue_hash_function_offset</key><string>2</string>
@ -1473,7 +1473,7 @@
<key>type</key><string>Improper use of &apos;dispatch_once&apos;</string>
<key>check_name</key><string>osx.API</string>
<!-- This hash is experimental and going to change! -->
<key>issue_hash_content_of_line_in_context</key><string>8ded1f2025c1e4a4bcd5302dc97006d9</string>
<key>issue_hash_content_of_line_in_context</key><string>6fec229f3dde6d311481c6a64eeffefa</string>
<key>issue_context_kind</key><string>function</string>
<key>issue_context</key><string>test_dispatch_once_in_macro</string>
<key>issue_hash_function_offset</key><string>2</string>

View File

@ -5,7 +5,7 @@
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
// REQUIRES: asserts
void escapes() {
void escapes(void) {
// CHECK: <td align="left"><b>Store: </b> <font color="gray">(0x{{[0-9a-f]*}})</font></td>
// CHECK-SAME: <td align="left">foo</td><td align="left">0</td>
// CHECK-SAME: <td align="left">&amp;Element\{"foo",0 S64b,char\}</td>

View File

@ -1,5 +1,5 @@
#define NULL 0
void *foo() {
void *foo(void) {
return NULL;
}

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
void clang_analyzer_printState();
void clang_analyzer_printState(void);
void test_disequality_info(int e0, int b0, int b1, int c0) {
int e1 = e0 - b0;

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 \
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
void clang_analyzer_printState();
void clang_analyzer_printState(void);
void test_equivalence_classes(int a, int b, int c, int d) {
if (a + b != c)

View File

@ -6,8 +6,8 @@
void clang_analyzer_dump(int x);
void clang_analyzer_dump_pointer(int *p);
void clang_analyzer_printState();
void clang_analyzer_numTimesReached();
void clang_analyzer_printState(void);
void clang_analyzer_numTimesReached(void);
void foo(int x) {
clang_analyzer_dump(x); // expected-warning{{reg_$0<int x>}}

View File

@ -2,9 +2,9 @@
void clang_analyzer_eval(int);
unsigned foo();
unsigned foo(void);
typedef struct bf { unsigned x:2; } bf;
void bar() {
void bar(void) {
bf y;
*(unsigned*)&y = foo();
y.x = 1;
@ -14,7 +14,7 @@ struct s {
int n;
};
void f() {
void f(void) {
struct s a;
int *p = &(a.n) + 1; // expected-warning{{Pointer arithmetic on}}
}
@ -24,7 +24,7 @@ typedef struct {
} Point;
Point getit(void);
void test() {
void test(void) {
Point p;
(void)(p = getit()).x;
}
@ -34,7 +34,7 @@ void test() {
typedef _Bool bool;
void testLazyCompoundVal() {
void testLazyCompoundVal(void) {
Point p = {42, 0};
Point q;
clang_analyzer_eval((q = p).x == 42); // expected-warning{{TRUE}}
@ -58,7 +58,7 @@ struct Bits {
} inner;
};
void testBitfields() {
void testBitfields(void) {
struct Bits bits;
if (foo() && bits.b) // expected-warning {{garbage}}
@ -89,7 +89,7 @@ void testBitfields() {
if (foo() && bits.inner.f) // expected-warning {{garbage}}
return;
extern struct InnerBits getInner();
extern struct InnerBits getInner(void);
bits.inner = getInner();
if (foo() && bits.inner.e) // no-warning
@ -117,7 +117,7 @@ void testBitfields() {
// Incorrect behavior
//-----------------------------------------------------------------------------
void testTruncation() {
void testTruncation(void) {
struct Bits bits;
bits.c = 0x11; // expected-warning{{implicit truncation}}
// FIXME: We don't model truncation of bitfields.

View File

@ -22,7 +22,7 @@ void *alloca(size_t size);
void *malloc(size_t size);
void free(void *ptr);
void test_incomplete_array_fam() {
void test_incomplete_array_fam(void) {
typedef struct FAM {
char c;
int data[];
@ -48,7 +48,7 @@ void test_incomplete_array_fam() {
free(q);
}
void test_zero_length_array_fam() {
void test_zero_length_array_fam(void) {
typedef struct FAM {
char c;
int data[0];
@ -74,7 +74,7 @@ void test_zero_length_array_fam() {
free(q);
}
void test_single_element_array_possible_fam() {
void test_single_element_array_possible_fam(void) {
typedef struct FAM {
char c;
int data[1];

View File

@ -8,7 +8,7 @@
/* A lexical scanner generated by flex */
void clang_analyzer_warnIfReached();
void foo() {
void clang_analyzer_warnIfReached(void);
void foo(void) {
clang_analyzer_warnIfReached(); // conditional-warning {{REACHABLE}}
}

View File

@ -10,21 +10,21 @@ typedef __typeof(sizeof(int)) size_t;
void free(void *);
void *alloca(size_t);
void t1 () {
void t1 (void) {
int a[] = { 1 };
free(a);
// expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object 'a'}}
}
void t2 () {
void t2 (void) {
int a = 1;
free(&a);
// expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object 'a'}}
}
void t3 () {
void t3 (void) {
static int a[] = { 1 };
free(a);
// expected-warning@-1{{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}
@ -35,12 +35,12 @@ void t4 (char *x) {
free(x); // no-warning
}
void t5 () {
extern char *ptr();
void t5 (void) {
extern char *ptr(void);
free(ptr()); // no-warning
}
void t6 () {
void t6 (void) {
free((void*)1000);
// expected-warning@-1{{Argument to free() is a constant address (1000), which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object '(void *)1000'}}
@ -55,30 +55,30 @@ void t8 (char **x) {
free((*x)+8); // no-warning
}
void t9 () {
void t9 (void) {
label:
free(&&label);
// expected-warning@-1{{Argument to free() is the address of the label 'label', which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object 'label'}}
}
void t10 () {
void t10 (void) {
free((void*)&t10);
// expected-warning@-1{{Argument to free() is the address of the function 't10', which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object 't10'}}
}
void t11 () {
void t11 (void) {
char *p = (char*)alloca(2);
free(p); // expected-warning {{Memory allocated by alloca() should not be deallocated}}
}
void t12 () {
void t12 (void) {
char *p = (char*)__builtin_alloca(2);
free(p); // expected-warning {{Memory allocated by alloca() should not be deallocated}}
}
void t13 () {
void t13 (void) {
free(^{return;});
// expected-warning@-1{{Argument to free() is a block, which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object: block expression}}
@ -91,7 +91,7 @@ void t14 (char a) {
}
static int someGlobal[2];
void t15 () {
void t15 (void) {
free(someGlobal);
// expected-warning@-1{{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}
// expected-warning@-2{{attempt to call free on non-heap object 'someGlobal'}}

View File

@ -29,7 +29,7 @@ void bad2(void) {
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
}
void bad3() {
void bad3(void) {
spin_lock_init(&mtx1);
if (spin_trylock(&mtx1) != 0)
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
@ -42,14 +42,14 @@ void bad4(void) {
spin_unlock(&mtx2);
}
void good() {
void good(void) {
spin_lock_t mtx;
spin_lock_init(&mtx);
spin_lock_save(&mtx, 0, 0);
spin_unlock_restore(&mtx, 0, 0);
}
void good2() {
void good2(void) {
spin_lock_t mtx;
spin_lock_init(&mtx);
if (spin_trylock(&mtx) == 0)
@ -78,7 +78,7 @@ void bad12(void) {
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
}
void bad13() {
void bad13(void) {
sync_mutex_unlock(&smtx1);
if (sync_mutex_trylock(&smtx1) != 0)
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
@ -91,13 +91,13 @@ void bad14(void) {
sync_mutex_unlock(&smtx2);
}
void good11() {
void good11(void) {
sync_mutex_t mtx;
if (sync_mutex_trylock(&mtx) == 0)
sync_mutex_unlock(&mtx);
}
void good12() {
void good12(void) {
sync_mutex_t mtx;
if (sync_mutex_timedlock(&mtx, 0) == 0)
sync_mutex_unlock(&mtx);

View File

@ -3,7 +3,7 @@
typedef int spin_lock_t;
void spin_lock(spin_lock_t *lock);
int getCond();
int getCond(void);
int spin_trylock(spin_lock_t *lock) {
if (getCond())
return 0;
@ -12,7 +12,7 @@ int spin_trylock(spin_lock_t *lock) {
void spin_unlock(spin_lock_t *lock);
spin_lock_t mtx;
void no_crash() {
void no_crash(void) {
if (spin_trylock(&mtx) == 0)
spin_unlock(&mtx);
}

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
void f(void) {
void (*p)(void);
@ -13,7 +13,7 @@ void f(void) {
void g(void (*fp)(void));
void f2() {
void f2(void) {
g(f);
}
@ -27,7 +27,7 @@ void f3(void (*f)(void), void (*g)(void)) {
clang_analyzer_eval(!g); // expected-warning{{FALSE}}
}
void nullFunctionPointerConstant() {
void nullFunctionPointerConstant(void) {
void (*f)(void) = 0;
f(); // expected-warning{{Called function pointer is null}}
clang_analyzer_warnIfReached(); // no-warning

View File

@ -11,10 +11,10 @@ typedef signed char BOOL;
typedef int dispatch_semaphore_t;
typedef int dispatch_group_t;
typedef void (^block_t)();
typedef void (^block_t)(void);
dispatch_semaphore_t dispatch_semaphore_create(int);
dispatch_group_t dispatch_group_create();
dispatch_group_t dispatch_group_create(void);
void dispatch_group_enter(dispatch_group_t);
void dispatch_group_leave(dispatch_group_t);
void dispatch_group_wait(dispatch_group_t, int);
@ -26,9 +26,9 @@ void dispatch_semaphore_signal(dispatch_semaphore_t);
void func(void (^)(void));
void func_w_typedef(block_t);
int coin();
int coin(void);
void use_semaphor_antipattern() {
void use_semaphor_antipattern(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
func(^{
@ -39,7 +39,7 @@ void use_semaphor_antipattern() {
// It's OK to use pattern in tests.
// We simply match the containing function name against ^test.
void test_no_warning() {
void test_no_warning(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
func(^{
@ -48,7 +48,7 @@ void test_no_warning() {
dispatch_semaphore_wait(sema, 100);
}
void use_semaphor_antipattern_multiple_times() {
void use_semaphor_antipattern_multiple_times(void) {
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
func(^{
@ -64,7 +64,7 @@ void use_semaphor_antipattern_multiple_times() {
dispatch_semaphore_wait(sema2, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void use_semaphor_antipattern_multiple_wait() {
void use_semaphor_antipattern_multiple_wait(void) {
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
func(^{
@ -75,7 +75,7 @@ void use_semaphor_antipattern_multiple_wait() {
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void warn_incorrect_order() {
void warn_incorrect_order(void) {
// FIXME: ASTMatchers do not allow ordered matching, so would match even
// if out of order.
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
@ -86,7 +86,7 @@ void warn_incorrect_order() {
});
}
void warn_w_typedef() {
void warn_w_typedef(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
func_w_typedef(^{
@ -95,7 +95,7 @@ void warn_w_typedef() {
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void warn_nested_ast() {
void warn_nested_ast(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
if (coin()) {
@ -110,7 +110,7 @@ void warn_nested_ast() {
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void use_semaphore_assignment() {
void use_semaphore_assignment(void) {
dispatch_semaphore_t sema;
sema = dispatch_semaphore_create(0);
@ -120,7 +120,7 @@ void use_semaphore_assignment() {
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void use_semaphore_assignment_init() {
void use_semaphore_assignment_init(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
sema = dispatch_semaphore_create(1);
@ -130,7 +130,7 @@ void use_semaphore_assignment_init() {
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
}
void differentsemaphoreok() {
void differentsemaphoreok(void) {
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
dispatch_semaphore_t sema2 = dispatch_semaphore_create(0);
@ -140,25 +140,25 @@ void differentsemaphoreok() {
dispatch_semaphore_wait(sema2, 100); // no-warning
}
void nosignalok() {
void nosignalok(void) {
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
dispatch_semaphore_wait(sema1, 100);
}
void nowaitok() {
void nowaitok(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
func(^{
dispatch_semaphore_signal(sema);
});
}
void noblockok() {
void noblockok(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
dispatch_semaphore_signal(sema);
dispatch_semaphore_wait(sema, 100);
}
void storedblockok() {
void storedblockok(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
block_t b = ^{
dispatch_semaphore_signal(sema);
@ -173,7 +173,7 @@ void passed_semaphore_ok(dispatch_semaphore_t sema) {
dispatch_semaphore_wait(sema, 100);
}
void warn_with_cast() {
void warn_with_cast(void) {
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
func(^{

View File

@ -81,9 +81,9 @@ __attribute__((objc_root_class))
@interface UnrelatedType : NSObject<NSCopying>
@end
int getUnknown();
NSArray *getStuff();
NSArray *getTypedStuff() {
int getUnknown(void);
NSArray *getStuff(void);
NSArray *getTypedStuff(void) {
NSArray<NSNumber *> *c = getStuff();
return c;
}
@ -107,7 +107,7 @@ void incompatibleTypesErased(NSArray *a, NSMutableArray<NSString *> *b,
[d addObject: [[NSNumber alloc] init]]; // expected-warning {{Conversion from value of type 'NSNumber *' to incompatible type 'NSString *'}}
}
void crossProceduralErasedTypes() {
void crossProceduralErasedTypes(void) {
NSArray<NSString *> *a = getTypedStuff(); // expected-warning {{Conversion}}
}
@ -263,7 +263,7 @@ void InferenceFromAPIWithBuggyTypes4(__kindof NSArray<NSString *> *a) {
withMutArrMutableString(b); // expected-warning {{Conversion}}
}
NSArray<NSString *> *getStrings();
NSArray<NSString *> *getStrings(void);
void enforceDynamicRulesInsteadOfStatic(NSArray<NSNumber *> *a) {
NSArray *b = a;
// Valid uses of NSArray of NSNumbers.
@ -305,13 +305,13 @@ void findMethodDeclInTrackedType2(__kindof NSArray<NSString *> *a,
}
}
void testUnannotatedLiterals() {
void testUnannotatedLiterals(void) {
// ObjCArrayLiterals are not specialized in the AST.
NSArray *arr = @[@"A", @"B"];
[arr contains: [[NSNumber alloc] init]];
}
void testAnnotatedLiterals() {
void testAnnotatedLiterals(void) {
NSArray<NSString *> *arr = @[@"A", @"B"];
NSArray *arr2 = arr;
[arr2 contains: [[NSNumber alloc] init]];
@ -322,7 +322,7 @@ void nonExistentMethodDoesNotCrash(id a, MutableArray<NSMutableString *> *b) {
[a nonExistentMethod];
}
void trackedClassVariables() {
void trackedClassVariables(void) {
Class c = [NSArray<NSString *> class];
NSArray<NSNumber *> *a = [c getEmpty]; // expected-warning {{Conversion}}
a = [c getEmpty2]; // expected-warning {{Conversion}}

View File

@ -7,7 +7,7 @@ void clang_analyzer_eval(int);
// Test that system header does not invalidate the internal global.
int size_rdar9373039 = 1;
int rdar9373039() {
int rdar9373039(void) {
int x;
int j = 0;
@ -24,8 +24,8 @@ int rdar9373039() {
}
// Test stdin does not get invalidated by a system call nor by an internal call.
void foo();
int stdinTest() {
void foo(void);
int stdinTest(void) {
int i = 0;
fscanf(stdin, "%d", &i);
foo();
@ -36,7 +36,7 @@ int stdinTest() {
}
// Test errno gets invalidated by a system call.
int testErrnoSystem() {
int testErrnoSystem(void) {
int i;
int *p = 0;
fscanf(stdin, "%d", &i);
@ -51,7 +51,7 @@ int testErrnoSystem() {
}
// Test that errno gets invalidated by internal calls.
int testErrnoInternal() {
int testErrnoInternal(void) {
int i;
int *p = 0;
fscanf(stdin, "%d", &i);
@ -64,14 +64,14 @@ int testErrnoInternal() {
// Test that const integer does not get invalidated.
const int x = 0;
int constIntGlob() {
int constIntGlob(void) {
const int *m = &x;
foo();
return 3 / *m; // expected-warning {{Division by zero}}
}
extern const int y;
int constIntGlobExtern() {
int constIntGlobExtern(void) {
if (y == 0) {
foo();
return 5 / y; // expected-warning {{Division by zero}}
@ -80,20 +80,20 @@ int constIntGlobExtern() {
}
static void * const ptr = 0;
void constPtrGlob() {
void constPtrGlob(void) {
clang_analyzer_eval(ptr == 0); // expected-warning{{TRUE}}
foo();
clang_analyzer_eval(ptr == 0); // expected-warning{{TRUE}}
}
static const int x2 = x;
void constIntGlob2() {
void constIntGlob2(void) {
clang_analyzer_eval(x2 == 0); // expected-warning{{TRUE}}
foo();
clang_analyzer_eval(x2 == 0); // expected-warning{{TRUE}}
}
void testAnalyzerEvalIsPure() {
void testAnalyzerEvalIsPure(void) {
extern int someGlobal;
if (someGlobal == 0) {
clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}}
@ -104,7 +104,7 @@ void testAnalyzerEvalIsPure() {
// Test that static variables with initializers do not get reinitialized on
// recursive calls.
void Function2(void);
int *getPtr();
int *getPtr(void);
void Function1(void) {
static unsigned flag;
static int *p = 0;

View File

@ -24,7 +24,7 @@ gpointer g_memdup(gconstpointer mem, guint byte_size);
static const gsize n_bytes = 1024;
void f1() {
void f1(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -43,7 +43,7 @@ void f1() {
g_free(g2); // expected-warning{{Attempt to free released memory}}
}
void f2() {
void f2(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -63,7 +63,7 @@ void f2() {
g3 = g_memdup(g3, n_bytes); // expected-warning{{Use of memory after it is freed}}
}
void f3() {
void f3(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -82,7 +82,7 @@ void f3() {
g_free(g3);
}
void f4() {
void f4(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -102,7 +102,7 @@ void f4() {
g_free(g4);
}
void f5() {
void f5(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -123,7 +123,7 @@ void f5() {
g_free(g5);
}
void f6() {
void f6(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);
@ -145,7 +145,7 @@ void f6() {
g_free(g6);
}
void f7() {
void f7(void) {
gpointer g1 = g_malloc(n_bytes);
gpointer g2 = g_malloc0(n_bytes);
g1 = g_realloc(g1, n_bytes * 2);

View File

@ -11,7 +11,7 @@ extern void __assert_fail(__const char *__assertion, __const char *__file,
void clang_analyzer_eval(int);
int g();
int g(void);
int f(int y) {
return y + g();

View File

@ -6,7 +6,7 @@
#include "html-diag-singlefile.h"
int main(){
int main(void){
f();
return 0;
}

View File

@ -1,4 +1,4 @@
static void f() {
static void f(void) {
int *p = 0;
*p = 1; // expected-warning{{Dereference of null pointer}}
}

View File

@ -1,5 +1,5 @@
#include "html-diags-multifile.h"
void test_call_macro() {
void test_call_macro(void) {
has_bug(0);
}

View File

@ -9,7 +9,7 @@
#define CALL_HAS_BUG(q) has_bug(q)
void test_call_macro() {
void test_call_macro(void) {
CALL_HAS_BUG(0);
}

View File

@ -27,6 +27,6 @@ void has_bug(int *p) {
#define CALL_HAS_BUG(q) has_bug(q)
void test_call_macro() {
void test_call_macro(void) {
CALL_HAS_BUG(0);
}

View File

@ -1,4 +1,4 @@
int f() {
int f(void) {
int zzz = 200;
zzz += 100;
return 0;

View File

@ -6,7 +6,7 @@
void bar(int);
void foo() {
void foo(void) {
int a;
bar(a); // expected-warning{{1st function call argument is an uninitialized value}}
}

View File

@ -8,7 +8,7 @@ void bar(int);
#define MACRO if (b)
void foo2() {
void foo2(void) {
int a;
int b = 1;
MACRO

View File

@ -6,7 +6,7 @@
void bar(int);
void foo() {
void foo(void) {
int a;
for (unsigned i = 0; i < 3; ++i)
if (i)

View File

@ -6,7 +6,7 @@
void bar(int);
void foo2() {
void foo2(void) {
int a;
int b = 1;
if (b)

View File

@ -8,7 +8,7 @@
#define X86_ARRAY_SIZE (UINT_MAX/2 + 4)
void testIndexTooBig() {
void testIndexTooBig(void) {
char arr[X86_ARRAY_SIZE];
char *ptr = arr + UINT_MAX/2;
ptr += 2; // index shouldn't overflow
@ -19,7 +19,7 @@ void testIndexTooBig() {
#define ARRAY_SIZE 0x100000000
void testIndexOverflow64() {
void testIndexOverflow64(void) {
char arr[ARRAY_SIZE];
char *ptr = arr + UINT_MAX/2;
ptr += 2; // don't overflow 64-bit index
@ -29,7 +29,7 @@ void testIndexOverflow64() {
#define ULONG_MAX (~0ul)
#define BIG_INDEX (ULONG_MAX/16)
void testIndexTooBig64() {
void testIndexTooBig64(void) {
char arr[ULONG_MAX/8-1];
char *ptr = arr + BIG_INDEX;
ptr += 2; // don't overflow 64-bit index
@ -42,16 +42,16 @@ static unsigned size;
static void * addr;
static unsigned buf[SIZE];
void testOutOfBounds() {
void testOutOfBounds(void) {
// Not out of bounds.
buf[SIZE-1] = 1; // no-warning
}
void testOutOfBoundsCopy1() {
void testOutOfBoundsCopy1(void) {
memcpy(buf, addr, size); // no-warning
}
void testOutOfBoundsCopy2() {
void testOutOfBoundsCopy2(void) {
memcpy(addr, buf, size); // no-warning
}

View File

@ -2,13 +2,13 @@
void clang_analyzer_eval(int);
void initbug() {
void initbug(void) {
const union { float a; } u = {};
(void)u.a; // no-crash
}
int const parr[2] = {1};
void constarr() {
void constarr(void) {
int i = 2;
clang_analyzer_eval(parr[i]); // expected-warning{{UNDEFINED}}
i = 1;
@ -22,13 +22,13 @@ struct SM {
int b;
};
const struct SM sm = {.a = 1};
void multinit() {
void multinit(void) {
clang_analyzer_eval(sm.a == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(sm.b == 0); // expected-warning{{TRUE}}
}
const int glob_arr1[6] = {[2] = 3, [0] = 1, [1] = 2, [3] = 4};
void glob_array_index1() {
void glob_array_index1(void) {
clang_analyzer_eval(glob_arr1[0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr1[1] == 2); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr1[2] == 3); // expected-warning{{TRUE}}
@ -37,7 +37,7 @@ void glob_array_index1() {
clang_analyzer_eval(glob_arr1[5] == 0); // expected-warning{{TRUE}}
}
void glob_array_index2() {
void glob_array_index2(void) {
const int *ptr = glob_arr1;
clang_analyzer_eval(ptr[0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(ptr[1] == 2); // expected-warning{{TRUE}}
@ -47,19 +47,19 @@ void glob_array_index2() {
clang_analyzer_eval(ptr[5] == 0); // expected-warning{{TRUE}}
}
void glob_invalid_index1() {
void glob_invalid_index1(void) {
int x = -42;
int res = glob_arr1[x]; // expected-warning{{garbage or undefined}}
}
void glob_invalid_index2() {
void glob_invalid_index2(void) {
const int *ptr = glob_arr1;
int x = 42;
int res = ptr[x]; // expected-warning{{garbage or undefined}}
}
const int glob_arr2[3][3] = {[0][0] = 1, [1][1] = 5, [2][0] = 7};
void glob_arr_index3() {
void glob_arr_index3(void) {
clang_analyzer_eval(glob_arr2[0][0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr2[0][1] == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr2[0][2] == 0); // expected-warning{{TRUE}}
@ -71,7 +71,7 @@ void glob_arr_index3() {
clang_analyzer_eval(glob_arr2[2][2] == 0); // expected-warning{{TRUE}}
}
void negative_index() {
void negative_index(void) {
int x = 2, y = -2;
clang_analyzer_eval(glob_arr2[x][y] == 5); // expected-warning{{UNDEFINED}}
x = 3;
@ -79,37 +79,37 @@ void negative_index() {
clang_analyzer_eval(glob_arr2[x][y] == 7); // expected-warning{{UNDEFINED}}
}
void glob_invalid_index3() {
void glob_invalid_index3(void) {
int x = -1, y = -1;
int res = glob_arr2[x][y]; // expected-warning{{garbage or undefined}}
}
void glob_invalid_index4() {
void glob_invalid_index4(void) {
int x = 3, y = 2;
int res = glob_arr2[x][y]; // expected-warning{{garbage or undefined}}
}
const int glob_arr_no_init[10];
void glob_arr_index4() {
void glob_arr_index4(void) {
// FIXME: Should warn {{FALSE}}, since the array has a static storage.
clang_analyzer_eval(glob_arr_no_init[2]); // expected-warning{{UNKNOWN}}
}
const int glob_arr3[]; // IncompleteArrayType
const int glob_arr3[4] = {1, 2, 3}; // ConstantArrayType
void glob_arr_index5() {
void glob_arr_index5(void) {
clang_analyzer_eval(glob_arr3[0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr3[1] == 2); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr3[2] == 3); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr3[3] == 0); // expected-warning{{TRUE}}
}
void glob_invalid_index5() {
void glob_invalid_index5(void) {
int x = 42;
int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
}
void glob_invalid_index6() {
void glob_invalid_index6(void) {
int x = -42;
int res = glob_arr3[x]; // expected-warning{{garbage or undefined}}
}
@ -117,19 +117,19 @@ void glob_invalid_index6() {
const int glob_arr4[]; // IncompleteArrayType
const int glob_arr4[4] = {1, 2, 3}; // ConstantArrayType
const int glob_arr4[]; // ConstantArrayType (according to AST)
void glob_arr_index6() {
void glob_arr_index6(void) {
clang_analyzer_eval(glob_arr4[0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr4[1] == 2); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr4[2] == 3); // expected-warning{{TRUE}}
clang_analyzer_eval(glob_arr4[3] == 0); // expected-warning{{TRUE}}
}
void glob_invalid_index7() {
void glob_invalid_index7(void) {
int x = 42;
int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
}
void glob_invalid_index8() {
void glob_invalid_index8(void) {
int x = -42;
int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
}

View File

@ -5,25 +5,25 @@ void foo(int *x, ...) {
*x = 1;
}
void bar() {
void bar(void) {
foo(0, 2); // no-warning
}
// For now, don't inline vararg blocks.
void (^baz)(int *x, ...) = ^(int *x, ...) { *x = 1; };
void taz() {
void taz(void) {
baz(0, 2); // no-warning
}
// For now, don't inline global blocks.
void (^qux)(int *p) = ^(int *p) { *p = 1; };
void test_qux() {
void test_qux(void) {
qux(0); // no-warning
}
void test_analyzer_is_running() {
void test_analyzer_is_running(void) {
int *p = 0;
*p = 0xDEADBEEF; // expected-warning {{null}}
}

View File

@ -23,7 +23,7 @@ void has_bug(int *p) {
*p = 0xDEADBEEF; // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} expected-note{{Dereference of null pointer (loaded from variable 'p')}}
}
void test_has_bug() {
void test_has_bug(void) {
has_bug(0);
// expected-note@-1 {{Passing null pointer value via 1st parameter 'p'}}
// expected-note@-2 {{Calling 'has_bug'}}
@ -55,31 +55,31 @@ void bar(int *p) {
// Test inlining of blocks.
// ========================================================================== //
void test_block__capture_null() {
void test_block__capture_null(void) {
int *p = 0; // expected-note{{'p' initialized to a null pointer value}}
^(){ // expected-note {{Calling anonymous block}}
^(void){ // 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() {
int *p = ^int*(){ // expected-note {{Calling anonymous block}} expected-note{{Returning to caller}} expected-note {{'p' initialized to a null pointer value}}
void test_block_ret(void) {
int *p = ^int*(void){ // expected-note {{Calling anonymous block}} expected-note{{Returning to caller}} expected-note {{'p' initialized to a null pointer value}}
int *q = 0; // expected-note {{'q' initialized to a null pointer value}}
return q; // expected-note {{Returning null pointer (loaded from 'q')}}
}();
*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_blockvar() {
void test_block_blockvar(void) {
__block int *p;
^(){ // expected-note{{Calling anonymous block}} expected-note{{Returning to caller}}
^(void){ // expected-note{{Calling anonymous block}} expected-note{{Returning to caller}}
p = 0; // expected-note{{Null pointer value stored to 'p'}}
}();
*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_arg() {
void test_block_arg(void) {
int *p;
^(int **q){ // expected-note{{Calling anonymous block}} expected-note{{Returning to caller}}
*q = 0; // expected-note{{Null pointer value stored to 'p'}}

View File

@ -5,12 +5,12 @@ static inline bug(int *p) {
*p = 0xDEADBEEF;
}
void test_bug_1() {
void test_bug_1(void) {
int *p = 0;
bug(p);
}
void test_bug_2() {
void test_bug_2(void) {
int *p = 0;
bug(p);
}

View File

@ -3,14 +3,14 @@
void clang_analyzer_eval(int);
void clang_analyzer_checkInlined(int);
int test1_f1() {
int test1_f1(void) {
int y = 1;
y++;
clang_analyzer_checkInlined(1); // expected-warning{{TRUE}}
return y;
}
void test1_f2() {
void test1_f2(void) {
int x = 1;
x = test1_f1();
if (x == 1) {
@ -26,9 +26,9 @@ void test1_f2() {
// Test that inlining works when the declared function has less arguments
// than the actual number in the declaration.
void test2_f1() {}
int test2_f2();
int test2_f2(void);
void test2_f3() {
void test2_f3(void) {
test2_f1(test2_f2()); // expected-warning{{too many arguments in call to 'test2_f1'}}
}
@ -40,7 +40,7 @@ unsigned factorial(unsigned x) {
return x * factorial(x - 1);
}
void test_factorial() {
void test_factorial(void) {
if (factorial(3) == 6) {
int *p = 0;
*p = 0xDEADBEEF; // expected-warning {{null}}
@ -51,7 +51,7 @@ void test_factorial() {
}
}
void test_factorial_2() {
void test_factorial_2(void) {
unsigned x = factorial(3);
if (x == factorial(3)) {
int *p = 0;
@ -69,13 +69,13 @@ static char *return_buf(char *buf) {
return buf + 10;
}
void test_return_stack_memory_ok() {
void test_return_stack_memory_ok(void) {
char stack_buf[100];
char *pos = return_buf(stack_buf);
(void) pos;
}
char *test_return_stack_memory_bad() {
char *test_return_stack_memory_bad(void) {
char stack_buf[100];
char *x = stack_buf;
return x; // expected-warning {{stack memory associated}}
@ -86,7 +86,7 @@ char *test_return_stack_memory_bad() {
struct rdar10977037 { int x, y; };
int test_rdar10977037_aux(struct rdar10977037 v) { return v.y; }
int test_rdar10977037_aux_2(struct rdar10977037 v);
int test_rdar10977037() {
int test_rdar10977037(void) {
struct rdar10977037 v;
v.y = 1;
v. y += test_rdar10977037_aux(v); // no-warning
@ -97,7 +97,7 @@ int test_rdar10977037() {
// Test inlining a forward-declared function.
// This regressed when CallEvent was first introduced.
int plus1(int x);
void test() {
void test(void) {
clang_analyzer_eval(plus1(2) == 3); // expected-warning{{TRUE}}
}
@ -106,13 +106,13 @@ int plus1(int x) {
}
void never_called_by_anyone() {
void never_called_by_anyone(void) {
clang_analyzer_checkInlined(0); // no-warning
}
void knr_one_argument(a) int a; { }
void call_with_less_arguments() {
void call_with_less_arguments(void) {
knr_one_argument(); // expected-warning{{too few arguments}} expected-warning{{Function taking 1 argument is called with fewer (0)}}
}

View File

@ -9,7 +9,7 @@ int f1(int a) {
return 1;
}
void f2() {
void f2(void) {
int x;
x = f1(1);
}

View File

@ -5,11 +5,11 @@
// Otherwise, block-level expr '1 && a' would not be block-level.
int a;
void f1() {
void f1(void) {
if (1 && a)
return;
}
void f2() {
void f2(void) {
f1();
}

View File

@ -68,7 +68,7 @@ typedef struct objc_object {
@interface AAA (MyCat)
+ (int)getInt;
@end
int foo() {
int foo(void) {
int y = [AAA getInt];
return 5/y; // expected-warning {{Division by zero}}
}
@ -88,7 +88,7 @@ int foo() {
@end
@interface CCC : PPP
@end
int foo4() {
int foo4(void) {
int y = [CCC getInt];
return 5/y; // expected-warning {{Division by zero}}
}
@ -182,7 +182,7 @@ int foo4() {
return 5/y; // expected-warning{{Division by zero}}
}
@end
int foo2() {
int foo2(void) {
int y = [MyParentSelf testSelf];
return 5/y; // expected-warning{{Division by zero}}
}
@ -214,7 +214,7 @@ int foo2() {
return [super foo];
}
@end
int checkSelfUsedInparentClassMethod() {
int checkSelfUsedInparentClassMethod(void) {
return 5/[SelfUsedInParentChild fooA];
}
@ -222,7 +222,7 @@ int checkSelfUsedInparentClassMethod() {
@interface Rdar15037033 : NSObject
@end
void rdar15037033() {
void rdar15037033(void) {
[Rdar15037033 forwardDeclaredMethod]; // expected-warning {{class method '+forwardDeclaredMethod' not found}}
[Rdar15037033 forwardDeclaredVariadicMethod:1, 2, 3, 0]; // expected-warning {{class method '+forwardDeclaredVariadicMethod:' not found}}
}

View File

@ -123,7 +123,7 @@ void randomlyMessageAnObject(MyClass *arr[], int i) {
@end
int testNonCovariantReturnType() {
int testNonCovariantReturnType(void) {
MyParent *obj = [[EvilChild alloc] init];
// Devirtualization allows us to directly call -[EvilChild getInt], but
@ -137,7 +137,7 @@ int testNonCovariantReturnType() {
return 5/(x-1); // no-warning
}
int testCovariantReturnTypeNoErrorSinceTypesMatch() {
int testCovariantReturnTypeNoErrorSinceTypesMatch(void) {
MyParent *obj = [[EvilChild alloc] init];
CFStringRef S = ((void*)0);

View File

@ -4,7 +4,7 @@
void clang_analyzer_eval(int);
PublicSubClass2 *getObj();
PublicSubClass2 *getObj(void);
@implementation PublicParent
- (int)getZeroOverridden {

View File

@ -28,7 +28,7 @@ typedef struct objc_object {
}
@end
void selfStaysLive() {
void selfStaysLive(void) {
SelfStaysLive *foo = [[SelfStaysLive alloc] init];
[foo release];
}

View File

@ -1,13 +1,13 @@
// 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();
void test1(void);
void test2() {
void test2(void) {
test1();
}
void test1() {
void test1(void) {
}
// CHECK: analysis-order.c test2

View File

@ -7,7 +7,7 @@ void use(int *ptr, int val) {
// expected-note@-1 {{Dereference of null pointer (loaded from variable 'ptr')}}
}
int compute() {
int compute(void) {
// Do something that will take enough processing to trigger trimming.
// FIXME: This is actually really sensitive. If the interval timing is just
// wrong, the node for the actual dereference may also be collected, and all
@ -15,7 +15,7 @@ int compute() {
return 2 + 3 + 4 + 5 + 6;
}
void testSimple() {
void testSimple(void) {
int *p = 0;
// expected-note@-1 {{'p' initialized to a null pointer value}}
use(p, compute());
@ -35,7 +35,7 @@ void passThrough(int *p) {
// expected-note@-2 {{Calling 'use2'}}
}
void testChainedCalls() {
void testChainedCalls(void) {
int *ptr = 0;
// expected-note@-1 {{'ptr' initialized to a null pointer value}}
passThrough(ptr);

View File

@ -3,13 +3,13 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s
int opaquePropertyCheck(void *object);
int coin();
int coin(void);
int *getNull() {
int *getNull(void) {
return 0;
}
int* getPtr();
int* getPtr(void);
int *dynCastToInt(void *ptr) {
if (opaquePropertyCheck(ptr))
@ -85,10 +85,10 @@ void testMultipleStore(void *p) {
}
// Test that div by zero does not get suppressed. This is a policy choice.
int retZero() {
int retZero(void) {
return 0;
}
int triggerDivZero () {
int triggerDivZero (void) {
int y = retZero();
return 5/y; // expected-warning {{Division by zero}}
}
@ -183,7 +183,7 @@ int testDifferentMacro(int *p) {
// "Suppression suppression"
// --------------------------
void testDynCastOrNullOfNull() {
void testDynCastOrNullOfNull(void) {
// Don't suppress when one of the arguments is NULL.
int *casted = dynCastOrNull(0);
*casted = 1;
@ -192,7 +192,7 @@ void testDynCastOrNullOfNull() {
#endif
}
void testDynCastOfNull() {
void testDynCastOfNull(void) {
// Don't suppress when one of the arguments is NULL.
int *casted = dynCastToInt(0);
*casted = 1;
@ -208,7 +208,7 @@ int *lookUpInt(int unused) {
return &x;
}
void testZeroIsNotNull() {
void testZeroIsNotNull(void) {
// /Do/ suppress when the argument is 0 (an integer).
int *casted = lookUpInt(0);
*casted = 1;
@ -217,7 +217,7 @@ void testZeroIsNotNull() {
#endif
}
void testTrackNull() {
void testTrackNull(void) {
// /Do/ suppress if the null argument came from another call returning null.
int *casted = dynCastOrNull(getNull());
*casted = 1;
@ -226,7 +226,7 @@ void testTrackNull() {
#endif
}
void testTrackNullVariable() {
void testTrackNullVariable(void) {
// /Do/ suppress if the null argument came from another call returning null.
int *ptr;
ptr = getNull();
@ -253,7 +253,7 @@ void inlinedIsDifferent(int inlined) {
#endif
}
void testInlinedIsDifferent() {
void testInlinedIsDifferent(void) {
// <rdar://problem/13787723>
inlinedIsDifferent(0);
}
@ -263,7 +263,7 @@ void testInlinedIsDifferent() {
// FALSE NEGATIVES (over-suppression)
// ---------------------------------------
void testNoArguments() {
void testNoArguments(void) {
// In this case the function has no branches, and MUST return null.
int *casted = getNull();
*casted = 1;

View File

@ -14,7 +14,7 @@
- (id)getObject;
@end
id getNil() {
id getNil(void) {
return 0;
}
@ -106,7 +106,7 @@ void testPropertyReturningNull(SomeClass *sc) {
}
@end
void testClassPropertyReturningNull() {
void testClassPropertyReturningNull(void) {
int *result = SomeClass.classPropertyReturningNull;
*result = 1;
#ifndef SUPPRESSED

View File

@ -53,7 +53,7 @@ dispatch_resume(dispatch_object_t object);
- (Foo *)getFooPtr;
@end
Foo *retNil() {
Foo *retNil(void) {
return 0;
}

View File

@ -26,9 +26,9 @@ void testCheck(int *a) {
}
int *getPointer();
int *getPointer(void);
void testInitCheck() {
void testInitCheck(void) {
int *a = getPointer();
// expected-note@-1 {{'a' initialized here}}
if (a) {
@ -53,7 +53,7 @@ void testStoreCheck(int *a) {
}
int *getZero() {
int *getZero(void) {
int *p = 0;
// expected-note@-1 + {{'p' initialized to a null pointer value}}
// ^ This note checks that we add a second visitor for the return value.
@ -61,21 +61,21 @@ int *getZero() {
// expected-note@-1 + {{Returning null pointer (loaded from 'p')}}
}
void testReturnZero() {
void testReturnZero(void) {
*getZero() = 1; // expected-warning{{Dereference of null pointer}}
// expected-note@-1 {{Calling 'getZero'}}
// expected-note@-2 {{Returning from 'getZero'}}
// expected-note@-3 {{Dereference of null pointer}}
}
int testReturnZero2() {
int testReturnZero2(void) {
return *getZero(); // expected-warning{{Dereference of null pointer}}
// expected-note@-1 {{Calling 'getZero'}}
// expected-note@-2 {{Returning from 'getZero'}}
// expected-note@-3 {{Dereference of null pointer}}
}
void testInitZero() {
void testInitZero(void) {
int *a = getZero();
// expected-note@-1 {{Calling 'getZero'}}
// expected-note@-2 {{Returning from 'getZero'}}
@ -98,7 +98,7 @@ void usePointer(int *p) {
// expected-note@-1 {{Dereference of null pointer}}
}
void testUseOfNullPointer() {
void testUseOfNullPointer(void) {
// Test the case where an argument expression is itself a call.
usePointer(getZero());
// expected-note@-1 {{Calling 'getZero'}}
@ -140,7 +140,7 @@ void test4(int **p) {
// expected-note@-1 {{Dereference of null pointer}}
}
void boringCallee() {
void boringCallee(void) {
}
void interestingCallee(int *x) {
@ -148,7 +148,7 @@ void interestingCallee(int *x) {
boringCallee(); // no-note
}
int testBoringCalleeOfInterestingCallee() {
int testBoringCalleeOfInterestingCallee(void) {
int x;
interestingCallee(&x); // expected-note{{Calling 'interestingCallee'}}
// expected-note@-1{{Returning from 'interestingCallee'}}

View File

@ -75,7 +75,7 @@ int *getZeroIfNil(Test *x) {
// expected-note@-2 {{Returning null pointer}}
}
void testReturnZeroIfNil() {
void testReturnZeroIfNil(void) {
*getZeroIfNil(0) = 1; // expected-warning{{Dereference of null pointer}}
// expected-note@-1 {{Calling 'getZeroIfNil'}}
// expected-note@-2 {{Passing nil object reference via 1st parameter 'x'}}
@ -84,7 +84,7 @@ void testReturnZeroIfNil() {
}
int testDispatchSyncInlining() {
int testDispatchSyncInlining(void) {
extern dispatch_queue_t globalQueue;
__block int x;
@ -127,7 +127,7 @@ int testDispatchSyncInliningNoPruning(int coin) {
- (int *)getPtr;
@end
id getNil() {
id getNil(void) {
return 0;
}
@ -163,7 +163,7 @@ id testCreateArrayLiteral(id myNil) {
}
// <rdar://problem/14611722>
id testAutoreleaseTakesEffectInDispatch() {
id testAutoreleaseTakesEffectInDispatch(void) {
static dispatch_once_t token = 0;
dispatch_once(&token, ^{});
@ -178,7 +178,7 @@ id testAutoreleaseTakesEffectInDispatch() {
// expected-note@-1 {{Object was autoreleased 2 times but the object has a +0 retain count}}
}
void testNullDereferenceInDispatch() {
void testNullDereferenceInDispatch(void) {
dispatch_once(0, ^{}); // no-warning, don't crash
}

View File

@ -1,7 +1,7 @@
// 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() {
int nested5(void) {
if (5 < 3)
return 0;
else
@ -9,40 +9,40 @@ int nested5() {
return 0;
return 0;
}
int nested4() {
int nested4(void) {
return nested5();
}
int nested3() {
int nested3(void) {
return nested4();
}
int nested2() {
int nested2(void) {
return nested3();
}
int nested1() {
int nested1(void) {
return nested2();
}
void testNested() {
void testNested(void) {
clang_analyzer_eval(nested1() == 0); // expected-warning{{TRUE}}
}
// Make sure we terminate a recursive path.
int recursive() {
int recursive(void) {
return recursive();
}
int callRecursive() {
int callRecursive(void) {
return recursive();
}
int mutuallyRecursive1();
int mutuallyRecursive1(void);
int mutuallyRecursive2() {
int mutuallyRecursive2(void) {
return mutuallyRecursive1();
}
int mutuallyRecursive1() {
int mutuallyRecursive1(void) {
return mutuallyRecursive2();
}
int callMutuallyRecursive() {
int callMutuallyRecursive(void) {
return mutuallyRecursive1();
}

View File

@ -81,4 +81,4 @@
// expected-no-diagnostics
int main() {}
int main(void) {}

View File

@ -77,4 +77,4 @@
// expected-no-diagnostics
int main() {}
int main(void) {}

View File

@ -94,4 +94,4 @@
// expected-no-diagnostics
int main() {}
int main(void) {}

View File

@ -2,7 +2,7 @@
typedef unsigned uintptr_t;
void f1() {
void f1(void) {
int *p;
*p = 0; // expected-warning{{Dereference of undefined pointer value}}
}
@ -11,20 +11,20 @@ struct foo_struct {
int x;
};
int f2() {
int f2(void) {
struct foo_struct *p;
return p->x++; // expected-warning{{Access to field 'x' results in a dereference of an undefined pointer value (loaded from variable 'p')}}
}
int f3() {
int f3(void) {
char *x;
int i = 2;
return x[i + 1]; // expected-warning{{Array access (from variable 'x') results in an undefined pointer dereference}}
}
int f3_b() {
int f3_b(void) {
char *x;
int i = 2;

View File

@ -40,7 +40,7 @@ void testInvalidation(Root *obj) {
}
@end
struct S makeS();
struct S makeS(void);
@implementation ManyIvars

View File

@ -19,7 +19,7 @@ OSStatus SecKeychainItemCopyContent (
void **outData
);
void DellocWithCFStringCreate4() {
void DellocWithCFStringCreate4(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;

View File

@ -70,7 +70,7 @@ OSStatus SecKeychainItemFreeAttributesAndData (
void *data
);
void errRetVal() {
void errRetVal(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -81,7 +81,7 @@ void errRetVal() {
} // 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.
void fooDoNotReportNull() {
void fooDoNotReportNull(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 *length = 0;
@ -90,7 +90,7 @@ void fooDoNotReportNull() {
SecKeychainItemCopyContent(2, ptr, ptr, length, outData);
}// no-warning
void doubleAlloc() {
void doubleAlloc(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -102,7 +102,7 @@ void doubleAlloc() {
}
// Do not warn if undefined value is passed to a function.
void fooOnlyFreeUndef() {
void fooOnlyFreeUndef(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -116,7 +116,7 @@ void fooOnlyFreeParam(void *attrList, void* X) {
}// no-warning
// If we are returning the value, do not report.
void* returnContent() {
void* returnContent(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -235,7 +235,7 @@ int testErrorCodeAsLHS(CFTypeRef keychainOrArray, SecProtocolType protocol,
}
void free(void *ptr);
void deallocateWithFree() {
void deallocateWithFree(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -314,7 +314,7 @@ void DellocWithCFStringCreate4(CFAllocatorRef alloc) {
static CFAllocatorRef gKeychainDeallocator = 0;
static CFAllocatorRef GetKeychainDeallocator() {
static CFAllocatorRef GetKeychainDeallocator(void) {
return gKeychainDeallocator;
}
@ -331,7 +331,7 @@ CFStringRef DellocWithCFStringCreate5(CFAllocatorRef alloc) {
return 0;
}
void radar10508828() {
void radar10508828(void) {
UInt32 pwdLen = 0;
void* pwdBytes = 0;
OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
@ -340,7 +340,7 @@ void radar10508828() {
SecKeychainItemFreeContent(0, pwdBytes);
}
void radar10508828_20092614() {
void radar10508828_20092614(void) {
UInt32 pwdLen = 0;
void* pwdBytes = 0;
OSStatus rc = SecKeychainFindGenericPassword(0, 3, "foo", 3, "bar", &pwdLen, &pwdBytes, 0);
@ -386,7 +386,7 @@ OSStatus my_Allocate_Param(void** password, UInt32* passwordLength) {
return err;
}
void allocAndFree1() {
void allocAndFree1(void) {
unsigned int *ptr = 0;
OSStatus st = 0;
UInt32 length;
@ -417,7 +417,7 @@ void allocAndFree2(void *attrList) {
my_FreeParam(attrList, outData);
}
void allocNoFree3() {
void allocNoFree3(void) {
UInt32 length = 32;
void *outData;
void *outData2;
@ -441,7 +441,7 @@ typedef struct AuthorizationCallback {
OSStatus (*SetContextVal)(AuthorizationValue *inValue);
} AuthorizationCallback;
static AuthorizationCallback cb;
int radar_19196494() {
int radar_19196494(void) {
@autoreleasepool {
AuthorizationValue login_password = {};
UInt32 passwordLength;
@ -454,7 +454,7 @@ int radar_19196494() {
}
return 0;
}
int radar_19196494_v2() {
int radar_19196494_v2(void) {
@autoreleasepool {
AuthorizationValue login_password = {};
OSStatus err = SecKeychainFindGenericPassword(0, 0, "", 0, "", (UInt32 *)&login_password.length, (void**)&login_password.data, 0);

View File

@ -16,7 +16,7 @@ struct test {
void foo(struct test *);
void test_zeroed() {
void test_zeroed(void) {
struct test **list, *t;
int i;
@ -31,7 +31,7 @@ void test_zeroed() {
kfree(list); // no-warning
}
void test_nonzero() {
void test_nonzero(void) {
struct test **list, *t;
int i;
@ -126,12 +126,12 @@ void test_3arg_malloc_leak(struct malloc_type *mtp, int flags) {
// if a block of size 0 is requested
#define ZERO_SIZE_PTR ((void *)16)
void test_kfree_ZERO_SIZE_PTR() {
void test_kfree_ZERO_SIZE_PTR(void) {
void *ptr = ZERO_SIZE_PTR;
kfree(ptr); // no warning about freeing this value
}
void test_kfree_other_constant_value() {
void test_kfree_other_constant_value(void) {
void *ptr = (void *)1;
kfree(ptr); // expected-warning{{Argument to kfree() is a constant address (1)}}
}

View File

@ -5,9 +5,9 @@
@interface NSString : NSObject
- (id)lastPathComponent;
@end
int getBool();
int *getPtr();
int foo() {
int getBool(void);
int *getPtr(void);
int foo(void) {
int r = 0;
NSString *filename = @"filename";
for (int x = 0; x< 10; x++) {

View File

@ -60,7 +60,7 @@ typedef struct CGPoint CGPoint;
NSString *ForceLocalized(NSString *str)
__attribute__((annotate("returns_localized_nsstring")));
CGPoint CGPointMake(CGFloat x, CGFloat y);
int random();
int random(void);
// This next one is a made up API
NSString *CFNumberFormatterCreateStringWithNumber(float x);
+ (NSString *)forceLocalized:(NSString *)str

View File

@ -37,7 +37,7 @@
@end
@interface LocalizationTestSuite : NSObject
int random();
int random(void);
@property (assign) int unreadArticlesCount;
@end
#define MCLocalizedString(s) NSLocalizedString(s,nil);

View File

@ -40,7 +40,7 @@ void useUndef(void) { 0 || undef(); }
void testPointer(void) { (void) (1 && testPointer && 0); }
char *global_ap, *global_bp, *global_cp;
void ambiguous_backtrack_1() {
void ambiguous_backtrack_1(void) {
for (;;) {
(global_bp - global_ap ? global_cp[global_bp - global_ap] : 0) || 1;
global_bp++;

View File

@ -10,7 +10,7 @@ variable 'x' is still referred to by the stack variable 'arr' upon \
returning to the caller}}
}
void loop() {
void loop(void) {
void *arr[2];
for (int i = 0; i < 2; ++i)
callee(&arr[i]);
@ -18,7 +18,7 @@ void loop() {
clang_analyzer_eval(arr[0] == arr[1]); // expected-warning{{FALSE}}
}
void loopWithCall() {
void loopWithCall(void) {
void *arr[2];
for (int i = 0; i < 2; ++i) {
int x;

View File

@ -2,13 +2,13 @@
// RUN: %clang_analyze_cc1 -DTEST_NULL_TERM -analyzer-checker=core,unix.Malloc,debug.ExprInspection,alpha.cplusplus.IteratorRange -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify -analyzer-config eagerly-assume=false %s
void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
void loop_which_iterates_limit_times_not_widened() {
void loop_which_iterates_limit_times_not_widened(void) {
int i;
int x = 1;
// Check loop isn't widened by checking x isn't invalidated
@ -24,7 +24,7 @@ void loop_which_iterates_limit_times_not_widened() {
int a_global;
void loop_evaluated_before_widening() {
void loop_evaluated_before_widening(void) {
int i;
a_global = 1;
for (i = 0; i < 10; ++i) {
@ -36,31 +36,31 @@ void loop_evaluated_before_widening() {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void warnings_after_loop() {
void warnings_after_loop(void) {
int i;
for (i = 0; i < 10; ++i) {}
char *m = (char*)malloc(12);
} // expected-warning {{Potential leak of memory pointed to by 'm'}}
void for_loop_exits() {
void for_loop_exits(void) {
int i;
for (i = 0; i < 10; ++i) {}
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void while_loop_exits() {
void while_loop_exits(void) {
int i = 0;
while (i < 10) {++i;}
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void do_while_loop_exits() {
void do_while_loop_exits(void) {
int i = 0;
do {++i;} while (i < 10);
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void loop_body_is_widened() {
void loop_body_is_widened(void) {
int i = 0;
while (i < 100) {
if (i > 10) {
@ -71,13 +71,13 @@ void loop_body_is_widened() {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void invariably_infinite_loop() {
void invariably_infinite_loop(void) {
int i = 0;
while (1) { ++i; }
clang_analyzer_warnIfReached(); // no-warning
}
void invariably_infinite_break_loop() {
void invariably_infinite_break_loop(void) {
int i = 0;
while (1) {
++i;
@ -87,7 +87,7 @@ void invariably_infinite_break_loop() {
clang_analyzer_warnIfReached(); // no-warning
}
void reachable_break_loop() {
void reachable_break_loop(void) {
int i = 0;
while (1) {
++i;
@ -96,7 +96,7 @@ void reachable_break_loop() {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void condition_constrained_true_in_loop() {
void condition_constrained_true_in_loop(void) {
int i = 0;
while (i < 50) {
clang_analyzer_eval(i < 50); // expected-warning {{TRUE}}
@ -105,7 +105,7 @@ void condition_constrained_true_in_loop() {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void condition_constrained_false_after_loop() {
void condition_constrained_false_after_loop(void) {
int i = 0;
while (i < 50) {
++i;
@ -114,7 +114,7 @@ void condition_constrained_false_after_loop() {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
void multiple_exit_test() {
void multiple_exit_test(void) {
int x = 0;
int i = 0;
while (i < 50) {
@ -133,7 +133,7 @@ void multiple_exit_test() {
if (i > 10 && i < 50) clang_analyzer_warnIfReached(); // no-warning
}
void pointer_doesnt_leak_from_loop() {
void pointer_doesnt_leak_from_loop(void) {
int *h_ptr = (int *) malloc(sizeof(int));
for (int i = 0; i < 2; ++i) {}
for (int i = 0; i < 10; ++i) {} // no-warning
@ -166,7 +166,7 @@ void variable_bound_exiting_loops_widened(int x) {
clang_analyzer_eval(t == 1); // expected-warning {{TRUE}} // expected-warning {{UNKNOWN}}
}
void nested_loop_outer_widen() {
void nested_loop_outer_widen(void) {
int i = 0, j = 0;
for (i = 0; i < 10; i++) {
clang_analyzer_eval(i < 10); // expected-warning {{TRUE}}
@ -178,7 +178,7 @@ void nested_loop_outer_widen() {
clang_analyzer_eval(i >= 10); // expected-warning {{TRUE}}
}
void nested_loop_inner_widen() {
void nested_loop_inner_widen(void) {
int i = 0, j = 0;
for (i = 0; i < 2; i++) {
clang_analyzer_eval(i < 2); // expected-warning {{TRUE}}

View File

@ -10,7 +10,7 @@ int arr[] = {4, 5, 6};
void clang_analyzer_eval(int);
int main() {
int main(void) {
// In main() we know that the initial values are still valid.
clang_analyzer_eval(x == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(s.a == 2); // expected-warning{{TRUE}}
@ -21,7 +21,7 @@ int main() {
return 0;
}
void foo() {
void foo(void) {
// In other functions these values may already be overwritten.
clang_analyzer_eval(x == 1); // expected-warning{{TRUE}} // expected-warning{{FALSE}}
clang_analyzer_eval(s.a == 2); // expected-warning{{TRUE}} // expected-warning{{FALSE}}

View File

@ -30,53 +30,53 @@ struct stuff {
};
struct stuff myglobalstuff;
void f1() {
void f1(void) {
int *p = malloc(12);
return; // expected-warning{{Potential leak of memory pointed to by}}
}
void f2() {
void f2(void) {
int *p = malloc(12);
free(p);
free(p); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_0() {
void f2_realloc_0(void) {
int *p = malloc(12);
realloc(p,0);
realloc(p,0); // expected-warning{{Attempt to free released memory}}
}
void f2_realloc_1() {
void f2_realloc_1(void) {
int *p = malloc(12);
int *q = realloc(p,0); // no-warning
}
// ownership attributes tests
void naf1() {
void naf1(void) {
int *p = my_malloc3(12);
return; // no-warning
}
void n2af1() {
void n2af1(void) {
int *p = my_malloc2(12);
return; // expected-warning{{Potential leak of memory pointed to by}}
}
void af1() {
void af1(void) {
int *p = my_malloc(12);
return; // expected-warning{{Potential leak of memory pointed to by}}
}
void af1_b() {
void af1_b(void) {
int *p = my_malloc(12);
} // expected-warning{{Potential leak of memory pointed to by}}
void af1_c() {
void af1_c(void) {
myglobalpointer = my_malloc(12); // no-warning
}
void af1_d() {
void af1_d(void) {
struct stuff mystuff;
mystuff.somefield = my_malloc(12);
} // expected-warning{{Potential leak of memory pointed to by}}
@ -96,32 +96,32 @@ void af1_g(struct stuff **pps) {
(*pps)->somefield = my_malloc(42); // no-warning
}
void af2() {
void af2(void) {
int *p = my_malloc(12);
my_free(p);
free(p); // expected-warning{{Attempt to free released memory}}
}
void af2b() {
void af2b(void) {
int *p = my_malloc(12);
free(p);
my_free(p); // expected-warning{{Attempt to free released memory}}
}
void af2c() {
void af2c(void) {
int *p = my_malloc(12);
free(p);
my_hold(p); // expected-warning{{Attempt to free released memory}}
}
void af2d() {
void af2d(void) {
int *p = my_malloc(12);
free(p);
my_hold2(0, 0, p); // expected-warning{{Attempt to free released memory}}
}
// No leak if malloc returns null.
void af2e() {
void af2e(void) {
int *p = my_malloc(12);
if (!p)
return; // no-warning
@ -129,20 +129,20 @@ void af2e() {
}
// This case inflicts a possible double-free.
void af3() {
void af3(void) {
int *p = my_malloc(12);
my_hold(p);
free(p); // expected-warning{{Attempt to free non-owned memory}}
}
int * af4() {
int * af4(void) {
int *p = my_malloc(12);
my_free(p);
return p; // expected-warning{{Use of memory after it is freed}}
}
// This case is (possibly) ok, be conservative
int * af5() {
int * af5(void) {
int *p = my_malloc(12);
my_hold(p);
return p; // no-warning
@ -153,7 +153,7 @@ int * af5() {
// This case tests that storing malloc'ed memory to a static variable which is
// then returned is not leaked. In the absence of known contracts for functions
// or inter-procedural analysis, this is a conservative answer.
int *f3() {
int *f3(void) {
static int *p = 0;
p = malloc(12);
return p; // no-warning
@ -163,18 +163,18 @@ int *f3() {
// which is then returned is not leaked. In the absence of known contracts for
// functions or inter-procedural analysis, this is a conservative answer.
static int *p_f4 = 0;
int *f4() {
int *f4(void) {
p_f4 = malloc(12);
return p_f4; // no-warning
}
int *f5() {
int *f5(void) {
int *q = malloc(12);
q = realloc(q, 20);
return q; // no-warning
}
void f6() {
void f6(void) {
int *p = malloc(12);
if (!p)
return; // no-warning
@ -182,7 +182,7 @@ void f6() {
free(p);
}
void f6_realloc() {
void f6_realloc(void) {
int *p = malloc(12);
if (!p)
return; // no-warning
@ -191,51 +191,51 @@ void f6_realloc() {
}
char *doit2();
void pr6069() {
char *doit2(void);
void pr6069(void) {
char *buf = doit2();
free(buf);
}
void pr6293() {
void pr6293(void) {
free(0);
}
void f7() {
void f7(void) {
char *x = (char*) malloc(4);
free(x);
x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void f7_realloc() {
void f7_realloc(void) {
char *x = (char*) malloc(4);
realloc(x,0);
x[0] = 'a'; // expected-warning{{Use of memory after it is freed}}
}
void PR6123() {
void PR6123(void) {
int *x = malloc(11); // expected-warning{{Cast a region whose size is not a multiple of the destination type size}}
}
void PR7217() {
void PR7217(void) {
int *buf = malloc(2); // expected-warning{{Cast a region whose size is not a multiple of the destination type size}}
buf[1] = 'c'; // not crash
}
void mallocCastToVoid() {
void mallocCastToVoid(void) {
void *p = malloc(2);
const void *cp = p; // not crash
free(p);
}
void mallocCastToFP() {
void mallocCastToFP(void) {
void *p = malloc(2);
void (*fp)() = p; // not crash
void (*fp)(void) = p; // not crash
free(p);
}
// This tests that malloc() buffers are undefined by default
char mallocGarbage () {
char mallocGarbage (void) {
char *buf = malloc(2);
char result = buf[1]; // expected-warning{{undefined}}
free(buf);
@ -243,13 +243,13 @@ char mallocGarbage () {
}
// This tests that calloc() buffers need to be freed
void callocNoFree () {
void callocNoFree (void) {
char *buf = calloc(2,2);
return; // expected-warning{{Potential leak of memory pointed to by}}
}
// These test that calloc() buffers are zeroed by default
char callocZeroesGood () {
char callocZeroesGood (void) {
char *buf = calloc(2,2);
char result = buf[3]; // no-warning
if (buf[1] == 0) {
@ -258,7 +258,7 @@ char callocZeroesGood () {
return result; // no-warning
}
char callocZeroesBad () {
char callocZeroesBad (void) {
char *buf = calloc(2,2);
char result = buf[3]; // no-warning
if (buf[1] != 0) {
@ -267,7 +267,7 @@ char callocZeroesBad () {
return result; // expected-warning{{Potential leak of memory pointed to by}}
}
void testMultipleFreeAnnotations() {
void testMultipleFreeAnnotations(void) {
int *p = malloc(12);
int *q = malloc(12);
my_freeBoth(p, q);

View File

@ -8,17 +8,17 @@
// expected-no-diagnostics
char alloca();
char malloc();
char realloc();
char kmalloc();
char valloc();
char calloc();
char alloca(void);
char malloc(void);
char realloc(void);
char kmalloc(void);
char valloc(void);
char calloc(void);
char free();
char kfree();
char free(void);
char kfree(void);
void testCustomArgumentlessAllocation() {
void testCustomArgumentlessAllocation(void) {
alloca(); // no-crash
malloc(); // no-crash
realloc(); // no-crash

View File

@ -3,7 +3,7 @@
void free(void *);
void (*fnptr)(int);
void foo() {
void foo(void) {
free((void *)fnptr);
// expected-warning@-1{{Argument to free() is a function pointer}}
// expected-warning@-2{{attempt to call free on non-heap object '(void *)fnptr'}}

View File

@ -29,32 +29,32 @@ static void my_free1(void *p) {
free(p);
}
static void test1() {
static void test1(void) {
void *data = 0;
my_malloc1(&data, 4);
} // expected-warning {{Potential leak of memory pointed to by 'data'}}
static void test11() {
static void test11(void) {
void *data = 0;
my_malloc1(&data, 4);
my_free1(data);
}
static void testUniqueingByallocationSiteInTopLevelFunction() {
static void testUniqueingByallocationSiteInTopLevelFunction(void) {
void *data = my_malloc2(1, 4);
data = 0;
int x = 5;// expected-warning {{Potential leak of memory pointed to by 'data'}}
data = my_malloc2(1, 4);
} // expected-warning {{Potential leak of memory pointed to by 'data'}}
static void test3() {
static void test3(void) {
void *data = my_malloc2(1, 4);
free(data);
data = my_malloc2(1, 4);
free(data);
}
int test4() {
int test4(void) {
int *data = (int*)my_malloc2(1, 4);
my_free1(data);
data = (int *)my_malloc2(1, 4);
@ -62,14 +62,14 @@ int test4() {
return *data; // expected-warning {{Use of memory after it is freed}}
}
void test6() {
void test6(void) {
int *data = (int *)my_malloc2(1, 4);
my_free1((int*)data);
my_free1((int*)data); // expected-warning{{Use of memory after it is freed}}
}
// TODO: We should warn here.
void test5() {
void test5(void) {
int *data;
my_free1((int*)data);
}
@ -78,7 +78,7 @@ static char *reshape(char *in) {
return 0;
}
void testThatRemoveDeadBindingsRunBeforeEachCall() {
void testThatRemoveDeadBindingsRunBeforeEachCall(void) {
char *v = malloc(12);
v = reshape(v);
v = reshape(v);// expected-warning {{Potential leak of memory pointed to by 'v'}}
@ -92,7 +92,7 @@ void fooWithEmptyReturn(int x) {
return;
}
int uafAndCallsFooWithEmptyReturn() {
int uafAndCallsFooWithEmptyReturn(void) {
int *x = (int*)malloc(12);
free(x);
fooWithEmptyReturn(12);

View File

@ -14,7 +14,7 @@ void * f2(int n)
return malloc(sizeof(int) * n); // // expected-warning {{the computation of the size of the memory allocation may overflow}}
}
void * f3()
void * f3(void)
{
return malloc(4 * sizeof(int)); // no-warning
}

View File

@ -16,13 +16,13 @@ void diagnosticTest(int in) {
in++; // expected-warning {{leak}}
}
void myArrayAllocation() {
void myArrayAllocation(void) {
int **A;
A = malloc(2*sizeof(int*));
A[0] = 0;
}//expected-warning{{Potential leak}}
void reallocDiagnostics() {
void reallocDiagnostics(void) {
char * buf = malloc(100);
char * tmp;
tmp = (char*)realloc(buf, 0x1000000);
@ -33,7 +33,7 @@ void reallocDiagnostics() {
free(buf);
}
void *wrapper() {
void *wrapper(void) {
void *x = malloc(100);
// This is intentionally done to test diagnostic emission.
if (x)
@ -41,7 +41,7 @@ void *wrapper() {
return 0;
}
void test_wrapper() {
void test_wrapper(void) {
void *buf = wrapper();
(void) buf;
}//expected-warning{{Potential leak}}
@ -57,7 +57,7 @@ void my_malloc_and_free(void **x) {
my_free(*x);
return;
}
void *test_double_action_call() {
void *test_double_action_call(void) {
void *buf;
my_malloc_and_free(&buf);
return buf; //expected-warning{{Use of memory after it is freed}}
@ -72,17 +72,17 @@ char *my_realloc(char *buf) {
}
return tmp;
}
void reallocIntra() {
void reallocIntra(void) {
char *buf = (char *)malloc(100);
buf = my_realloc(buf);
free(buf);//expected-warning{{Potential leak}}
}
// Test stack hint when returning a result.
static char *malloc_wrapper_ret() {
static char *malloc_wrapper_ret(void) {
return (char*)malloc(12);
}
void use_ret() {
void use_ret(void) {
char *v;
v = malloc_wrapper_ret();
}//expected-warning{{Potential leak}}
@ -94,7 +94,7 @@ void myfree_takingblock(void (^ignored)(void), int *p) {
free(p);
}
void call_myfree_takingblock() {
void call_myfree_takingblock(void) {
void (^some_block)(void) = ^void(void) { };
int *p = malloc(sizeof(int));
@ -116,19 +116,19 @@ void LeakedSymbol(int in) {
}
// Tests that exercise running remove dead bindings at Call exit.
static void function_with_leak1() {
static void function_with_leak1(void) {
char *x = (char*)malloc(12);
} //expected-warning{{Potential leak}}
void use_function_with_leak1() {
void use_function_with_leak1(void) {
function_with_leak1();
int y = 0;
}
static void function_with_leak2() {
static void function_with_leak2(void) {
char *x = (char*)malloc(12);
int m = 0; //expected-warning{{Potential leak}}
}
void use_function_with_leak2() {
void use_function_with_leak2(void) {
function_with_leak2();
}
@ -152,58 +152,58 @@ void use_function_with_leak4(int y) {
function_with_leak4(y);
}
int anotherFunction5() {
int anotherFunction5(void) {
return 5;
}
static int function_with_leak5() {
static int function_with_leak5(void) {
char *x = (char*)malloc(12);
return anotherFunction5();//expected-warning{{Potential leak}}
}
void use_function_with_leak5() {
void use_function_with_leak5(void) {
function_with_leak5();
}
void anotherFunction6(int m) {
m++;
}
static void function_with_leak6() {
static void function_with_leak6(void) {
char *x = (char*)malloc(12);
anotherFunction6(3);//expected-warning{{Potential leak}}
}
void use_function_with_leak6() {
void use_function_with_leak6(void) {
function_with_leak6();
}
static void empty_function(){
static void empty_function(void){
}
void use_empty_function() {
void use_empty_function(void) {
empty_function();
}
static char *function_with_leak7() {
static char *function_with_leak7(void) {
return (char*)malloc(12);
}
void use_function_with_leak7() {
void use_function_with_leak7(void) {
function_with_leak7();
}//expected-warning{{Potential memory leak}}
// Test that we do not print the name of a variable not visible from where
// the issue is reported.
int *my_malloc() {
int *my_malloc(void) {
int *p = malloc(12);
return p;
}
void testOnlyRefferToVisibleVariables() {
void testOnlyRefferToVisibleVariables(void) {
my_malloc();
} // expected-warning{{Potential memory leak}}
struct PointerWrapper{
int*p;
};
int *my_malloc_into_struct() {
int *my_malloc_into_struct(void) {
struct PointerWrapper w;
w.p = malloc(12);
return w.p;
}
void testMyMalloc() {
void testMyMalloc(void) {
my_malloc_into_struct();
} // expected-warning{{Potential memory leak}}

View File

@ -6,12 +6,12 @@
void malloc(int i);
void valloc(int i);
void test1()
void test1(void)
{
malloc(1);
}
void test2()
void test2(void)
{
valloc(1);
}

View File

@ -31,13 +31,13 @@ void foo(unsigned int unsignedInt, unsigned int readSize) {
}
// Don't warn when the types differ only by constness.
void ignore_const() {
void ignore_const(void) {
const char **x = (const char **)malloc(1 * sizeof(char *)); // no-warning
const char ***y = (const char ***)malloc(1 * sizeof(char *)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'const char **', which is incompatible with sizeof operand type 'char *'}}
free(x);
}
int *mallocArraySize() {
int *mallocArraySize(void) {
static const int sTable[10];
static const int nestedTable[10][2];
int *table = malloc(sizeof sTable);
@ -47,7 +47,7 @@ int *mallocArraySize() {
return table;
}
int *mallocWrongArraySize() {
int *mallocWrongArraySize(void) {
static const double sTable[10];
int *table = malloc(sizeof sTable); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'int', which is incompatible with sizeof operand type 'const double[10]'}}
return table;

View File

@ -12,7 +12,7 @@ struct test {
void foo(struct test *);
void test_zeroed() {
void test_zeroed(void) {
struct test **list, *t;
int i;
@ -27,7 +27,7 @@ void test_zeroed() {
free(list); // no-warning
}
void test_nonzero() {
void test_nonzero(void) {
struct test **list, *t;
int i;

File diff suppressed because it is too large Load Diff

View File

@ -40,18 +40,18 @@ void rdar10579586(char x);
}
@end
void _ArrayCreate() {
void _ArrayCreate(void) {
MyArray *array = (MyArray *)malloc(12);
array = [array init];
free(array); // no-warning
}
void testNSDataTruePositiveLeak() {
void testNSDataTruePositiveLeak(void) {
char *b = (char *)malloc(12);
NSData *d = [[NSData alloc] initWithBytes: b length: 12]; // expected-warning {{Potential leak of memory pointed to by 'b'}}
}
id wrapInNSValue() {
id wrapInNSValue(void) {
void *buffer = malloc(4);
return [NSValue valueWithPointer:buffer]; // no-warning
}

View File

@ -15,9 +15,9 @@ extern void exit(int) __attribute__ ((__noreturn__));
void clang_analyzer_warnIfReached(void);
int coin();
int coin(void);
void test_single_cfg_block_sink() {
void test_single_cfg_block_sink(void) {
void *p = malloc(1); // no-warning (wherever the leak warning may occur here)
// Due to max-nodes option in the run line, we should reach the first call
@ -34,7 +34,7 @@ void test_single_cfg_block_sink() {
// A similar test with more complicated control flow before the no-return thing,
// so that the no-return thing wasn't in the same CFG block.
void test_more_complex_control_flow_before_sink() {
void test_more_complex_control_flow_before_sink(void) {
void *p = malloc(1); // no-warning
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
@ -72,7 +72,7 @@ void test_loop_with_sink(int n) {
}
// Handle unreachable blocks correctly.
void test_unreachable_successor_blocks() {
void test_unreachable_successor_blocks(void) {
void *p = malloc(1); // no-warning
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}

View File

@ -11,8 +11,8 @@ typedef struct
float x, y;
} Rdar11405978Vec;
float32x2_t rdar11405978_bar();
float32_t rdar11405978() {
float32x2_t rdar11405978_bar(void);
float32_t rdar11405978(void) {
float32x2_t v = rdar11405978_bar();
Rdar11405978Vec w = *(Rdar11405978Vec *)&v;
return w.x; // no-warning

View File

@ -92,7 +92,7 @@ void pr3836(int *a, int *b) {
void rdar7342806_aux(short x);
void rdar7342806() {
void rdar7342806(void) {
extern short Count;
extern short Flag1;

View File

@ -6,7 +6,7 @@
// we don't crash.
typedef unsigned uintptr_t;
void test_pointer_invalidated_as_int_aux(uintptr_t* ptr);
void test_pointer_invalidated_as_int() {
void test_pointer_invalidated_as_int(void) {
void *x;
test_pointer_invalidated_as_int_aux((uintptr_t*) &x);
// Here we have a pointer to integer cast.

View File

@ -6,7 +6,7 @@
// we don't crash.
typedef unsigned long uintptr_t;
void test_pointer_invalidated_as_int_aux(uintptr_t* ptr);
void test_pointer_invalidated_as_int() {
void test_pointer_invalidated_as_int(void) {
void *x;
test_pointer_invalidated_as_int_aux((uintptr_t*) &x);
// Here we have a pointer to integer cast.

View File

@ -43,7 +43,7 @@ typedef int32_t intptr_t;
// PR 2948 (testcase; crash on VisitLValue for union types)
// http://llvm.org/bugs/show_bug.cgi?id=2948
void checkaccess_union() {
void checkaccess_union(void) {
int ret = 0, status;
// Since RegionStore doesn't handle unions yet,
// this branch condition won't be triggered
@ -61,7 +61,7 @@ void checkaccess_union() {
struct test2_struct { int x; int y; char* s; };
void test2_help(struct test2_struct* p);
char test2() {
char test2(void) {
struct test2_struct s;
test2_help(&s);
char *p = 0;
@ -144,7 +144,7 @@ void testB_2(BStruct *b) {
// engine caches out. Previously a false transition would cause UnknownVal
// to bind to the variable, firing an assertion failure. This bug was fixed
// in r76262.
void test_declstmt_caching() {
void test_declstmt_caching(void) {
again:
{
const char a[] = "I like to crash";
@ -170,7 +170,7 @@ void test_rdar_7114618(struct s_7114618 *s) {
}
// Test pointers increment correctly.
void f() {
void f(void) {
int a[2];
a[1] = 3;
int *p = a;
@ -190,7 +190,7 @@ struct test_7185607 {
int x : 10;
int y : 22;
};
int rdar_test_7185607() {
int rdar_test_7185607(void) {
struct test_7185607 s; // Uninitialized.
*((unsigned *) &s) = 0U;
return s.x; // no-warning
@ -277,12 +277,12 @@ struct s_test_field_invalidate {
int x;
};
extern void test_invalidate_field(int *x);
int test_invalidate_field_test() {
int test_invalidate_field_test(void) {
struct s_test_field_invalidate y;
test_invalidate_field(&y.x);
return y.x; // no-warning
}
int test_invalidate_field_test_positive() {
int test_invalidate_field_test_positive(void) {
struct s_test_field_invalidate y;
return y.x; // expected-warning{{garbage}}
}
@ -296,7 +296,7 @@ struct WrappedStruct { unsigned z; };
void test_handle_array_wrapper_helper();
int test_handle_array_wrapper() {
int test_handle_array_wrapper(void) {
struct ArrayWrapper x;
test_handle_array_wrapper_helper(&x);
struct WrappedStruct *p = (struct WrappedStruct*) x.y; // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}}
@ -350,7 +350,7 @@ struct rdar_7312221_value { int x; };
- (void) doSomething_7312221;
@end
extern struct rdar_7312221_value *rdar_7312221_helper();
extern struct rdar_7312221_value *rdar_7312221_helper(void);
extern int rdar_7312221_helper_2(id o);
extern void rdar_7312221_helper_3(int z);
@ -389,12 +389,12 @@ void doSomething_7312221_with_struct(struct rdar_7312221_container *Self) {
// <rdar://problem/7332673> - Just more tests cases for regions
//===----------------------------------------------------------------------===//
void rdar_7332673_test1() {
void rdar_7332673_test1(void) {
char value[1];
if ( *(value) != 1 ) {} // expected-warning{{The left operand of '!=' is a garbage value}}
}
int rdar_7332673_test2_aux(char *x);
void rdar_7332673_test2() {
void rdar_7332673_test2(void) {
char *value;
if ( rdar_7332673_test2_aux(value) != 1 ) {} // expected-warning{{1st function call argument is an uninitialized value}}
}
@ -462,7 +462,7 @@ void element_region_with_symbolic_superregion(int* p) {
//===----------------------------------------------------------------------===//
static int test_cwe466_return_outofbounds_pointer_a[10]; // expected-note{{Original object declared here}}
int *test_cwe466_return_outofbounds_pointer() {
int *test_cwe466_return_outofbounds_pointer(void) {
int *p = test_cwe466_return_outofbounds_pointer_a+11;
return p; // expected-warning{{Returned pointer value points outside the original object}}
// expected-note@-1{{Original object 'test_cwe466_return_outofbounds_pointer_a' is an array of 10 'int' objects, returned pointer points at index 11}}
@ -475,7 +475,7 @@ int *test_cwe466_return_outofbounds_pointer() {
typedef struct { int *a; } pr3135_structure;
int pr3135_bar(pr3135_structure *x);
int pr3135() {
int pr3135(void) {
int x;
pr3135_structure y = { &x };
// the call to pr3135_bar may initialize x
@ -494,7 +494,7 @@ typedef struct RDar7403269 {
unsigned y;
} RDar7403269;
void rdar7403269() {
void rdar7403269(void) {
RDar7403269 z = { .y = 0 };
if (z.x[4] == 0)
return;
@ -507,7 +507,7 @@ typedef struct RDar7403269_b {
unsigned y;
} RDar7403269_b;
void rdar7403269_b() {
void rdar7403269_b(void) {
RDar7403269_b z = { .y = 0 };
if (z.x[5].w == 0)
return;
@ -515,7 +515,7 @@ void rdar7403269_b() {
*p = 0xDEADBEEF; // no-warning
}
void rdar7403269_b_pos() {
void rdar7403269_b_pos(void) {
RDar7403269_b z = { .y = 0 };
if (z.x[5].w == 1)
return;
@ -559,11 +559,11 @@ double rdar_6811085(void) {
// Path-sensitive tests for blocks.
//===----------------------------------------------------------------------===//
void indirect_block_call(void (^f)());
void indirect_block_call(void (^f)(void));
int blocks_1(int *p, int z) {
__block int *q = 0;
void (^bar)() = ^{ q = p; };
void (^bar)(void) = ^{ q = p; };
if (z == 1) {
// The call to 'bar' might cause 'q' to be invalidated.
@ -635,9 +635,9 @@ unsigned long rdar7582031_b2(RDar7582031 *o) {
// Show that we handle static variables also getting invalidated.
void rdar7582031_aux(void (^)(void));
RDar7582031 *rdar7582031_aux_2();
RDar7582031 *rdar7582031_aux_2(void);
unsigned rdar7582031_static() {
unsigned rdar7582031_static(void) {
static RDar7582031 *o = 0;
rdar7582031_aux(^{ o = rdar7582031_aux_2(); });
@ -686,10 +686,10 @@ typedef void (^RDar_7462324_Callback)(id obj);
// not crash on variables passed by reference via __block.
//===----------------------------------------------------------------------===//
int rdar7468209_aux();
void rdar7468209_aux_2();
int rdar7468209_aux(void);
void rdar7468209_aux_2(void);
void rdar7468209() {
void rdar7468209(void) {
__block int x = 0;
^{
x = rdar7468209_aux();
@ -760,9 +760,9 @@ int test_return_struct(TestReturnStruct_rdar_7526777 *x) {
return [x foo].x;
}
testReturn_rdar_7526777 test_return_struct_2_aux_rdar_7526777();
testReturn_rdar_7526777 test_return_struct_2_aux_rdar_7526777(void);
int test_return_struct_2_rdar_7526777() {
int test_return_struct_2_rdar_7526777(void) {
return test_return_struct_2_aux_rdar_7526777().x;
}
@ -775,7 +775,7 @@ int test_return_struct_2_rdar_7526777() {
_Bool OSAtomicCompareAndSwapPtrBarrier( void *__oldValue, void *__newValue, void * volatile *__theValue );
void rdar_7527292() {
void rdar_7527292(void) {
static id Cache7527292[32];
for (signed long idx = 0;
idx < 32;
@ -796,7 +796,7 @@ struct rdar_7515938 {
int y[];
};
const struct rdar_7515938 *rdar_7515938() {
const struct rdar_7515938 *rdar_7515938(void) {
static const struct rdar_7515938 z = { 0, { 1, 2 } };
if (z.y[0] != 1) {
int *p = 0;
@ -810,7 +810,7 @@ struct rdar_7515938_str {
char y[];
};
const struct rdar_7515938_str *rdar_7515938_str() {
const struct rdar_7515938_str *rdar_7515938_str(void) {
static const struct rdar_7515938_str z = { 0, "hello" };
return &z;
}
@ -853,20 +853,20 @@ struct s_rev96062_nested { struct s_rev96062 z; };
void test_a_rev96062_aux(struct s_rev96062 *s);
void test_a_rev96062_aux2(struct s_rev96062_nested *s);
int test_a_rev96062() {
int test_a_rev96062(void) {
int a, b;
struct s_rev96062 x = { &a, &b };
test_a_rev96062_aux(&x);
return a + b; // no-warning
}
int test_b_rev96062() {
int test_b_rev96062(void) {
int a, b;
struct s_rev96062 x = { &a, &b };
struct s_rev96062 z = x;
test_a_rev96062_aux(&z);
return a + b; // no-warning
}
int test_c_rev96062() {
int test_c_rev96062(void) {
int a, b;
struct s_rev96062 x = { &a, &b };
struct s_rev96062_nested w = { x };
@ -966,7 +966,7 @@ void pr6288_b(void) {
- (void) rdar7817800_baz;
@end
char *rdar7817800_foobar();
char *rdar7817800_foobar(void);
void rdar7817800_qux(void*);
@implementation Rdar7817800
@ -1019,8 +1019,8 @@ void pr6854(void * arg) {
// <rdar://problem/8032791> False positive due to symbolic store not find
// value because of 'const' qualifier
double rdar_8032791_2();
double rdar_8032791_1() {
double rdar_8032791_2(void);
double rdar_8032791_1(void) {
struct R8032791 { double x[2]; double y; }
data[3] = {
{{1.0, 3.0}, 3.0}, // 1 2 3
@ -1038,7 +1038,7 @@ double rdar_8032791_1() {
// PR 7450 - Handle pointer arithmetic with __builtin_alloca
void pr_7450_aux(void *x);
void pr_7450() {
void pr_7450(void) {
void *p = __builtin_alloca(10);
// Don't crash when analyzing the following statement.
pr_7450_aux(p + 8);
@ -1061,7 +1061,7 @@ void rdar_8243408(void) {
}
// <rdar://problem/8258814>
int r8258814()
int r8258814(void)
{
int foo;
int * a = &foo;
@ -1098,10 +1098,10 @@ pr8052(u_int boot_addr)
// PR 8015 - don't return undefined values for arrays when using a valid
// symbolic index
int pr8015_A();
int pr8015_A(void);
void pr8015_B(const char *);
void pr8015_C() {
void pr8015_C(void) {
int number = pr8015_A();
const char *numbers[] = { "zero" };
if (number == 0) {
@ -1112,7 +1112,7 @@ void pr8015_C() {
// Tests that we correctly handle that 'number' is perfectly constrained
// after 'if (number == 0)', allowing us to resolve that
// numbers[number] == numbers[0].
void pr8015_D_FIXME() {
void pr8015_D_FIXME(void) {
int number = pr8015_A();
const char *numbers[] = { "zero" };
if (number == 0) {
@ -1124,7 +1124,7 @@ void pr8015_D_FIXME() {
}
}
void pr8015_E() {
void pr8015_E(void) {
// Similar to pr8015_C, but number is allowed to be a valid range.
unsigned number = pr8015_A();
const char *numbers[] = { "zero", "one", "two" };
@ -1133,7 +1133,7 @@ void pr8015_E() {
}
}
void pr8015_F_FIXME() {
void pr8015_F_FIXME(void) {
// Similar to pr8015_E, but like pr8015_D we check if the pointer
// is the same as one of the string literals. The null dereference
// here is not feasible in practice, so this is a false positive.
@ -1217,7 +1217,7 @@ typedef struct s_test_rdar8848957 {
int x, y, z;
} s_test_rdar8848957;
s_test_rdar8848957 foo_rdar8848957();
s_test_rdar8848957 foo_rdar8848957(void);
int rdar8848957(int index) {
s_test_rdar8848957 vals[10];
vals[index] = foo_rdar8848957();
@ -1261,7 +1261,7 @@ void Rdar_9103310_E(Rdar_9103310_A * x, struct Rdar_9103310_C * b) { // expected
// Test handling binding lazy compound values to a region and then have
// specific elements have other bindings.
int PR9455() {
int PR9455(void) {
char arr[4] = "000";
arr[0] = '1';
if (arr[1] == '0')
@ -1270,7 +1270,7 @@ int PR9455() {
*p = 0xDEADBEEF; // no-warning
return 1;
}
int PR9455_2() {
int PR9455_2(void) {
char arr[4] = "000";
arr[0] = '1';
if (arr[1] == '0') {
@ -1306,7 +1306,7 @@ RDar9163742_Rect RDar9163742_IntegralRect(RDar9163742_Rect frame)
}
// Test correct handling of prefix '--' operator.
void rdar9444714() {
void rdar9444714(void) {
int x;
char str[ 32 ];
char buf[ 32 ];
@ -1335,7 +1335,7 @@ typedef struct {
unsigned value;
} RDar11127008;
signed rdar_11127008_index();
signed rdar_11127008_index(void);
static unsigned rdar_11127008(void) {
RDar11127008 values[] = {{.value = 0}, {.value = 1}};
@ -1351,7 +1351,7 @@ typedef void (^radar11125868_cb)(int *, unsigned);
void rdar11125868_aux(radar11125868_cb cb);
int rdar11125868() {
int rdar11125868(void) {
int integersStackArray[1];
int *integers = integersStackArray;
rdar11125868_aux(^(int *integerValue, unsigned index) {
@ -1360,7 +1360,7 @@ int rdar11125868() {
return integers[0] == 0; // no-warning
}
int rdar11125868_positive() {
int rdar11125868_positive(void) {
int integersStackArray[1];
int *integers = integersStackArray;
return integers[0] == 0; // expected-warning {{The left operand of '==' is a}}

View File

@ -5,7 +5,7 @@ void clang_analyzer_eval(int);
int size_rdar9373039 = 1;
int foo_rdar9373039(const char *);
int rdar93730392() {
int rdar93730392(void) {
int x;
int j = 0;
@ -91,8 +91,8 @@ static int radar10367606(int t) {
}
/* Caching out on a sink node. */
extern int fooR10376675();
extern int* bazR10376675();
extern int fooR10376675(void);
extern int* bazR10376675(void);
extern int nR10376675;
void barR10376675(int *x) {
int *pm;
@ -116,7 +116,7 @@ void RDar10385775(struct rdar10385775* p) {
// Test double loop of array and array literals. Previously this
// resulted in a false positive uninitailized value warning.
void rdar10686586() {
void rdar10686586(void) {
int array1[] = { 1, 2, 3, 0 };
int array2[] = { 1, 2, 3, 0 };
int *array[] = { array1, array2 };

View File

@ -76,9 +76,9 @@ unsigned foo(unsigned x) { return __alignof__((x)) + sizeof(x); }
// Addresses false positive in <rdar://problem/6268365>
//
unsigned r6268365Aux();
unsigned r6268365Aux(void);
void r6268365() {
void r6268365(void) {
unsigned x = 0;
x &= r6268365Aux();
unsigned j = 0;
@ -104,7 +104,7 @@ void divzeroassumeB(unsigned x, unsigned j) {
// InitListExpr processing
typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
__m128 return128() {
__m128 return128(void) {
// This compound literal has a Vector type. We currently just
// return UnknownVal.
return __extension__(__m128) { 0.0f, 0.0f, 0.0f, 0.0f };
@ -151,7 +151,7 @@ void check_deref_undef(void) {
// PR 3422
void pr3422_helper(char *p);
void pr3422() {
void pr3422(void) {
char buf[100];
char *q = &buf[10];
pr3422_helper(&q[1]);
@ -240,8 +240,8 @@ void pr6708148_test(void) {
}
// Handle both kinds of noreturn attributes for pruning paths.
void rdar_6777003_noret() __attribute__((noreturn));
void rdar_6777003_analyzer_noret() __attribute__((analyzer_noreturn));
void rdar_6777003_noret(void) __attribute__((noreturn));
void rdar_6777003_analyzer_noret(void) __attribute__((analyzer_noreturn));
void rdar_6777003(int x) {
int *p = 0;
@ -288,7 +288,7 @@ void rdar_6777209(char *p) {
// PR 4033. A symbolic 'void *' pointer can be used as the address for a
// computed goto.
typedef void *Opcode;
Opcode pr_4033_getOpcode();
Opcode pr_4033_getOpcode(void);
void pr_4033(void) {
void *lbl = &&next_opcode;
next_opcode:
@ -302,7 +302,7 @@ next_opcode:
// example came from a recent false positive due to a regression where the
// branch condition was falsely reported as being uninitialized.
void invalidate_by_ref(char **x);
int test_invalidate_by_ref() {
int test_invalidate_by_ref(void) {
unsigned short y;
invalidate_by_ref((char**) &y);
if (y) // no-warning
@ -314,26 +314,26 @@ int test_invalidate_by_ref() {
// constructed correctly. Previously, the successor block of the entrance
// was the block containing the merge for '?', which would trigger an
// assertion failure.
int rdar_7027684_aux();
int rdar_7027684_aux_2() __attribute__((noreturn));
int rdar_7027684_aux(void);
int rdar_7027684_aux_2(void) __attribute__((noreturn));
void rdar_7027684(int x, int y) {
{}; // this empty compound statement is critical.
(rdar_7027684_aux() ? rdar_7027684_aux_2() : (void) 0);
}
// Test that we handle casts of string literals to arbitrary types.
unsigned const char *string_literal_test1() {
unsigned const char *string_literal_test1(void) {
return (const unsigned char*) "hello";
}
const float *string_literal_test2() {
const float *string_literal_test2(void) {
return (const float*) "hello";
}
// Test that we handle casts *from* incomplete struct types.
extern const struct _FooAssertStruct _cmd;
void test_cast_from_incomplete_struct_aux(volatile const void *x);
void test_cast_from_incomplete_struct() {
void test_cast_from_incomplete_struct(void) {
test_cast_from_incomplete_struct_aux(&_cmd);
}
@ -350,13 +350,13 @@ void test_rdar_7034511(NSArray *y) {
// Handle casts of function pointers (CodeTextRegions) to arbitrary pointer
// types. This was previously causing a crash in CastRegion.
void handle_funcptr_voidptr_casts() {
void handle_funcptr_voidptr_casts(void) {
void **ptr;
typedef void *PVOID;
typedef void *PCHAR;
typedef long INT_PTR, *PINT_PTR;
typedef INT_PTR (*FARPROC)();
FARPROC handle_funcptr_voidptr_casts_aux();
typedef INT_PTR (*FARPROC)(void);
FARPROC handle_funcptr_voidptr_casts_aux(void);
PVOID handle_funcptr_voidptr_casts_aux_2(PVOID volatile *x);
PVOID handle_funcptr_voidptr_casts_aux_3(PCHAR volatile *x);
@ -367,7 +367,7 @@ void handle_funcptr_voidptr_casts() {
// RegionStore::Retrieve previously crashed on this example. This example
// was previously in the test file 'xfail_regionstore_wine_crash.c'.
void testA() {
void testA(void) {
long x = 0;
char *y = (char *) &x;
if (!*y)
@ -396,7 +396,7 @@ void testB(BStruct *b) {
}
void test_trivial_symbolic_comparison(int *x) {
int test_trivial_symbolic_comparison_aux();
int test_trivial_symbolic_comparison_aux(void);
int a = test_trivial_symbolic_comparison_aux();
int b = a;
if (a != b) {
@ -420,7 +420,7 @@ void test_trivial_symbolic_comparison(int *x) {
// static and non-static).
//
static int* x_rdar_7062158;
void rdar_7062158() {
void rdar_7062158(void) {
int *current = x_rdar_7062158;
if (current == x_rdar_7062158)
return;
@ -430,7 +430,7 @@ void rdar_7062158() {
}
int* x_rdar_7062158_2;
void rdar_7062158_2() {
void rdar_7062158_2(void) {
int *current = x_rdar_7062158_2;
if (current == x_rdar_7062158_2)
return;
@ -456,8 +456,8 @@ unsigned char test_array_index_bitwidth(const unsigned char *p) {
// This case tests that CastRegion handles casts involving BlockPointerTypes.
// It should not crash.
void test_block_cast() {
id test_block_cast_aux();
void test_block_cast(void) {
id test_block_cast_aux(void);
(void (^)(void *))test_block_cast_aux(); // expected-warning{{expression result unused}}
}
@ -491,7 +491,7 @@ void radar11390991_NoBarrier_CompareAndSwap(volatile Atomic32 *ptr,
}
// PR 4594 - This was a crash when handling casts in SimpleSValuator.
void PR4594() {
void PR4594(void) {
char *buf[1];
char **foo = buf;
*foo = "test";
@ -499,7 +499,7 @@ void PR4594() {
// Test invalidation logic where an integer is casted to an array with a
// different sign and then invalidated.
void test_invalidate_cast_int() {
void test_invalidate_cast_int(void) {
void test_invalidate_cast_int_aux(unsigned *i);
signed i;
test_invalidate_cast_int_aux((unsigned*) &i);
@ -517,7 +517,7 @@ static NSNumber *test_ivar_offset(id self, SEL _cmd, Ivar inIvar) {
// Reduced from a crash in StoreManager::CastRegion involving a divide-by-zero.
// This resulted from not properly handling region casts to 'const void*'.
void test_cast_const_voidptr() {
void test_cast_const_voidptr(void) {
char x[10];
char *p = &x[1];
const void* q = p;
@ -525,7 +525,7 @@ void test_cast_const_voidptr() {
// Reduced from a crash when analyzing Wine. This test handles loads from
// function addresses.
typedef long (*FARPROC)();
typedef long (*FARPROC)(void);
FARPROC test_load_func(FARPROC origfun) {
if (!*(unsigned char*) origfun)
return origfun;
@ -538,7 +538,7 @@ struct test_pass_val {
int y;
};
void test_pass_val_aux(struct test_pass_val s);
void test_pass_val() {
void test_pass_val(void) {
struct test_pass_val s;
s.x = 1;
s.y = 2;
@ -599,21 +599,21 @@ struct test_offsetof_B {
int w;
int z;
};
void test_offsetof_1() {
void test_offsetof_1(void) {
if (__builtin_offsetof(struct test_offsetof_A, x) ==
__builtin_offsetof(struct test_offsetof_B, w))
return;
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
void test_offsetof_2() {
void test_offsetof_2(void) {
if (__builtin_offsetof(struct test_offsetof_A, y) ==
__builtin_offsetof(struct test_offsetof_B, z))
return;
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
void test_offsetof_3() {
void test_offsetof_3(void) {
if (__builtin_offsetof(struct test_offsetof_A, y) -
__builtin_offsetof(struct test_offsetof_A, x)
==
@ -623,7 +623,7 @@ void test_offsetof_3() {
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
void test_offsetof_4() {
void test_offsetof_4(void) {
if (__builtin_offsetof(struct test_offsetof_A, y) ==
__builtin_offsetof(struct test_offsetof_B, w))
return;
@ -639,8 +639,8 @@ void test_offsetof_4() {
- (id) init;
@end
id rdar_6829164_1();
double rdar_6829164_2();
id rdar_6829164_1(void);
double rdar_6829164_2(void);
@implementation RDar6829164
- (id) init {
@ -657,7 +657,7 @@ double rdar_6829164_2();
// <rdar://problem/7242015> - Invalidate values passed-by-reference
// to functions when the pointer to the value is passed as an integer.
void test_7242015_aux(unsigned long);
int rdar_7242015() {
int rdar_7242015(void) {
int x;
test_7242015_aux((unsigned long) &x); // no-warning
return x; // Previously we return and uninitialized value when
@ -680,7 +680,7 @@ void pr_4988(void) {
// <rdar://problem/7152418> - A 'signed char' is used as a flag, which is
// implicitly converted to an int.
void *rdar7152418_bar();
void *rdar7152418_bar(void);
@interface RDar7152418 {
signed char x;
}
@ -760,7 +760,7 @@ NSSwappedFloat test_cast_nonstruct_to_union(float x) {
return ((union bran *)&x)->sf; // no-warning
}
void test_undefined_array_subscript() {
void test_undefined_array_subscript(void) {
int i, a[10];
int *p = &a[i]; // expected-warning{{Array subscript is undefined}}
}
@ -864,9 +864,9 @@ int rdar_7593875(int n) {
// Previously this caused an assertion failure.
//===----------------------------------------------------------------------===//
void *foo_rev95119();
void *foo_rev95119(void);
void baz_rev95119(double x);
void bar_rev95119() {
void bar_rev95119(void) {
// foo_rev95119() returns a symbolic pointer. It is then
// cast to an int which is then cast to a double.
int value = (int) foo_rev95119();
@ -893,8 +893,8 @@ void foo_rev95192(int **x) {
// violates our invariants.
//===----------------------------------------------------------------------===//
void *foo_rev95267();
int bar_rev95267() {
void *foo_rev95267(void);
int bar_rev95267(void) {
char (*Callback_rev95267)(void) = (char (*)(void)) foo_rev95267;
if ((*Callback_rev95267)() == (char) 0)
return 1;
@ -902,20 +902,20 @@ int bar_rev95267() {
}
// Same as previous case, but handle casts to 'void'.
int bar_rev95274() {
int bar_rev95274(void) {
void (*Callback_rev95274)(void) = (void (*)(void)) foo_rev95267;
(*Callback_rev95274)();
return 0;
}
void rdar7582031_test_static_init_zero() {
void rdar7582031_test_static_init_zero(void) {
static unsigned x;
if (x == 0)
return;
int *p = 0;
*p = 0xDEADBEEF;
}
void rdar7582031_test_static_init_zero_b() {
void rdar7582031_test_static_init_zero_b(void) {
static void* x;
if (x == 0)
return;
@ -947,7 +947,7 @@ void foo_rev95547_b(struct s_rev95547 w) {
// This previously triggered a crash.
//===----------------------------------------------------------------------===//
void pr6938() {
void pr6938(void) {
if (1 && ({
while (0);
0;
@ -955,7 +955,7 @@ void pr6938() {
}
}
void pr6938_b() {
void pr6938_b(void) {
if (1 && *({ // expected-warning{{Dereference of null pointer}}
while (0) {}
({
@ -988,8 +988,8 @@ MAKE_TEST_FN() // expected-warning{{null pointer}}
// PR 7491 - Test that symbolic expressions can be used as conditions.
//===----------------------------------------------------------------------===
void pr7491 () {
extern int getint();
void pr7491 (void) {
extern int getint(void);
int a = getint()-1;
if (a) {
return;
@ -1008,15 +1008,15 @@ void pr7491 () {
//===----------------------------------------------------------------------===
int *pr7475_someGlobal;
void pr7475_setUpGlobal();
void pr7475_setUpGlobal(void);
void pr7475() {
void pr7475(void) {
if (pr7475_someGlobal == 0)
pr7475_setUpGlobal();
*pr7475_someGlobal = 0; // no-warning
}
void pr7475_warn() {
void pr7475_warn(void) {
static int *someStatic = 0;
if (someStatic == 0)
pr7475_setUpGlobal();
@ -1097,7 +1097,7 @@ void test_enum_cases_positive(enum Cases C) {
}
// <rdar://problem/6351970> rule request: warn if synchronization mutex can be nil
void rdar6351970() {
void rdar6351970(void) {
id x = 0;
@synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
}
@ -1107,7 +1107,7 @@ void rdar6351970_b(id x) {
@synchronized(x) {} // expected-warning{{Nil value used as mutex for @synchronized() (no synchronization will occur)}}
}
void rdar6351970_c() {
void rdar6351970_c(void) {
id x;
@synchronized(x) {} // expected-warning{{Uninitialized value used as mutex for @synchronized}}
}
@ -1169,8 +1169,8 @@ static struct {
char **data;
} saved_pr8440;
char *foo_pr8440();
char **bar_pr8440();
char *foo_pr8440(void);
char **bar_pr8440(void);
void baz_pr8440(int n)
{
saved_pr8440.num = n;
@ -1184,12 +1184,12 @@ void baz_pr8440(int n)
// Support direct accesses to non-null memory. Reported in:
// PR 5272
// <rdar://problem/6839683>
int test_direct_address_load() {
int test_direct_address_load(void) {
int *p = (int*) 0x4000;
return *p; // no-warning
}
void pr5272_test() {
void pr5272_test(void) {
struct pr5272 { int var2; };
(*(struct pr5272*)0xBC000000).var2 = 0; // no-warning
(*(struct pr5272*)0xBC000000).var2 += 2; // no-warning
@ -1198,10 +1198,10 @@ void pr5272_test() {
// Support casting the return value of function to another different type
// This previously caused a crash, although we likely need more precise
// reasoning here. <rdar://problem/8663544>
void* rdar8663544();
void* rdar8663544(void);
typedef struct {} Val8663544;
Val8663544 bazR8663544() {
Val8663544(*func) () = (Val8663544(*) ()) rdar8663544;
Val8663544 bazR8663544(void) {
Val8663544(*func) (void) = (Val8663544(*) (void)) rdar8663544;
return func();
}
@ -1218,7 +1218,7 @@ void pr8619(int a, int b, int c) {
union pr8648_union {
signed long long pr8648_union_field;
};
void pr8648() {
void pr8648(void) {
long long y;
union pr8648_union x = { .pr8648_union_field = 0LL };
y = x.pr8648_union_field;
@ -1240,7 +1240,7 @@ void pr8648() {
// contains a condition with multiple basic blocks, and the value of the
// statement expression is then indexed as part of a bigger condition expression.
// This example exposed a bug in child traversal in the CFGBuilder.
void pr9269() {
void pr9269(void) {
struct s { char *bar[10]; } baz[2] = { 0 };
unsigned i = 0;
for (i = 0;
@ -1271,7 +1271,7 @@ void pr9287_c(int type, int *p) {
}
}
void test_switch() {
void test_switch(void) {
switch (4) {
case 1: {
int *p = 0;
@ -1305,8 +1305,8 @@ static void test(unsigned int bit_mask)
}
// Don't crash on code containing __label__.
int radar9414427_aux();
void radar9414427() {
int radar9414427_aux(void);
void radar9414427(void) {
__label__ mylabel;
if (radar9414427_aux()) {
mylabel: do {}
@ -1343,7 +1343,7 @@ void radar9414427() {
// Don't crash when a ?: is only preceded by a statement (not an expression)
// in the CFG.
void __assert_fail();
void __assert_fail(void);
enum rdar1196620_e { E_A, E_B, E_C, E_D };
struct rdar1196620_s { int ints[E_D+1]; };

View File

@ -18,7 +18,7 @@ typedef __typeof(sizeof(int)) size_t;
void *mmap(void *, size_t, int, int, int, long);
int mprotect(void *, size_t, int);
void f1()
void f1(void)
{
void *a = mmap(NULL, 16, PROT_READ | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning
void *b = mmap(a, 16, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0); // no-warning
@ -28,7 +28,7 @@ void f1()
(void)c;
}
void f2()
void f2(void)
{
void *(*callm)(void *, size_t, int, int, int, long);
callm = mmap;
@ -36,7 +36,7 @@ void f2()
(void)callm(NULL, 1024, prot, MAP_PRIVATE | MAP_ANON, -1, 0); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
}
void f3()
void f3(void)
{
void *p = mmap(NULL, 1024, PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); // no-warning
int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}

View File

@ -24,39 +24,39 @@
- (void)voidM {}
@end
void createFoo() {
void createFoo(void) {
MyClass *obj = 0;
void *v = [obj voidPtrM]; // no-warning
int i = [obj intM]; // no-warning
}
void createFoo2() {
void createFoo2(void) {
MyClass *obj = 0;
long double ld = [obj longDoubleM];
}
void createFoo3() {
void createFoo3(void) {
MyClass *obj;
obj = 0;
long long ll = [obj longlongM];
}
void createFoo4() {
void createFoo4(void) {
MyClass *obj = 0;
double d = [obj doubleM];
}
void createFoo5() {
void createFoo5(void) {
MyClass *obj = (id)@"";
double d = [obj doubleM]; // no-warning
}
void createFoo6() {
void createFoo6(void) {
MyClass *obj;
obj = 0;
@ -75,7 +75,7 @@ void handleNilPruneLoop(MyClass *obj) {
long long j = [obj longlongM];
}
int handleVoidInComma() {
int handleVoidInComma(void) {
MyClass *obj = 0;
return [obj voidM], 0;
}

View File

@ -5,7 +5,7 @@
// This file tests cases where we should not flag out-of-bounds warnings.
//===----------------------------------------------------------------------===//
void f() {
void f(void) {
long x = 0;
char *y = (char*) &x;
char c = y[0] + y[1] + y[2]; // no-warning
@ -13,7 +13,7 @@ void f() {
short s = z[0] + z[1]; // no-warning
}
void g() {
void g(void) {
int a[2];
char *b = (char*)a;
b[3] = 'c'; // no-warning
@ -23,7 +23,7 @@ typedef typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
void field() {
void field(void) {
struct vec { size_t len; int data[0]; };
struct vec *a = malloc(sizeof(struct vec) + 10*sizeof(int));
a->len = 10;

View File

@ -11,9 +11,9 @@
// non-diagnosable conditions.
// Function calls are currently non-diagnosable.
int non_diagnosable();
int non_diagnosable(void);
void test_true() {
void test_true(void) {
if (non_diagnosable()) {
// expected-note@-1{{Assuming the condition is true}}
// expected-note@-2{{Taking true branch}}
@ -23,7 +23,7 @@ void test_true() {
}
}
void test_false() {
void test_false(void) {
if (non_diagnosable()) {
// expected-note@-1{{Assuming the condition is false}}
// expected-note@-2{{Taking false branch}}
@ -36,7 +36,7 @@ void test_false() {
// Test that we're still reporting that the condition is true,
// when we encounter an exclamation mark (used to be broken).
void test_exclamation_mark() {
void test_exclamation_mark(void) {
if (!non_diagnosable()) {
// expected-note@-1{{Assuming the condition is true}}
// expected-note@-2{{Taking true branch}}

View File

@ -188,7 +188,7 @@ void testVararg(int k, void *p) {
testVararg_check(2, p, n); // expected-warning{{nonnull}}
}
void testNotPtr() {
void testNotPtr(void) {
struct S { int a; int b; int c; } s = {};
extern void testNotPtr_check(struct S, int) __attribute__((nonnull(1, 2)));
testNotPtr_check(s, 0);

View File

@ -2,7 +2,7 @@
// Avoid the crash when finding the expression for tracking the origins
// of the null pointer for path notes.
void pr34373() {
void pr34373(void) {
int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
(a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}}
// expected-note@-1{{Array access results in a null pointer dereference}}

View File

@ -41,7 +41,7 @@ void repeatedStores(int coin) {
if (coin) {
// expected-note@-1 {{Assuming 'coin' is 0}}
// expected-note@-2 {{Taking false branch}}
extern int *getPointer();
extern int *getPointer(void);
p = getPointer();
} else {
p = 0; // expected-note {{Null pointer value stored to 'p'}}

View File

@ -23,56 +23,56 @@ void f14(int *a) {
}
}
void foo() {
void foo(void) {
int *x = malloc(sizeof(int));
memset(x, 0, sizeof(int));
int n = 1 / *x; // expected-warning {{Division by zero}}
free(x);
}
void bar() {
void bar(void) {
int *x = malloc(sizeof(int));
memset(x, 0, 1);
int n = 1 / *x; // no-warning
free(x);
}
void testConcreteNull() {
void testConcreteNull(void) {
int *x = 0;
memset(x, 0, 1); // expected-warning {{Null pointer passed as 1st argument to memory set function}}
}
void testStackArray() {
void testStackArray(void) {
char buf[13];
memset(buf, 0, 1); // no-warning
}
void testHeapSymbol() {
void testHeapSymbol(void) {
char *buf = (char *)malloc(13);
memset(buf, 0, 1); // no-warning
free(buf);
}
void testStackArrayOutOfBound() {
void testStackArrayOutOfBound(void) {
char buf[1];
memset(buf, 0, 1024);
// expected-warning@-1 {{Memory set function overflows the destination buffer}}
// expected-warning@-2 {{'memset' will always overflow; destination buffer has size 1, but size argument is 1024}}
}
void testHeapSymbolOutOfBound() {
void testHeapSymbolOutOfBound(void) {
char *buf = (char *)malloc(1);
memset(buf, 0, 1024);
// expected-warning@-1 {{Memory set function overflows the destination buffer}}
free(buf);
}
void testStackArraySameSize() {
void testStackArraySameSize(void) {
char buf[1];
memset(buf, 0, sizeof(buf)); // no-warning
}
void testHeapSymbolSameSize() {
void testHeapSymbolSameSize(void) {
char *buf = (char *)malloc(1);
memset(buf, 0, 1); // no-warning
free(buf);

View File

@ -58,7 +58,7 @@ int f4(int *p) {
return *q; // expected-warning{{Dereference of null pointer (loaded from variable 'q')}}
}
int f4_b() {
int f4_b(void) {
short array[2];
uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}}
short *p = x; // expected-warning{{incompatible integer to pointer conversion}}
@ -79,7 +79,7 @@ int f4_b() {
return 0;
}
int f5() {
int f5(void) {
char *s = "hello world";
return s[0]; // no-warning
@ -275,7 +275,7 @@ void f12(HF12ITEM i, char *q) {
}
// Test handling of translating between integer "pointers" and back.
void f13() {
void f13(void) {
int *x = 0;
if (((((int) x) << 2) + 1) >> 1) *x = 1;
}
@ -284,7 +284,7 @@ void f13() {
// handling pointer values that were undefined.
void pr4759_aux(int *p) __attribute__((nonnull));
void pr4759() {
void pr4759(void) {
int *p;
pr4759_aux(p); // expected-warning{{1st function call argument is an uninitialized value}}
}
@ -323,7 +323,7 @@ void test_address_space_condition(int AS_ATTRIBUTE *cpu_data) {
}
}
struct X { int member; };
int test_address_space_member() {
int test_address_space_member(void) {
struct X AS_ATTRIBUTE *data = (struct X AS_ATTRIBUTE *)0UL;
int ret;
ret = data->member; // no-warning

View File

@ -1,16 +1,16 @@
// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,deadcode,alpha.core,debug.ExprInspection -verify %s
void *malloc(unsigned long);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
void test_static_from_block() {
void test_static_from_block(void) {
static int *x;
^{
*x; // no-warning
};
}
void test_static_within_block() {
void test_static_within_block(void) {
^{
static int *x;
*x; // expected-warning{{Dereference of null pointer}}

View File

@ -2,10 +2,10 @@
// expected-no-diagnostics
id _Nonnull conjure_nonnull();
id _Nonnull conjure_nonnull(void);
void use_nullable(_Nullable id x);
id _Nonnull foo() {
id _Nonnull foo(void) {
void *j = conjure_nonnull();
use_nullable(j);
return j; // no-warning

View File

@ -49,7 +49,7 @@ __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __a
__attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
// Test the analyzer is working at all.
void test_working() {
void test_working(void) {
int *p = 0;
*p = 0xDEADBEEF; // expected-warning {{null}}
}
@ -75,7 +75,7 @@ void testblock_qux(int x) {
}
// Test that Objective-C pointers are null initialized.
void test_nil_initialized() {
void test_nil_initialized(void) {
id x;
if (x == 0)
return;
@ -84,12 +84,12 @@ void test_nil_initialized() {
}
// Test that we don't flag leaks of Objective-C objects.
void test_alloc() {
void test_alloc(void) {
[NSObject alloc]; // no-warning
}
// Test that CF allocations are still caught as leaks.
void test_cf_leak() {
void test_cf_leak(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t); // expected-warning {{Potential leak}}
(void) date;
@ -115,7 +115,7 @@ void test_cf_leak() {
@end
// Test that dead store checking works in the prescence of "cleanups" in the AST.
void rdar9424882() {
void rdar9424882(void) {
id x = [NSObject alloc]; // expected-warning {{Value stored to 'x' during its initialization is never read}}
}
@ -127,15 +127,15 @@ typedef const struct __CFString *CFStringRef;
- (id) self;
@end
CFTypeRef CFCreateSomething();
CFStringRef CFCreateString();
CFTypeRef CFGetSomething();
CFStringRef CFGetString();
CFTypeRef CFCreateSomething(void);
CFStringRef CFCreateString(void);
CFTypeRef CFGetSomething(void);
CFStringRef CFGetString(void);
id CreateSomething();
NSString *CreateNSString();
id CreateSomething(void);
NSString *CreateNSString(void);
void from_cf() {
void from_cf(void) {
id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning{{never read}}
id obj2 = (__bridge_transfer NSString*)CFCreateString();
[obj2 self]; // Add a use, to show we can use the object after it has been transferred.
@ -153,14 +153,14 @@ void to_cf(id obj) {
CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); // expected-warning{{never read}}
}
void test_objc_retainedObject() {
void test_objc_retainedObject(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
id x = objc_retainedObject(date);
(void) x;
}
void test_objc_unretainedObject() {
void test_objc_unretainedObject(void) {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t); // expected-warning {{Potential leak}}
id x = objc_unretainedObject(date);
@ -168,12 +168,12 @@ void test_objc_unretainedObject() {
}
// Previously this resulted in a "return of stack address" warning.
id test_return() {
id test_return(void) {
id x = (__bridge_transfer id) CFCreateString();
return x; // no-warning
}
void test_objc_arrays() {
void test_objc_arrays(void) {
{ // CASE ONE -- OBJECT IN ARRAY CREATED DIRECTLY
NSObject *o = [[NSObject alloc] init];
NSArray *a = [[NSArray alloc] initWithObjects:o, (void*)0];
@ -210,20 +210,20 @@ void rdar11059275(dispatch_object_t object) {
NSObject *o = [[NSObject alloc] init];
dispatch_set_context(object, CFBridgingRetain(o)); // no-warning
}
void rdar11059275_positive() {
void rdar11059275_positive(void) {
NSObject *o = [[NSObject alloc] init]; // expected-warning {{leak}}
CFBridgingRetain(o);
}
void rdar11059275_negative() {
void rdar11059275_negative(void) {
NSObject *o = [[NSObject alloc] init]; // no-warning
(void) o;
}
__attribute__((ns_returns_retained)) id rdar14061675_helper() {
__attribute__((ns_returns_retained)) id rdar14061675_helper(void) {
return [[NSObject alloc] init];
}
id rdar14061675() {
id rdar14061675(void) {
// ARC produces an implicit cast here. We need to make sure the combination
// of that and the inlined call don't produce a spurious edge cycle.
id result = rdar14061675_helper();
@ -240,7 +240,7 @@ extern CFTypeRef CFRetain(CFTypeRef cf);
extern void CFRelease(CFTypeRef cf);
void check_bridge_retained_cast() {
void check_bridge_retained_cast(void) {
NSString *nsStr = [[NSString alloc] init];
CFStringRef cfStr = (__bridge_retained CFStringRef)nsStr;
CFRelease(cfStr); // no-warning
@ -255,7 +255,7 @@ void check_bridge_to_non_cocoa(CFStringRef s) {
struct B;
struct B * check_bridge_to_non_cf() {
struct B * check_bridge_to_non_cf(void) {
NSString *s = [[NSString alloc] init];
return (__bridge struct B*) s;
}

View File

@ -5,7 +5,7 @@
typedef signed char BOOL;
void rdar_10597458() {
void rdar_10597458(void) {
if (__objc_yes)
return;
int *p = 0;

View File

@ -49,11 +49,11 @@ extern void *malloc(size_t);
extern void free(void *);
extern char *strdup(const char *str);
id constant_string() {
id constant_string(void) {
return @("boxed constant string.");
}
id dynamic_string() {
id dynamic_string(void) {
return @(strdup("boxed dynamic string")); // expected-warning{{Potential memory leak}}
}
@ -61,14 +61,14 @@ typedef struct __attribute__((objc_boxable)) {
const char *str;
} BoxableStruct;
id leak_within_boxed_struct() {
id leak_within_boxed_struct(void) {
BoxableStruct bs;
bs.str = strdup("dynamic string"); // The duped string shall be owned by val.
NSValue *val = @(bs); // no-warning
return val;
}
id leak_of_boxed_struct() {
id leak_of_boxed_struct(void) {
BoxableStruct *bs = malloc(sizeof(BoxableStruct)); // The pointer stored in bs isn't owned by val.
NSValue *val = @(*bs); // expected-warning{{Potential leak of memory pointed to by 'bs'}}
return val;
@ -80,7 +80,7 @@ id const_char_pointer(int *x) {
return @(*x); // expected-warning {{Dereference of null pointer (loaded from variable 'x')}}
}
void checkNonNil() {
void checkNonNil(void) {
clang_analyzer_eval(!!@3); // expected-warning{{TRUE}}
clang_analyzer_eval(!!@(3+4)); // expected-warning{{TRUE}}
clang_analyzer_eval(!!@(57.0)); // expected-warning{{TRUE}}

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.Loops,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
#define nil ((id)0)
@ -53,7 +53,7 @@ typedef unsigned long NSUInteger;
@interface NSString : NSObject
@end
void test() {
void test(void) {
id x;
for (x in [NSArray testObject])
clang_analyzer_eval(x != nil); // expected-warning{{TRUE}}
@ -71,7 +71,7 @@ void test() {
clang_analyzer_eval(x != nil); // expected-warning{{UNKNOWN}}
}
void testWithVarInFor() {
void testWithVarInFor(void) {
for (id x in [NSArray testObject])
clang_analyzer_eval(x != nil); // expected-warning{{TRUE}}
for (id x in [NSPointerArray testObject])
@ -168,7 +168,7 @@ void onlySuppressLoopExitAfterZeroIterations_WithContinue(NSMutableDictionary *D
}
}
int* getPtr();
int* getPtr(void);
void onlySuppressLoopExitAfterZeroIterations_WithBreak(NSMutableDictionary *D) {
if (D.count > 0) {
int *x;
@ -345,7 +345,7 @@ void boxedArrayEscape(NSMutableArray *array) {
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
}
int not_reachable_on_iteration_through_nil() {
int not_reachable_on_iteration_through_nil(void) {
NSDictionary* d = nil;
for (NSString* s in [d allKeys])
clang_analyzer_warnIfReached(); // no-warning

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -fobjc-arc -analyzer-checker=core,debug.ExprInspection -verify %s
void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
extern void __assert_fail (__const char *__assertion, __const char *__file,
unsigned int __line, __const char *__function)

View File

@ -1,6 +1,6 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify -Wno-objc-root-class %s
extern void clang_analyzer_warnIfReached();
extern void clang_analyzer_warnIfReached(void);
void clang_analyzer_eval(int);
@interface SomeClass

View File

@ -1,7 +1,7 @@
// REQUIRES: asserts
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-stats -fblocks %s 2>&1 | FileCheck %s
@interface I
int f() {
int f(void) {
return 0;
}
@end

Some files were not shown because too many files have changed in this diff Show More