From 746a45c095d8966f89305850e71d8480bb13ff5b Mon Sep 17 00:00:00 2001 From: George Karpenkov Date: Wed, 16 May 2018 22:46:47 +0000 Subject: [PATCH] [analyzer] Change the warning message for GCD antipattern checker git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332544 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/GCDAntipatternChecker.cpp | 4 +- test/Analysis/gcdantipatternchecker_test.m | 42 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp b/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp index 4ee5159b43..1b7ea53aea 100644 --- a/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -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( diff --git a/test/Analysis/gcdantipatternchecker_test.m b/test/Analysis/gcdantipatternchecker_test.m index d79a6baec3..adc7a52bf5 100644 --- a/test/Analysis/gcdantipatternchecker_test.m +++ b/test/Analysis/gcdantipatternchecker_test.m @@ -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}} } -- 2.40.0