mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 05:40:09 +00:00
Use function prototypes when appropriate; NFC
This prepares the clang-tools-extra project for -Wstrict-prototypes being enabled by default.
This commit is contained in:
parent
cfab126888
commit
27d39e4da0
@ -7,7 +7,7 @@ struct Foo {
|
||||
int w; // CHECK-NEXT: {{^ const int\* x}}
|
||||
};
|
||||
|
||||
int main() {
|
||||
int main(void) {
|
||||
const int x = 13;
|
||||
struct Foo foo = { &x, 0, 1.29, 17 }; // CHECK: {{^ struct Foo foo = { 1.29, 17, 0, &x };}}
|
||||
return 0;
|
||||
|
@ -18,10 +18,10 @@
|
||||
__z; \
|
||||
})
|
||||
|
||||
int foo();
|
||||
int foo(void);
|
||||
int bar(int a);
|
||||
|
||||
void with_custom_macro() {
|
||||
void with_custom_macro(void) {
|
||||
MY_TEMP_FAILURE_RETRY(foo());
|
||||
MY_TEMP_FAILURE_RETRY(foo() == 1);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in MY_TEMP_FAILURE_RETRY
|
||||
@ -33,7 +33,7 @@ void with_custom_macro() {
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: top-level comparison in MY_TEMP_FAILURE_RETRY
|
||||
}
|
||||
|
||||
void with_other_custom_macro() {
|
||||
void with_other_custom_macro(void) {
|
||||
MY_OTHER_TEMP_FAILURE_RETRY(foo());
|
||||
MY_OTHER_TEMP_FAILURE_RETRY(foo() == 1);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: top-level comparison in MY_OTHER_TEMP_FAILURE_RETRY
|
||||
|
@ -9,10 +9,10 @@
|
||||
__z; \
|
||||
})
|
||||
|
||||
int foo();
|
||||
int foo(void);
|
||||
int bar(int a);
|
||||
|
||||
void test() {
|
||||
void test(void) {
|
||||
int i;
|
||||
TEMP_FAILURE_RETRY((i = foo()));
|
||||
TEMP_FAILURE_RETRY(foo());
|
||||
@ -86,7 +86,7 @@ void test() {
|
||||
}
|
||||
|
||||
// Be sure that it works inside of things like loops, if statements, etc.
|
||||
void control_flow() {
|
||||
void control_flow(void) {
|
||||
do {
|
||||
if (TEMP_FAILURE_RETRY(foo())) {
|
||||
}
|
||||
@ -105,7 +105,7 @@ void control_flow() {
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: top-level comparison in TEMP_FAILURE_RETRY
|
||||
}
|
||||
|
||||
void with_nondependent_variable_type() {
|
||||
void with_nondependent_variable_type(void) {
|
||||
#undef TEMP_FAILURE_RETRY
|
||||
#define TEMP_FAILURE_RETRY(x) \
|
||||
({ \
|
||||
@ -126,7 +126,7 @@ void with_nondependent_variable_type() {
|
||||
|
||||
// I can't find a case where TEMP_FAILURE_RETRY is implemented like this, but if
|
||||
// we can cheaply support it, I don't see why not.
|
||||
void obscured_temp_failure_retry() {
|
||||
void obscured_temp_failure_retry(void) {
|
||||
#undef TEMP_FAILURE_RETRY
|
||||
#define IMPL(x) \
|
||||
({ \
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: %check_clang_tidy %s bugprone-assert-side-effect %t
|
||||
|
||||
int abort();
|
||||
int abort(void);
|
||||
|
||||
@interface NSObject
|
||||
@end
|
||||
@ -46,7 +46,7 @@ int abort();
|
||||
}
|
||||
@end
|
||||
|
||||
void foo() {
|
||||
void foo(void) {
|
||||
int x = 0;
|
||||
NSCAssert((++x) == 1, @"Ugh.");
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: side effect in NSCAssert() condition discarded in release builds [bugprone-assert-side-effect]
|
||||
|
@ -8,7 +8,7 @@ int y = 1;
|
||||
else if (c) \
|
||||
d = b;
|
||||
|
||||
f() {
|
||||
void f(void) {
|
||||
// CHECK-MESSAGES: warning: repeated branch in conditional chain [bugprone-branch-clone]
|
||||
a(x, y)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 1}, \
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
|
||||
// RUN: ]}' -- -x c
|
||||
// RUN: ]}' -- -Wno-strict-prototypes -x c
|
||||
|
||||
int myprint();
|
||||
int add(int X, int Y);
|
||||
|
@ -7,7 +7,7 @@
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.ModelImplicitConversions, value: 0}, \
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether, value: 0}, \
|
||||
// RUN: {key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold, value: 0} \
|
||||
// RUN: ]}' -- -x c
|
||||
// RUN: ]}' -- -Wno-strict-prototypes -x c
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
|
@ -13,7 +13,7 @@
|
||||
// False positive suppression.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void good_memcpy_known_src() {
|
||||
void good_memcpy_known_src(void) {
|
||||
char dest[13];
|
||||
char src[] = "foobar";
|
||||
memcpy(dest, src, sizeof(src));
|
||||
@ -69,7 +69,7 @@ void good_memcpy_variable_array(int dest_length) {
|
||||
strcpy(dst02, "foobarbazqux");
|
||||
}
|
||||
|
||||
void bad_memcpy_equal_src_length_and_length() {
|
||||
void bad_memcpy_equal_src_length_and_length(void) {
|
||||
char dest03[13];
|
||||
const char *src = "foobarbazqux";
|
||||
memcpy(dest03, src, 12);
|
||||
@ -77,7 +77,7 @@ void bad_memcpy_equal_src_length_and_length() {
|
||||
// CHECK-FIXES: strcpy(dest03, src);
|
||||
}
|
||||
|
||||
void good_memcpy_equal_src_length_and_length() {
|
||||
void good_memcpy_equal_src_length_and_length(void) {
|
||||
char dst03[13];
|
||||
const char *src = "foobarbazqux";
|
||||
strcpy(dst03, src);
|
||||
@ -98,7 +98,7 @@ void good_memcpy_dest_size_overflows(const char *src) {
|
||||
strcpy(dst04, src);
|
||||
}
|
||||
|
||||
void bad_memcpy_macro() {
|
||||
void bad_memcpy_macro(void) {
|
||||
char dest05[SRC_LENGTH];
|
||||
memcpy(dest05, SRC, SRC_LENGTH);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result]
|
||||
@ -106,7 +106,7 @@ void bad_memcpy_macro() {
|
||||
// CHECK-FIXES-NEXT: strcpy(dest05, SRC);
|
||||
}
|
||||
|
||||
void good_memcpy_macro() {
|
||||
void good_memcpy_macro(void) {
|
||||
char dst05[SRC_LENGTH + 1];
|
||||
strcpy(dst05, SRC);
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
// in C, double underscores are fine except at the beginning
|
||||
|
||||
void foo__();
|
||||
void f__o__o();
|
||||
void f_________oo();
|
||||
void __foo();
|
||||
void foo__(void);
|
||||
void f__o__o(void);
|
||||
void f_________oo(void);
|
||||
void __foo(void);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration uses identifier '__foo', which is a reserved identifier [bugprone-reserved-identifier]
|
||||
// CHECK-FIXES: {{^}}void foo();{{$}}
|
||||
// CHECK-FIXES: {{^}}void foo(void);{{$}}
|
||||
|
@ -25,7 +25,7 @@ void handler_good(int) {
|
||||
signal(0, SIG_DFL);
|
||||
}
|
||||
|
||||
void test() {
|
||||
void test(void) {
|
||||
signal(SIGINT, handler_bad1);
|
||||
signal(SIGINT, handler_bad2);
|
||||
signal(SIGINT, handler_good);
|
||||
|
@ -23,7 +23,7 @@ void handler_good(int) {
|
||||
memcpy((void*)10, (const void*)20, 1);
|
||||
}
|
||||
|
||||
void test() {
|
||||
void test(void) {
|
||||
signal(SIGINT, handler_good);
|
||||
signal(SIGINT, handler_bad);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ int printf(const char *, ...);
|
||||
typedef void (*sighandler_t)(int);
|
||||
sighandler_t signal(int signum, sighandler_t handler);
|
||||
|
||||
void f_extern();
|
||||
void f_extern(void);
|
||||
|
||||
void handler_printf(int) {
|
||||
printf("1234");
|
||||
@ -22,7 +22,7 @@ void handler_printf(int) {
|
||||
// CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_printf' registered here as signal handler
|
||||
}
|
||||
|
||||
void test_printf() {
|
||||
void test_printf(void) {
|
||||
signal(SIGINT, handler_printf);
|
||||
}
|
||||
|
||||
@ -33,11 +33,11 @@ void handler_extern(int) {
|
||||
// CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_extern' registered here as signal handler
|
||||
}
|
||||
|
||||
void test_extern() {
|
||||
void test_extern(void) {
|
||||
signal(SIGINT, handler_extern);
|
||||
}
|
||||
|
||||
void f_ok() {
|
||||
void f_ok(void) {
|
||||
abort();
|
||||
}
|
||||
|
||||
@ -45,11 +45,11 @@ void handler_ok(int) {
|
||||
f_ok();
|
||||
}
|
||||
|
||||
void test_ok() {
|
||||
void test_ok(void) {
|
||||
signal(SIGINT, handler_ok);
|
||||
}
|
||||
|
||||
void f_bad() {
|
||||
void f_bad(void) {
|
||||
printf("1234");
|
||||
// CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
|
||||
// CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_bad'
|
||||
@ -61,11 +61,11 @@ void handler_bad(int) {
|
||||
f_bad();
|
||||
}
|
||||
|
||||
void test_bad() {
|
||||
void test_bad(void) {
|
||||
signal(SIGINT, handler_bad);
|
||||
}
|
||||
|
||||
void f_bad1() {
|
||||
void f_bad1(void) {
|
||||
printf("1234");
|
||||
// CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
|
||||
// CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_bad1'
|
||||
@ -74,7 +74,7 @@ void f_bad1() {
|
||||
// CHECK-NOTES: :[[@LINE+13]]:18: note: function 'handler_bad1' registered here as signal handler
|
||||
}
|
||||
|
||||
void f_bad2() {
|
||||
void f_bad2(void) {
|
||||
f_bad1();
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ void handler_bad1(int) {
|
||||
f_bad1();
|
||||
}
|
||||
|
||||
void test_bad1() {
|
||||
void test_bad1(void) {
|
||||
signal(SIGINT, handler_bad1);
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ void handler_false_condition(int) {
|
||||
// CHECK-NOTES: :[[@LINE+4]]:18: note: function 'handler_false_condition' registered here as signal handler
|
||||
}
|
||||
|
||||
void test_false_condition() {
|
||||
void test_false_condition(void) {
|
||||
signal(SIGINT, handler_false_condition);
|
||||
}
|
||||
|
||||
@ -121,11 +121,11 @@ void handler_multiple_calls(int) {
|
||||
// first 'f_extern' call found only
|
||||
}
|
||||
|
||||
void test_multiple_calls() {
|
||||
void test_multiple_calls(void) {
|
||||
signal(SIGINT, handler_multiple_calls);
|
||||
}
|
||||
|
||||
void f_recursive();
|
||||
void f_recursive(void);
|
||||
|
||||
void handler_recursive(int) {
|
||||
f_recursive();
|
||||
@ -133,7 +133,7 @@ void handler_recursive(int) {
|
||||
// first 'printf' call (in other function) found only
|
||||
}
|
||||
|
||||
void f_recursive() {
|
||||
void f_recursive(void) {
|
||||
f_extern();
|
||||
// CHECK-NOTES: :[[@LINE-1]]:3: warning: 'f_extern' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
|
||||
// CHECK-NOTES: :[[@LINE-2]]:3: note: function 'f_extern' called here from 'f_recursive'
|
||||
@ -147,11 +147,11 @@ void f_recursive() {
|
||||
handler_recursive(2);
|
||||
}
|
||||
|
||||
void test_recursive() {
|
||||
void test_recursive(void) {
|
||||
signal(SIGINT, handler_recursive);
|
||||
}
|
||||
|
||||
void f_multiple_paths() {
|
||||
void f_multiple_paths(void) {
|
||||
printf("");
|
||||
// CHECK-NOTES: :[[@LINE-1]]:3: warning: 'printf' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
|
||||
// CHECK-NOTES: :[[@LINE-2]]:3: note: function 'printf' called here from 'f_multiple_paths'
|
||||
@ -164,21 +164,21 @@ void handler_multiple_paths(int) {
|
||||
f_multiple_paths();
|
||||
}
|
||||
|
||||
void test_multiple_paths() {
|
||||
void test_multiple_paths(void) {
|
||||
signal(SIGINT, handler_multiple_paths);
|
||||
}
|
||||
|
||||
void handler_function_pointer(int) {
|
||||
void (*fp)() = f_extern;
|
||||
void (*fp)(void) = f_extern;
|
||||
// Call with function pointer is not evalauted by the check.
|
||||
(*fp)();
|
||||
}
|
||||
|
||||
void test_function_pointer() {
|
||||
void test_function_pointer(void) {
|
||||
signal(SIGINT, handler_function_pointer);
|
||||
}
|
||||
|
||||
void test_other() {
|
||||
void test_other(void) {
|
||||
signal(SIGINT, handler_abort);
|
||||
signal(SIGINT, handler_signal);
|
||||
|
||||
|
@ -161,4 +161,4 @@ void consume_list_element(void) {
|
||||
for (;; list_c.next == NULL)
|
||||
cnd_timedwait(&condition_c, &lock, &ts);
|
||||
}
|
||||
int main() { return 0; }
|
||||
int main(void) { return 0; }
|
||||
|
@ -64,13 +64,13 @@ int flp37_c_compliant(const struct S2 *s1, const struct S2 *s2) {
|
||||
// no-warning
|
||||
}
|
||||
|
||||
void Test_Float() {
|
||||
void Test_Float(void) {
|
||||
float a, b;
|
||||
memcmp(&a, &b, sizeof(float));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'float' which does not have a unique object representation; consider comparing the values manually
|
||||
}
|
||||
|
||||
void TestArray_Float() {
|
||||
void TestArray_Float(void) {
|
||||
float a[3], b[3];
|
||||
memcmp(a, b, sizeof(a));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'float' which does not have a unique object representation; consider comparing the values manually
|
||||
@ -88,12 +88,12 @@ struct NoPadding {
|
||||
int y;
|
||||
};
|
||||
|
||||
void Test_NoPadding() {
|
||||
void Test_NoPadding(void) {
|
||||
struct NoPadding a, b;
|
||||
memcmp(&a, &b, sizeof(struct NoPadding));
|
||||
}
|
||||
|
||||
void TestArray_NoPadding() {
|
||||
void TestArray_NoPadding(void) {
|
||||
struct NoPadding a[3], b[3];
|
||||
memcmp(a, b, 3 * sizeof(struct NoPadding));
|
||||
}
|
||||
@ -103,7 +103,7 @@ struct TrailingPadding {
|
||||
char c;
|
||||
};
|
||||
|
||||
void Test_TrailingPadding() {
|
||||
void Test_TrailingPadding(void) {
|
||||
struct TrailingPadding a, b;
|
||||
memcmp(&a, &b, sizeof(struct TrailingPadding));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct TrailingPadding' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -117,7 +117,7 @@ struct TrailingPadding2 {
|
||||
char c;
|
||||
};
|
||||
|
||||
void Test_TrailingPadding2() {
|
||||
void Test_TrailingPadding2(void) {
|
||||
struct TrailingPadding2 a, b;
|
||||
memcmp(&a, &b, 2 * sizeof(int)); // no-warning: not comparing entire object
|
||||
memcmp(&a, &b, sizeof(struct TrailingPadding2));
|
||||
@ -129,13 +129,13 @@ void Test_UnknownCount(size_t count) {
|
||||
memcmp(&a, &b, count); // no-warning: unknown count value
|
||||
}
|
||||
|
||||
void Test_ExplicitVoidCast() {
|
||||
void Test_ExplicitVoidCast(void) {
|
||||
struct TrailingPadding a, b;
|
||||
memcmp((void *)&a, (void *)&b,
|
||||
sizeof(struct TrailingPadding)); // no-warning: explicit cast
|
||||
}
|
||||
|
||||
void TestArray_TrailingPadding() {
|
||||
void TestArray_TrailingPadding(void) {
|
||||
struct TrailingPadding a[3], b[3];
|
||||
memcmp(a, b, 3 * sizeof(struct TrailingPadding));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct TrailingPadding' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -146,7 +146,7 @@ struct InnerPadding {
|
||||
int i;
|
||||
};
|
||||
|
||||
void Test_InnerPadding() {
|
||||
void Test_InnerPadding(void) {
|
||||
struct InnerPadding a, b;
|
||||
memcmp(&a, &b, sizeof(struct InnerPadding));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct InnerPadding' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -157,7 +157,7 @@ struct Bitfield_TrailingPaddingBytes {
|
||||
int y : 6;
|
||||
};
|
||||
|
||||
void Test_Bitfield_TrailingPaddingBytes() {
|
||||
void Test_Bitfield_TrailingPaddingBytes(void) {
|
||||
struct Bitfield_TrailingPaddingBytes a, b;
|
||||
memcmp(&a, &b, sizeof(struct S));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_TrailingPaddingBytes' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -168,7 +168,7 @@ struct Bitfield_TrailingPaddingBits {
|
||||
int y : 20;
|
||||
};
|
||||
|
||||
void Test_Bitfield_TrailingPaddingBits() {
|
||||
void Test_Bitfield_TrailingPaddingBits(void) {
|
||||
struct Bitfield_TrailingPaddingBits a, b;
|
||||
memcmp(&a, &b, sizeof(struct Bitfield_TrailingPaddingBits));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_TrailingPaddingBits' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -180,7 +180,7 @@ struct Bitfield_InnerPaddingBits {
|
||||
char y : 8;
|
||||
};
|
||||
|
||||
void Test_Bitfield_InnerPaddingBits() {
|
||||
void Test_Bitfield_InnerPaddingBits(void) {
|
||||
struct Bitfield_InnerPaddingBits a, b;
|
||||
memcmp(&a, &b, sizeof(struct Bitfield_InnerPaddingBits));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct Bitfield_InnerPaddingBits' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -195,7 +195,7 @@ struct Bitfield_NoPadding {
|
||||
_Static_assert(sizeof(struct Bitfield_NoPadding) == sizeof(int),
|
||||
"Bit-fields should line up perfectly");
|
||||
|
||||
void Test_Bitfield_NoPadding() {
|
||||
void Test_Bitfield_NoPadding(void) {
|
||||
struct Bitfield_NoPadding a, b;
|
||||
memcmp(&a, &b, sizeof(struct Bitfield_NoPadding)); // no-warning
|
||||
}
|
||||
@ -205,7 +205,7 @@ struct Bitfield_TrailingUnnamed {
|
||||
int : 0;
|
||||
};
|
||||
|
||||
void Bitfield_TrailingUnnamed() {
|
||||
void Bitfield_TrailingUnnamed(void) {
|
||||
struct Bitfield_TrailingUnnamed a, b;
|
||||
memcmp(&a, &b, 2 * sizeof(int)); // no-warning
|
||||
memcmp(&a, &b, sizeof(struct Bitfield_TrailingUnnamed)); // no-warning
|
||||
@ -220,7 +220,7 @@ struct PaddingAfterUnion {
|
||||
int y;
|
||||
};
|
||||
|
||||
void Test_PaddingAfterUnion() {
|
||||
void Test_PaddingAfterUnion(void) {
|
||||
struct PaddingAfterUnion a, b;
|
||||
memcmp(&a, &b, sizeof(struct PaddingAfterUnion));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingAfterUnion' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -235,7 +235,7 @@ struct Union_NoPadding {
|
||||
int y;
|
||||
};
|
||||
|
||||
void Test_Union_NoPadding() {
|
||||
void Test_Union_NoPadding(void) {
|
||||
struct Union_NoPadding a, b;
|
||||
memcmp(&a, &b, 2 * sizeof(int));
|
||||
memcmp(&a, &b, sizeof(struct Union_NoPadding));
|
||||
@ -250,7 +250,7 @@ union UnionWithPaddingInNestedStruct {
|
||||
} x;
|
||||
};
|
||||
|
||||
void Test_UnionWithPaddingInNestedStruct() {
|
||||
void Test_UnionWithPaddingInNestedStruct(void) {
|
||||
union UnionWithPaddingInNestedStruct a, b;
|
||||
memcmp(&a, &b, sizeof(union UnionWithPaddingInNestedStruct));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'union UnionWithPaddingInNestedStruct' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -261,7 +261,7 @@ struct PaddingInNested {
|
||||
char y;
|
||||
};
|
||||
|
||||
void Test_PaddingInNested() {
|
||||
void Test_PaddingInNested(void) {
|
||||
struct PaddingInNested a, b;
|
||||
memcmp(&a, &b, sizeof(struct PaddingInNested));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingInNested' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -275,7 +275,7 @@ struct PaddingAfterNested {
|
||||
int y;
|
||||
};
|
||||
|
||||
void Test_PaddingAfterNested() {
|
||||
void Test_PaddingAfterNested(void) {
|
||||
struct PaddingAfterNested a, b;
|
||||
memcmp(&a, &b, sizeof(struct PaddingAfterNested));
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'struct PaddingAfterNested' which does not have a unique object representation; consider comparing the members of the object manually
|
||||
@ -285,7 +285,7 @@ struct AtomicMember {
|
||||
_Atomic(int) x;
|
||||
};
|
||||
|
||||
void Test_AtomicMember() {
|
||||
void Test_AtomicMember(void) {
|
||||
// FIXME: this is a false positive as the list of objects with unique object
|
||||
// representations is incomplete.
|
||||
struct AtomicMember a, b;
|
||||
|
@ -4,7 +4,7 @@ void *memset(void *, int, __SIZE_TYPE__);
|
||||
void *memset(void *);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:7: error: conflicting types for 'memset'
|
||||
|
||||
void test() {
|
||||
void test(void) {
|
||||
// no crash
|
||||
memset(undefine);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:10: error: use of undeclared identifier
|
||||
|
@ -8,7 +8,7 @@ static const char A[] = "abc";
|
||||
|
||||
int strcmp(const char *, const char *);
|
||||
|
||||
int test_warning_patterns() {
|
||||
int test_warning_patterns(void) {
|
||||
if (strcmp(A, "a"))
|
||||
return 0;
|
||||
// CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result [bugprone-suspicious-string-compare]
|
||||
@ -42,7 +42,7 @@ int test_warning_patterns() {
|
||||
// CHECK-FIXES: if (strcmp(A, "a") == 0)
|
||||
}
|
||||
|
||||
void test_structure_patterns() {
|
||||
void test_structure_patterns(void) {
|
||||
if (strcmp(A, "a")) {}
|
||||
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: function 'strcmp' is called without explicitly comparing result
|
||||
// CHECK-FIXES: if (strcmp(A, "a") != 0) {}
|
||||
@ -56,7 +56,7 @@ void test_structure_patterns() {
|
||||
// CHECK-FIXES: for (;strcmp(A, "a") != 0;) {}
|
||||
}
|
||||
|
||||
int test_valid_patterns() {
|
||||
int test_valid_patterns(void) {
|
||||
// The following cases are valid.
|
||||
if (strcmp(A, "a") < 0) return 0;
|
||||
if (strcmp(A, "a") == 0) return 0;
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
void *aligned_alloc(size_t alignment, size_t size);
|
||||
void test_aligned_alloc() {
|
||||
void test_aligned_alloc(void) {
|
||||
aligned_alloc(2, 10);
|
||||
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
|
||||
// CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
|
||||
}
|
||||
|
||||
long strtol(const char *restrict nptr, char **restrict endptr, int base);
|
||||
void test_strtol() {
|
||||
void test_strtol(void) {
|
||||
strtol("123", 0, 10);
|
||||
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
|
||||
// CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
|
||||
@ -17,7 +17,7 @@ void test_strtol() {
|
||||
|
||||
typedef char wchar_t;
|
||||
int wscanf_s(const wchar_t *restrict format, ...);
|
||||
void test_wscanf_s() {
|
||||
void test_wscanf_s(void) {
|
||||
int Val;
|
||||
wscanf_s("%i", &Val);
|
||||
// CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
|
||||
|
@ -1,9 +1,9 @@
|
||||
// RUN: %check_clang_tidy %s cert-msc30-c %t
|
||||
|
||||
extern int rand(void);
|
||||
int nonrand();
|
||||
int nonrand(void);
|
||||
|
||||
int cTest() {
|
||||
int cTest(void) {
|
||||
int i = rand();
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: rand() has limited randomness [cert-msc30-c]
|
||||
|
||||
|
@ -4,7 +4,7 @@ void srand(int seed);
|
||||
typedef int time_t;
|
||||
time_t time(time_t *t);
|
||||
|
||||
void f() {
|
||||
void f(void) {
|
||||
srand(1);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a constant value will generate a predictable sequence of values [cert-msc32-c]
|
||||
|
||||
@ -17,7 +17,7 @@ void f() {
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: random number generator seeded with a disallowed source of seed value will generate a predictable sequence of values [cert-msc32-c]
|
||||
}
|
||||
|
||||
void g() {
|
||||
void g(void) {
|
||||
typedef int user_t;
|
||||
user_t a = 1;
|
||||
srand(a);
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: clang-tidy -checks=-*,google-runtime-int %s -- -x c 2>&1 | not grep 'warning:\|error:'
|
||||
|
||||
long a();
|
||||
long a(void);
|
||||
|
||||
long b(long x);
|
||||
|
||||
@ -22,6 +22,6 @@ short bar(const short q, unsigned short w) {
|
||||
return q;
|
||||
}
|
||||
|
||||
void qux() {
|
||||
void qux(void) {
|
||||
short port;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ int __must_check IS_ERR_OR_NULL(const void *ptr);
|
||||
void * __must_check ERR_CAST(const void *ptr);
|
||||
int __must_check PTR_ERR_OR_ZERO(const void *ptr);
|
||||
|
||||
void f() {
|
||||
void f(void) {
|
||||
ERR_PTR(0);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'ERR_PTR' is unused
|
||||
PTR_ERR((void *)0);
|
||||
@ -24,18 +24,18 @@ out:
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'PTR_ERR_OR_ZERO' is unused
|
||||
}
|
||||
|
||||
void *f1() {
|
||||
void *f1(void) {
|
||||
return ERR_PTR(0);
|
||||
}
|
||||
|
||||
long f2() {
|
||||
long f2(void) {
|
||||
if (IS_ERR((void *)0)) {
|
||||
return PTR_ERR((void *)0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void f3() {
|
||||
void f3(void) {
|
||||
f1();
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'f1' is unused but represents an error value
|
||||
f2();
|
||||
|
@ -1,7 +1,7 @@
|
||||
// RUN: %check_clang_tidy %s misc-static-assert %t -- -- -std=c11
|
||||
// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
|
||||
|
||||
void abort() {}
|
||||
void abort(void) {}
|
||||
#ifdef NDEBUG
|
||||
#define assert(x) 1
|
||||
#else
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -xc
|
||||
// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -Wno-strict-prototypes -xc
|
||||
|
||||
// Basic removal
|
||||
// =============
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: clang-tidy -checks=-*,modernize-redundant-void-arg %s -- -x c | count 0
|
||||
// RUN: clang-tidy -checks=-*,modernize-redundant-void-arg %s -- -Wno-strict-prototypes -x c | count 0
|
||||
|
||||
#define NULL 0
|
||||
|
||||
@ -38,7 +38,7 @@ void (*(*returns_fn_returns_fn_void_void(void))(void))(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void bar() {
|
||||
void bar(void) {
|
||||
int i;
|
||||
int *pi = NULL;
|
||||
void *pv = (void *) pi;
|
||||
|
@ -1,10 +1,10 @@
|
||||
// RUN: %check_clang_tidy %s objc-assert-equals %t -- -- -I %S/Inputs/objc-assert
|
||||
#include "XCTestAssertions.h"
|
||||
// Can't reference NSString directly so we use this getStr() instead.
|
||||
__typeof(@"abc") getStr() {
|
||||
__typeof(@"abc") getStr(void) {
|
||||
return @"abc";
|
||||
}
|
||||
void foo() {
|
||||
void foo(void) {
|
||||
XCTAssertEqual(getStr(), @"abc");
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use XCTAssertEqualObjects for comparing objects
|
||||
// CHECK-FIXES: XCTAssertEqualObjects(getStr(), @"abc");
|
||||
|
@ -29,9 +29,9 @@ void foo(NSInvocation *Invocation) {
|
||||
// CHECK-FIXES: __unsafe_unretained id Arg5;
|
||||
id ReturnValue;
|
||||
// CHECK-FIXES: __unsafe_unretained id ReturnValue;
|
||||
void (^BlockArg1)();
|
||||
// CHECK-FIXES: __unsafe_unretained void (^BlockArg1)();
|
||||
__unsafe_unretained void (^BlockArg2)();
|
||||
void (^BlockArg1)(void);
|
||||
// CHECK-FIXES: __unsafe_unretained void (^BlockArg1)(void);
|
||||
__unsafe_unretained void (^BlockArg2)(void);
|
||||
int IntVar;
|
||||
struct Foo Bar;
|
||||
|
||||
|
@ -20,7 +20,7 @@ void n0(const int a) {
|
||||
|
||||
// 'parallel' directive can have 'default' clause, but said clause is not
|
||||
// specified, diagnosed.
|
||||
void p0_0() {
|
||||
void p0_0(void) {
|
||||
#pragma omp parallel
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does not specify 'default' clause, consider specifying 'default(none)' clause
|
||||
@ -28,14 +28,14 @@ void p0_0() {
|
||||
|
||||
// 'parallel' directive can have 'default' clause, and said clause specified,
|
||||
// with 'none' kind, all good.
|
||||
void p0_1() {
|
||||
void p0_1(void) {
|
||||
#pragma omp parallel default(none)
|
||||
;
|
||||
}
|
||||
|
||||
// 'parallel' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'shared' kind, which is not 'none', diagnose.
|
||||
void p0_2() {
|
||||
void p0_2(void) {
|
||||
#pragma omp parallel default(shared)
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
|
||||
@ -44,7 +44,7 @@ void p0_2() {
|
||||
|
||||
// 'parallel' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'firstprivate' kind, which is not 'none', diagnose.
|
||||
void p0_3() {
|
||||
void p0_3(void) {
|
||||
#pragma omp parallel default(firstprivate)
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
|
||||
@ -55,7 +55,7 @@ void p0_3() {
|
||||
|
||||
// 'task' directive can have 'default' clause, but said clause is not
|
||||
// specified, diagnosed.
|
||||
void p1_0() {
|
||||
void p1_0(void) {
|
||||
#pragma omp task
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not specify 'default' clause, consider specifying 'default(none)' clause
|
||||
@ -63,14 +63,14 @@ void p1_0() {
|
||||
|
||||
// 'task' directive can have 'default' clause, and said clause specified,
|
||||
// with 'none' kind, all good.
|
||||
void p1_1() {
|
||||
void p1_1(void) {
|
||||
#pragma omp task default(none)
|
||||
;
|
||||
}
|
||||
|
||||
// 'task' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'shared' kind, which is not 'none', diagnose.
|
||||
void p1_2() {
|
||||
void p1_2(void) {
|
||||
#pragma omp task default(shared)
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
|
||||
@ -79,7 +79,7 @@ void p1_2() {
|
||||
|
||||
// 'task' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'firstprivate' kind, which is not 'none', diagnose.
|
||||
void p1_3() {
|
||||
void p1_3(void) {
|
||||
#pragma omp task default(firstprivate)
|
||||
;
|
||||
// CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(firstprivate)' clause, consider using 'default(none)' clause instead
|
||||
@ -90,7 +90,7 @@ void p1_3() {
|
||||
|
||||
// 'teams' directive can have 'default' clause, but said clause is not
|
||||
// specified, diagnosed.
|
||||
void p2_0() {
|
||||
void p2_0(void) {
|
||||
#pragma omp target
|
||||
#pragma omp teams
|
||||
;
|
||||
@ -99,7 +99,7 @@ void p2_0() {
|
||||
|
||||
// 'teams' directive can have 'default' clause, and said clause specified,
|
||||
// with 'none' kind, all good.
|
||||
void p2_1() {
|
||||
void p2_1(void) {
|
||||
#pragma omp target
|
||||
#pragma omp teams default(none)
|
||||
;
|
||||
@ -107,7 +107,7 @@ void p2_1() {
|
||||
|
||||
// 'teams' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'shared' kind, which is not 'none', diagnose.
|
||||
void p2_2() {
|
||||
void p2_2(void) {
|
||||
#pragma omp target
|
||||
#pragma omp teams default(shared)
|
||||
;
|
||||
@ -117,7 +117,7 @@ void p2_2() {
|
||||
|
||||
// 'teams' directive can have 'default' clause, and said clause specified,
|
||||
// but with 'firstprivate' kind, which is not 'none', diagnose.
|
||||
void p2_3() {
|
||||
void p2_3(void) {
|
||||
#pragma omp target
|
||||
#pragma omp teams default(firstprivate)
|
||||
;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// RUN: %check_clang_tidy %s readability-isolate-declaration %t
|
||||
|
||||
void c_specific() {
|
||||
void c_specific(void) {
|
||||
void (*signal(int sig, void (*func)(int)))(int);
|
||||
int i = sizeof(struct S { int i; });
|
||||
int j = sizeof(struct T { int i; }), k;
|
||||
|
@ -16,16 +16,16 @@ extern int Buf[10]; // Buf[10]
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'Buf' declaration
|
||||
// CHECK-FIXES: {{^}}// Buf[10]{{$}}
|
||||
|
||||
static int f();
|
||||
static int f(); // f
|
||||
static int f(void);
|
||||
static int f(void); // f
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant 'f' declaration
|
||||
// CHECK-FIXES: {{^}}// f{{$}}
|
||||
static int f() {}
|
||||
static int f(void) {}
|
||||
|
||||
inline void g() {}
|
||||
inline void g(void) {}
|
||||
|
||||
inline void g();
|
||||
inline void g(void);
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant 'g' declaration
|
||||
|
||||
// OK: Needed to emit an external definition.
|
||||
extern inline void g();
|
||||
extern inline void g(void);
|
||||
|
Loading…
Reference in New Issue
Block a user