diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-07-16 20:32:57 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-07-16 20:32:57 +0000 |
commit | 09885d05cebe699a61a09fd8f796b40d8de798b4 (patch) | |
tree | 6d736644e6dfec499ccac46ded82e00811c9485c /clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp | |
parent | cfed504a4b2c69e75753c09f6271acf0bf238ec2 (diff) | |
download | bcm5719-llvm-09885d05cebe699a61a09fd8f796b40d8de798b4.tar.gz bcm5719-llvm-09885d05cebe699a61a09fd8f796b40d8de798b4.zip |
[analyzer] Fix GCDAntipatternChecker to only fire when the semaphore is initialized to zero
Initializing a semaphore with a different constant most likely signals a different intent
rdar://41802552
Differential Revision: https://reviews.llvm.org/D48911
llvm-svn: 337212
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp index 1b7ea53aeac..5cb51b01f04 100644 --- a/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp @@ -93,7 +93,9 @@ static bool isTest(const Decl *D) { static auto findGCDAntiPatternWithSemaphore() -> decltype(compoundStmt()) { const char *SemaphoreBinding = "semaphore_name"; - auto SemaphoreCreateM = callExpr(callsName("dispatch_semaphore_create")); + auto SemaphoreCreateM = callExpr(allOf( + callsName("dispatch_semaphore_create"), + hasArgument(0, ignoringParenCasts(integerLiteral(equals(0)))))); auto SemaphoreBindingM = anyOf( forEachDescendant( |