diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h index 0cf66c218f43f..44d962d5da9a9 100644 --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h +++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h @@ -240,12 +240,15 @@ checkDataflow(AnalysisInputs AI, }; } - for (const ast_matchers::BoundNodes &BN : - ast_matchers::match(ast_matchers::functionDecl( - ast_matchers::hasBody(ast_matchers::stmt()), - AI.TargetFuncMatcher) - .bind("target"), - Context)) { + SmallVector MatchResult = ast_matchers::match( + ast_matchers::functionDecl(ast_matchers::hasBody(ast_matchers::stmt()), + AI.TargetFuncMatcher) + .bind("target"), + Context); + if (MatchResult.empty()) + return llvm::createStringError(llvm::inconvertibleErrorCode(), + "didn't find any matching target functions"); + for (const ast_matchers::BoundNodes &BN : MatchResult) { // Get the AST node of the target function. const FunctionDecl *Target = BN.getNodeAs("target"); if (Target == nullptr)