Skip to content

Commit 1ea5843

Browse files
committed
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have a prototype for the situations where the test is not specific to K&R C declarations. e.g., void func(); becomes void func(void); This is the ninth batch of tests being updated (there are a significant number of other tests left to be updated).
1 parent d462e64 commit 1ea5843

File tree

365 files changed

+1906
-1906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

365 files changed

+1906
-1906
lines changed

clang/test/Analysis/Inputs/expected-plists/unix-fns.c.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@
561561
<key>type</key><string>Improper use of &apos;dispatch_once&apos;</string>
562562
<key>check_name</key><string>osx.API</string>
563563
<!-- This hash is experimental and going to change! -->
564-
<key>issue_hash_content_of_line_in_context</key><string>173fbcac3fc64dbaec32768d4cfda250</string>
564+
<key>issue_hash_content_of_line_in_context</key><string>3c7c4524233ba46b615e7c4c2ce7c20d</string>
565565
<key>issue_context_kind</key><string>function</string>
566566
<key>issue_context</key><string>test_dispatch_once</string>
567567
<key>issue_hash_function_offset</key><string>2</string>
@@ -1473,7 +1473,7 @@
14731473
<key>type</key><string>Improper use of &apos;dispatch_once&apos;</string>
14741474
<key>check_name</key><string>osx.API</string>
14751475
<!-- This hash is experimental and going to change! -->
1476-
<key>issue_hash_content_of_line_in_context</key><string>8ded1f2025c1e4a4bcd5302dc97006d9</string>
1476+
<key>issue_hash_content_of_line_in_context</key><string>6fec229f3dde6d311481c6a64eeffefa</string>
14771477
<key>issue_context_kind</key><string>function</string>
14781478
<key>issue_context</key><string>test_dispatch_once_in_macro</string>
14791479
<key>issue_hash_function_offset</key><string>2</string>

clang/test/Analysis/exploded-graph-rewriter/escapes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %exploded_graph_rewriter %t.dot | FileCheck %s
66
// REQUIRES: asserts
77

8-
void escapes() {
8+
void escapes(void) {
99
// CHECK: <td align="left"><b>Store: </b> <font color="gray">(0x{{[0-9a-f]*}})</font></td>
1010
// CHECK-SAME: <td align="left">foo</td><td align="left">0</td>
1111
// CHECK-SAME: <td align="left">&amp;Element\{"foo",0 S64b,char\}</td>

clang/test/Analysis/exploded-graph-rewriter/macros.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#define NULL 0
2-
void *foo() {
2+
void *foo(void) {
33
return NULL;
44
}
55

clang/test/Analysis/expr-inspection-printState-diseq-info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_analyze_cc1 \
22
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
33

4-
void clang_analyzer_printState();
4+
void clang_analyzer_printState(void);
55

66
void test_disequality_info(int e0, int b0, int b1, int c0) {
77
int e1 = e0 - b0;

clang/test/Analysis/expr-inspection-printState-eq-classes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_analyze_cc1 \
22
// RUN: -analyzer-checker=debug.ExprInspection %s 2>&1 | FileCheck %s
33

4-
void clang_analyzer_printState();
4+
void clang_analyzer_printState(void);
55

66
void test_equivalence_classes(int a, int b, int c, int d) {
77
if (a + b != c)

clang/test/Analysis/expr-inspection.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
void clang_analyzer_dump(int x);
88
void clang_analyzer_dump_pointer(int *p);
9-
void clang_analyzer_printState();
10-
void clang_analyzer_numTimesReached();
9+
void clang_analyzer_printState(void);
10+
void clang_analyzer_numTimesReached(void);
1111

1212
void foo(int x) {
1313
clang_analyzer_dump(x); // expected-warning{{reg_$0<int x>}}

clang/test/Analysis/fields.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
void clang_analyzer_eval(int);
44

5-
unsigned foo();
5+
unsigned foo(void);
66
typedef struct bf { unsigned x:2; } bf;
7-
void bar() {
7+
void bar(void) {
88
bf y;
99
*(unsigned*)&y = foo();
1010
y.x = 1;
@@ -14,7 +14,7 @@ struct s {
1414
int n;
1515
};
1616

17-
void f() {
17+
void f(void) {
1818
struct s a;
1919
int *p = &(a.n) + 1; // expected-warning{{Pointer arithmetic on}}
2020
}
@@ -24,7 +24,7 @@ typedef struct {
2424
} Point;
2525

2626
Point getit(void);
27-
void test() {
27+
void test(void) {
2828
Point p;
2929
(void)(p = getit()).x;
3030
}
@@ -34,7 +34,7 @@ void test() {
3434
typedef _Bool bool;
3535

3636

37-
void testLazyCompoundVal() {
37+
void testLazyCompoundVal(void) {
3838
Point p = {42, 0};
3939
Point q;
4040
clang_analyzer_eval((q = p).x == 42); // expected-warning{{TRUE}}
@@ -58,7 +58,7 @@ struct Bits {
5858
} inner;
5959
};
6060

61-
void testBitfields() {
61+
void testBitfields(void) {
6262
struct Bits bits;
6363

6464
if (foo() && bits.b) // expected-warning {{garbage}}
@@ -89,7 +89,7 @@ void testBitfields() {
8989
if (foo() && bits.inner.f) // expected-warning {{garbage}}
9090
return;
9191

92-
extern struct InnerBits getInner();
92+
extern struct InnerBits getInner(void);
9393
bits.inner = getInner();
9494

9595
if (foo() && bits.inner.e) // no-warning
@@ -117,7 +117,7 @@ void testBitfields() {
117117
// Incorrect behavior
118118
//-----------------------------------------------------------------------------
119119

120-
void testTruncation() {
120+
void testTruncation(void) {
121121
struct Bits bits;
122122
bits.c = 0x11; // expected-warning{{implicit truncation}}
123123
// FIXME: We don't model truncation of bitfields.

clang/test/Analysis/flexible-array-members.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void *alloca(size_t size);
2222
void *malloc(size_t size);
2323
void free(void *ptr);
2424

25-
void test_incomplete_array_fam() {
25+
void test_incomplete_array_fam(void) {
2626
typedef struct FAM {
2727
char c;
2828
int data[];
@@ -48,7 +48,7 @@ void test_incomplete_array_fam() {
4848
free(q);
4949
}
5050

51-
void test_zero_length_array_fam() {
51+
void test_zero_length_array_fam(void) {
5252
typedef struct FAM {
5353
char c;
5454
int data[0];
@@ -74,7 +74,7 @@ void test_zero_length_array_fam() {
7474
free(q);
7575
}
7676

77-
void test_single_element_array_possible_fam() {
77+
void test_single_element_array_possible_fam(void) {
7878
typedef struct FAM {
7979
char c;
8080
int data[1];

clang/test/Analysis/flexignore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/* A lexical scanner generated by flex */
1010

11-
void clang_analyzer_warnIfReached();
12-
void foo() {
11+
void clang_analyzer_warnIfReached(void);
12+
void foo(void) {
1313
clang_analyzer_warnIfReached(); // conditional-warning {{REACHABLE}}
1414
}

clang/test/Analysis/free.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ typedef __typeof(sizeof(int)) size_t;
1010
void free(void *);
1111
void *alloca(size_t);
1212

13-
void t1 () {
13+
void t1 (void) {
1414
int a[] = { 1 };
1515
free(a);
1616
// expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
1717
// expected-warning@-2{{attempt to call free on non-heap object 'a'}}
1818
}
1919

20-
void t2 () {
20+
void t2 (void) {
2121
int a = 1;
2222
free(&a);
2323
// expected-warning@-1{{Argument to free() is the address of the local variable 'a', which is not memory allocated by malloc()}}
2424
// expected-warning@-2{{attempt to call free on non-heap object 'a'}}
2525
}
2626

27-
void t3 () {
27+
void t3 (void) {
2828
static int a[] = { 1 };
2929
free(a);
3030
// expected-warning@-1{{Argument to free() is the address of the static variable 'a', which is not memory allocated by malloc()}}
@@ -35,12 +35,12 @@ void t4 (char *x) {
3535
free(x); // no-warning
3636
}
3737

38-
void t5 () {
39-
extern char *ptr();
38+
void t5 (void) {
39+
extern char *ptr(void);
4040
free(ptr()); // no-warning
4141
}
4242

43-
void t6 () {
43+
void t6 (void) {
4444
free((void*)1000);
4545
// expected-warning@-1{{Argument to free() is a constant address (1000), which is not memory allocated by malloc()}}
4646
// expected-warning@-2{{attempt to call free on non-heap object '(void *)1000'}}
@@ -55,30 +55,30 @@ void t8 (char **x) {
5555
free((*x)+8); // no-warning
5656
}
5757

58-
void t9 () {
58+
void t9 (void) {
5959
label:
6060
free(&&label);
6161
// expected-warning@-1{{Argument to free() is the address of the label 'label', which is not memory allocated by malloc()}}
6262
// expected-warning@-2{{attempt to call free on non-heap object 'label'}}
6363
}
6464

65-
void t10 () {
65+
void t10 (void) {
6666
free((void*)&t10);
6767
// expected-warning@-1{{Argument to free() is the address of the function 't10', which is not memory allocated by malloc()}}
6868
// expected-warning@-2{{attempt to call free on non-heap object 't10'}}
6969
}
7070

71-
void t11 () {
71+
void t11 (void) {
7272
char *p = (char*)alloca(2);
7373
free(p); // expected-warning {{Memory allocated by alloca() should not be deallocated}}
7474
}
7575

76-
void t12 () {
76+
void t12 (void) {
7777
char *p = (char*)__builtin_alloca(2);
7878
free(p); // expected-warning {{Memory allocated by alloca() should not be deallocated}}
7979
}
8080

81-
void t13 () {
81+
void t13 (void) {
8282
free(^{return;});
8383
// expected-warning@-1{{Argument to free() is a block, which is not memory allocated by malloc()}}
8484
// expected-warning@-2{{attempt to call free on non-heap object: block expression}}
@@ -91,7 +91,7 @@ void t14 (char a) {
9191
}
9292

9393
static int someGlobal[2];
94-
void t15 () {
94+
void t15 (void) {
9595
free(someGlobal);
9696
// expected-warning@-1{{Argument to free() is the address of the global variable 'someGlobal', which is not memory allocated by malloc()}}
9797
// expected-warning@-2{{attempt to call free on non-heap object 'someGlobal'}}

clang/test/Analysis/fuchsia_lock.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void bad2(void) {
2929
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
3030
}
3131

32-
void bad3() {
32+
void bad3(void) {
3333
spin_lock_init(&mtx1);
3434
if (spin_trylock(&mtx1) != 0)
3535
spin_unlock(&mtx1); // expected-warning {{This lock has already been unlocked}}
@@ -42,14 +42,14 @@ void bad4(void) {
4242
spin_unlock(&mtx2);
4343
}
4444

45-
void good() {
45+
void good(void) {
4646
spin_lock_t mtx;
4747
spin_lock_init(&mtx);
4848
spin_lock_save(&mtx, 0, 0);
4949
spin_unlock_restore(&mtx, 0, 0);
5050
}
5151

52-
void good2() {
52+
void good2(void) {
5353
spin_lock_t mtx;
5454
spin_lock_init(&mtx);
5555
if (spin_trylock(&mtx) == 0)
@@ -78,7 +78,7 @@ void bad12(void) {
7878
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
7979
}
8080

81-
void bad13() {
81+
void bad13(void) {
8282
sync_mutex_unlock(&smtx1);
8383
if (sync_mutex_trylock(&smtx1) != 0)
8484
sync_mutex_unlock(&smtx1); // expected-warning {{This lock has already been unlocked}}
@@ -91,13 +91,13 @@ void bad14(void) {
9191
sync_mutex_unlock(&smtx2);
9292
}
9393

94-
void good11() {
94+
void good11(void) {
9595
sync_mutex_t mtx;
9696
if (sync_mutex_trylock(&mtx) == 0)
9797
sync_mutex_unlock(&mtx);
9898
}
9999

100-
void good12() {
100+
void good12(void) {
101101
sync_mutex_t mtx;
102102
if (sync_mutex_timedlock(&mtx, 0) == 0)
103103
sync_mutex_unlock(&mtx);

clang/test/Analysis/fuchsia_lock_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
typedef int spin_lock_t;
44

55
void spin_lock(spin_lock_t *lock);
6-
int getCond();
6+
int getCond(void);
77
int spin_trylock(spin_lock_t *lock) {
88
if (getCond())
99
return 0;
@@ -12,7 +12,7 @@ int spin_trylock(spin_lock_t *lock) {
1212
void spin_unlock(spin_lock_t *lock);
1313

1414
spin_lock_t mtx;
15-
void no_crash() {
15+
void no_crash(void) {
1616
if (spin_trylock(&mtx) == 0)
1717
spin_unlock(&mtx);
1818
}

clang/test/Analysis/func.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify -analyzer-config eagerly-assume=false %s
22

33
void clang_analyzer_eval(int);
4-
void clang_analyzer_warnIfReached();
4+
void clang_analyzer_warnIfReached(void);
55

66
void f(void) {
77
void (*p)(void);
@@ -13,7 +13,7 @@ void f(void) {
1313

1414
void g(void (*fp)(void));
1515

16-
void f2() {
16+
void f2(void) {
1717
g(f);
1818
}
1919

@@ -27,7 +27,7 @@ void f3(void (*f)(void), void (*g)(void)) {
2727
clang_analyzer_eval(!g); // expected-warning{{FALSE}}
2828
}
2929

30-
void nullFunctionPointerConstant() {
30+
void nullFunctionPointerConstant(void) {
3131
void (*f)(void) = 0;
3232
f(); // expected-warning{{Called function pointer is null}}
3333
clang_analyzer_warnIfReached(); // no-warning

0 commit comments

Comments
 (0)