130 changes: 65 additions & 65 deletions clang/test/Analysis/misc-ps.m

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions clang/test/Analysis/mmap-writeexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,15 +28,15 @@ void f1()
(void)c;
}

void f2()
void f2(void)
{
void *(*callm)(void *, size_t, int, int, int, long);
callm = mmap;
int prot = PROT_WRITE | PROT_EXEC;
(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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ - (long double)longDoubleM { return 0.0; }
- (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;

Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/no-outofbounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
// 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
short *z = (short*) &x;
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
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/non-diagnosable-assumptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -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}}
Expand All @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/nonnull.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/null-deref-path-notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/null-deref-path-notes.m
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down
18 changes: 9 additions & 9 deletions clang/test/Analysis/null-deref-ps-region.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions clang/test/Analysis/null-deref-ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -79,7 +79,7 @@ int f4_b() {
return 0;
}

int f5() {
int f5(void) {

char *s = "hello world";
return s[0]; // no-warning
Expand Down Expand Up @@ -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;
}
Expand All @@ -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}}
}
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/null-deref-static.m
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/nullability.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions clang/test/Analysis/objc-arc.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (id)initWithArray:(NSArray *)array;
__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}}
}
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -115,7 +115,7 @@ - (RDar9424890_A *)obj:(RDar9424890_A *)obj {
@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}}
}

Expand All @@ -127,15 +127,15 @@ @interface NSString : NSObject
- (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.
Expand All @@ -153,27 +153,27 @@ 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);
(void) x;
}

// 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];
Expand Down Expand Up @@ -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();
Expand All @@ -240,7 +240,7 @@ id rdar14061675() {
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
Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion clang/test/Analysis/objc-bool.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

typedef signed char BOOL;

void rdar_10597458() {
void rdar_10597458(void) {
if (__objc_yes)
return;
int *p = 0;
Expand Down
10 changes: 5 additions & 5 deletions clang/test/Analysis/objc-boxing.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,26 @@ + (NSValue *)valueWithBytes:(const void *)value
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}}
}

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;
Expand All @@ -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}}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/Analysis/objc-for.m
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -53,7 +53,7 @@ @interface NSPointerArray : NSObject <NSFastEnumeration>
@interface NSString : NSObject
@end

void test() {
void test(void) {
id x;
for (x in [NSArray testObject])
clang_analyzer_eval(x != nil); // expected-warning{{TRUE}}
Expand All @@ -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])
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/objc-indirect-copy-restore.m
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/objc-message.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/objc-method-coverage.m
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/objc-radar17039661.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static inline BOOL performAction(NSNumber *(^action)(NSNumber *traitValue)) {
return didFindTrait;
}

void runTest() {
void runTest(void) {
__attribute__((__blocks__(byref))) NSNumber *builtinResult = ((NSNumber *)0);
BOOL wasBuiltinTrait = performAction(^(NSNumber *traitValue) {
builtinResult = [traitValue retain];
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/offsetofexpr-callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct S {
char c;
};

void test() {
void test(void) {
offsetof(struct S, c);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/openmp-unsupported.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.builtin -fopenmp -verify %s
// expected-no-diagnostics

void openmp_parallel_crash_test() {
void openmp_parallel_crash_test(void) {
#pragma omp parallel
;
#pragma omp parallel for
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/out-of-bounds-false-positive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RUN: -analyzer-config eagerly-assume=false -verify %s

void clang_analyzer_eval(int);
void clang_analyzer_printState();
void clang_analyzer_printState(void);

typedef unsigned long long size_t;
const char a[] = "abcd"; // extent: 5 bytes
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/out-of-bounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,19 @@ void test_assume_after_access(unsigned long x) {

// Don't warn when indexing below the start of a symbolic region's whose
// base extent we don't know.
int *get_symbolic();
void test_index_below_symboloc() {
int *get_symbolic(void);
void test_index_below_symboloc(void) {
int *buf = get_symbolic();
buf[-1] = 0; // no-warning;
}

void test_incomplete_struct() {
void test_incomplete_struct(void) {
extern struct incomplete incomplete;
int *p = (int *)&incomplete;
p[1] = 42; // no-warning
}

void test_extern_void() {
void test_extern_void(void) {
extern void v;
int *p = (int *)&v;
p[1] = 42; // no-warning
Expand Down
14 changes: 7 additions & 7 deletions clang/test/Analysis/outofbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void *calloc(size_t, size_t);

char f1() {
char f1(void) {
char* s = "abcd";
char c = s[4]; // no-warning
return s[5] + c; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
}

void f2() {
void f2(void) {
int *p = malloc(12);
p[3] = 4; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
}
Expand All @@ -27,34 +27,34 @@ struct seven_words {
int c[7];
};

void f3() {
void f3(void) {
struct three_words a, *p;
p = &a;
p[0] = a; // no-warning
p[1] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
}

void f4() {
void f4(void) {
struct seven_words c;
struct three_words a, *p = (struct three_words *)&c;
p[0] = a; // no-warning
p[1] = a; // no-warning
p[2] = a; // expected-warning{{Access out-of-bound array element (buffer overflow)}}
}

void f5() {
void f5(void) {
char *p = calloc(2,2);
p[3] = '.'; // no-warning
p[4] = '!'; // expected-warning{{out-of-bound}}
}

void f6() {
void f6(void) {
char a[2];
int *b = (int*)a;
b[1] = 3; // expected-warning{{out-of-bound}}
}

void f7() {
void f7(void) {
struct three_words a;
a.c[3] = 1; // expected-warning{{out-of-bound}}
}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/Analysis/padding_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct HoldsOverlyAlignedChar { // expected-warning{{Excessive padding in 'struc
char c2;
};

void internalStructFunc() {
void internalStructFunc(void) {
struct X { // expected-warning{{Excessive padding in 'struct X'}}
char c1;
int t;
Expand All @@ -187,7 +187,7 @@ void internalStructFunc() {
struct X obj;
}

void typedefStructFunc() {
void typedefStructFunc(void) {
typedef struct { // expected-warning{{Excessive padding in 'S'}}
char c1;
int t;
Expand All @@ -196,7 +196,7 @@ void typedefStructFunc() {
S obj;
}

void anonStructFunc() {
void anonStructFunc(void) {
struct { // expected-warning{{Excessive padding in 'struct (unnamed}}
char c1;
int t;
Expand Down Expand Up @@ -230,7 +230,7 @@ struct SmallArrayInFunc {
char c2;
};

void arrayHolder() {
void arrayHolder(void) {
struct SmallArrayInFunc Arr[15];
}

Expand All @@ -245,6 +245,6 @@ struct HoldsSmallArray {
struct SmallArrayInStruct Field[20];
} HoldsSmallArrayElt;

void nestedPadding() {
void nestedPadding(void) {
struct HoldsSmallArray Arr[15];
}
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-html-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void null_deref(int *a) {
*a = 1; // expected-warning{{null}}
}

void test1() {
void test1(void) {
CALL_FN(0);
}

Expand Down
12 changes: 6 additions & 6 deletions clang/test/Analysis/plist-macros-with-expansion-ctu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern void F2(int **);
extern void F3(int **);
extern void F_H(int **);

void test0() {
void test0(void) {
int *X;
F3(&X);
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand All @@ -28,7 +28,7 @@ void test0() {
// CHECK-NEXT: <array>
// CHECK-NEXT: </array>

void test1() {
void test1(void) {
int *X;
F1(&X);
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand All @@ -38,7 +38,7 @@ void test1() {
// CHECK-NEXT: <array>
// CHECK-NEXT: </array>

void test2() {
void test2(void) {
int *X;
F2(&X);
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand All @@ -50,7 +50,7 @@ void test2() {

#define M F1(&X)

void test3() {
void test3(void) {
int *X;
M;
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand All @@ -73,7 +73,7 @@ void test3() {
#undef M
#define M F2(&X)

void test4() {
void test4(void) {
int *X;
M;
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand All @@ -93,7 +93,7 @@ void test4() {
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>

void test_h() {
void test_h(void) {
int *X;
F_H(&X);
*X = 1; // expected-warning{{Dereference of null pointer}}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-macros-with-expansion.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// RUN: FileCheck --input-file=%t.plist %s

#define STRANGE_FN(x) STRANGE_FN(x, 0)
void test_strange_macro_expansion() {
void test_strange_macro_expansion(void) {
char *path;
STRANGE_FN(path); // no-crash
// expected-warning@-1 {{implicit declaration of function}}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-output-alternate.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void test_null_field(void) {
}

// <rdar://problem/8331641> leak reports should not show paths that end with exit() (but ones that don't end with exit())
void panic() __attribute__((noreturn));
void panic(void) __attribute__((noreturn));
enum { kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2, kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4, kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6, kCFNumberCharType = 7, kCFNumberShortType = 8, kCFNumberIntType = 9, kCFNumberLongType = 10, kCFNumberLongLongType = 11, kCFNumberFloatType = 12, kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14, kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16, kCFNumberMaxType = 16 };
typedef const struct __CFAllocator * CFAllocatorRef;
extern const CFAllocatorRef kCFAllocatorDefault;
Expand Down
18 changes: 9 additions & 9 deletions clang/test/Analysis/plist-output.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void test_assumptions(int a, int b)
*p = 0xDEADBEEF;
}

int *bar_cond_assign();
int test_cond_assign() {
int *bar_cond_assign(void);
int test_cond_assign(void) {
int *p;
if (p = bar_cond_assign())
return 1;
Expand Down Expand Up @@ -91,7 +91,7 @@ - (void)test2 {
@end

// Test that loops are documented in the path.
void rdar12280665() {
void rdar12280665(void) {
for (unsigned i = 0; i < 2; ++i) {
if (i == 1) {
int *p = 0;
Expand All @@ -101,7 +101,7 @@ void rdar12280665() {
}

// Test for a "loop executed 0 times" diagnostic.
int *radar12322528_bar();
int *radar12322528_bar(void);

void radar12322528_for(int x) {
int *p = 0;
Expand All @@ -121,7 +121,7 @@ void radar12322528_while(int x) {
*p = 0xDEADBEEF;
}

void radar12322528_foo_2() {
void radar12322528_foo_2(void) {
int *p = 0;
for (unsigned i = 0; i < 2; ++i) {
if (i == 1)
Expand All @@ -130,13 +130,13 @@ void radar12322528_foo_2() {
*p = 0xDEADBEEF;
}

void test_loop_diagnostics() {
void test_loop_diagnostics(void) {
int *p = 0;
for (int i = 0; i < 2; ++i) { p = 0; }
*p = 1;
}

void test_loop_diagnostics_2() {
void test_loop_diagnostics_2(void) {
int *p = 0;
for (int i = 0; i < 2; ) {
++i;
Expand All @@ -145,7 +145,7 @@ void test_loop_diagnostics_2() {
*p = 1;
}

void test_loop_diagnostics_3() {
void test_loop_diagnostics_3(void) {
int *p = 0;
int i = 0;
while (i < 2) {
Expand Down Expand Up @@ -178,7 +178,7 @@ - (void)test {

struct RDar13295437_S { int *i; };

int RDar13295437() {
int RDar13295437(void) {
struct RDar13295437_S s = {0};
struct RDar13295437_S *sp = &s;
RDar13295437_f(sp->i);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/plist-stats-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// REQUIRES: asserts
// RUN: FileCheck --input-file=%t.plist %s

int foo() {}
int foo(void) {}


// CHECK: <key>diagnostics</key>
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/pointer-arithmetic.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s

int test1() {
int test1(void) {
int *p = (int *)sizeof(int);
p -= 1;
return *p; // expected-warning {{Dereference of null pointer}}
}

int test2() {
int test2(void) {
int *p = (int *)sizeof(int);
p -= 2;
p += 1;
return *p; // expected-warning {{Dereference of null pointer}}
}

int test3() {
int test3(void) {
int *p = (int *)sizeof(int);
p++;
p--;
p--;
return *p; // expected-warning {{Dereference of null pointer}}
}

int test4() {
int test4(void) {
// This is a special case where pointer arithmetic is not calculated to
// preserve useful warnings on dereferences of null pointers.
int *p = 0;
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/pointer-escape-on-conservative-calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


void f(int *);
int *getMem();
int *getMem(void);

int main() {
int main(void) {
f(getMem());
return 0;
}
Expand Down
52 changes: 26 additions & 26 deletions clang/test/Analysis/pr22954.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct aa {
};

// Test different types of structure initialisation.
int f0() {
int f0(void) {
struct aa a0 = {{1, 2, 3, 4}, 0};
a0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -34,7 +34,7 @@ int f0() {
return 0;
}

int f1() {
int f1(void) {
struct aa a1;
a1.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -48,7 +48,7 @@ int f1() {
return 0;
}

int f2() {
int f2(void) {
struct aa a2 = {{1, 2}};
a2.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -62,7 +62,7 @@ int f2() {
return 0;
}

int f3() {
int f3(void) {
struct aa a3 = {{1, 2, 3, 4}, 0};
a3.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -86,7 +86,7 @@ struct bb {
char * s2;
};

int f4() {
int f4(void) {
struct bb b0 = {{1, 2, 3, 4}, 0};
b0.s2 = strdup("hello");
b0.a.s2 = strdup("hola");
Expand All @@ -108,31 +108,31 @@ int f4() {
}

// Test that memory leaks are caught.
int f5() {
int f5(void) {
struct aa a0 = {{1, 2, 3, 4}, 0};
a0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
memcpy(a0.s1, input, 4);
return 0; // expected-warning{{Potential leak of memory pointed to by 'a0.s2'}}
}

int f6() {
int f6(void) {
struct aa a1;
a1.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
memcpy(a1.s1, input, 4);
return 0; // expected-warning{{Potential leak of memory pointed to by 'a1.s2'}}
}

int f7() {
int f7(void) {
struct aa a2 = {{1, 2}};
a2.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
memcpy(a2.s1, input, 4);
return 0; // expected-warning{{Potential leak of memory pointed to by 'a2.s2'}}
}

int f8() {
int f8(void) {
struct aa a3 = {{1, 2, 3, 4}, 0};
a3.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -141,7 +141,7 @@ int f8() {
return 0; // expected-warning{{Potential leak of memory pointed to by 'a3.s2'}}
}

int f9() {
int f9(void) {
struct bb b0 = {{1, 2, 3, 4}, 0};
b0.s2 = strdup("hello");
b0.a.s2 = strdup("hola");
Expand All @@ -152,7 +152,7 @@ int f9() {
return 0;
}

int f10() {
int f10(void) {
struct bb b0 = {{1, 2, 3, 4}, 0};
b0.s2 = strdup("hello");
b0.a.s2 = strdup("hola");
Expand All @@ -169,7 +169,7 @@ struct cc {
char * s2;
};

int f11() {
int f11(void) {
char x[4] = {1, 2};
x[0] = 1;
x[1] = 2;
Expand All @@ -194,7 +194,7 @@ struct dd {
char s1[4];
};

int f12() {
int f12(void) {
struct dd d0 = {0, {1, 2, 3, 4}};
d0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -219,7 +219,7 @@ struct EE {
char * s2;
};

int f13() {
int f13(void) {
struct EE E0 = {{{1, 2}, {3, 4}}, 0};
E0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -236,7 +236,7 @@ int f13() {
// Test global parameters.
struct aa a15 = {{1, 2, 3, 4}, 0};

int f15() {
int f15(void) {
a15.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
memcpy(a15.s1, input, 4);
Expand All @@ -256,7 +256,7 @@ struct gg {
char * s2;
};

int f16() {
int f16(void) {
struct gg g0 = {{}, 0};
g0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -277,7 +277,7 @@ struct hh {
char * s2;
};

int f17() {
int f17(void) {
struct hh h0;
h0.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -297,7 +297,7 @@ struct ii {
char * s2;
};

int f18() {
int f18(void) {
struct ii i18 = {{1, 2, 3, 4}, 5, 6};
i18.i = 10;
i18.j = 11;
Expand All @@ -314,7 +314,7 @@ int f18() {
return 0;
}

int f181() {
int f181(void) {
struct ii i181 = {{1, 2, 3, 4}, 5, 6};
i181.i = 10;
i181.j = 11;
Expand Down Expand Up @@ -453,7 +453,7 @@ struct mm {
char * s4;
};

int f24() {
int f24(void) {
struct ll l24 = {{1, 2, 3, 4}, 0};
struct mm * m24 = (struct mm *)&l24;
m24->s4 = strdup("hello");
Expand Down Expand Up @@ -518,7 +518,7 @@ int f26(int i) {
}

// Test sizeof as a size argument.
int f261() {
int f261(void) {
struct aa a261 = {{1, 2, 3, 4}, 0};
a261.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -532,7 +532,7 @@ int f261() {
}

// Test negative size argument.
int f262() {
int f262(void) {
struct aa a262 = {{1, 2, 3, 4}, 0};
a262.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand Down Expand Up @@ -639,7 +639,7 @@ union uu {
char s1[4];
};

int f30() {
int f30(void) {
union uu u30 = { .s1 = {1, 2, 3, 4}};
char input[] = {1, 2, 3, 4};
memcpy(u30.s1, input, 4);
Expand All @@ -656,7 +656,7 @@ struct kk {
char * s2;
};

int f31() {
int f31(void) {
struct kk k31;
k31.s2 = strdup("hello");
k31.u.x = 1;
Expand All @@ -677,7 +677,7 @@ union vv {
char * s2;
};

int f32() {
int f32(void) {
union vv v32;
v32.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand All @@ -699,7 +699,7 @@ struct nn {
};

// Test bad types to dest buffer.
int f33() {
int f33(void) {
struct nn n33 = {1, 2, 3, 4, 0};
n33.s2 = strdup("hello");
char input[] = {'a', 'b', 'c', 'd'};
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/pr_4164.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef __uint32_t __darwin_socklen_t;
typedef __darwin_socklen_t socklen_t;
int getsockopt(int, int, int, void * restrict, socklen_t * restrict);

int test1() {
int test1(void) {
int s = -1;
int size;
socklen_t size_len = sizeof(size);
Expand All @@ -32,7 +32,7 @@ int test1() {
// ElementRegion itself has elements whose type are integral (essentially raw
// data) we strip off the ElementRegion when doing the invalidation.
int takes_charptr(char* p);
int test2() {
int test2(void) {
int size;
if (takes_charptr((char*)&size))
return -1;
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/properties.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ -(void)dealloc {
@end

#if !__has_feature(objc_arc)
void rdar6611873() {
void rdar6611873(void) {
Person *p = [[[Person alloc] init] autorelease];

p.name = [[NSString string] retain]; // expected-warning {{leak}}
Expand Down Expand Up @@ -967,7 +967,7 @@ - (void)testAssignImplicitSynthOkay:(id)newValue {

// rdar://problem/19862648
- (void)establishIvarIsNilDuringLoops {
extern id getRandomObject();
extern id getRandomObject(void);

int i = 4; // Must be at least 4 to trigger the bug.
while (--i) {
Expand Down Expand Up @@ -998,7 +998,7 @@ @implementation Wrapper
@synthesize value;
@end

void testNoCrashWhenAccessPropertyAndThereAreNoDirectBindingsAtAll() {
void testNoCrashWhenAccessPropertyAndThereAreNoDirectBindingsAtAll(void) {
union {
Wrapper *wrapper;
} u = { 0 };
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/pthreadlock_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#define NULL 0

void clang_analyzer_printState();
void clang_analyzer_printState(void);

pthread_mutex_t mtx;

void test() {
void test(void) {
clang_analyzer_printState();
// CHECK: "checker_messages": null

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/pthreadlock_state_nottracked.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#define NULL 0

void clang_analyzer_printState();
void clang_analyzer_printState(void);

void test(pthread_mutex_t *mtx) {
int ret = pthread_mutex_destroy(mtx);
Expand Down
28 changes: 14 additions & 14 deletions clang/test/Analysis/ptr-arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
void clang_analyzer_eval(int);
void clang_analyzer_dump(int);

void f1() {
void f1(void) {
int a[10];
int *p = a;
++p;
}

char* foo();
char* foo(void);

void f2() {
void f2(void) {
char *p = foo();
++p;
}

// This test case checks if we get the right rvalue type of a TypedViewRegion.
// The ElementRegion's type depends on the array region's rvalue type. If it was
// a pointer type, we would get a loc::SymbolVal for '*p'.
void* memchr();
void* memchr(const void *, int, __typeof__(sizeof(0)));
static int
domain_port (const char *domain_b, const char *domain_e,
const char **domain_e_ptr)
Expand All @@ -35,7 +35,7 @@ domain_port (const char *domain_b, const char *domain_e,
return port;
}

void f3() {
void f3(void) {
int x, y;
int d = &y - &x; // expected-warning{{Subtraction of two pointers that do not point to the same memory chunk may cause incorrect result}}

Expand All @@ -45,12 +45,12 @@ void f3() {
d = q-p; // no-warning
}

void f4() {
void f4(void) {
int *p;
p = (int*) 0x10000; // expected-warning{{Using a fixed address is not portable because that address will probably not be valid in all environments or platforms}}
}

void f5() {
void f5(void) {
int x, y;
int *p;
p = &x + 1; // expected-warning{{Pointer arithmetic on non-array variables relies on memory layout, which is dangerous}}
Expand Down Expand Up @@ -96,7 +96,7 @@ void null_operand(int *a) {
clang_analyzer_eval(0 < a); // expected-warning{{UNKNOWN}}
}

void const_locs() {
void const_locs(void) {
char *a = (char*)0x1000;
char *b = (char*)0x1100;
start:
Expand All @@ -111,7 +111,7 @@ void const_locs() {
clang_analyzer_eval((char**)a == &a); // expected-warning{{UNKNOWN}}
}

void array_matching_types() {
void array_matching_types(void) {
int array[10];
int *a = &array[2];
int *b = &array[5];
Expand All @@ -123,7 +123,7 @@ void array_matching_types() {
}

// This takes a different code path than array_matching_types()
void array_different_types() {
void array_different_types(void) {
int array[10];
int *a = &array[2];
char *b = (char*)&array[5];
Expand All @@ -134,7 +134,7 @@ void array_different_types() {
}

struct test { int x; int y; };
void struct_fields() {
void struct_fields(void) {
struct test a, b;

clang_analyzer_eval(&a.x != &a.y); // expected-warning{{TRUE}}
Expand All @@ -146,7 +146,7 @@ void struct_fields() {
clang_analyzer_eval(&a.x >= &b.x); // expected-warning{{UNKNOWN}}
}

void mixed_region_types() {
void mixed_region_types(void) {
struct test s;
int array[2];
void *a = &array, *b = &s;
Expand Down Expand Up @@ -320,14 +320,14 @@ void negativeIndex(char *str) {
clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
}

void test_no_crash_on_pointer_to_label() {
void test_no_crash_on_pointer_to_label(void) {
char *a = &&label;
a[0] = 0;
label:;
}

typedef __attribute__((__ext_vector_type__(2))) float simd_float2;
float test_nowarning_on_vector_deref() {
float test_nowarning_on_vector_deref(void) {
simd_float2 x = {0, 1};
return x[1]; // no-warning
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/range_casts.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This test checks that intersecting ranges does not cause 'system is over constrained' assertions in the case of eg: 32 bits unsigned integers getting their range from 64 bits signed integers.
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s

void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);

void f1(long foo)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ - (Bar)foo {
}
@end

void createFoo() {
void createFoo(void) {
MyClass *obj = 0;
Bar f = [obj foo]; // no-warning
}

void createFoo2() {
void createFoo2(void) {
MyClass *obj = 0;
[obj foo]; // no-warning
Bar f = [obj foo]; // no-warning
Expand Down
18 changes: 9 additions & 9 deletions clang/test/Analysis/redefined_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

// Make sure we don't crash when someone redefines a system function we reason about.

char memmove ();
char malloc();
char system();
char stdin();
char memccpy();
char free();
char strdup();
char atoi();
char memmove (void);
char malloc(void);
char system(void);
char stdin(void);
char memccpy(void);
char free(void);
char strdup(void);
char atoi(void);

int foo () {
int foo (void) {
return memmove() + malloc() + system() + stdin() + memccpy() + free() + strdup() + atoi();

}
4 changes: 2 additions & 2 deletions clang/test/Analysis/region-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ int printf(const char *restrict,...);

// Testing core functionality of the region store.
// radar://10127782
int compoundLiteralTest() {
int compoundLiteralTest(void) {
int index = 0;
for (index = 0; index < 2; index++) {
int thing = (int []){0, 1}[index];
Expand All @@ -13,7 +13,7 @@ int compoundLiteralTest() {
return 0;
}

int compoundLiteralTest2() {
int compoundLiteralTest2(void) {
int index = 0;
for (index = 0; index < 3; index++) {
int thing = (int [][3]){{0,0,0}, {1,1,1}, {2,2,2}}[index][index];
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/retain-release-arc.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ - (CFDictionaryRef)copyTestReturningCoreFoundation:(NSData *)plistData {

int buf[1024];

void libdispatch_leaked_data() {
void libdispatch_leaked_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
}
Expand All @@ -132,23 +132,23 @@ void libdispatch_leaked_data() {
// expected-note@-4{{Object leaked: object allocated and stored into 'data' is not referenced later in this execution path and has a retain count of +1}}
#endif

void libdispatch_dispatch_released_data() {
void libdispatch_dispatch_released_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
dispatch_release(data); // no-warning
#endif
}

void libdispatch_objc_released_data() {
void libdispatch_objc_released_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
[data release]; // no-warning
#endif
}

void libdispatch_leaked_retained_data() {
void libdispatch_leaked_retained_data(void) {
dispatch_data_t data = dispatch_data_create(buf, 1024,
dispatch_get_main_queue(), ^{});
#if !HAS_ARC
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/retain-release-cf-audited.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
extern CFTypeRef CFRetain(CFTypeRef cf);
extern void CFRelease(CFTypeRef cf);

extern CFTypeRef CFCreateSomethingAudited();
extern CFTypeRef CFCreateSomethingAudited(void);
#pragma clang arc_cf_code_audited end

extern CFTypeRef CFCreateSomethingUnaudited();
extern CFTypeRef CFCreateSomethingUnaudited(void);

void testAudited() {
void testAudited(void) {
CFTypeRef obj = CFCreateSomethingAudited(); // no-warning
CFRelease(obj); // no-warning

Expand All @@ -23,7 +23,7 @@ void testAudited() {
CFRelease(obj2); // no-warning
}

void testUnaudited() {
void testUnaudited(void) {
CFTypeRef obj = CFCreateSomethingUnaudited(); // no-warning
CFRelease(obj); // no-warning

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/retain-release-compound-literal.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

typedef const void *CFTypeRef;

extern CFTypeRef CFCreate() CF_RETURNS_RETAINED;
extern CFTypeRef CFCreate(void) CF_RETURNS_RETAINED;
extern CFTypeRef CFRetain(CFTypeRef cf);
extern void CFRelease(CFTypeRef cf);

void bar(CFTypeRef *v) {}

void test1() {
void test1(void) {
CFTypeRef *values = (CFTypeRef[]){
CFCreate(), // no-warning
CFCreate(), // expected-warning{{leak}}
Expand Down
12 changes: 6 additions & 6 deletions clang/test/Analysis/retain-release-inline.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ void bar(id x) {
[x release];
}

void test() {
void test(void) {
NSString *s = [[NSString alloc] init]; // expected-warning {{Potential leak}}
foo(s);
foo(s);
bar(s);
}

void test_neg() {
void test_neg(void) {
NSString *s = [[NSString alloc] init]; // no-warning
foo(s);
foo(s);
Expand Down Expand Up @@ -396,11 +396,11 @@ CFStringRef test_return_ratained_CF(char *bytes) {
}

// On return (intraprocedural), assume NSObjects are not leaked.
id test_return_retained_NS() {
id test_return_retained_NS(void) {
return [[NSString alloc] init]; // no-warning
}

void test_test_return_retained() {
void test_test_return_retained(void) {
id x = test_return_retained_NS(); // expected-warning {{leak}}
[x retain];
[x release];
Expand Down Expand Up @@ -437,14 +437,14 @@ void test_test_return_inline_2(char *bytes) {
extern CFStringRef getString(void);
CFStringRef testCovariantReturnType(void) __attribute__((cf_returns_retained));

void usetestCovariantReturnType() {
void usetestCovariantReturnType(void) {
CFStringRef S = ((void*)0);
S = testCovariantReturnType();
if (S)
CFRelease(S);
}

CFStringRef testCovariantReturnType() {
CFStringRef testCovariantReturnType(void) {
CFStringRef Str = ((void*)0);
Str = getString();
if (Str) {
Expand Down
32 changes: 16 additions & 16 deletions clang/test/Analysis/retain-release-path-notes.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ - (id)objectForKeyedSubscript:(id)key;
id NSMakeCollectable(CFTypeRef);
CFTypeRef CFMakeCollectable(CFTypeRef);

CFTypeRef CFCreateSomething();
CFTypeRef CFGetSomething();
CFTypeRef CFCreateSomething(void);
CFTypeRef CFGetSomething(void);


void creationViaAlloc () {
void creationViaAlloc (void) {
id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}

void creationViaCFCreate () {
void creationViaCFCreate (void) {
CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type 'CFTypeRef' with a +1 retain count}}
return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}
Expand All @@ -67,25 +67,25 @@ void acquisitionViaProperty (Foo *foo) {
return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}

void acquisitionViaCFFunction () {
void acquisitionViaCFFunction (void) {
CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type 'CFTypeRef' with a +0 retain count}}
CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}}
return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}

void explicitDealloc () {
void explicitDealloc (void) {
id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
[object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}}
[object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
}

void implicitDealloc () {
void implicitDealloc (void) {
id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
[object release]; // expected-note{{Object released}}
[object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
}

void overAutorelease () {
void overAutorelease (void) {
id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
[object autorelease]; // expected-note{{Object autoreleased}}
[object autorelease]; // expected-note{{Object autoreleased}}
Expand All @@ -98,19 +98,19 @@ void autoreleaseUnowned (Foo *foo) {
return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased but has a +0 retain count}}
}

void makeCollectableIgnored() {
void makeCollectableIgnored(void) {
CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type 'CFTypeRef' with a +1 retain count}}
CFMakeCollectable(leaked);
NSMakeCollectable(leaked);
return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
}

CFTypeRef CFCopyRuleViolation () {
CFTypeRef CFCopyRuleViolation (void) {
CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type 'CFTypeRef' with a +0 retain count}}
return object; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}}
}

CFTypeRef CFGetRuleViolation () {
CFTypeRef CFGetRuleViolation (void) {
CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type 'CFTypeRef' with a +1 retain count}}
return object; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation}}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id /* <NSCopying
@end


void testNumericLiteral() {
void testNumericLiteral(void) {
id result = @1; // expected-note{{NSNumber literal is an object with a +0 retain count}}
[result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}}
}
Expand Down Expand Up @@ -243,20 +243,20 @@ +(void)test {
@end


void CFOverAutorelease() {
void CFOverAutorelease(void) {
CFTypeRef object = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type 'CFTypeRef' with a +1 retain count}}
CFAutorelease(object); // expected-note{{Object autoreleased}}
CFAutorelease(object); // expected-note{{Object autoreleased}}
return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +1 retain count}}
}

void CFAutoreleaseUnowned() {
void CFAutoreleaseUnowned(void) {
CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type 'CFTypeRef' with a +0 retain count}}
CFAutorelease(object); // expected-note{{Object autoreleased}}
return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased but has a +0 retain count}}
}

void CFAutoreleaseUnownedMixed() {
void CFAutoreleaseUnownedMixed(void) {
CFTypeRef object = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type 'CFTypeRef' with a +0 retain count}}
CFAutorelease(object); // expected-note{{Object autoreleased}}
[(id)object autorelease]; // expected-note{{Object autoreleased}}
Expand Down Expand Up @@ -327,7 +327,7 @@ - (void)testOverreleaseIvarOnlyAutorelease {

@end

int seed();
int seed(void);

@interface LeakReassignmentTests : MyObj
@end
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/retain-release-region-store.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ -(id) initWithObjects:(const id *)objects count:(NSUInteger) cnt;
// temporarily "escape" retain counted objects stored to structs very eagerly
// until we can properly tell whether they have escaped via a return value
// or not.
CFAbsoluteTime f4() {
CFAbsoluteTime f4(void) {
struct foo x;

CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/retain-release-safe.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern void CFRelease(CFTypeRef cf);
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#define CF_CONSUMED __attribute__((cf_consumed))

extern CFTypeRef CFCreate() CF_RETURNS_RETAINED;
extern CFTypeRef CFCreate(void) CF_RETURNS_RETAINED;

// A "safe" variant of CFRetain that doesn't crash when a null pointer is
// retained. This is often defined by users in a similar manner. The
Expand Down Expand Up @@ -51,7 +51,7 @@ void releaseCFType(CFTypeRef CF_CONSUMED cf) {

void escape(CFTypeRef cf);

void makeSureTestsWork() {
void makeSureTestsWork(void) {
CFTypeRef cf = CFCreate();
CFRelease(cf);
CFRelease(cf); // expected-warning{{Reference-counted object is used after it is released}}
Expand Down
194 changes: 97 additions & 97 deletions clang/test/Analysis/retain-release.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clang/test/Analysis/security-syntax-checks-no-emit.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ long nrand48(unsigned short[3]);
long random(void);
int rand_r(unsigned *);

void test_rand()
void test_rand(void)
{
unsigned short a[7];
unsigned b;
Expand Down
28 changes: 14 additions & 14 deletions clang/test/Analysis/security-syntax-checks.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//
// For reference: https://www.securecoding.cert.org/confluence/display/seccode/FLP30-C.+Do+not+use+floating+point+variables+as+loop+counters
//
void test_float_condition() {
void test_float_condition(void) {
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
for (float x = 100000001.0f; x <= 100000010.0f; x += 1.0f) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
for (float x = 100000001.0f; x <= 100000010.0f; x++ ) {} // expected-warning{{Variable 'x' with floating point type 'float'}}
Expand Down Expand Up @@ -94,14 +94,14 @@ void test_bzero(void *a, size_t n) {
// Part of recommendation: 300-BSI (buildsecurityin.us-cert.gov)
char* gets(char *buf);

void test_gets() {
void test_gets(void) {
char buff[1024];
gets(buff); // expected-warning{{Call to function 'gets' is extremely insecure as it can always result in a buffer overflow}}
}

int getpw(unsigned int uid, char *buf);

void test_getpw() {
void test_getpw(void) {
char buff[1024];
getpw(2, buff); // expected-warning{{The getpw() function is dangerous as it may overflow the provided buffer. It is obsoleted by getpwuid()}}
}
Expand All @@ -119,7 +119,7 @@ void test_getpw() {
extern void check(int);
void abort(void);

void test_setuid()
void test_setuid(void)
{
setuid(2); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
setuid(0); // expected-warning{{The return value from the call to 'setuid' is not checked. If an error occurs in 'setuid', the following code may execute with unexpected privileges}}
Expand Down Expand Up @@ -151,7 +151,7 @@ void test_setuid()
long random(void);
int rand_r(unsigned *);

void test_rand()
void test_rand(void)
{
unsigned short a[7];
unsigned b;
Expand All @@ -170,7 +170,7 @@ void test_rand()

char *mktemp(char *buf);

void test_mktemp() {
void test_mktemp(void) {
char *x = mktemp("/tmp/zxcv"); // expected-warning{{Call to function 'mktemp' is insecure as it always creates or uses insecure temporary file}}
}

Expand All @@ -192,24 +192,24 @@ void test_mktemp() {

#endif /* VARIANT */

void test_strcpy() {
void test_strcpy(void) {
char x[4];
char *y;

strcpy(x, y); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119}}
}

void test_strcpy_2() {
void test_strcpy_2(void) {
char x[4];
strcpy(x, "abcd"); //expected-warning{{Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119}}
}

void test_strcpy_safe() {
void test_strcpy_safe(void) {
char x[5];
strcpy(x, "abcd");
}

void test_strcpy_safe_2() {
void test_strcpy_safe_2(void) {
struct {char s1[100];} s;
strcpy(s.s1, "hello");
}
Expand All @@ -231,7 +231,7 @@ void test_strcpy_safe_2() {

#endif /* VARIANT */

void test_strcat() {
void test_strcat(void) {
char x[4];
char *y;

Expand All @@ -245,7 +245,7 @@ void test_strcat() {
typedef __int32_t pid_t;
pid_t vfork(void);

void test_vfork() {
void test_vfork(void) {
vfork(); //expected-warning{{Call to function 'vfork' is insecure as it can lead to denial of service situations in the parent process}}
}

Expand All @@ -258,7 +258,7 @@ void test_vfork() {
int mkstemp(char *template);
char *mktemp(char *template);

void test_mkstemp() {
void test_mkstemp(void) {
mkstemp("XX"); // expected-warning {{Call to 'mkstemp' should have at least 6 'X's in the format string to be secure (2 'X's seen)}}
mkstemp("XXXXXX");
mkstemp("XXXXXXX");
Expand Down Expand Up @@ -300,7 +300,7 @@ void test_mkstemp() {
char *strncat(char *destination, const char *source, size_t num);
void *memset(void *ptr, int value, size_t num);

void test_deprecated_or_unsafe_buffer_handling_1() {
void test_deprecated_or_unsafe_buffer_handling_1(void) {
char buf [5];
wchar_t wbuf [5];
int a;
Expand Down
12 changes: 6 additions & 6 deletions clang/test/Analysis/simple-stream-checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void checkLeakFollowedByAssert(int *Data) {
}
}

void CloseOnlyOnValidFileHandle() {
void CloseOnlyOnValidFileHandle(void) {
FILE *F = fopen("myfile.txt", "w");
if (F)
fclose(F);
Expand All @@ -58,14 +58,14 @@ FILE *leakOnEnfOfPath3(int *Data) {
}

void myfclose(FILE *F);
void SymbolEscapedThroughFunctionCall() {
void SymbolEscapedThroughFunctionCall(void) {
FILE *F = fopen("myfile.txt", "w");
myfclose(F);
return; // no warning
}

FILE *GlobalF;
void SymbolEscapedThroughAssignmentToGlobal() {
void SymbolEscapedThroughAssignmentToGlobal(void) {
FILE *F = fopen("myfile.txt", "w");
GlobalF = F;
return; // no warning
Expand All @@ -78,19 +78,19 @@ void SymbolDoesNotEscapeThoughStringAPIs(char *Data) {
}

void passConstPointer(const FILE * F);
void testPassConstPointer() {
void testPassConstPointer(void) {
FILE *F = fopen("myfile.txt", "w");
passConstPointer(F);
return; // expected-warning {{Opened file is never closed; potential resource leak}}
}

void testPassToSystemHeaderFunctionIndirectly() {
void testPassToSystemHeaderFunctionIndirectly(void) {
FileStruct fs;
fs.p = fopen("myfile.txt", "w");
fakeSystemHeaderCall(&fs); // invalidates fs, making fs.p unreachable
} // no-warning

void testOverwrite() {
void testOverwrite(void) {
FILE *fp = fopen("myfile.txt", "w");
fp = 0;
} // expected-warning {{Opened file is never closed; potential resource leak}}
4 changes: 2 additions & 2 deletions clang/test/Analysis/solver-sym-simplification-adjustment.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -verify

void clang_analyzer_warnIfReached();
void clang_analyzer_eval();
void clang_analyzer_warnIfReached(void);
void clang_analyzer_eval(_Bool);

void test_simplification_adjustment_concrete_int(int b, int c) {
if (b < 0 || b > 1) // b: [0,1]
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/solver-sym-simplification-concreteint.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// RUN: -analyzer-config eagerly-assume=false \
// RUN: -verify

void clang_analyzer_warnIfReached();
void clang_analyzer_eval();
void clang_analyzer_warnIfReached(void);
void clang_analyzer_eval(_Bool);

void test_simplification_to_concrete_int_infeasible(int b, int c) {
if (c + b != 0) // c + b == 0
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/solver-sym-simplification-no-crash2.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// expected-no-diagnostics

int a, b, c, d;
void f() {
void f(void) {
a = -1;
d = b * a;
a = d / c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Here we test that the range based solver equivalency tracking mechanism
// assigns a properly typed range to the simplified symbol.

void clang_analyzer_printState();
void clang_analyzer_printState(void);
void clang_analyzer_eval(int);

void f(int a0, int b0, int c)
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/stack-addr-ps.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -fblocks -verify %s

int* f1() {
int* f1(void) {
int x = 0;
return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}
Expand Down Expand Up @@ -33,7 +33,7 @@ void* compound_literal(int x, int y) {
return p; // expected-warning{{Address of stack memory}}
}

void* alloca_test() {
void* alloca_test(void) {
void* p = __builtin_alloca(10);
return p; // expected-warning{{Address of stack memory}}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ ComparatorBlock test_return_block_neg(void) {
}

// <rdar://problem/7523821>
int *rdar_7523821_f2() {
int *rdar_7523821_f2(void) {
int a[3];
return a; // expected-warning 2 {{ddress of stack memory associated with local variable 'a' returned}}
};
Expand All @@ -93,7 +93,7 @@ RDar10348049 test_rdar10348049(void) {
void testRegister(register const char *reg) {
if (reg) (void)reg[0];
}
void callTestRegister() {
void callTestRegister(void) {
char buf[20];
testRegister(buf); // no-warning
}
16 changes: 8 additions & 8 deletions clang/test/Analysis/stackaddrleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
typedef __INTPTR_TYPE__ intptr_t;
char const *p;

void f0() {
void f0(void) {
char const str[] = "This will change";
p = str;
} // expected-warning{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}

void f1() {
void f1(void) {
char const str[] = "This will change";
p = str;
p = 0; // no-warning
}

void f2() {
void f2(void) {
p = (const char *) __builtin_alloca(12);
} // expected-warning{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller. This will be a dangling reference}}

Expand All @@ -28,30 +28,30 @@ static int pr7383(__const char *__)
extern __const char *__const pr7383_list[];

// Test that we catch multiple returns via globals when analyzing a function.
void test_multi_return() {
void test_multi_return(void) {
static int *a, *b;
int x;
a = &x;
b = &x;
} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'b' upon returning}}

intptr_t returnAsNonLoc() {
intptr_t returnAsNonLoc(void) {
int x;
return (intptr_t)&x; // expected-warning{{Address of stack memory associated with local variable 'x' returned to caller}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

bool returnAsBool() {
bool returnAsBool(void) {
int x;
return &x; // no-warning
}

void assignAsNonLoc() {
void assignAsNonLoc(void) {
extern intptr_t ip;
int x;
ip = (intptr_t)&x;
} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'ip' upon returning}}

void assignAsBool() {
void assignAsBool(void) {
extern bool b;
int x;
b = &x;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/static_local.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// expected-no-diagnostics

// Test reasoning about static locals in ObjCMethods.
int *getValidPtr();
int *getValidPtr(void);
@interface Radar11275803
- (int) useStaticInMethod;
@end
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/stats.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// REQUIRES: asserts
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-stats %s 2>&1 | FileCheck %s

void foo() {
void foo(void) {
int x;
}
// CHECK: ... Statistics Collected ...
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/std-c-library-functions-POSIX-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Must have at least one call expression to initialize the summary map.
int bar(void);
void foo() {
void foo(void) {
bar();
}

Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/std-c-library-functions-POSIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,6 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex);

// Must have at least one call expression to initialize the summary map.
int bar(void);
void foo() {
void foo(void) {
bar();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
typedef typeof(sizeof(int)) size_t;

int __buf_size_arg_constraint(const void *, size_t);
void test_buf_size_concrete() {
void test_buf_size_concrete(void) {
char buf[3]; // bugpath-note{{'buf' initialized here}}
int s = 4; // bugpath-note{{'s' initialized to 4}}
__buf_size_arg_constraint(buf, s); // \
Expand All @@ -22,7 +22,7 @@ void test_buf_size_concrete() {
}

int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
void test_buf_size_concrete_with_multiplication() {
void test_buf_size_concrete_with_multiplication(void) {
short buf[3]; // bugpath-note{{'buf' initialized here}}
int s1 = 4; // bugpath-note{{'s1' initialized to 4}}
int s2 = sizeof(short); // bugpath-note{{'s2' initialized to}}
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/std-c-library-functions-arg-constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ void test_multiple_constraints_on_same_arg(int x) {
}

int __variadic(void *stream, const char *format, ...);
void test_arg_constraint_on_variadic_fun() {
void test_arg_constraint_on_variadic_fun(void) {
__variadic(0, "%d%d", 1, 2); // \
// report-warning{{Function argument constraint is not satisfied}} \
// report-note{{}} \
Expand All @@ -271,7 +271,7 @@ void test_arg_constraint_on_variadic_fun() {
}

int __buf_size_arg_constraint(const void *, size_t);
void test_buf_size_concrete() {
void test_buf_size_concrete(void) {
char buf[3]; // bugpath-note{{'buf' initialized here}}
__buf_size_arg_constraint(buf, 4); // \
// report-warning{{Function argument constraint is not satisfied}} \
Expand Down Expand Up @@ -300,7 +300,7 @@ void test_buf_size_symbolic_and_offset(int s) {
}

int __buf_size_arg_constraint_mul(const void *, size_t, size_t);
void test_buf_size_concrete_with_multiplication() {
void test_buf_size_concrete_with_multiplication(void) {
short buf[3]; // bugpath-note{{'buf' initialized here}}
__buf_size_arg_constraint_mul(buf, 4, sizeof(short)); // \
// report-warning{{Function argument constraint is not satisfied}} \
Expand Down Expand Up @@ -328,7 +328,7 @@ void test_buf_size_symbolic_and_offset_with_multiplication(size_t s) {

// The minimum buffer size for this function is set to 10.
int __buf_size_arg_constraint_concrete(const void *);
void test_min_buf_size() {
void test_min_buf_size(void) {
char buf[9];// bugpath-note{{'buf' initialized here}}
__buf_size_arg_constraint_concrete(buf); // \
// report-warning{{Function argument constraint is not satisfied}} \
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Analysis/std-c-library-functions-arg-weakdeps.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
// CHECK: Loaded summary for: unsigned long fread(void *restrict, size_t, size_t, FILE *restrict) __attribute__((nonnull(1)))
// CHECK: Loaded summary for: int fileno(FILE *stream)

void initializeSummaryMap();
void initializeSummaryMap(void);
// We analyze this function first, and the call expression inside initializes
// the summary map. This way we force the loading of the summaries. The
// summaries would not be loaded without this because during the first bug
// report in WeakDependency::checkPreCall we stop further evaluation. And
// StdLibraryFunctionsChecker lazily initializes its summary map from its
// checkPreCall.
void analyzeThisFirst() {
void analyzeThisFirst(void) {
initializeSummaryMap();
}

Expand All @@ -45,7 +45,7 @@ int isalnum(int);
size_t fread(void *restrict, size_t, size_t, FILE *restrict) __attribute__((nonnull(1)));
int fileno(FILE *stream);

void test_uninit_arg() {
void test_uninit_arg(void) {
int v;
int r = isalnum(v); // \
// expected-warning{{1st function call argument is an uninitialized value [core.CallAndMessage]}}
Expand All @@ -58,7 +58,7 @@ void test_notnull_arg(FILE *F) {
expected-warning{{Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker]}}
}

void test_notnull_stream_arg() {
void test_notnull_stream_arg(void) {
fileno(0); // \
// expected-warning{{Stream pointer might be NULL [alpha.unix.Stream]}}
}
2 changes: 1 addition & 1 deletion clang/test/Analysis/std-c-library-functions-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ size_t fread(void *restrict, size_t, size_t, FILE *restrict);

// Must have at least one call expression to initialize the summary map.
int bar(void);
void foo() {
void foo(void) {
bar();
}
2 changes: 1 addition & 1 deletion clang/test/Analysis/std-c-library-functions-restrict.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ void __test_restrict_param_2(void *restrict p);

// Must have at least one call expression to initialize the summary map.
int bar(void);
void foo() {
void foo(void) {
bar();
}
12 changes: 6 additions & 6 deletions clang/test/Analysis/std-c-library-functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void test_islower(int x) {
}

int getchar(void);
void test_getchar() {
void test_getchar(void) {
int x = getchar();
if (x == EOF)
return;
Expand All @@ -175,20 +175,20 @@ void test_getchar() {
}

int isalpha(int);
void test_isalpha() {
void test_isalpha(void) {
clang_analyzer_eval(isalpha(']')); // expected-warning{{FALSE}}
clang_analyzer_eval(isalpha('Q')); // expected-warning{{TRUE}}
clang_analyzer_eval(isalpha(128)); // expected-warning{{UNKNOWN}}
}

int isalnum(int);
void test_alnum() {
void test_alnum(void) {
clang_analyzer_eval(isalnum('1')); // expected-warning{{TRUE}}
clang_analyzer_eval(isalnum(')')); // expected-warning{{FALSE}}
}

int isblank(int);
void test_isblank() {
void test_isblank(void) {
clang_analyzer_eval(isblank('\t')); // expected-warning{{TRUE}}
clang_analyzer_eval(isblank(' ')); // expected-warning{{TRUE}}
clang_analyzer_eval(isblank('\n')); // expected-warning{{FALSE}}
Expand Down Expand Up @@ -247,7 +247,7 @@ void test_isxdigit(int x) {
}
}

void test_call_by_pointer() {
void test_call_by_pointer(void) {
typedef int (*func)(int);
func f = isascii;
clang_analyzer_eval(f('A')); // expected-warning{{TRUE}}
Expand All @@ -256,7 +256,7 @@ void test_call_by_pointer() {
}

char *getenv(const char *name);
void test_getenv() {
void test_getenv(void) {
// getenv() bifurcates here.
clang_analyzer_eval(getenv("FOO") == 0);
// expected-warning@-1 {{TRUE}}
Expand Down
26 changes: 13 additions & 13 deletions clang/test/Analysis/stream-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
#include "Inputs/system-header-simulator.h"

void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
void StreamTesterChecker_make_feof_stream(FILE *);
void StreamTesterChecker_make_ferror_stream(FILE *);

void error_fopen() {
void error_fopen(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand All @@ -20,7 +20,7 @@ void error_fopen() {
fclose(F);
}

void error_freopen() {
void error_freopen(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand All @@ -32,7 +32,7 @@ void error_freopen() {
fclose(F);
}

void stream_error_feof() {
void stream_error_feof(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand All @@ -45,7 +45,7 @@ void stream_error_feof() {
fclose(F);
}

void stream_error_ferror() {
void stream_error_ferror(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand All @@ -58,7 +58,7 @@ void stream_error_ferror() {
fclose(F);
}

void error_fread() {
void error_fread(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand All @@ -83,7 +83,7 @@ void error_fread() {
Ret = fread(Buf, 1, 10, F); // expected-warning {{Stream might be already closed}}
}

void error_fwrite() {
void error_fwrite(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand Down Expand Up @@ -114,7 +114,7 @@ void freadwrite_zerosize_eofstate(FILE *F) {
fread(0, 0, 1, F); // expected-warning {{Read function called when stream is in EOF state}}
}

void error_fread_fwrite_zerosize() {
void error_fread_fwrite_zerosize(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand All @@ -136,7 +136,7 @@ void error_fread_fwrite_zerosize() {
fclose(F);
}

void error_fseek() {
void error_fseek(void) {
FILE *F = fopen("file", "r");
if (!F)
return;
Expand Down Expand Up @@ -167,7 +167,7 @@ void error_fseek() {
fclose(F);
}

void error_indeterminate() {
void error_indeterminate(void) {
FILE *F = fopen("file", "r+");
if (!F)
return;
Expand All @@ -185,7 +185,7 @@ void error_indeterminate() {
fclose(F);
}

void error_indeterminate_clearerr() {
void error_indeterminate_clearerr(void) {
FILE *F = fopen("file", "r+");
if (!F)
return;
Expand All @@ -206,7 +206,7 @@ void error_indeterminate_clearerr() {
fclose(F);
}

void error_indeterminate_feof1() {
void error_indeterminate_feof1(void) {
FILE *F = fopen("file", "r+");
if (!F)
return;
Expand All @@ -220,7 +220,7 @@ void error_indeterminate_feof1() {
fclose(F);
}

void error_indeterminate_feof2() {
void error_indeterminate_feof2(void) {
FILE *F = fopen("file", "r+");
if (!F)
return;
Expand Down
14 changes: 7 additions & 7 deletions clang/test/Analysis/stream-note.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "Inputs/system-header-simulator.h"

void check_note_at_correct_open() {
void check_note_at_correct_open(void) {
FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
if (!F1)
// expected-note@-1 {{'F1' is non-null}}
Expand All @@ -22,7 +22,7 @@ void check_note_at_correct_open() {
// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
// expected-note@-2 {{Opened stream never closed. Potential resource leak}}

void check_note_fopen() {
void check_note_fopen(void) {
FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
if (!F)
// expected-note@-1 {{'F' is non-null}}
Expand All @@ -32,7 +32,7 @@ void check_note_fopen() {
// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
// expected-note@-2 {{Opened stream never closed. Potential resource leak}}

void check_note_freopen() {
void check_note_freopen(void) {
FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
if (!F)
// expected-note@-1 {{'F' is non-null}}
Expand Down Expand Up @@ -78,7 +78,7 @@ void check_note_leak_2(int c) {
fclose(F2);
}

void check_track_null() {
void check_track_null(void) {
FILE *F;
F = fopen("foo1.c", "r"); // expected-note {{Value assigned to 'F'}} expected-note {{Assuming pointer value is null}}
if (F != NULL) { // expected-note {{Taking false branch}} expected-note {{'F' is equal to NULL}}
Expand All @@ -89,7 +89,7 @@ void check_track_null() {
// expected-note@-1 {{Stream pointer might be NULL}}
}

void check_eof_notes_feof_after_feof() {
void check_eof_notes_feof_after_feof(void) {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
Expand All @@ -108,7 +108,7 @@ void check_eof_notes_feof_after_feof() {
fclose(F);
}

void check_eof_notes_feof_after_no_feof() {
void check_eof_notes_feof_after_no_feof(void) {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
Expand All @@ -131,7 +131,7 @@ void check_eof_notes_feof_after_no_feof() {
fclose(F);
}

void check_eof_notes_feof_or_no_error() {
void check_eof_notes_feof_or_no_error(void) {
FILE *F;
char Buf[10];
F = fopen("foo1.c", "r");
Expand Down
42 changes: 21 additions & 21 deletions clang/test/Analysis/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,69 @@

#include "Inputs/system-header-simulator.h"

void check_fread() {
void check_fread(void) {
FILE *fp = tmpfile();
fread(0, 0, 0, fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_fwrite() {
void check_fwrite(void) {
FILE *fp = tmpfile();
fwrite(0, 0, 0, fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_fseek() {
void check_fseek(void) {
FILE *fp = tmpfile();
fseek(fp, 0, 0); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_ftell() {
void check_ftell(void) {
FILE *fp = tmpfile();
ftell(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_rewind() {
void check_rewind(void) {
FILE *fp = tmpfile();
rewind(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_fgetpos() {
void check_fgetpos(void) {
FILE *fp = tmpfile();
fpos_t pos;
fgetpos(fp, &pos); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_fsetpos() {
void check_fsetpos(void) {
FILE *fp = tmpfile();
fpos_t pos;
fsetpos(fp, &pos); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_clearerr() {
void check_clearerr(void) {
FILE *fp = tmpfile();
clearerr(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_feof() {
void check_feof(void) {
FILE *fp = tmpfile();
feof(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_ferror() {
void check_ferror(void) {
FILE *fp = tmpfile();
ferror(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
}

void check_fileno() {
void check_fileno(void) {
FILE *fp = tmpfile();
fileno(fp); // expected-warning {{Stream pointer might be NULL}}
fclose(fp);
Expand Down Expand Up @@ -160,12 +160,12 @@ void pr8081(FILE *stream, long offset, int whence) {
fseek(stream, offset, whence);
}

void check_freopen_1() {
void check_freopen_1(void) {
FILE *f1 = freopen("foo.c", "r", (FILE *)0); // expected-warning {{Stream pointer might be NULL}}
f1 = freopen(0, "w", (FILE *)0x123456); // Do not report this as error.
}

void check_freopen_2() {
void check_freopen_2(void) {
FILE *f1 = fopen("foo.c", "r");
if (f1) {
FILE *f2 = freopen(0, "w", f1);
Expand All @@ -183,7 +183,7 @@ void check_freopen_2() {
}
}

void check_freopen_3() {
void check_freopen_3(void) {
FILE *f1 = fopen("foo.c", "r");
if (f1) {
// Unchecked result of freopen.
Expand All @@ -197,7 +197,7 @@ void check_freopen_3() {
extern FILE *GlobalF;
extern void takeFile(FILE *);

void check_escape1() {
void check_escape1(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand All @@ -206,7 +206,7 @@ void check_escape1() {
fwrite("1", 1, 1, F); // no warning
}

void check_escape2() {
void check_escape2(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand All @@ -215,7 +215,7 @@ void check_escape2() {
fwrite("1", 1, 1, F); // no warning
}

void check_escape3() {
void check_escape3(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand All @@ -227,7 +227,7 @@ void check_escape3() {
fwrite("1", 1, 1, F); // no warning
}

void check_escape4() {
void check_escape4(void) {
FILE *F = tmpfile();
if (!F)
return;
Expand All @@ -242,9 +242,9 @@ void check_escape4() {
}

int Test;
_Noreturn void handle_error();
_Noreturn void handle_error(void);

void check_leak_noreturn_1() {
void check_leak_noreturn_1(void) {
FILE *F1 = tmpfile();
if (!F1)
return;
Expand All @@ -256,7 +256,7 @@ void check_leak_noreturn_1() {

// Check that "location uniqueing" works.
// This results in reporting only one occurence of resource leak for a stream.
void check_leak_noreturn_2() {
void check_leak_noreturn_2(void) {
FILE *F1 = tmpfile();
if (!F1)
return;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/string-with-signedness.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
void *strcpy(unsigned char *, unsigned char *);

unsigned char a, b;
void testUnsignedStrcpy() {
void testUnsignedStrcpy(void) {
strcpy(&a, &b);
}
238 changes: 119 additions & 119 deletions clang/test/Analysis/string.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clang/test/Analysis/sval-dump-int128.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

void clang_analyzer_dump(unsigned __int128 x);

void testDumpInt128() {
void testDumpInt128(void) {
clang_analyzer_dump((unsigned __int128)5 << 64); // expected-warning{{92233720368547758080 U128b}}
}
2 changes: 1 addition & 1 deletion clang/test/Analysis/svalbuilder-float-cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void SymbolCast_of_float_type_aux(int *p) {
clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
}

void SymbolCast_of_float_type() {
void SymbolCast_of_float_type(void) {
extern float x;
void (*f)() = SymbolCast_of_float_type_aux;
f(&x);
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/svalbuilder-logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ int SValBuilderLogicNoCrash(int *x) {

// http://llvm.org/bugs/show_bug.cgi?id=15863
// Don't crash when mixing 'bool' and 'int' in implicit comparisons to 0.
void pr15863() {
extern int getBool();
void pr15863(void) {
extern int getBool(void);
_Bool a = getBool();
(void)!a; // no-warning
}
226 changes: 113 additions & 113 deletions clang/test/Analysis/svalbuilder-rearrange-comparisons.c

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clang/test/Analysis/switch-case.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s

void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);

#define INT_MIN 0x80000000
#define INT_MAX 0x7fffffff
Expand Down Expand Up @@ -208,7 +208,7 @@ void testDifferentTypes3(int arg) {
}
}

void testConstant() {
void testConstant(void) {
switch (3) {
case 1 ... 5:
clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
Expand Down
30 changes: 15 additions & 15 deletions clang/test/Analysis/symbol-reaper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

void clang_analyzer_eval(int);
void clang_analyzer_warnOnDeadSymbol(int);
void clang_analyzer_numTimesReached();
void clang_analyzer_warnIfReached();
void clang_analyzer_numTimesReached(void);
void clang_analyzer_warnIfReached(void);

void exit(int);

int conjure_index();
int conjure_index(void);

void test_that_expr_inspection_works() {
void test_that_expr_inspection_works(void) {
do {
int x = conjure_index();
clang_analyzer_warnOnDeadSymbol(x);
Expand All @@ -27,7 +27,7 @@ void test_that_expr_inspection_works() {

int arr[3];

int *test_element_index_lifetime_in_environment_values() {
int *test_element_index_lifetime_in_environment_values(void) {
int *ptr;
do {
int x = conjure_index();
Expand All @@ -37,7 +37,7 @@ int *test_element_index_lifetime_in_environment_values() {
return ptr;
}

void test_element_index_lifetime_in_store_keys() {
void test_element_index_lifetime_in_store_keys(void) {
do {
int x = conjure_index();
clang_analyzer_warnOnDeadSymbol(x);
Expand All @@ -47,7 +47,7 @@ void test_element_index_lifetime_in_store_keys() {
}

int *ptr;
void test_element_index_lifetime_in_store_values() {
void test_element_index_lifetime_in_store_values(void) {
do {
int x = conjure_index();
clang_analyzer_warnOnDeadSymbol(x);
Expand All @@ -65,10 +65,10 @@ struct S3 {
void *field;
};

struct S1 *conjure_S1();
struct S3 *conjure_S3();
struct S1 *conjure_S1(void);
struct S3 *conjure_S3(void);

void test_element_index_lifetime_with_complicated_hierarchy_of_regions() {
void test_element_index_lifetime_with_complicated_hierarchy_of_regions(void) {
do {
int x = conjure_index();
clang_analyzer_warnOnDeadSymbol(x);
Expand All @@ -77,7 +77,7 @@ void test_element_index_lifetime_with_complicated_hierarchy_of_regions() {
} while (0); // no-warning
}

void test_loc_as_integer_element_index_lifetime() {
void test_loc_as_integer_element_index_lifetime(void) {
do {
int x;
struct S3 *s = conjure_S3();
Expand All @@ -99,18 +99,18 @@ void test_region_lifetime_as_store_value(int *x) {
clang_analyzer_eval(**ptrptr); // expected-warning{{TRUE}}
} // no-warning

int *produce_region_referenced_only_through_field_in_environment_value() {
int *produce_region_referenced_only_through_field_in_environment_value(void) {
struct S1 *s = conjure_S1();
clang_analyzer_warnOnDeadSymbol((int) s);
int *x = &s->field;
return x;
}

void test_region_referenced_only_through_field_in_environment_value() {
void test_region_referenced_only_through_field_in_environment_value(void) {
produce_region_referenced_only_through_field_in_environment_value();
} // expected-warning{{SYMBOL DEAD}}

void test_region_referenced_only_through_field_in_store_value() {
void test_region_referenced_only_through_field_in_store_value(void) {
struct S1 *s = conjure_S1();
clang_analyzer_warnOnDeadSymbol((int) s);
ptr = &s->field; // Write the symbol into a global. It should live forever.
Expand All @@ -128,7 +128,7 @@ void test_region_referenced_only_through_field_in_store_value() {
// to put the diagnostic on.
} // expected-warning{{SYMBOL DEAD}}

void test_zombie_referenced_only_through_field_in_store_value() {
void test_zombie_referenced_only_through_field_in_store_value(void) {
struct S1 *s = conjure_S1();
clang_analyzer_warnOnDeadSymbol((int) s);
int *x = &s->field;
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/taint-diagnostic-visitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
int scanf(const char *restrict format, ...);
int system(const char *command);

void taintDiagnostic()
void taintDiagnostic(void)
{
char buf[128];
scanf("%s", buf); // expected-note {{Taint originated here}}
system(buf); // expected-warning {{Untrusted data is passed to a system call}} // expected-note {{Untrusted data is passed to a system call (CERT/STR02-C. Sanitize data passed to complex subsystems)}}
}

int taintDiagnosticOutOfBound() {
int taintDiagnosticOutOfBound(void) {
int index;
int Array[] = {1, 2, 3, 4, 5};
scanf("%d", &index); // expected-note {{Taint originated here}}
Expand All @@ -27,7 +27,7 @@ int taintDiagnosticDivZero(int operand) {
// expected-note@-1 {{Division by a tainted value, possibly zero}}
}

void taintDiagnosticVLA() {
void taintDiagnosticVLA(void) {
int x;
scanf("%d", &x); // expected-note {{Value assigned to 'x'}}
// expected-note@-1 {{Taint originated here}}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/taint-dumps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// RUN: -analyzer-checker=debug.ExprInspection %s\
// RUN: 2>&1 | FileCheck %s

void clang_analyzer_printState();
int getchar();
void clang_analyzer_printState(void);
int getchar(void);

// CHECK: Tainted symbols:
// CHECK-NEXT: conj_$2{{.*}} : 0
int test_taint_dumps() {
int test_taint_dumps(void) {
int x = getchar();
clang_analyzer_printState();
return x;
Expand Down
38 changes: 19 additions & 19 deletions clang/test/Analysis/taint-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void bufferScanfAssignment(int x) {
}
}

void scanfArg() {
void scanfArg(void) {
int t = 0;
scanf("%d", t); // expected-warning {{format specifies type 'int *' but the argument has type 'int'}}
}
Expand Down Expand Up @@ -160,7 +160,7 @@ void testUncontrolledFormatString(char **p) {
}

int system(const char *command);
void testTaintSystemCall() {
void testTaintSystemCall(void) {
char buffer[156];
char addr[128];
scanf("%s", addr);
Expand All @@ -171,7 +171,7 @@ void testTaintSystemCall() {
system(buffer); // expected-warning {{Untrusted data is passed to a system call}}
}

void testTaintSystemCall2() {
void testTaintSystemCall2(void) {
// Test that snpintf transfers taint.
char buffern[156];
char addr[128];
Expand All @@ -180,7 +180,7 @@ void testTaintSystemCall2() {
system(buffern); // expected-warning {{Untrusted data is passed to a system call}}
}

void testTaintSystemCall3() {
void testTaintSystemCall3(void) {
char buffern2[156];
int numt;
char addr[128];
Expand All @@ -189,13 +189,13 @@ void testTaintSystemCall3() {
system(buffern2); // expected-warning {{Untrusted data is passed to a system call}}
}

void testGets() {
void testGets(void) {
char str[50];
gets(str);
system(str); // expected-warning {{Untrusted data is passed to a system call}}
}

void testTaintedBufferSize() {
void testTaintedBufferSize(void) {
size_t ts;
scanf("%zd", &ts);

Expand All @@ -217,7 +217,7 @@ int socket(int, int, int);
size_t read(int, void *, size_t);
int execl(const char *, const char *, ...);

void testSocket() {
void testSocket(void) {
int sock;
char buffer[100];

Expand All @@ -235,7 +235,7 @@ void testSocket() {
execl(buffer, "filename", 0); // expected-warning {{Untrusted data is passed to a system call}}
}

void testStruct() {
void testStruct(void) {
struct {
char buf[16];
int length;
Expand All @@ -249,7 +249,7 @@ void testStruct() {
__builtin_memcpy(buffer, tainted.buf, tainted.length); // expected-warning {{Untrusted data is used to specify the buffer size}}
}

void testStructArray() {
void testStructArray(void) {
struct {
int length;
} tainted[4];
Expand All @@ -274,7 +274,7 @@ void testStructArray() {
__builtin_memcpy(dstbuf, srcbuf, tainted[2].length); // no-warning
}

void testUnion() {
void testUnion(void) {
union {
int x;
char y[4];
Expand All @@ -288,14 +288,14 @@ void testUnion() {
__builtin_memcpy(buffer, tainted.y, tainted.x);
}

int testDivByZero() {
int testDivByZero(void) {
int x;
scanf("%d", &x);
return 5/x; // expected-warning {{Division by a tainted value, possibly zero}}
}

// Zero-sized VLAs.
void testTaintedVLASize() {
void testTaintedVLASize(void) {
int x;
scanf("%d", &x);
int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}}
Expand Down Expand Up @@ -353,46 +353,46 @@ int sprintf_propagates_taint(char *buf, char *msg) {
}

// Test configuration
int mySource1();
int mySource1(void);
void mySource2(int*);
void myScanf(const char*, ...);
int myPropagator(int, int*);
int mySnprintf(char*, size_t, const char*, ...);
bool isOutOfRange(const int*);
void mySink(int, int, int);

void testConfigurationSources1() {
void testConfigurationSources1(void) {
int x = mySource1();
Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
}

void testConfigurationSources2() {
void testConfigurationSources2(void) {
int x;
mySource2(&x);
Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
}

void testConfigurationSources3() {
void testConfigurationSources3(void) {
int x, y;
myScanf("%d %d", &x, &y);
Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
}

void testConfigurationPropagation() {
void testConfigurationPropagation(void) {
int x = mySource1();
int y;
myPropagator(x, &y);
Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
}

void testConfigurationFilter() {
void testConfigurationFilter(void) {
int x = mySource1();
if (isOutOfRange(&x)) // the filter function
return;
Buffer[x] = 1; // no-warning
}

void testConfigurationSinks() {
void testConfigurationSinks(void) {
int x = mySource1();
mySink(x, 1, 2);
// expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
Expand Down
14 changes: 7 additions & 7 deletions clang/test/Analysis/taint-tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int fscanfTest(void) {
}

// Check if we propagate taint from stdin when it's used in an assignment.
void stdinTest1() {
void stdinTest1(void) {
int i;
fscanf(stdin, "%d", &i);
int j = i; // expected-warning + {{tainted}}
Expand All @@ -133,24 +133,24 @@ void stdinTest2(FILE *pIn) {
int jj4 = ii;// no warning
}

void stdinTest3() {
void stdinTest3(void) {
FILE **ppp = &stdin;
int iii;
fscanf(*ppp, "%d", &iii);
int jjj = iii;// expected-warning + {{tainted}}
}

// Test that stdin does not get invalidated by calls.
void foo();
void stdinTest4() {
void foo(void);
void stdinTest4(void) {
int i;
fscanf(stdin, "%d", &i);
foo();
int j = i; // expected-warning + {{tainted}}
}

int getw(FILE *);
void getwTest() {
void getwTest(void) {
int i = getw(stdin); // expected-warning + {{tainted}}
}

Expand All @@ -176,7 +176,7 @@ int atoi(const char *nptr);
long atol(const char *nptr);
long long atoll(const char *nptr);

void atoiTest() {
void atoiTest(void) {
char s[80];
scanf("%s", s);
int d = atoi(s); // expected-warning + {{tainted}}
Expand All @@ -192,7 +192,7 @@ void atoiTest() {

char *pointer1;
void *pointer2;
void noCrashTest() {
void noCrashTest(void) {
if (!*pointer1) {
__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
}
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/test-after-div-zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void ok_pif(int x) {

int getValue(bool *isPositive);
void use(int a);
void foo() {
void foo(void) {
bool isPositive;
int x = getValue(&isPositive);
if (isPositive) {
Expand All @@ -147,8 +147,8 @@ void foo() {
}
}

int getValue2();
void foo2() {
int getValue2(void);
void foo2(void) {
int x = getValue2();
int y = x;

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/test-include.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ void test_01(int *data) {
*data = 1; // expected-warning{{Dereference of null pointer}}
}

int test_02() {
int test_02(void) {
int res = DIVXY(1,0); // expected-warning{{Division by zero}}
// expected-warning@-1{{division by zero is undefined}}
return res;
}

int test_03() {
int test_03(void) {
int res = DIVYX(0,1); // expected-warning{{Division by zero}}
// expected-warning@-1{{division by zero is undefined}}
return res;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/track-control-dependency-conditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @interface J
@property C *c;
@end

J *conjure_J();
J *conjure_J(void);

@implementation I
- (void)bar {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/transparent_union_bug.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -analyze -triple x86_64-apple-darwin10 \
// RUN: -analyzer-checker=core,debug.ExprInspection -verify %s

void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);

typedef struct {
int value;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Analysis/traversal-begin-end-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
void inline_callee(int i);

// CHECK: --BEGIN FUNCTION--
void inline_caller() {
void inline_caller(void) {
// CHECK: --BEGIN FUNCTION--
// CHECK: --BEGIN FUNCTION--
// CHECK: --BEGIN FUNCTION--
Expand Down
Loading