summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
index 23ef032bb05..eda7a5fcd17 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GCDAsyncSemaphoreChecker.cpp
@@ -111,23 +111,26 @@ void GCDAsyncSemaphoreChecker::checkASTCodeBody(const Decl *D,
)
).bind(WarningBinding));
- auto AcceptsBlockM =
- forEachDescendant(callExpr(hasAnyArgument(hasType(
+ auto HasBlockArgumentM = hasAnyArgument(hasType(
hasCanonicalType(blockPointerType())
- ))));
+ ));
- auto BlockSignallingM =
- forEachDescendant(callExpr(hasAnyArgument(hasDescendant(callExpr(
+ auto ArgCallsSignalM = hasArgument(0, hasDescendant(callExpr(
allOf(
callsName("dispatch_semaphore_signal"),
equalsBoundArgDecl(0, SemaphoreBinding)
- ))))));
+ ))));
+
+ auto HasBlockAndCallsSignalM = allOf(HasBlockArgumentM, ArgCallsSignalM);
+
+ auto AcceptsBlockM =
+ forEachDescendant(
+ stmt(anyOf(
+ callExpr(HasBlockAndCallsSignalM),
+ objcMessageExpr(HasBlockAndCallsSignalM)
+ )));
- auto FinalM = compoundStmt(
- SemaphoreBindingM,
- SemaphoreWaitM,
- AcceptsBlockM,
- BlockSignallingM);
+ auto FinalM = compoundStmt(SemaphoreBindingM, SemaphoreWaitM, AcceptsBlockM);
MatchFinder F;
Callback CB(BR, AM.getAnalysisDeclContext(D), this);
OpenPOWER on IntegriCloud