Skip to content

Commit eb7dea8

Browse files
authored
[mutation analyzer] enhance stability for hasAnyInit matcher (llvm#122915)
I cannot minimal produce it, but when I run clangd with `misc-const-correctness` check in a big project clangd crashed due to deref nullptr here. clang may pass a nullptr to `InitExprs` when meets some error cases.
1 parent dc1ef2c commit eb7dea8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clang/lib/Analysis/ExprMutationAnalyzer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ AST_MATCHER_P(Stmt, canResolveToExpr, const Stmt *, Inner) {
104104
AST_MATCHER_P(InitListExpr, hasAnyInit, ast_matchers::internal::Matcher<Expr>,
105105
InnerMatcher) {
106106
for (const Expr *Arg : Node.inits()) {
107+
if (Arg == nullptr)
108+
continue;
107109
ast_matchers::internal::BoundNodesTreeBuilder Result(*Builder);
108110
if (InnerMatcher.matches(*Arg, Finder, &Result)) {
109111
*Builder = std::move(Result);

0 commit comments

Comments
 (0)