@@ -353,7 +353,7 @@ namespace clang
353353
354354 // Assume Exp is not mutated before analyzing Exp.
355355 MemoizedResults[Exp] = nullptr ;
356- if (isUnevaluated (Exp)) {
356+ if (ExprAutoMutationAnalyzer:: isUnevaluated (Exp, Context )) {
357357 return nullptr ;
358358 }
359359
@@ -390,45 +390,29 @@ namespace clang
390390 return nullptr ;
391391 }
392392
393- bool ExprAutoMutationAnalyzer::Analyzer::isUnevaluated (
394- Stmt const *Exp, Stmt const &Stm, ASTContext &Context)
395- {
396- return selectFirst<Stmt>(
397- NodeID<Expr>::value,
398- match (
399- findFirst (
400- stmt (
401- canResolveToExpr (Exp),
402- anyOf (
403- // `Exp` is part of the underlying expression
404- // of decltype/typeof if it has an ancestor
405- // of typeLoc.
406- hasAncestor (typeLoc (unless (hasAncestor (
407- unaryExprOrTypeTraitExpr ())))),
408- hasAncestor (expr (anyOf (
409- // `UnaryExprOrTypeTraitExpr` is
410- // unevaluated unless it's sizeof on VLA.
411- unaryExprOrTypeTraitExpr (
412- unless (sizeOfExpr (hasArgumentOfType (
413- variableArrayType ())))),
414- // `CXXTypeidExpr` is unevaluated unless
415- // it's applied to an expression of
416- // glvalue of polymorphic class type.
417- cxxTypeidExpr (
418- unless (isPotentiallyEvaluated ())),
419- // The controlling expression of
420- // `GenericSelectionExpr` is unevaluated.
421- genericSelectionExpr (hasControllingExpr (
422- hasDescendant (equalsNode (Exp)))),
423- cxxNoexceptExpr ())))))
424- .bind (NodeID<Expr>::value)),
425- Stm,
426- Context)) != nullptr ;
427- }
428-
429- bool ExprAutoMutationAnalyzer::Analyzer::isUnevaluated (Expr const *Exp)
430- {
431- return isUnevaluated (Exp, Stm, Context);
393+ bool ExprAutoMutationAnalyzer::isUnevaluated (const Stmt *Stm, ASTContext &Context) {
394+ return !match (stmt (anyOf (
395+ // `Exp` is part of the underlying expression of
396+ // decltype/typeof if it has an ancestor of
397+ // typeLoc.
398+ hasAncestor (typeLoc (
399+ unless (hasAncestor (unaryExprOrTypeTraitExpr ())))),
400+ hasAncestor (expr (anyOf (
401+ // `UnaryExprOrTypeTraitExpr` is unevaluated
402+ // unless it's sizeof on VLA.
403+ unaryExprOrTypeTraitExpr (unless (sizeOfExpr (
404+ hasArgumentOfType (variableArrayType ())))),
405+ // `CXXTypeidExpr` is unevaluated unless it's
406+ // applied to an expression of glvalue of
407+ // polymorphic class type.
408+ cxxTypeidExpr (unless (isPotentiallyEvaluated ())),
409+ // The controlling expression of
410+ // `GenericSelectionExpr` is unevaluated.
411+ genericSelectionExpr (
412+ hasControllingExpr (hasDescendant (equalsNode (Stm)))),
413+ cxxNoexceptExpr ()))))),
414+ *Stm, Context)
415+ .empty ();
432416 }
433417
434418 Stmt const *ExprAutoMutationAnalyzer::Analyzer::findExprMutation (
0 commit comments