Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the eighth batch of tests being updated (there are a
significant number of other tests left to be updated).
This commit is contained in:
Aaron Ballman 2022-02-12 07:23:43 -05:00
parent 7ad94bd74b
commit 0dd49a5628
158 changed files with 506 additions and 506 deletions

View File

@ -13,7 +13,7 @@ CFArrayRef CFArrayCreate(CFAllocatorRef);
CFDictionaryRef CFDictionaryCreate(CFAllocatorRef);
CFSetRef CFSetCreate(CFAllocatorRef);
void testNoCrash() {
void testNoCrash(void) {
(void)CFArrayCreate(kCFAllocatorDefault);
(void)CFDictionaryCreate(kCFAllocatorDefault);
(void)CFSetCreate(kCFAllocatorDefault);

View File

@ -5,12 +5,12 @@ extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
extern CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef space);
extern void CGColorSpaceRelease(CGColorSpaceRef space);
void f() {
void f(void) {
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB(); // expected-warning{{leak}}
CGColorSpaceRetain(X);
}
void fb() {
void fb(void) {
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
CGColorSpaceRetain(X);
CGColorSpaceRelease(X);

View File

@ -15,19 +15,19 @@
#ifndef EXTRA
void just_runloop() { // No warning: no statements in between
void just_runloop(void) { // No warning: no statements in between
@autoreleasepool {
[[NSRunLoop mainRunLoop] run]; // no-warning
}
}
void just_xpcmain() { // No warning: no statements in between
void just_xpcmain(void) { // No warning: no statements in between
@autoreleasepool {
xpc_main(); // no-warning
}
}
void runloop_init_before() { // Warning: object created before the loop.
void runloop_init_before(void) { // Warning: object created before the loop.
@autoreleasepool {
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
(void) object;
@ -35,7 +35,7 @@ void runloop_init_before() { // Warning: object created before the loop.
}
}
void runloop_init_before_separate_pool() { // No warning: separate autorelease pool.
void runloop_init_before_separate_pool(void) { // No warning: separate autorelease pool.
@autoreleasepool {
NSObject *object;
@autoreleasepool {
@ -46,7 +46,7 @@ void runloop_init_before_separate_pool() { // No warning: separate autorelease p
}
}
void xpcmain_init_before() { // Warning: object created before the loop.
void xpcmain_init_before(void) { // Warning: object created before the loop.
@autoreleasepool {
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}}
(void) object;
@ -54,7 +54,7 @@ void xpcmain_init_before() { // Warning: object created before the loop.
}
}
void runloop_init_before_two_objects() { // Warning: object created before the loop.
void runloop_init_before_two_objects(void) { // Warning: object created before the loop.
@autoreleasepool {
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
NSObject *object2 = [[NSObject alloc] init]; // no-warning, warning on the first one is enough.
@ -64,13 +64,13 @@ void runloop_init_before_two_objects() { // Warning: object created before the l
}
}
void runloop_no_autoreleasepool() {
void runloop_no_autoreleasepool(void) {
NSObject *object = [[NSObject alloc] init]; // no-warning
(void)object;
[[NSRunLoop mainRunLoop] run];
}
void runloop_init_after() { // No warning: objects created after the loop
void runloop_init_after(void) { // No warning: objects created after the loop
@autoreleasepool {
[[NSRunLoop mainRunLoop] run];
NSObject *object = [[NSObject alloc] init]; // no-warning
@ -78,7 +78,7 @@ void runloop_init_after() { // No warning: objects created after the loop
}
}
void no_crash_on_empty_children() {
void no_crash_on_empty_children(void) {
@autoreleasepool {
for (;;) {}
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
@ -90,7 +90,7 @@ void no_crash_on_empty_children() {
#endif
#ifdef AP1
int main() {
int main(void) {
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool of last resort followed by the launch of main run loop may never get released; consider moving them to a separate autorelease pool}}
(void) object;
[[NSRunLoop mainRunLoop] run];
@ -100,7 +100,7 @@ int main() {
#ifdef AP2
// expected-no-diagnostics
int main() {
int main(void) {
NSObject *object = [[NSObject alloc] init]; // no-warning
(void) object;
@autoreleasepool {
@ -112,7 +112,7 @@ int main() {
#ifdef AP3
// expected-no-diagnostics
int main() {
int main(void) {
[[NSRunLoop mainRunLoop] run];
NSObject *object = [[NSObject alloc] init]; // no-warning
(void) object;
@ -121,7 +121,7 @@ int main() {
#endif
#ifdef AP4
int main() {
int main(void) {
NSObject *object = [[NSObject alloc] init]; // expected-warning{{Temporary objects allocated in the autorelease pool of last resort followed by the launch of xpc_main may never get released; consider moving them to a separate autorelease pool}}
(void) object;
xpc_main();
@ -148,7 +148,7 @@ CFStringRef processString(const __NSConstantString *, void *);
#define CFSTR __builtin___CFStringMakeConstantString
int main() {
int main(void) {
I *i;
@autoreleasepool {
NSString *s1 = (__bridge_transfer NSString *)processString(0, 0);

View File

@ -1,6 +1,6 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
#define nil ((id)0)

View File

@ -33,7 +33,7 @@ int g(struct S *ctx) {
// Test that asm import does not fail.
// TODO: Support the GNU extension asm keyword as well.
// Example using the GNU extension: asm("mov $42, %0" : "=r"(res));
int inlineAsm() {
int inlineAsm(void) {
int res;
__asm__("mov $42, %0"
: "=r"(res));

View File

@ -112,33 +112,33 @@ typedef struct {
@end
// NSMutableArray API
void testNilArgNSMutableArray1() {
void testNilArgNSMutableArray1(void) {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray addObject:0]; // expected-warning {{Argument to 'NSMutableArray' method 'addObject:' cannot be nil}}
}
void testNilArgNSMutableArray2() {
void testNilArgNSMutableArray2(void) {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray insertObject:0 atIndex:1]; // expected-warning {{Argument to 'NSMutableArray' method 'insertObject:atIndex:' cannot be nil}}
}
void testNilArgNSMutableArray3() {
void testNilArgNSMutableArray3(void) {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray replaceObjectAtIndex:1 withObject:0]; // expected-warning {{Argument to 'NSMutableArray' method 'replaceObjectAtIndex:withObject:' cannot be nil}}
}
void testNilArgNSMutableArray4() {
void testNilArgNSMutableArray4(void) {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray setObject:0 atIndexedSubscript:1]; // expected-warning {{Argument to 'NSMutableArray' method 'setObject:atIndexedSubscript:' cannot be nil}}
}
void testNilArgNSMutableArray5() {
void testNilArgNSMutableArray5(void) {
NSMutableArray *marray = [[NSMutableArray alloc] init];
marray[1] = 0; // expected-warning {{Array element cannot be nil}}
}
// NSArray API
void testNilArgNSArray1() {
void testNilArgNSArray1(void) {
NSArray *array = [[NSArray alloc] init];
NSArray *copyArray = [array arrayByAddingObject:0]; // expected-warning {{Argument to 'NSArray' method 'arrayByAddingObject:' cannot be nil}}
}
@ -224,7 +224,7 @@ void idc2(id x) {
if (!x)
return;
}
Foo *retNil() {
Foo *retNil(void) {
return 0;
}
@ -282,7 +282,7 @@ void testCountAwareNSOrderedSet(NSOrderedSet *containers, int *validptr) {
}
}
void testLiteralsNonNil() {
void testLiteralsNonNil(void) {
clang_analyzer_eval(!!@[]); // expected-warning{{TRUE}}
clang_analyzer_eval(!!@{}); // expected-warning{{TRUE}}
}

View File

@ -134,7 +134,7 @@ NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
return s4;
}
NSMutableArray* f8() {
NSMutableArray* f8(void) {
NSString* s = [[NSString alloc] init];
NSMutableArray* a = [[NSMutableArray alloc] initWithCapacity:2];
@ -143,7 +143,7 @@ NSMutableArray* f8() {
return a;
}
void f9() {
void f9(void) {
NSString* s = [[NSString alloc] init];
NSString* q = s;
@ -151,7 +151,7 @@ void f9() {
[q release]; // expected-warning {{used after it is released}}
}
NSString* f10() {
NSString* f10(void) {
static NSString* s = 0;
if (!s) s = [[NSString alloc] init];
return s; // no-warning
@ -172,7 +172,7 @@ NSString* f11(CFDictionaryRef dict, const char* key) {
// Test case for passing a tracked object by-reference to a function we
// don't understand.
void unknown_function_f12(NSString** s);
void f12() {
void f12(void) {
NSString *string = [[NSString alloc] init];
unknown_function_f12(&string); // no-warning
}
@ -275,7 +275,7 @@ void f14(MyString *s) {
}
@end
id testSharedClassFromFunction() {
id testSharedClassFromFunction(void) {
return [[SharedClass alloc] _init]; // no-warning
}
@ -300,7 +300,7 @@ extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile
}
#endif
void testOSCompareAndSwap() {
void testOSCompareAndSwap(void) {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!OSAtomicCompareAndSwapPtr(0, s, (void**) &old))
@ -309,7 +309,7 @@ void testOSCompareAndSwap() {
[old release];
}
void testOSCompareAndSwapXXBarrier_local() {
void testOSCompareAndSwapXXBarrier_local(void) {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
@ -318,7 +318,7 @@ void testOSCompareAndSwapXXBarrier_local() {
[old release];
}
void testOSCompareAndSwapXXBarrier_local_no_direct_release() {
void testOSCompareAndSwapXXBarrier_local_no_direct_release(void) {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
@ -333,7 +333,7 @@ int testOSCompareAndSwapXXBarrier_id(Class myclass, id xclass) {
return 0;
}
void test_objc_atomicCompareAndSwap_local() {
void test_objc_atomicCompareAndSwap_local(void) {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
@ -342,7 +342,7 @@ void test_objc_atomicCompareAndSwap_local() {
[old release];
}
void test_objc_atomicCompareAndSwap_local_no_direct_release() {
void test_objc_atomicCompareAndSwap_local_no_direct_release(void) {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
@ -369,13 +369,13 @@ void test_objc_atomicCompareAndSwap_parameter_no_direct_release(NSString **old)
// Test stringWithFormat (<rdar://problem/6815234>)
void test_stringWithFormat() {
void test_stringWithFormat(void) {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain];
[string release];
[string release]; // expected-warning{{Incorrect decrement of the reference count}}
}
// Test isTrackedObjectType().
// Test isTrackedObjectType(void).
typedef NSString* WonkyTypedef;
@interface TestIsTracked
+ (WonkyTypedef)newString;

View File

@ -44,7 +44,7 @@ extern NSString *NSWindowDidBecomeKeyNotification;
// Test cases.
void f1() {
void f1(void) {
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0,0,100,100)
styleMask:NSTitledWindowMask|NSClosableWindowMask
@ -54,7 +54,7 @@ void f1() {
[window orderFrontRegardless]; // no-warning
}
void f2() {
void f2(void) {
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0,0,100,100)
styleMask:NSTitledWindowMask|NSClosableWindowMask
@ -65,7 +65,7 @@ void f2() {
[window orderFrontRegardless]; // no-warning
}
void f2b() {
void f2b(void) {
// FIXME: NSWindow doesn't own itself until it is displayed.
NSWindow *window = [[NSWindow alloc] // no-warning
initWithContentRect:NSMakeRect(0,0,100,100)
@ -80,7 +80,7 @@ void f2b() {
}
void f3() {
void f3(void) {
// FIXME: For now we don't track NSWindow.
NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}}
}

View File

@ -95,7 +95,7 @@ int testCustomException(int *x) {
- (void) alsoDoesNotReturn __attribute__((analyzer_noreturn));
@end
void test_rdar11634353() {
void test_rdar11634353(void) {
[Radar11634353 doesNotReturn];
int *p = 0;
*p = 0xDEADBEEF; // no-warning
@ -107,7 +107,7 @@ void test_rdar11634352_instance(Radar11634353 *o) {
*p = 0xDEADBEEF; // no-warning
}
void test_rdar11634353_positive() {
void test_rdar11634353_positive(void) {
int *p = 0;
*p = 0xDEADBEEF; // expected-warning {{null pointer}}
}
@ -126,7 +126,7 @@ void PR11959(int *p) {
// Test that hard-coded Microsoft _wassert name is recognized as a noreturn
#define assert(_Expression) (void)( (!!(_Expression)) || (_wassert(#_Expression, __FILE__, __LINE__), 0) )
extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
void test_wassert() {
void test_wassert(void) {
assert(0);
int *p = 0;
*p = 0xDEADBEEF; // no-warning
@ -137,7 +137,7 @@ void test_wassert() {
#define assert(_Expression) ((_Expression) ? (void)0 : __assert2(0, 0, 0, 0));
extern void __assert2(const char *, int, const char *, const char *);
extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
void test___assert2() {
void test___assert2(void) {
assert(0);
int *p = 0;
*p = 0xDEADBEEF; // no-warning

View File

@ -7,7 +7,7 @@ int OSAtomicCompareAndSwapPtrBarrier() {
// but we should trust our BodyFarm instead.
}
int *invalidSLocOnRedecl() {
int *invalidSLocOnRedecl(void) {
// Was crashing when trying to throw a report about returning an uninitialized
// value to the caller. FIXME: We should probably still throw that report,
// something like "The "compare" part of CompareAndSwap depends on an
@ -17,7 +17,7 @@ int *invalidSLocOnRedecl() {
return b;
}
void testThatItActuallyWorks() {
void testThatItActuallyWorks(void) {
void *x = 0;
int res = OSAtomicCompareAndSwapPtrBarrier(0, &x, &x);
clang_analyzer_eval(res); // expected-warning{{TRUE}}

View File

@ -26,7 +26,7 @@ typedef struct NestedNonnullMember {
int *_Nonnull Value;
} NestedNonnullMember;
NestedNonnullMember *foo();
NestedNonnullMember *foo(void);
void f1(NestedNonnullMember *Root) {
NestedNonnullMember *Grandson = Root->Child->Child;

View File

@ -2,7 +2,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify -std=c11 -Dbool=_Bool -Dtrue=1 -Dfalse=0 %s
extern void clang_analyzer_eval(bool);
void test__Bool_value() {
void test__Bool_value(void) {
{
bool b = true;
clang_analyzer_eval(b == 1); // expected-warning{{TRUE}}
@ -36,7 +36,7 @@ void test__Bool_value() {
}
}
void test__Bool_increment() {
void test__Bool_increment(void) {
{
bool b = true;
b++;
@ -87,7 +87,7 @@ void test__Bool_increment() {
}
}
void test__Bool_decrement() {
void test__Bool_decrement(void) {
{
bool b = true;
b--;

View File

@ -2,7 +2,7 @@
#include "Inputs/system-header-simulator-objc.h"
static void f() {}
static void f(void) {}
@interface I: NSObject
-(void)instanceMethod:(int)arg1 with:(int)arg2;

View File

@ -1,8 +1,8 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks -analyzer-max-loop 4 %s
int foo();
int foo(void);
int test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}}
int test(void) { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}}
int a = 1;
a = 34 / 12;
@ -14,7 +14,7 @@ int test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unrea
}
int sink() // expected-warning-re{{sink -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 1 | Exhausted Block: yes | Empty WorkList: yes}}
int sink(void) // expected-warning-re{{sink -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 1 | Exhausted Block: yes | Empty WorkList: yes}}
{
for (int i = 0; i < 10; ++i) // expected-warning {{(sink): The analyzer generated a sink at this point}}
++i;
@ -22,7 +22,7 @@ int sink() // expected-warning-re{{sink -> Total CFGBlocks: {{[0-9]+}} | Unreach
return 0;
}
int emptyConditionLoop() // expected-warning-re{{emptyConditionLoop -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: yes | Empty WorkList: yes}}
int emptyConditionLoop(void) // expected-warning-re{{emptyConditionLoop -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: yes | Empty WorkList: yes}}
{
int num = 1;
for (;;)

View File

@ -8,7 +8,7 @@
@interface SomeClass
@end
void simpleStrongPointerValue() {
void simpleStrongPointerValue(void) {
SomeClass *x;
if (x) {}
#if !__has_feature(objc_arc)
@ -16,7 +16,7 @@ void simpleStrongPointerValue() {
#endif
}
void simpleArray() {
void simpleArray(void) {
SomeClass *vlaArray[5];
if (vlaArray[0]) {}
@ -25,7 +25,7 @@ void simpleArray() {
#endif
}
void variableLengthArray() {
void variableLengthArray(void) {
int count = 1;
SomeClass * vlaArray[count];
@ -35,7 +35,7 @@ void variableLengthArray() {
#endif
}
void variableLengthArrayWithExplicitStrongAttribute() {
void variableLengthArrayWithExplicitStrongAttribute(void) {
int count = 1;
__attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];

View File

@ -2,7 +2,7 @@
void clang_analyzer_eval(int);
int string_literal_init() {
int string_literal_init(void) {
char a[] = "abc";
char b[2] = "abc"; // expected-warning{{too long}}
char c[5] = "abc";
@ -42,7 +42,7 @@ void nested_compound_literals_float(float rad) {
}
void struct_as_array() {
void struct_as_array(void) {
struct simple { int x; int y; };
struct simple a;
struct simple *p = &a;
@ -60,14 +60,14 @@ void struct_as_array() {
// PR13264 / <rdar://problem/11802440>
struct point { int x; int y; };
struct circle { struct point o; int r; };
struct circle get_circle() {
struct circle get_circle(void) {
struct circle result;
result.r = 5;
result.o = (struct point){0, 0};
return result;
}
void struct_in_struct() {
void struct_in_struct(void) {
struct circle c;
c = get_circle();
// This used to think c.r was undefined because c.o is a LazyCompoundVal.
@ -77,14 +77,14 @@ void struct_in_struct() {
// We also test with floats because we don't model floats right now,
// and the original bug report used a float.
struct circle_f { struct point o; float r; };
struct circle_f get_circle_f() {
struct circle_f get_circle_f(void) {
struct circle_f result;
result.r = 5.0;
result.o = (struct point){0, 0};
return result;
}
float struct_in_struct_f() {
float struct_in_struct_f(void) {
struct circle_f c;
c = get_circle_f();
@ -92,7 +92,7 @@ float struct_in_struct_f() {
}
int randomInt();
int randomInt(void);
int testSymbolicInvalidation(int index) {
int vals[10];
@ -122,7 +122,7 @@ typedef struct {
int x, y, z;
} S;
S makeS();
S makeS(void);
int testSymbolicInvalidationStruct(int index) {
S vals[10];
@ -183,7 +183,7 @@ int testConcreteInvalidationDoubleStruct(int index) {
}
int testNonOverlappingStructFieldsSimple() {
int testNonOverlappingStructFieldsSimple(void) {
S val;
val.x = 1;
@ -277,7 +277,7 @@ typedef struct {
int length;
} ShortStringWrapper;
void testArrayStructCopy() {
void testArrayStructCopy(void) {
ShortString s = { "abc" };
ShortString s2 = s;
ShortString s3 = s2;
@ -294,7 +294,7 @@ void testArrayStructCopy() {
clang_analyzer_eval(s4.data[2] == 'c'); // expected-warning{{TRUE}}
}
void testArrayStructCopyNested() {
void testArrayStructCopyNested(void) {
ShortString s = { "abc" };
ShortString s2 = s;

View File

@ -46,16 +46,16 @@ bool operator ~(const struct S &s) { return (&s) != &s; }
#ifdef INLINE
struct S getS() {
struct S getS(void) {
struct S s = { 42 };
return s;
}
#else
struct S getS();
struct S getS(void);
#endif
void testAssignment() {
void testAssignment(void) {
struct S s = getS();
if (s.field != 42) return;
@ -78,7 +78,7 @@ void testAssignment() {
}
void testImmediateUse() {
void testImmediateUse(void) {
int x = getS().field;
if (x != 42) return;
@ -105,12 +105,12 @@ int getAssignedField(struct S s) {
return s.field;
}
void testArgument() {
void testArgument(void) {
clang_analyzer_eval(getConstrainedField(getS()) == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(getAssignedField(getS()) == 42); // expected-warning{{TRUE}}
}
void testImmediateUseParens() {
void testImmediateUseParens(void) {
int x = ((getS())).field;
if (x != 42) return;

View File

@ -28,19 +28,19 @@ void f(void) {
// StringLiteral in lvalue context and pointer to array type.
// p: ElementRegion, q: StringRegion
void f2() {
void f2(void) {
char *p = "/usr/local";
char (*q)[4];
q = &"abc";
}
// Typedef'ed struct definition.
void f3() {
void f3(void) {
STYPE s;
}
// Initialize array with InitExprList.
void f4() {
void f4(void) {
int a[] = { 1, 2, 3};
int b[3] = { 1, 2 };
struct s c[] = {{1,{1}}};
@ -48,13 +48,13 @@ void f4() {
// Struct variable in lvalue context.
// Assign UnknownVal to the whole struct.
void f5() {
void f5(void) {
struct s data;
g1(&data);
}
// AllocaRegion test.
void f6() {
void f6(void) {
char *p;
p = __builtin_alloca(10);
g(p);
@ -70,30 +70,30 @@ struct s2;
void g2(struct s2 *p);
// Incomplete struct pointer used as function argument.
void f7() {
void f7(void) {
struct s2 *p = __builtin_alloca(10);
g2(p);
}
// sizeof() is unsigned while -1 is signed in array index.
void f8() {
void f8(void) {
int a[10];
a[sizeof(a)/sizeof(int) - 1] = 1; // no-warning
}
// Initialization of struct array elements.
void f9() {
void f9(void) {
struct s a[10];
}
// Initializing array with string literal.
void f10() {
void f10(void) {
char a1[4] = "abc";
char a3[6] = "abc";
}
// Retrieve the default value of element/field region.
void f11() {
void f11(void) {
struct s a;
g1(&a);
if (a.data == 0) // no-warning
@ -129,25 +129,25 @@ struct s3 {
static struct s3 opt;
// Test if the embedded array is retrieved correctly.
void f14() {
void f14(void) {
struct s3 my_opt = opt;
}
void bar(int*);
struct s3 gets3() {
struct s3 gets3(void) {
struct s3 s;
return s;
}
void accessArrayFieldNoCrash() {
void accessArrayFieldNoCrash(void) {
bar(gets3().a);
bar((gets3().a));
bar(((gets3().a)));
}
// Test if the array is correctly invalidated.
void f15() {
void f15(void) {
int a[10];
bar(a);
if (a[1]) // no-warning
@ -167,7 +167,7 @@ void f16(struct s3 *p) {
void inv(struct s1 *);
// Invalidate the struct field.
void f17() {
void f17(void) {
struct s1 t;
int x;
inv(&t);
@ -177,7 +177,7 @@ void f17() {
void read(char*);
void f18() {
void f18(void) {
char *q;
char *p = (char *) __builtin_alloca(10);
read(p);

View File

@ -16,7 +16,7 @@
char *getenv(const char *name);
void foo() {
void foo(void) {
char *p = getenv("FOO"); // untrusted-env-warning {{tainted}}
(void)p; // untrusted-env-warning {{tainted}}
}

View File

@ -3,7 +3,7 @@
void clang_analyzer_eval(int);
void testInvalidation() {
void testInvalidation(void) {
__block int i = 0;
^{
++i;
@ -15,7 +15,7 @@ void testInvalidation() {
const int globalConstant = 1;
void testCapturedConstants() {
void testCapturedConstants(void) {
const int localConstant = 2;
static const int staticConstant = 3;
@ -28,7 +28,7 @@ void testCapturedConstants() {
typedef const int constInt;
constInt anotherGlobalConstant = 1;
void testCapturedConstantsTypedef() {
void testCapturedConstantsTypedef(void) {
constInt localConstant = 2;
static constInt staticConstant = 3;

View File

@ -6,7 +6,7 @@ typedef struct {
int x;
} S;
void foo() {
void foo(void) {
^{
S s;
return s; // no-crash

View File

@ -82,27 +82,27 @@ void test1(NSString *format, ...) {
// test2 - Test that captured variables that are uninitialized are flagged
// as such.
void test2() {
void test2(void) {
static int y = 0;
int x;
^{ y = x + 1; }(); // expected-warning{{Variable 'x' is uninitialized when captured by block}}
}
void test2_b() {
void test2_b(void) {
static int y = 0;
__block int x;
^{ y = x + 1; }(); // expected-warning {{left operand of '+' is a garbage value}}
}
void test2_c() {
void test2_c(void) {
typedef void (^myblock)(void);
myblock f = ^() { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}}
myblock f = ^(void) { f(); }; // expected-warning{{Variable 'f' is uninitialized when captured by block}}
}
void testMessaging() {
void testMessaging(void) {
// <rdar://problem/12119814>
[[^(){} copy] release];
[[^(void){} copy] release];
}
@ -133,8 +133,8 @@ void testMessaging() {
}
@end
void testReturnVariousSignatures() {
(void)^int(){
void testReturnVariousSignatures(void) {
(void)^int(void){
return 42;
}();
@ -142,7 +142,7 @@ void testReturnVariousSignatures() {
return 42;
}();
(void)^(){
(void)^(void){
return 42;
}();
@ -173,7 +173,7 @@ void blockCapturesItselfInTheLoop(int x, int m) {
void takeNonnullBlock(void (^)(void)) __attribute__((nonnull));
void takeNonnullIntBlock(int (^)(void)) __attribute__((nonnull));
void testCallContainingWithSignature1()
void testCallContainingWithSignature1(void)
{
takeNonnullBlock(^{
static const char str[] = "Lost connection to sharingd";
@ -181,7 +181,7 @@ void testCallContainingWithSignature1()
});
}
void testCallContainingWithSignature2()
void testCallContainingWithSignature2(void)
{
takeNonnullBlock(^void{
static const char str[] = "Lost connection to sharingd";
@ -189,15 +189,15 @@ void testCallContainingWithSignature2()
});
}
void testCallContainingWithSignature3()
void testCallContainingWithSignature3(void)
{
takeNonnullBlock(^void(){
takeNonnullBlock(^void(void){
static const char str[] = "Lost connection to sharingd";
testCallContainingWithSignature3();
});
}
void testCallContainingWithSignature4()
void testCallContainingWithSignature4(void)
{
takeNonnullBlock(^void(void){
static const char str[] = "Lost connection to sharingd";
@ -205,7 +205,7 @@ void testCallContainingWithSignature4()
});
}
void testCallContainingWithSignature5()
void testCallContainingWithSignature5(void)
{
takeNonnullIntBlock(^{
static const char str[] = "Lost connection to sharingd";
@ -240,13 +240,13 @@ __attribute__((objc_root_class))
// The incorrect block variable initialization below is a hard compile-time
// error in C++.
#if !defined(__cplusplus)
void call_block_with_fewer_arguments() {
void call_block_with_fewer_arguments(void) {
void (^b)() = ^(int a) { };
b(); // expected-warning {{Block taking 1 argument is called with fewer (0)}}
}
#endif
int getBlockFlags() {
int getBlockFlags(void) {
int x = 0;
return ((struct Block_layout *)^{ (void)x; })->flags; // no-warning
}

View File

@ -12,12 +12,12 @@ size_t strlcat(char *dst, const char *src, size_t n);
size_t strlen(const char *s);
void clang_analyzer_eval(int);
void f1() {
void f1(void) {
char overlap[] = "123456789";
strlcpy(overlap, overlap + 1, 3); // expected-warning{{Arguments must not be overlapping buffers}}
}
void f2() {
void f2(void) {
char buf[5];
size_t len;
len = strlcpy(buf, "abcd", sizeof(buf)); // expected-no-warning
@ -26,33 +26,33 @@ void f2() {
clang_analyzer_eval(len == 8); // expected-warning{{TRUE}}
}
void f3() {
void f3(void) {
char dst[2];
const char *src = "abdef";
strlcpy(dst, src, 5); // expected-warning{{String copy function overflows the destination buffer}}
}
void f4() {
void f4(void) {
strlcpy(NULL, "abcdef", 6); // expected-warning{{Null pointer passed as 1st argument to string copy function}}
}
void f5() {
void f5(void) {
strlcat(NULL, "abcdef", 6); // expected-warning{{Null pointer passed as 1st argument to string concatenation function}}
}
void f6() {
void f6(void) {
char buf[8];
strlcpy(buf, "abc", 3);
size_t len = strlcat(buf, "defg", 4);
clang_analyzer_eval(len == 7); // expected-warning{{TRUE}}
}
int f7() {
int f7(void) {
char buf[8];
return strlcpy(buf, "1234567", 0); // no-crash
}
void f8(){
void f8(void){
char buf[5];
size_t len;
@ -116,7 +116,7 @@ void f9(int unknown_size, char* unknown_src, char* unknown_dst){
// expected-warning@-1 {{String concatenation function overflows the destination buffer}}
}
void f10(){
void f10(void){
char buf[8];
size_t len;
@ -126,7 +126,7 @@ void f10(){
// expected-warning@-1 {{String concatenation function overflows the destination buffer}}
}
void f11() {
void f11(void) {
//test for Bug 41729
char a[256], b[256];
strlcpy(a, "world", sizeof(a));
@ -135,7 +135,7 @@ void f11() {
}
int a, b;
void unknown_val_crash() {
void unknown_val_crash(void) {
// We're unable to evaluate the integer-to-pointer cast.
strlcat(&b, a, 0); // no-crash
}

View File

@ -71,7 +71,7 @@ void *memcpy(void *restrict s1, const void *restrict s2, size_t n);
#endif /* VARIANT */
void memcpy0 () {
void memcpy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
@ -84,14 +84,14 @@ void memcpy0 () {
clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void memcpy1 () {
void memcpy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memcpy(dst, src, 5); // expected-warning{{Memory copy function accesses out-of-bound array element}}
}
void memcpy2 () {
void memcpy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
@ -101,21 +101,21 @@ void memcpy2 () {
#endif
}
void memcpy3 () {
void memcpy3 (void) {
char src[] = {1, 2, 3, 4};
char dst[3];
memcpy(dst+1, src+2, 2); // no-warning
}
void memcpy4 () {
void memcpy4 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memcpy(dst+2, src+2, 3); // expected-warning{{Memory copy function accesses out-of-bound array element}}
}
void memcpy5() {
void memcpy5(void) {
char src[] = {1, 2, 3, 4};
char dst[3];
@ -125,43 +125,43 @@ void memcpy5() {
#endif
}
void memcpy6() {
void memcpy6(void) {
int a[4] = {0};
memcpy(a, a, 8); // expected-warning{{overlapping}}
}
void memcpy7() {
void memcpy7(void) {
int a[4] = {0};
memcpy(a+2, a+1, 8); // expected-warning{{overlapping}}
}
void memcpy8() {
void memcpy8(void) {
int a[4] = {0};
memcpy(a+1, a+2, 8); // expected-warning{{overlapping}}
}
void memcpy9() {
void memcpy9(void) {
int a[4] = {0};
memcpy(a+2, a+1, 4); // no-warning
memcpy(a+1, a+2, 4); // no-warning
}
void memcpy10() {
void memcpy10(void) {
char a[4] = {0};
memcpy(0, a, 4); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
}
void memcpy11() {
void memcpy11(void) {
char a[4] = {0};
memcpy(a, 0, 4); // expected-warning{{Null pointer passed as 2nd argument to memory copy function}}
}
void memcpy12() {
void memcpy12(void) {
char a[4] = {0};
memcpy(0, a, 0); // no-warning
}
void memcpy13() {
void memcpy13(void) {
char a[4] = {0};
memcpy(a, 0, 0); // no-warning
}
@ -197,7 +197,7 @@ void *mempcpy(void *restrict s1, const void *restrict s2, size_t n);
#endif /* VARIANT */
void mempcpy0 () {
void mempcpy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[5] = {0};
@ -210,14 +210,14 @@ void mempcpy0 () {
clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void mempcpy1 () {
void mempcpy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
mempcpy(dst, src, 5); // expected-warning{{Memory copy function accesses out-of-bound array element}}
}
void mempcpy2 () {
void mempcpy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
@ -227,21 +227,21 @@ void mempcpy2 () {
#endif
}
void mempcpy3 () {
void mempcpy3 (void) {
char src[] = {1, 2, 3, 4};
char dst[3];
mempcpy(dst+1, src+2, 2); // no-warning
}
void mempcpy4 () {
void mempcpy4 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
mempcpy(dst+2, src+2, 3); // expected-warning{{Memory copy function accesses out-of-bound array element}}
}
void mempcpy5() {
void mempcpy5(void) {
char src[] = {1, 2, 3, 4};
char dst[3];
@ -251,48 +251,48 @@ void mempcpy5() {
#endif
}
void mempcpy6() {
void mempcpy6(void) {
int a[4] = {0};
mempcpy(a, a, 8); // expected-warning{{overlapping}}
}
void mempcpy7() {
void mempcpy7(void) {
int a[4] = {0};
mempcpy(a+2, a+1, 8); // expected-warning{{overlapping}}
}
void mempcpy8() {
void mempcpy8(void) {
int a[4] = {0};
mempcpy(a+1, a+2, 8); // expected-warning{{overlapping}}
}
void mempcpy9() {
void mempcpy9(void) {
int a[4] = {0};
mempcpy(a+2, a+1, 4); // no-warning
mempcpy(a+1, a+2, 4); // no-warning
}
void mempcpy10() {
void mempcpy10(void) {
char a[4] = {0};
mempcpy(0, a, 4); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
}
void mempcpy11() {
void mempcpy11(void) {
char a[4] = {0};
mempcpy(a, 0, 4); // expected-warning{{Null pointer passed as 2nd argument to memory copy function}}
}
void mempcpy12() {
void mempcpy12(void) {
char a[4] = {0};
mempcpy(0, a, 0); // no-warning
}
void mempcpy13() {
void mempcpy13(void) {
char a[4] = {0};
mempcpy(a, 0, 0); // no-warning
}
void mempcpy14() {
void mempcpy14(void) {
int src[] = {1, 2, 3, 4};
int dst[5] = {0};
int *p;
@ -307,7 +307,7 @@ struct st {
int j;
};
void mempcpy15() {
void mempcpy15(void) {
struct st s1 = {0};
struct st s2;
struct st *p1;
@ -319,7 +319,7 @@ void mempcpy15() {
clang_analyzer_eval(p1 == p2); // expected-warning{{TRUE}}
}
void mempcpy16() {
void mempcpy16(void) {
struct st s1[10] = {{0}};
struct st s2[10];
struct st *p1;
@ -362,7 +362,7 @@ void *memmove(void *s1, const void *s2, size_t n);
#endif /* VARIANT */
void memmove0 () {
void memmove0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
@ -375,14 +375,14 @@ void memmove0 () {
clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void memmove1 () {
void memmove1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
memmove(dst, src, 5); // expected-warning{{out-of-bound}}
}
void memmove2 () {
void memmove2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];
@ -410,28 +410,28 @@ int memcmp(const void *s1, const void *s2, size_t n);
#endif /* VARIANT */
void memcmp0 () {
void memcmp0 (void) {
char a[] = {1, 2, 3, 4};
char b[4] = { 0 };
memcmp(a, b, 4); // no-warning
}
void memcmp1 () {
void memcmp1 (void) {
char a[] = {1, 2, 3, 4};
char b[10] = { 0 };
memcmp(a, b, 5); // expected-warning{{out-of-bound}}
}
void memcmp2 () {
void memcmp2 (void) {
char a[] = {1, 2, 3, 4};
char b[1] = { 0 };
memcmp(a, b, 4); // expected-warning{{out-of-bound}}
}
void memcmp3 () {
void memcmp3 (void) {
char a[] = {1, 2, 3, 4};
clang_analyzer_eval(memcmp(a, a, 4) == 0); // expected-warning{{TRUE}}
@ -483,7 +483,7 @@ int memcmp8(char *a, size_t n) {
void bcopy(/*const*/ void *s1, void *s2, size_t n);
void bcopy0 () {
void bcopy0 (void) {
char src[] = {1, 2, 3, 4};
char dst[4] = {0};
@ -494,14 +494,14 @@ void bcopy0 () {
clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}}
}
void bcopy1 () {
void bcopy1 (void) {
char src[] = {1, 2, 3, 4};
char dst[10];
bcopy(src, dst, 5); // expected-warning{{out-of-bound}}
}
void bcopy2 () {
void bcopy2 (void) {
char src[] = {1, 2, 3, 4};
char dst[1];

View File

@ -28,7 +28,7 @@ __attribute__((objc_root_class))
@end
void testBlocks() {
void testBlocks(void) {
int x = 5;
^{
clang_analyzer_hashDump(x); // expected-warning {{debug.ExprInspection$$29$clang_analyzer_hashDump(x);$Category}}

View File

@ -52,7 +52,7 @@ void bad5(void) {
mtx_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
}
void bad6() {
void bad6(void) {
mtx_init(&mtx1, 0);
if (mtx_trylock(&mtx1) != thrd_success)
mtx_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
@ -65,7 +65,7 @@ void bad7(void) {
mtx_unlock(&mtx2);
}
void good() {
void good(void) {
mtx_t mtx;
mtx_init(&mtx, 0);
mtx_lock(&mtx);
@ -73,7 +73,7 @@ void good() {
mtx_destroy(&mtx);
}
void good2() {
void good2(void) {
mtx_t mtx;
mtx_init(&mtx, 0);
if (mtx_trylock(&mtx) == thrd_success)
@ -81,7 +81,7 @@ void good2() {
mtx_destroy(&mtx);
}
void good3() {
void good3(void) {
mtx_t mtx;
mtx_init(&mtx, 0);
if (mtx_timedlock(&mtx, 0) == thrd_success)

View File

@ -11,7 +11,7 @@
// no-pointee-no-diagnostics
void doStuff_pointerToConstInt(const int *u){};
void pointee_uninit() {
void pointee_uninit(void) {
int i;
int *p = &i;
doStuff_pointerToConstInt(p); // expected-warning{{1st function call argument is a pointer to uninitialized value [core.CallAndMessage]}}

View File

@ -62,7 +62,7 @@ extern NSString *const NSUndoManagerCheckpointNotification;
// Test cases.
//===----------------------------------------------------------------------===//
unsigned f1() {
unsigned f1(void) {
NSString *aString;
return [aString length]; // expected-warning {{Receiver in message expression is an uninitialized value [core.CallAndMessage]}}
}

View File

@ -91,7 +91,7 @@ int foo (int* p) {
return 0;
}
void castsToBool() {
void castsToBool(void) {
clang_analyzer_eval(0); // expected-warning{{FALSE}}
clang_analyzer_eval(0U); // expected-warning{{FALSE}}
clang_analyzer_eval((void *)0); // expected-warning{{FALSE}}
@ -128,7 +128,7 @@ void locAsIntegerCasts(void *p) {
clang_analyzer_eval(++x < 10); // no-crash // expected-warning{{UNKNOWN}}
}
void multiDimensionalArrayPointerCasts() {
void multiDimensionalArrayPointerCasts(void) {
static int x[10][10];
int *y1 = &(x[3][5]);
char *z = ((char *) y1) + 2;
@ -154,15 +154,15 @@ void multiDimensionalArrayPointerCasts() {
clang_analyzer_eval(*((char *)y1) == *((char *) y3)); // expected-warning{{TRUE}}
}
void *getVoidPtr();
void *getVoidPtr(void);
void testCastVoidPtrToIntPtrThroughIntTypedAssignment() {
void testCastVoidPtrToIntPtrThroughIntTypedAssignment(void) {
int *x;
(*((int *)(&x))) = (int)getVoidPtr();
*x = 1; // no-crash
}
void testCastUIntPtrToIntPtrThroughIntTypedAssignment() {
void testCastUIntPtrToIntPtrThroughIntTypedAssignment(void) {
unsigned u;
int *x;
(*((int *)(&x))) = (int)&u;
@ -170,7 +170,7 @@ void testCastUIntPtrToIntPtrThroughIntTypedAssignment() {
clang_analyzer_eval(u == 1); // expected-warning{{TRUE}}
}
void testCastVoidPtrToIntPtrThroughUIntTypedAssignment() {
void testCastVoidPtrToIntPtrThroughUIntTypedAssignment(void) {
int *x;
(*((int *)(&x))) = (int)(unsigned *)getVoidPtr();
*x = 1; // no-crash
@ -187,7 +187,7 @@ void testLocNonLocSymbolRemainder(int a, int *b) {
}
}
void testSwitchWithSizeofs() {
void testSwitchWithSizeofs(void) {
switch (sizeof(char) == 1) { // expected-warning{{switch condition has boolean value}}
case sizeof(char):; // no-crash
}
@ -219,8 +219,8 @@ void test_VectorSplat_cast(long x) {
#ifdef EAGERLY_ASSUME
int globalA;
extern int globalFunc();
void no_crash_on_symsym_cast_to_long() {
extern int globalFunc(void);
void no_crash_on_symsym_cast_to_long(void) {
char c = globalFunc() - 5;
c == 0;
globalA -= c;
@ -240,7 +240,7 @@ char no_crash_SymbolCast_of_float_type_aux(int *p) {
return *p;
}
void no_crash_SymbolCast_of_float_type() {
void no_crash_SymbolCast_of_float_type(void) {
extern float x;
char (*f)() = no_crash_SymbolCast_of_float_type_aux;
f(&x);

View File

@ -41,6 +41,6 @@ adium_media_ready_cb(RDR10087620 *InObj)
// PR16690
_Bool testLocAsIntegerToBool() {
_Bool testLocAsIntegerToBool(void) {
return (long long)&testLocAsIntegerToBool;
}

View File

@ -18,10 +18,10 @@ char *asctime(const tm *timeptr);
int strcmp(const char*, const char*);
extern void foo(char *e);
extern char* bar();
extern char* bar(void);
void getenv_test1() {
void getenv_test1(void) {
char *p;
p = getenv("VAR");
@ -31,7 +31,7 @@ void getenv_test1() {
*p; // no-warning, getenv result was assigned to the same pointer
}
void getenv_test2() {
void getenv_test2(void) {
char *p, *p2;
p = getenv("VAR");
@ -46,7 +46,7 @@ void getenv_test2() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test3() {
void getenv_test3(void) {
char *p, *p2, *p3;
p = getenv("VAR");
@ -64,7 +64,7 @@ void getenv_test3() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test4() {
void getenv_test4(void) {
char *p, *p2, *p3;
p = getenv("VAR");
@ -78,7 +78,7 @@ void getenv_test4() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test5() {
void getenv_test5(void) {
char *p, *p2, *p3;
p = getenv("VAR");
@ -92,7 +92,7 @@ void getenv_test5() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test6() {
void getenv_test6(void) {
char *p, *p2;
p = getenv("VAR");
*p; // no-warning
@ -120,7 +120,7 @@ void getenv_test6() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test7() {
void getenv_test7(void) {
char *p, *p2;
p = getenv("VAR");
// expected-note@-1{{previous function call was here}}
@ -134,7 +134,7 @@ void getenv_test7() {
// expected-note@-2{{use of invalidated pointer 'p' in a function call}}
}
void getenv_test8() {
void getenv_test8(void) {
static const char *array[] = {
0,
0,
@ -159,7 +159,7 @@ void getenv_test8() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test9() {
void getenv_test9(void) {
char *p, *p2;
p = getenv("something");
p = bar();
@ -167,7 +167,7 @@ void getenv_test9() {
*p; // no-warning: p does not point to getenv anymore
}
void getenv_test10() {
void getenv_test10(void) {
strcmp(getenv("VAR1"), getenv("VAR2"));
// expected-note@-1{{'getenv' call may invalidate the the result of the previous 'getenv'}}
// expected-note@-2{{previous function call was here}}
@ -181,7 +181,7 @@ void dereference_pointer(char* a) {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void getenv_test11() {
void getenv_test11(void) {
char *p = getenv("VAR");
// expected-note@-1{{previous function call was here}}
@ -212,7 +212,7 @@ void getenv_test12(int flag1, int flag2) {
}
}
void setlocale_test1() {
void setlocale_test1(void) {
char *p, *p2;
p = setlocale(0, "VAR");
*p; // no-warning
@ -250,7 +250,7 @@ void setlocale_test2(int flag) {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void strerror_test1() {
void strerror_test1(void) {
char *p, *p2;
p = strerror(0);
@ -298,7 +298,7 @@ void strerror_test2(int errno) {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void asctime_test() {
void asctime_test(void) {
const tm *t;
const tm *tt;
@ -312,7 +312,7 @@ void asctime_test() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void localeconv_test1() {
void localeconv_test1(void) {
lconv *lc1 = localeconv();
// expected-note@-1{{previous function call was here}}
lconv *lc2 = localeconv();
@ -323,7 +323,7 @@ void localeconv_test1() {
// expected-note@-2{{dereferencing an invalid pointer}}
}
void localeconv_test2() {
void localeconv_test2(void) {
// TODO: false negative
lconv *lc1 = localeconv();
lconv *lc2 = localeconv();

View File

@ -50,7 +50,7 @@ void checkWrap(int i) {
// CHECK-NEXT: 4: asm ("" : "=r" ([B1.3]));
// CHECK-NEXT: 5: arg
// CHECK-NEXT: 6: asm ("" : "=r" ([B1.5]));
void checkGCCAsmRValueOutput() {
void checkGCCAsmRValueOutput(void) {
int arg;
__asm__("" : "=r"((int)arg)); // rvalue output operand
__asm__("" : "=r"(arg)); // lvalue output operand

View File

@ -3,7 +3,7 @@
// expected-no-diagnostics
void clang_analyzer_printState();
void clang_analyzer_printState(void);
@interface NSObject {
}

View File

@ -11,7 +11,7 @@ void foo(void) {
}
// check that we propagate info through compound literal regions
void bar() {
void bar(void) {
int *integers = (int[]){1, 2, 3};
clang_analyzer_eval(integers[0] == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(integers[1] == 2); // expected-warning{{TRUE}}

View File

@ -1,7 +1,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify %s
// expected-no-diagnostics
void foo() {
void foo(void) {
int *p = (int*) 0x10000; // Should not crash here.
*p = 3;
}

View File

@ -179,7 +179,7 @@ void testBitwiseRules(unsigned int a, int b, int c) {
}
}
unsigned reset();
unsigned reset(void);
void testCombinedSources(unsigned a, unsigned b) {
if (b >= 10 && (a | b) <= 30) {

View File

@ -3,7 +3,7 @@
// RUN: -analyzer-checker=debug.ExprInspection \
// RUN: -verify
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
void clang_analyzer_eval(int);
void rem_constant_rhs_ne_zero(int x, int y) {

View File

@ -7,7 +7,7 @@
unsigned char U8;
signed char S8;
void track_assign() {
void track_assign(void) {
unsigned long L = 1000; // expected-note {{'L' initialized to 1000}}
int I = -1; // expected-note {{'I' initialized to -1}}
U8 *= L; // expected-warning {{Loss of precision in implicit conversion}}

View File

@ -17,21 +17,21 @@ void assign(unsigned U, signed S) {
S8 = U; // no-warning
}
void addAssign() {
void addAssign(void) {
unsigned long L = 1000;
int I = -100;
U8 += L; // expected-warning {{Loss of precision in implicit conversion}}
L += I; // no-warning
}
void subAssign() {
void subAssign(void) {
unsigned long L = 1000;
int I = -100;
U8 -= L; // expected-warning {{Loss of precision in implicit conversion}}
L -= I; // no-warning
}
void mulAssign() {
void mulAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 *= L; // expected-warning {{Loss of precision in implicit conversion}}
@ -40,42 +40,42 @@ void mulAssign() {
L *= I; // no-warning
}
void divAssign() {
void divAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 /= L; // no-warning
L /= I; // expected-warning {{Loss of sign in implicit conversion}}
}
void remAssign() {
void remAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 %= L; // no-warning
L %= I; // expected-warning {{Loss of sign in implicit conversion}}
}
void andAssign() {
void andAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 &= L; // no-warning
L &= I; // expected-warning {{Loss of sign in implicit conversion}}
}
void orAssign() {
void orAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 |= L; // expected-warning {{Loss of precision in implicit conversion}}
L |= I; // expected-warning {{Loss of sign in implicit conversion}}
}
void xorAssign() {
void xorAssign(void) {
unsigned long L = 1000;
int I = -1;
U8 ^= L; // expected-warning {{Loss of precision in implicit conversion}}
L ^= I; // expected-warning {{Loss of sign in implicit conversion}}
}
void init1() {
void init1(void) {
long long A = 1LL << 60;
short X = A; // expected-warning {{Loss of precision in implicit conversion}}
}
@ -108,7 +108,7 @@ void division(unsigned U, signed S) {
void f(unsigned x) {}
void g(unsigned x) {}
void functioncall1() {
void functioncall1(void) {
long x = -1;
int y = 0;
f(x); // expected-warning {{Loss of sign in implicit conversion}}
@ -145,11 +145,11 @@ void dontwarn3(int X) {
// don't warn for macros
#define DOSTUFF ({ unsigned X = 1000; U8 = X; })
void dontwarn4() {
void dontwarn4(void) {
DOSTUFF;
}
void dontwarn5() {
void dontwarn5(void) {
unsigned char c1 = 'A';
c1 = (c1 >= 'A' && c1 <= 'Z') ? c1 - 'A' + 'a' : c1;
unsigned char c2 = 0;
@ -162,7 +162,7 @@ void dontwarn5() {
c5 = (c5 >= 'A' && c5 <= 'Z') ? c5 - 'A' + 'a' : c5;
}
void dontwarn6() {
void dontwarn6(void) {
int x = ~0;
unsigned y = ~0;
}
@ -172,11 +172,11 @@ void dontwarn7(unsigned x) {
}
}
void dontwarn8() {
void dontwarn8(void) {
unsigned x = (unsigned)-1;
}
unsigned dontwarn9() {
unsigned dontwarn9(void) {
return ~0;
}
@ -190,7 +190,7 @@ char dontwarn10(long long x) {
// C library functions, handled via apiModeling.StdCLibraryFunctions
int isascii(int c);
void libraryFunction1() {
void libraryFunction1(void) {
char kb2[5];
int X = 1000;
if (isascii(X)) {
@ -204,7 +204,7 @@ typedef struct FILE {} FILE; int getc(FILE *stream);
char reply_string[8192];
FILE *cin;
extern int dostuff(void);
int libraryFunction2() {
int libraryFunction2(void) {
int c, n;
int dig;
char *cp = reply_string;
@ -239,7 +239,7 @@ double floating_point(long long a, int b) {
return 137;
}
double floating_point2() {
double floating_point2(void) {
int a = 1 << 24;
long long b = 1LL << 53;
float f = a; // no-warning

View File

@ -4,7 +4,7 @@
int global;
int foo1() {
int foo1(void) {
if (global > 0)
return 0;
else if (global < 0)
@ -13,7 +13,7 @@ int foo1() {
}
// Different associated type (int instead of float)
int foo2() {
int foo2(void) {
if (global > 0)
return 0;
else if (global < 0)
@ -22,7 +22,7 @@ int foo2() {
}
// Different number of associated types.
int foo3() {
int foo3(void) {
if (global > 0)
return 0;
else if (global < 0)

View File

@ -93,7 +93,7 @@ void coverage9(int *x) {
y = (*x); // no warning
}
static void empty_function(){
static void empty_function(void){
}
int use_empty_function(int x) {
x = 0;

View File

@ -13,7 +13,7 @@ void inlined(int x, float y) {
clang_analyzer_crash();
}
void test() {
void test(void) {
inlined(0, 0);
}

View File

@ -14,7 +14,7 @@ char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
void cstringchecker_bounds_nocrash() {
void cstringchecker_bounds_nocrash(void) {
char *p = malloc(2);
strncpy(p, "AAA", sizeof("AAA")); // we don't expect warning as the checker is disabled
free(p);

View File

@ -7,7 +7,7 @@
char *strcpy(char *, const char *);
void foo() {
void foo(void) {
char *a = 0, *b = 0;
strcpy(a, b);
}

View File

@ -6,9 +6,9 @@
typedef __SIZE_TYPE__ size_t;
// The last parameter is normally size_t but the test is about the abnormal
// situation when it's not a size_t.
size_t strlcpy(char *, const char *, void (*)());
size_t strlcpy(char *, const char *, void (*)(void));
void foo();
void foo(void);
void testWeirdDecls(const char *src) {
char dst[10];

View File

@ -18,7 +18,7 @@ typedef struct {
} FooBar;
extern FooBar fb;
int f(int);
void testGlobalVariable() {
void testGlobalVariable(void) {
clang_analyzer_eval(f(5) == 1); // expected-warning{{TRUE}}
}
@ -27,14 +27,14 @@ int enumCheck(void);
enum A { x,
y,
z };
void testEnum() {
void testEnum(void) {
clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(enumCheck() == 42); // expected-warning{{TRUE}}
}
// Test that asm import does not fail.
int inlineAsm();
int testInlineAsm() {
int inlineAsm(void);
int testInlineAsm(void) {
return inlineAsm();
}
@ -47,7 +47,7 @@ void testMacro(void) {
// The external function prototype is incomplete.
// warning:implicit functions are prohibited by c99
void testImplicit() {
void testImplicit(void) {
int res = identImplicit(6); // external implicit functions are not inlined
clang_analyzer_eval(res == 6); // expected-warning{{TRUE}}
// Call something with uninitialized from the same function in which the implicit was called.
@ -63,7 +63,7 @@ struct DataType {
int b;
};
int structInProto(struct DataType *d);
void testStructDefInArgument() {
void testStructDefInArgument(void) {
struct DataType d;
d.a = 1;
d.b = 0;

View File

@ -12,7 +12,7 @@
// RUN: -analyzer-config deadcode.DeadStores:ShowFixIts=true \
// RUN: -verify=non-nested,nested
void f1() {
void f1(void) {
int k, y; // non-nested-warning {{unused variable 'k'}}
// non-nested-warning@-1 {{unused variable 'y'}}
int abc = 1;
@ -34,8 +34,8 @@ void f2(void *b) {
// non-nested-note@-2 {{include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
int f();
void f3() {
int f(void);
void f3(void) {
int r;
if ((r = f()) != 0) { // no-warning
int y = r; // no-warning
@ -50,7 +50,7 @@ void f4(int k) {
k = 2; // non-nested-warning {{never read}}
}
void f5() {
void f5(void) {
int x = 4; // no-warning
int *p = &x; // non-nested-warning {{never read}}
// non-nested-warning@-1 {{unused variable 'p'}}
@ -58,7 +58,7 @@ void f5() {
// CHECK-FIXES-NEXT: int *p;
}
int f6() {
int f6(void) {
int x = 4;
++x; // no-warning
return 1;
@ -90,30 +90,30 @@ int f7d(int *p) {
// Warn for dead stores in nested expressions.
int f8(int *p) {
extern int *baz();
extern int *baz(void);
if ((p = baz())) // nested-warning {{Although the value stored}}
return 1;
return 0;
}
int f9() {
int f9(void) {
int x = 4;
x = x + 10; // non-nested-warning {{never read}}
return 1;
}
int f10() {
int f10(void) {
int x = 4;
x = 10 + x; // non-nested-warning {{never read}}
return 1;
}
int f11() {
int f11(void) {
int x = 4;
return x++; // non-nested-warning {{never read}}
}
int f11b() {
int f11b(void) {
int x = 4;
return ((((++x)))); // no-warning
}
@ -171,7 +171,7 @@ int f16(int x) {
}
// Self-assignments should not be flagged as dead stores.
void f17() {
void f17(void) {
int x = 1;
x = x;
}
@ -180,7 +180,7 @@ void f17() {
// The values of dead stores are only "consumed" in an enclosing expression
// what that value is actually used. In other words, don't say "Although the
// value stored to 'x' is used...".
int f18() {
int f18(void) {
int x = 0; // no-warning
if (1)
x = 10; // non-nested-warning {{Value stored to 'x' is never read}}
@ -193,24 +193,24 @@ int f18() {
return (x = 10); // no-warning
}
int f18_a() {
int f18_a(void) {
int x = 0; // no-warning
return (x = 10); // nested-warning {{Although the value stored}}
}
void f18_b() {
void f18_b(void) {
int x = 0; // no-warning
if (1)
x = 10; // non-nested-warning {{Value stored to 'x' is never read}}
}
void f18_c() {
void f18_c(void) {
int x = 0;
while (1)
x = 10; // non-nested-warning {{Value stored to 'x' is never read}}
}
void f18_d() {
void f18_d(void) {
int x = 0; // no-warning
do
x = 10; // non-nested-warning {{Value stored to 'x' is never read}}
@ -238,8 +238,8 @@ void f20(void) {
#pragma unused(x)
}
void halt() __attribute__((noreturn));
int f21() {
void halt(void) __attribute__((noreturn));
int f21(void) {
int x = 4;
x = x + 1; // non-nested-warning {{never read}}
if (1) {
@ -250,7 +250,7 @@ int f21() {
}
int j;
void f22() {
void f22(void) {
int x = 4;
int y1 = 4;
int y2 = 4;
@ -473,7 +473,7 @@ int f24_D(int y) {
int f25(int y) {
__block int x = (y > 2);
__block int z = 0;
void (^foo)() = ^{
void (^foo)(void) = ^{
z = x + y;
};
x = 4; // no-warning
@ -492,7 +492,7 @@ int f25_b(int y) {
return z;
}
int f26_nestedblocks() {
int f26_nestedblocks(void) {
int z;
z = 1;
__block int y = 0;
@ -508,7 +508,7 @@ int f26_nestedblocks() {
// The FOREACH macro in QT uses 'break' statements within statement expressions
// placed within the increment code of for loops.
void rdar8014335() {
void rdar8014335(void) {
for (int i = 0 ; i != 10 ; ({ break; })) {
for (;; ({ ++i; break; }))
;
@ -546,7 +546,7 @@ void rdar8320674(s_rdar8320674 *z, unsigned y, s2_rdar8320674 *st, int m)
// Avoid dead stores resulting from an assignment (and use) being unreachable.
void rdar8405222_aux(int i);
void rdar8405222() {
void rdar8405222(void) {
const int show = 0;
int i = 0;
if (show)
@ -557,13 +557,13 @@ void rdar8405222() {
// Look through chains of assignments, e.g.: int x = y = 0, when employing
// silencing heuristics.
int radar11185138_foo() {
int radar11185138_foo(void) {
int x, y;
x = y = 0; // non-nested-warning {{never read}}
return y;
}
int rdar11185138_bar() {
int rdar11185138_bar(void) {
int y;
int x = y = 0; // nested-warning {{Although the value stored}}
x = 2;
@ -571,15 +571,15 @@ int rdar11185138_bar() {
return x + y;
}
int *radar11185138_baz() {
int *radar11185138_baz(void) {
int *x, *y;
x = y = 0; // no-warning
return y;
}
int getInt();
int *getPtr();
void testBOComma() {
int getInt(void);
int *getPtr(void);
void testBOComma(void) {
int x0 = (getInt(), 0); // non-nested-warning {{unused variable 'x0'}}
int x1 = (getInt(), getInt());
// non-nested-warning@-1 {{Value stored to 'x1' during its initialization is never read}}
@ -631,7 +631,7 @@ void testBOComma() {
p = (getPtr(), (int *)0); // no warning
}
void testVolatile() {
void testVolatile(void) {
volatile int v;
v = 0; // no warning
}
@ -654,7 +654,7 @@ int rdar34122265_test(int input) {
return foo.x + foo.y;
}
void rdar34122265_test_cast() {
void rdar34122265_test_cast(void) {
// This is allowed for defensive programming.
struct Foo foo = {0, 0};
(void)foo;

View File

@ -45,8 +45,8 @@ void rdar_7631278(NSObject *x) {
// This test case issuing a bogus warning for the declaration of 'isExec'
// because the compound statement for the @synchronized was being visited
// twice by the LiveVariables analysis.
BOOL baz_rdar8527823();
void foo_rdar8527823();
BOOL baz_rdar8527823(void);
void foo_rdar8527823(void);
@interface RDar8527823
- (void) bar_rbar8527823;
@end
@ -83,9 +83,9 @@ void foo_rdar8527823();
@property (assign) int x;
@end
RDar10591355 *rdar10591355_aux();
RDar10591355 *rdar10591355_aux(void);
void rdar10591355() {
void rdar10591355(void) {
RDar10591355 *p = rdar10591355_aux();
^{ (void) p.x; }();
}
@ -110,8 +110,8 @@ Radar11059352_1 *_Path;
}
@end
id test_objc_precise_lifetime_foo();
void test_objc_precise_lifetime() {
id test_objc_precise_lifetime_foo(void);
void test_objc_precise_lifetime(void) {
__attribute__((objc_precise_lifetime)) id dead = test_objc_precise_lifetime_foo(); // no-warning
dead = 0;
dead = test_objc_precise_lifetime_foo(); // no-warning

View File

@ -8,7 +8,7 @@ void clang_analyzer_isTainted(char);
void clang_analyzer_isTainted_any_suffix(char);
void clang_analyzer_isTainted_many_arguments(char, int, int);
void foo() {
void foo(void) {
char buf[32] = "";
clang_analyzer_isTainted(buf[0]); // expected-warning {{NO}}
clang_analyzer_isTainted_any_suffix(buf[0]); // expected-warning {{NO}}
@ -19,7 +19,7 @@ void foo() {
int tainted_value = buf[0]; // no-warning
}
void exactly_one_argument_required() {
void exactly_one_argument_required(void) {
char buf[32] = "";
scanf("%s", buf);
clang_analyzer_isTainted_many_arguments(buf[0], 42, 42);

View File

@ -52,9 +52,9 @@ static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect)
return (aRect.size.height);
}
NSSize rdar880566_size();
NSSize rdar880566_size(void);
double rdar8808566() {
double rdar8808566(void) {
NSRect myRect;
myRect.size = rdar880566_size();
double x = NSWidth(myRect) + NSHeight(myRect); // no-warning

View File

@ -2,7 +2,7 @@
// This file is for testing enhanced diagnostics produced by the default BugReporterVisitors.
int getPasswordAndItem()
int getPasswordAndItem(void)
{
int err = 0;
int *password; // expected-note {{'password' declared without an initial value}}

View File

@ -2,7 +2,7 @@
void clang_analyzer_eval(int);
void array_init() {
void array_init(void) {
int a[5] = {[4] = 29, [2] = 15, [0] = 4};
clang_analyzer_eval(a[0] == 4); // expected-warning{{TRUE}}
clang_analyzer_eval(a[1] == 0); // expected-warning{{TRUE}}
@ -21,13 +21,13 @@ struct point {
int x, y;
};
void struct_init() {
void struct_init(void) {
struct point p = {.y = 5, .x = 3};
clang_analyzer_eval(p.x == 3); // expected-warning{{TRUE}}
clang_analyzer_eval(p.y == 5); // expected-warning{{TRUE}}
}
void array_of_struct() {
void array_of_struct(void) {
struct point ptarray[3] = { [2].y = 1, [2].x = 2, [0].x = 3 };
clang_analyzer_eval(ptarray[0].x == 3); // expected-warning{{TRUE}}
clang_analyzer_eval(ptarray[0].y == 0); // expected-warning{{TRUE}}

View File

@ -3,12 +3,12 @@
struct Q { int a, b, c; };
union UQ { struct Q q; };
union UQ getUQ() {
union UQ getUQ(void) {
union UQ u = { { 1, 2, 3 } };
return u;
}
void test() {
void test(void) {
struct LUQ { union UQ uq; } var = { getUQ(), .uq.q.a = 100 };
struct Q s[] = {
[0] = (struct Q){1, 2},
@ -19,7 +19,7 @@ void test() {
// CHECK: void test()
// CHECK: [B1]
// CHECK: 1: getUQ
// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, union UQ (*)())
// CHECK: 2: [B1.1] (ImplicitCastExpr, FunctionToPointerDecay, union UQ (*)(void))
// CHECK: 3: [B1.2]()
// CHECK: 4: 100
// CHECK: 5: /*no init*/

View File

@ -4,7 +4,7 @@
{
"artifacts": [
{
"length": 1077,
"length": 1081,
"location": {
},
"mimeType": "text/plain",

View File

@ -7,7 +7,7 @@ struct S {
int y;
};
int *foo();
int *foo(void);
void test(struct S syz, int *pp) {
int m = 0;

View File

@ -6,7 +6,7 @@
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
int radar12491259() {
int radar12491259(void) {
int *p = malloc(12);
FREE_POINTER(p);
FREE_POINTER(p); // no-warning: we are suppressing errors coming from sys/queue macros.
@ -15,7 +15,7 @@ int radar12491259() {
#define MYMACRO(p) FREE_POINTER(p)
int radar12491259_inside_macro() {
int radar12491259_inside_macro(void) {
int *p = malloc(12);
MYMACRO(p);
MYMACRO(p); // no-warning: we are suppressing errors coming from sys/queue macros.

View File

@ -1,11 +1,11 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
typedef struct { float b; } c;
void *a();
void *d() {
void *a(void);
void *d(void) {
return a();
}
void no_find_last_store() {
void no_find_last_store(void) {
c *e = d(); // expected-note{{'e' initialized here}}
(void)(e || e->b); // expected-note{{Assuming 'e' is null}}

View File

@ -2,7 +2,7 @@
#define NULL 0
int test_noparammacro() {
int test_noparammacro(void) {
int *x = NULL; // expected-note{{'x' initialized to a null pointer value}}
return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
// expected-note@-1{{Dereference of null pointer (loaded from variable 'x')}}
@ -22,7 +22,7 @@ char test_declaration(int *param) {
return *param2;
}
int coin();
int coin(void);
int test_multi_decl(int *paramA, int *paramB) {
char *param1 = DYN_CAST(paramA), *param2 = DYN_CAST(paramB);
@ -38,7 +38,7 @@ int testDivision(int a) {
}
// Warning should not be suppressed if it happens in the same macro.
#define DEREF_IN_MACRO(X) int fn() {int *p = 0; return *p; }
#define DEREF_IN_MACRO(X) int fn(void) {int *p = 0; return *p; }
DEREF_IN_MACRO(0) // expected-warning{{Dereference of null pointer}}
// expected-note@-1{{'p' initialized to a null}}
@ -47,8 +47,8 @@ DEREF_IN_MACRO(0) // expected-warning{{Dereference of null pointer}}
// Warning should not be suppressed if the null returned by the macro
// is not related to the warning.
#define RETURN_NULL() (0)
extern int* returnFreshPointer();
int noSuppressMacroUnrelated() {
extern int* returnFreshPointer(void);
int noSuppressMacroUnrelated(void) {
int *x = RETURN_NULL();
x = returnFreshPointer(); // expected-note{{Value assigned to 'x'}}
if (x) {} // expected-note{{Taking false branch}}
@ -59,7 +59,7 @@ int noSuppressMacroUnrelated() {
// Value haven't changed by the assignment, but the null pointer
// did not come from the macro.
int noSuppressMacroUnrelatedOtherReason() {
int noSuppressMacroUnrelatedOtherReason(void) {
int *x = RETURN_NULL();
x = returnFreshPointer();
x = 0; // expected-note{{Null pointer value stored to 'x'}}

View File

@ -4,12 +4,12 @@
// "prune-paths" is a debug option only; this is just a simple test to see that
// it's being honored.
void helper() {
extern void foo();
void helper(void) {
extern void foo(void);
foo();
}
void test() {
void test(void) {
helper();
#if NPRUNE
// expected-note@-2 {{Calling 'helper'}}

View File

@ -14,7 +14,7 @@ int initializer1(int *p, int x) {
}
}
int param_not_initialized_by_func() {
int param_not_initialized_by_func(void) {
int p; // expected-note {{'p' declared without an initial value}}
int out = initializer1(&p, 0); // expected-note{{Calling 'initializer1'}}
// expected-note@-1{{Returning from 'initializer1'}}
@ -22,7 +22,7 @@ int param_not_initialized_by_func() {
// expected-warning@-1{{Undefined or garbage value returned to caller}}
}
int param_initialized_properly() {
int param_initialized_properly(void) {
int p;
int out = initializer1(&p, 1);
return p; //no-warning
@ -40,7 +40,7 @@ int initializer2(int **p, int x) {
}
}
int param_not_written_into_by_func() {
int param_not_written_into_by_func(void) {
int *p = 0; // expected-note{{'p' initialized to a null pointer value}}
int out = initializer2(&p, 0); // expected-note{{Calling 'initializer2'}}
// expected-note@-1{{Returning from 'initializer2'}}
@ -54,7 +54,7 @@ void initializer3(int *p, int param) {
*p = 0;
} // expected-note{{Returning without writing to '*p'}}
int param_written_into_by_void_func() {
int param_written_into_by_void_func(void) {
int p; // expected-note{{'p' declared without an initial value}}
initializer3(&p, 0); // expected-note{{Calling 'initializer3'}}
// expected-note@-1{{Returning from 'initializer3'}}
@ -74,7 +74,7 @@ void initializer5(int *p, int param) {
*p = 0;
} // expected-note{{Returning without writing to '*p'}}
int multi_init_tries_func() {
int multi_init_tries_func(void) {
int p; // expected-note{{'p' declared without an initial value}}
initializer4(&p, 0); // expected-note{{Calling 'initializer4'}}
// expected-note@-1{{Returning from 'initializer4'}}
@ -88,7 +88,7 @@ int initializer6(const int *p) {
return 0;
}
int no_msg_on_const() {
int no_msg_on_const(void) {
int p; // expected-note{{'p' declared without an initial value}}
initializer6(&p);
return p; // expected-warning{{Undefined or garbage value returned to caller}}
@ -108,7 +108,7 @@ int initializer7(S *s, int param) {
return 1; // expected-note{{Returning without writing to 's->x'}}
}
int initialize_struct_field() {
int initialize_struct_field(void) {
S local;
initializer7(&local, 0); // expected-note{{Calling 'initializer7'}}
// expected-note@-1{{Returning from 'initializer7'}}
@ -120,7 +120,7 @@ void nullwriter(int **p) {
*p = 0; // expected-note{{Null pointer value stored to 'p'}}
} // no extra note
int usage() {
int usage(void) {
int x = 0;
int *p = &x;
nullwriter(&p); // expected-note{{Calling 'nullwriter'}}
@ -138,7 +138,7 @@ void partial_initializer(A *a) {
a->x = 0;
} // expected-note{{Returning without writing to 'a->y'}}
int use_partial_initializer() {
int use_partial_initializer(void) {
A a;
partial_initializer(&a); // expected-note{{Calling 'partial_initializer'}}
// expected-note@-1{{Returning from 'partial_initializer'}}
@ -159,7 +159,7 @@ void partial_nested_initializer(C *c) {
c->b.x = 0;
} // expected-note{{Returning without writing to 'c->b.y'}}
int use_partial_nested_initializer() {
int use_partial_nested_initializer(void) {
B localB;
C localC;
localC.b = localB;
@ -174,7 +174,7 @@ void test_subregion_assignment(C* c) {
c->b = b;
}
int use_subregion_assignment() {
int use_subregion_assignment(void) {
C c;
test_subregion_assignment(&c); // expected-note{{Calling 'test_subregion_assignment'}}
// expected-note@-1{{Returning from 'test_subregion_assignment'}}
@ -187,7 +187,7 @@ int confusing_signature(int *p) {
return 0; // expected-note{{Returning without writing to '*p'}}
}
int use_confusing_signature() {
int use_confusing_signature(void) {
int a; // expected-note {{'a' declared without an initial value}}
confusing_signature(&a); // expected-note{{Calling 'confusing_signature'}}
// expected-note@-1{{Returning from 'confusing_signature'}}
@ -195,7 +195,7 @@ int use_confusing_signature() {
// expected-warning@-1{{Undefined or garbage value returned to caller}}
}
int coin();
int coin(void);
int multiindirection(int **p) {
if (coin()) // expected-note{{Assuming the condition is true}}
@ -205,7 +205,7 @@ int multiindirection(int **p) {
return 0;
}
int usemultiindirection() {
int usemultiindirection(void) {
int a; // expected-note {{'a' declared without an initial value}}
int *b = &a;
multiindirection(&b); // expected-note{{Calling 'multiindirection'}}
@ -223,7 +223,7 @@ int indirectingstruct(S** s) {
return 0;
}
int useindirectingstruct() {
int useindirectingstruct(void) {
S s;
S* p = &s;
indirectingstruct(&p); //expected-note{{Calling 'indirectingstruct'}}
@ -242,7 +242,7 @@ void initializeMaybeInStruct(D* pD) {
*pD->x = 120;
} // expected-note{{Returning without writing to 'pD->x'}}
int useInitializeMaybeInStruct() {
int useInitializeMaybeInStruct(void) {
int z; // expected-note{{'z' declared without an initial value}}
D d;
d.x = &z;

View File

@ -2,7 +2,7 @@
#include "../Inputs/system-header-simulator-for-nullability.h"
extern int coin();
extern int coin(void);
@interface I : NSObject
- (int)initVar:(int *)var param:(int)param;
@ -41,7 +41,7 @@ int initializer1(int *p, int x) {
}
}
int initFromBlock() {
int initFromBlock(void) {
__block int z;
^{ // expected-note {{Calling anonymous block}}
int p; // expected-note{{'p' declared without an initial value}}

View File

@ -3,6 +3,6 @@
#include "plist-multi-file.h"
void bar() {
void bar(void) {
foo(0);
}

View File

@ -30,7 +30,7 @@ int leak(int i) {
return 0;
}
int unicode() {
int unicode(void) {
int løçål = 0;
/* ☃ */ return 1 / løçål; // expected-warning {{Division by zero}}
}

View File

@ -1,8 +1,8 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s
// expected-no-diagnostics
int *returnNull() { return 0; }
int coin();
int *returnNull(void) { return 0; }
int coin(void);
// Use a float parameter to ensure that the value is unknown. This will create
// a cycle in the generated ExplodedGraph.

View File

@ -1,6 +1,6 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core.NullDereference -analyzer-output=text -fno-caret-diagnostics %s 2>&1 | FileCheck %s
void testA() {
void testA(void) {
int *p = 0;
*p = 1;

View File

@ -1,4 +1,4 @@
void callee() {
void callee(void) {
;
}

View File

@ -43,7 +43,7 @@ int testPassingParentRegionArray(int x) {
//expected-note@-1 {{The right operand of '*' is a garbage value}}
}
double *getValidPtr();
double *getValidPtr(void);
struct WithFields {
double *f1;
};

View File

@ -14,7 +14,7 @@
// CHECK: no analyzer checkers or packages are associated with 'non.existant.Checker'
// CHECK: use -analyzer-disable-all-checks to disable all static analyzer checkers
int buggy() {
int buggy(void) {
int x = 0;
return 5/x; // no warning
}

View File

@ -19,17 +19,17 @@ typedef void (^dispatch_block_t)(void);
typedef long dispatch_once_t;
void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
void test_stack() {
void test_stack(void) {
dispatch_once_t once;
dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value. Using such transient memory for the predicate is potentially dangerous. Perhaps you intended to declare the variable as 'static'?}}
}
void test_static_local() {
void test_static_local(void) {
static dispatch_once_t once;
dispatch_once(&once, ^{}); // no-warning
}
void test_heap_var() {
void test_heap_var(void) {
dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
// Use regexps to check that we're NOT suggesting to make this static.
dispatch_once(once, ^{}); // expected-warning-re{{{{^Call to 'dispatch_once' uses heap-allocated memory for the predicate value. Using such transient memory for the predicate is potentially dangerous$}}}}
@ -44,12 +44,12 @@ typedef struct {
dispatch_once_t once;
} Struct;
void test_local_struct() {
void test_local_struct(void) {
Struct s;
dispatch_once(&s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the local variable 's' for the predicate value.}}
}
void test_heap_struct() {
void test_heap_struct(void) {
Struct *s = calloc(1, sizeof(Struct));
dispatch_once(&s->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses heap-allocated memory for the predicate value.}}
}
@ -76,15 +76,15 @@ void test_heap_struct() {
}
@end
void test_ivar_from_alloc_init() {
void test_ivar_from_alloc_init(void) {
Object *o = [[Object alloc] init];
dispatch_once(&o->once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
}
void test_ivar_struct_from_alloc_init() {
void test_ivar_struct_from_alloc_init(void) {
Object *o = [[Object alloc] init];
dispatch_once(&o->s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 's' for the predicate value.}}
}
void test_ivar_array_from_alloc_init() {
void test_ivar_array_from_alloc_init(void) {
Object *o = [[Object alloc] init];
dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
}
@ -100,7 +100,7 @@ void test_ivar_array_from_external_obj(Object *o) {
dispatch_once(&o->once_array[1], ^{}); // expected-warning{{Call to 'dispatch_once' uses memory within the instance variable 'once_array' for the predicate value.}}
}
void test_block_var_from_block() {
void test_block_var_from_block(void) {
__block dispatch_once_t once;
^{
dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
@ -109,7 +109,7 @@ void test_block_var_from_block() {
void use_block_var(dispatch_once_t *once);
void test_block_var_from_outside_block() {
void test_block_var_from_outside_block(void) {
__block dispatch_once_t once;
^{
use_block_var(&once);
@ -117,7 +117,7 @@ void test_block_var_from_outside_block() {
dispatch_once(&once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the block variable 'once' for the predicate value.}}
}
void test_static_var_from_outside_block() {
void test_static_var_from_outside_block(void) {
static dispatch_once_t once;
^{
dispatch_once(&once, ^{}); // no-warning

View File

@ -5,7 +5,7 @@
// RUN: 2>&1 | FileCheck %s
// Test the DominatorsTree implementation with various control flows
int test1()
int test1(void)
{
int x = 6;
int y = x/2;
@ -65,7 +65,7 @@ int test1()
// CHECK-NEXT: (8,7)
// CHECK-NEXT: (9,8)
int test2()
int test2(void)
{
int x,y,z;
@ -117,7 +117,7 @@ int test2()
// CHECK-NEXT: (6,1)
// CHECK-NEXT: (7,6)
int test3()
int test3(void)
{
int x,y,z;
@ -178,7 +178,7 @@ int test3()
// CHECK-NEXT: (7,1)
// CHECK-NEXT: (8,7)
int test4()
int test4(void)
{
int y = 3;
while(y > 0) {
@ -257,7 +257,7 @@ int test4()
// CHECK-NEXT: (11,10)
// CHECK-NEXT: (12,11)
int test5()
int test5(void)
{
int x,y,z,a,b,c;
x = 1;

View File

@ -6,7 +6,7 @@ typedef unsigned long int A;
extern int fill(A **values, int *nvalues);
void foo() {
void foo(void) {
A *values;
int nvalues;
fill(&values, &nvalues);

View File

@ -9,9 +9,9 @@
// REQUIRES: asserts
int getJ();
int getJ(void);
int foo() {
int foo(void) {
int *x = 0, *y = 0;
char c = '\x13';

View File

@ -5,7 +5,7 @@ typedef struct added_obj_st {
} ADDED_OBJ;
// Test if we are using the canonical type for ElementRegion.
void f() {
void f(void) {
ADDED_OBJ *ao[4]={((void*)0),((void*)0),((void*)0),((void*)0)};
if (ao[0] != ((void*)0)) {
ao[0]->type=0;

View File

@ -10,7 +10,7 @@ enum En_t {
En_4 = 4
};
void unscopedUnspecifiedCStyle() {
void unscopedUnspecifiedCStyle(void) {
enum En_t Below = (enum En_t)(-5); // expected-warning {{not in the valid range}}
enum En_t NegVal1 = (enum En_t)(-4); // OK.
enum En_t NegVal2 = (enum En_t)(-3); // OK.
@ -25,7 +25,7 @@ void unscopedUnspecifiedCStyle() {
}
enum En_t unused;
void unusedExpr() {
void unusedExpr(void) {
// Following line is not something that EnumCastOutOfRangeChecker should
// evaluate. Checker should either ignore this line or process it without
// producing any warnings. However, compilation will (and should) still

View File

@ -9,9 +9,9 @@
#define CHAR_MIN (char)(UCHAR_MAX & ~(UCHAR_MAX >> 1))
void clang_analyzer_eval(int);
void clang_analyzer_warnIfReached();
void clang_analyzer_warnIfReached(void);
int getInt();
int getInt(void);
void zeroImpliesEquality(int a, int b) {
clang_analyzer_eval((a - b) == 0); // expected-warning{{UNKNOWN}}

View File

@ -15,7 +15,7 @@ static void f1(const char *x, char *y) {
// the RvalueType of an ElementRegion.
typedef struct F12_struct {} F12_typedef;
typedef void* void_typedef;
void_typedef f2_helper();
void_typedef f2_helper(void);
static void f2(void *buf) {
F12_typedef* x;
x = f2_helper();

View File

@ -21,7 +21,7 @@ void test_1(Object *p) {
clang_analyzer_explain(q->x); // expected-warning-re{{{{^initial value of instance variable 'x' of object at symbol of type 'Object \*' conjured at statement '\[\[Object alloc\] init\]'$}}}}
}
void test_2() {
void test_2(void) {
__block int x;
^{
clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}}

View File

@ -20,7 +20,7 @@ static inline __attribute__((always_inline)) f(enum { x, y } p) {
#else
int main() {
int main(void) {
return f(0);
}

View File

@ -54,8 +54,8 @@ struct P1 l1 = {
.q.b = { [1] = 'x' }
};
extern struct Q1 *foo();
static struct P1 test_foo() {
extern struct Q1 *foo(void);
static struct P1 test_foo(void) {
struct P1 l = { *foo(),
.q.b = { "boo" },
.q.b = { [1] = 'x' }

View File

@ -8,7 +8,7 @@ extern int foo;
#else
void f() {
void f(void) {
int a = foo;
// Make sure we parsed this by getting an error.
int b = bar; // expected-error {{undeclared}}

View File

@ -8,7 +8,7 @@ extern int foo;
#else
void f() {
void f(void) {
int a = foo;
// Make sure we parsed this by getting an error.
int b = bar; // expected-error {{undeclared}}

View File

@ -3,7 +3,7 @@
// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only -MT %s.o -dependency-file - %s | FileCheck %s
// CHECK: chain-decls1.h
int main() {
int main(void) {
f();
return 0;
}

View File

@ -9,7 +9,7 @@
int i = Red;
int return_enum_constant() {
int return_enum_constant(void) {
int result = aRoundShape;
return result;
}

View File

@ -30,7 +30,7 @@ floating_literal *double_ptr = &floating;
imaginary_literal *cdouble_ptr = &floating_complex;
// StringLiteral
const char* printHello() {
const char* printHello(void) {
return hello;
}

View File

@ -23,7 +23,7 @@ id sharedObject = 0;
#else
//===----------------------------------------------------------------------===//
void callDoSomething() {
void callDoSomething(void) {
doSomething(sharedObject);
}

View File

@ -27,7 +27,7 @@ struct U {
#endif
//===----------------------------------------------------------------------===//
void bar() {
void bar(void) {
static const struct U plan = { .e = 1 };
}

View File

@ -11,7 +11,7 @@ extern int printf(const char *restrict, ...);
#else
void foo() {
void foo(void) {
LOG;
}

View File

@ -11,7 +11,7 @@ extern int x;
#warning parsed this
// expected-warning@-1 {{parsed this}}
int foo() {
int foo(void) {
return x;
}

View File

@ -6,6 +6,6 @@
void f() {
void f(void) {
extern int g(int, int);
}

View File

@ -10,7 +10,7 @@
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
void all() {
void all(void) {
NSMutableArray *array;
id oldObject = array[10];

View File

@ -9,7 +9,7 @@
#import "objc_import.h"
void func() {
void func(void) {
TestPCH *xx;
xx = [TestPCH alloc];

View File

@ -41,7 +41,7 @@ typedef unsigned char BOOL;
@end
// CHECK-IR: define internal {{.*}}void @test_numeric_literals()
static inline void test_numeric_literals() {
static inline void test_numeric_literals(void) {
// CHECK-PRINT: id intlit = @17
// CHECK-IR: {{call.*17}}
id intlit = @17;
@ -50,18 +50,18 @@ static inline void test_numeric_literals() {
id floatlit = @17.45;
}
static inline void test_array_literals() {
static inline void test_array_literals(void) {
// CHECK-PRINT: id arraylit = @[ @17, @17.449999999999999
id arraylit = @[@17, @17.45];
}
static inline void test_dictionary_literals() {
static inline void test_dictionary_literals(void) {
// CHECK-PRINT: id dictlit = @{ @17 : {{@17.449999999999999[^,]*}}, @"hello" : @"world" };
id dictlit = @{@17 : @17.45, @"hello" : @"world" };
}
#else
void test_all() {
void test_all(void) {
test_numeric_literals();
test_array_literals();
test_dictionary_literals();

View File

@ -7,7 +7,7 @@
// expected-no-diagnostics
void func() {
void func(void) {
TestPCH *xx;
TestForwardClassDecl *yy;
// FIXME:

View File

@ -7,7 +7,7 @@
// expected-no-diagnostics
void func() {
void func(void) {
TestProperties *xx = [TestProperties alloc];
xx.value = 5;
}

View File

@ -21,7 +21,7 @@
// CHECK-CBAR: int bar
int FOO;
int get() {
int get(void) {
#ifdef __cplusplus
// CHECK-CPP: .h.gch{{[/\\]}}cpp.gch
return i;

View File

@ -14,7 +14,7 @@
#else
void f() {
void f(void) {
int a = 0;
int b = a==a;
}

View File

@ -21,7 +21,7 @@
int a;
void f() {
void f(void) {
a = 12345;
}

View File

@ -17,7 +17,7 @@
#else
int f() {
int f(void) {
int a;
int b = a==a;
unsigned x;

View File

@ -11,7 +11,7 @@ float getX(struct Point *p1) {
return p1->x;
}
void *get_fun_ptr() {
void *get_fun_ptr(void) {
return fun->is_ptr? fun->ptr : 0;
}
@ -19,7 +19,7 @@ struct Fun2 {
int very_fun;
};
int get_very_fun() {
int get_very_fun(void) {
return fun2->very_fun;
}

View File

@ -53,7 +53,7 @@ void testDict(NSString *key, id newObject, id oldObject) {
NSDictionary *dict = @{ key: newObject, key: oldObject };
}
void testBoxableValue() {
void testBoxableValue(void) {
some_struct ss;
id value = @(ss);
}

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