Author: alexfh Date: Tue Mar 6 02:40:11 2018 New Revision: 326772 URL: http://llvm.org/viewvc/llvm-project?rev=326772&view=rev Log: Move test/gcdasyncsemaphorechecker_test.m to a subdirectory
Added: cfe/trunk/test/Analysis/gcdasyncsemaphorechecker_test.m - copied, changed from r326767, cfe/trunk/test/gcdasyncsemaphorechecker_test.m Removed: cfe/trunk/test/gcdasyncsemaphorechecker_test.m Copied: cfe/trunk/test/Analysis/gcdasyncsemaphorechecker_test.m (from r326767, cfe/trunk/test/gcdasyncsemaphorechecker_test.m) URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/gcdasyncsemaphorechecker_test.m?p2=cfe/trunk/test/Analysis/gcdasyncsemaphorechecker_test.m&p1=cfe/trunk/test/gcdasyncsemaphorechecker_test.m&r1=326767&r2=326772&rev=326772&view=diff ============================================================================== (empty) Removed: cfe/trunk/test/gcdasyncsemaphorechecker_test.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/gcdasyncsemaphorechecker_test.m?rev=326771&view=auto ============================================================================== --- cfe/trunk/test/gcdasyncsemaphorechecker_test.m (original) +++ cfe/trunk/test/gcdasyncsemaphorechecker_test.m (removed) @@ -1,203 +0,0 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.osx.GCDAsyncSemaphore %s -fblocks -verify -typedef signed char BOOL; -@protocol NSObject - (BOOL)isEqual:(id)object; @end -@interface NSObject <NSObject> {} -+(id)alloc; --(id)init; --(id)autorelease; --(id)copy; --(id)retain; -@end - -typedef int dispatch_semaphore_t; -typedef void (^block_t)(); - -dispatch_semaphore_t dispatch_semaphore_create(int); -void dispatch_semaphore_wait(dispatch_semaphore_t, int); -void dispatch_semaphore_signal(dispatch_semaphore_t); - -void func(void (^)(void)); -void func_w_typedef(block_t); - -int coin(); - -void use_semaphor_antipattern() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -// It's OK to use pattern in tests. -// We simply match the containing function name against ^test. -void test_no_warning() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); -} - -void use_semaphor_antipattern_multiple_times() { - dispatch_semaphore_t sema1 = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema1); - }); - dispatch_semaphore_wait(sema1, 100); // expected-warning{{Possible semaphore performance anti-pattern}} - - dispatch_semaphore_t sema2 = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema2); - }); - dispatch_semaphore_wait(sema2, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void use_semaphor_antipattern_multiple_wait() { - dispatch_semaphore_t sema1 = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema1); - }); - // FIXME: multiple waits on same semaphor should not raise a warning. - dispatch_semaphore_wait(sema1, 100); // expected-warning{{Possible semaphore performance anti-pattern}} - dispatch_semaphore_wait(sema1, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void warn_incorrect_order() { - // FIXME: ASTMatchers do not allow ordered matching, so would match even - // if out of order. - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} - func(^{ - dispatch_semaphore_signal(sema); - }); -} - -void warn_w_typedef() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func_w_typedef(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void warn_nested_ast() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - if (coin()) { - func(^{ - dispatch_semaphore_signal(sema); - }); - } else { - func(^{ - dispatch_semaphore_signal(sema); - }); - } - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void use_semaphore_assignment() { - dispatch_semaphore_t sema; - sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void use_semaphore_assignment_init() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - sema = dispatch_semaphore_create(1); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -void differentsemaphoreok() { - dispatch_semaphore_t sema1 = dispatch_semaphore_create(0); - dispatch_semaphore_t sema2 = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema1); - }); - dispatch_semaphore_wait(sema2, 100); // no-warning -} - -void nosignalok() { - dispatch_semaphore_t sema1 = dispatch_semaphore_create(0); - dispatch_semaphore_wait(sema1, 100); -} - -void nowaitok() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - func(^{ - dispatch_semaphore_signal(sema); - }); -} - -void noblockok() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - dispatch_semaphore_signal(sema); - dispatch_semaphore_wait(sema, 100); -} - -void storedblockok() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - block_t b = ^{ - dispatch_semaphore_signal(sema); - }; - dispatch_semaphore_wait(sema, 100); -} - -void passed_semaphore_ok(dispatch_semaphore_t sema) { - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); -} - -void warn_with_cast() { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal((int)sema); - }); - dispatch_semaphore_wait((int)sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - -@interface Test1 : NSObject --(void)use_method_warn; --(void)testNoWarn; -@end - -@implementation Test1 - --(void)use_method_warn { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); // expected-warning{{Possible semaphore performance anti-pattern}} -} - --(void)testNoWarn { - dispatch_semaphore_t sema = dispatch_semaphore_create(0); - - func(^{ - dispatch_semaphore_signal(sema); - }); - dispatch_semaphore_wait(sema, 100); -} - -@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits