Author: martinboehme Date: 2023-09-14T11:32:17+02:00 New Revision: 967604a07b1d5da15fb561d4ceae04cbaef02df7
URL: https://github.com/llvm/llvm-project/commit/967604a07b1d5da15fb561d4ceae04cbaef02df7 DIFF: https://github.com/llvm/llvm-project/commit/967604a07b1d5da15fb561d4ceae04cbaef02df7.diff LOG: [clang][dataflow] In tests, error out if we didn't find any matching target functions. (#66197) Before, we were silently letting the test pass, which masks test bugs; for an example, see https://github.com/llvm/llvm-project/pull/66195. Added: Modified: clang/unittests/Analysis/FlowSensitive/TestingSupport.h Removed: ################################################################################ diff --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h index 0cf66c218f43fdc..44d962d5da9a97b 100644 --- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h +++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h @@ -240,12 +240,15 @@ checkDataflow(AnalysisInputs<AnalysisT> 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<ast_matchers::BoundNodes, 1> 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<FunctionDecl>("target"); if (Target == nullptr) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits