forked from OSchip/llvm-project
[analyzer] Change the warning message for GCD antipattern checker
llvm-svn: 332544
This commit is contained in:
parent
acd1f4e738
commit
47bb3f7033
|
@ -187,8 +187,8 @@ static void emitDiagnostics(const BoundNodes &Nodes,
|
|||
|
||||
std::string Diagnostics;
|
||||
llvm::raw_string_ostream OS(Diagnostics);
|
||||
OS << "Waiting on a " << Type << " with Grand Central Dispatch creates "
|
||||
<< "useless threads and is subject to priority inversion; consider "
|
||||
OS << "Waiting on a callback using a " << Type << " creates useless threads "
|
||||
<< "and is subject to priority inversion; consider "
|
||||
<< "using a synchronous API or changing the caller to be asynchronous";
|
||||
|
||||
BR.EmitBasicReport(
|
||||
|
|
|
@ -34,7 +34,7 @@ void use_semaphor_antipattern() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
// It's OK to use pattern in tests.
|
||||
|
@ -54,14 +54,14 @@ void use_semaphor_antipattern_multiple_times() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema1);
|
||||
});
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
|
||||
dispatch_semaphore_t sema2 = dispatch_semaphore_create(0);
|
||||
|
||||
func(^{
|
||||
dispatch_semaphore_signal(sema2);
|
||||
});
|
||||
dispatch_semaphore_wait(sema2, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema2, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void use_semaphor_antipattern_multiple_wait() {
|
||||
|
@ -71,8 +71,8 @@ void use_semaphor_antipattern_multiple_wait() {
|
|||
dispatch_semaphore_signal(sema1);
|
||||
});
|
||||
// FIXME: multiple waits on same semaphor should not raise a warning.
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void warn_incorrect_order() {
|
||||
|
@ -80,7 +80,7 @@ void warn_incorrect_order() {
|
|||
// if out of order.
|
||||
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
||||
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback}}
|
||||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
|
@ -92,7 +92,7 @@ void warn_w_typedef() {
|
|||
func_w_typedef(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void warn_nested_ast() {
|
||||
|
@ -107,7 +107,7 @@ void warn_nested_ast() {
|
|||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void use_semaphore_assignment() {
|
||||
|
@ -117,7 +117,7 @@ void use_semaphore_assignment() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void use_semaphore_assignment_init() {
|
||||
|
@ -127,7 +127,7 @@ void use_semaphore_assignment_init() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
void differentsemaphoreok() {
|
||||
|
@ -179,7 +179,7 @@ void warn_with_cast() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal((int)sema);
|
||||
});
|
||||
dispatch_semaphore_wait((int)sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait((int)sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
||||
@interface MyInterface1 : NSObject
|
||||
|
@ -200,7 +200,7 @@ void warn_with_cast() {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback}}
|
||||
}
|
||||
|
||||
-(void) pass_block_as_second_param_warn {
|
||||
|
@ -209,7 +209,7 @@ void warn_with_cast() {
|
|||
[self flag:1 acceptBlock:^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
}];
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback}}
|
||||
}
|
||||
|
||||
-(void)testNoWarn {
|
||||
|
@ -235,7 +235,7 @@ void warn_with_cast() {
|
|||
[self acceptBlock:^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
}];
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback}}
|
||||
}
|
||||
|
||||
-(void)use_dispatch_group {
|
||||
|
@ -244,7 +244,7 @@ void warn_with_cast() {
|
|||
[self acceptBlock:^{
|
||||
dispatch_group_leave(group);
|
||||
}];
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a group with Grand Central Dispatch}}
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a callback using a group}}
|
||||
|
||||
}
|
||||
|
||||
|
@ -254,14 +254,14 @@ void use_objc_and_c_callback(MyInterface1 *t) {
|
|||
func(^{
|
||||
dispatch_semaphore_signal(sema);
|
||||
});
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
|
||||
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
|
||||
|
||||
[t acceptBlock:^{
|
||||
dispatch_semaphore_signal(sema1);
|
||||
}];
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback}}
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -305,7 +305,7 @@ void dispatch_group_wait_func(MyInterface1 *M) {
|
|||
func(^{
|
||||
dispatch_group_leave(group);
|
||||
});
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a group with Grand Central Dispatch}}
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a callback using a group}}
|
||||
}
|
||||
|
||||
|
||||
|
@ -315,7 +315,7 @@ void dispatch_group_wait_cfunc(MyInterface1 *M) {
|
|||
[M acceptBlock:^{
|
||||
dispatch_group_leave(group);
|
||||
}];
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a group with Grand Central Dispatch}}
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a callback using a group}}
|
||||
}
|
||||
|
||||
void dispatch_group_and_semaphore_use(MyInterface1 *M) {
|
||||
|
@ -324,12 +324,12 @@ void dispatch_group_and_semaphore_use(MyInterface1 *M) {
|
|||
[M acceptBlock:^{
|
||||
dispatch_group_leave(group);
|
||||
}];
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a group with Grand Central Dispatch}}
|
||||
dispatch_group_wait(group, 100); // expected-warning{{Waiting on a callback using a group}}
|
||||
|
||||
dispatch_semaphore_t sema1 = dispatch_semaphore_create(0);
|
||||
|
||||
[M acceptBlock:^{
|
||||
dispatch_semaphore_signal(sema1);
|
||||
}];
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a semaphore with Grand Central Dispatch creates useless threads and is subject to priority inversion}}
|
||||
dispatch_semaphore_wait(sema1, 100); // expected-warning{{Waiting on a callback using a semaphore}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue