Skip to content

Commit 58083df

Browse files
martinboehmeZijunZhaoCCK
authored andcommitted
[clang][dataflow] In tests, error out if we didn't find any matching target functions. (llvm#66197)
Before, we were silently letting the test pass, which masks test bugs; for an example, see llvm#66195.
1 parent 1db89d2 commit 58083df

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,15 @@ checkDataflow(AnalysisInputs<AnalysisT> AI,
240240
};
241241
}
242242

243-
for (const ast_matchers::BoundNodes &BN :
244-
ast_matchers::match(ast_matchers::functionDecl(
245-
ast_matchers::hasBody(ast_matchers::stmt()),
246-
AI.TargetFuncMatcher)
247-
.bind("target"),
248-
Context)) {
243+
SmallVector<ast_matchers::BoundNodes, 1> MatchResult = ast_matchers::match(
244+
ast_matchers::functionDecl(ast_matchers::hasBody(ast_matchers::stmt()),
245+
AI.TargetFuncMatcher)
246+
.bind("target"),
247+
Context);
248+
if (MatchResult.empty())
249+
return llvm::createStringError(llvm::inconvertibleErrorCode(),
250+
"didn't find any matching target functions");
251+
for (const ast_matchers::BoundNodes &BN : MatchResult) {
249252
// Get the AST node of the target function.
250253
const FunctionDecl *Target = BN.getNodeAs<FunctionDecl>("target");
251254
if (Target == nullptr)

0 commit comments

Comments
 (0)