Author: george.karpenkov Date: Wed May 16 15:46:47 2018 New Revision: 332544
URL: http://llvm.org/viewvc/llvm-project?rev=332544&view=rev Log: [analyzer] Change the warning message for GCD antipattern checker Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp cfe/trunk/test/Analysis/gcdantipatternchecker_test.m Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp?rev=332544&r1=332543&r2=332544&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp Wed May 16 15:46:47 2018 @@ -187,8 +187,8 @@ static void emitDiagnostics(const BoundN 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( Modified: cfe/trunk/test/Analysis/gcdantipatternchecker_test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/gcdantipatternchecker_test.m?rev=332544&r1=332543&r2=332544&view=diff ============================================================================== --- cfe/trunk/test/Analysis/gcdantipatternchecker_test.m (original) +++ cfe/trunk/test/Analysis/gcdantipatternchecker_test.m Wed May 16 15:46:47 2018 @@ -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_t 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_w 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(MyInterface 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(MyInterfac 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(MyInterfa [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(My [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}} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits