@@ -236,7 +236,7 @@ const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
236236 if (!Inserted)
237237 return Memoized->second ;
238238
239- if (isUnevaluated (Exp))
239+ if (ExprMutationAnalyzer:: isUnevaluated (Exp, Context ))
240240 return nullptr ;
241241
242242 for (const auto &Finder : Finders) {
@@ -268,41 +268,29 @@ ExprMutationAnalyzer::Analyzer::tryEachDeclRef(const Decl *Dec,
268268 return nullptr ;
269269}
270270
271- bool ExprMutationAnalyzer::Analyzer::isUnevaluated (const Stmt *Exp,
272- const Stmt &Stm,
273- ASTContext &Context) {
274- return selectFirst<Stmt>(
275- NodeID<Expr>::value,
276- match (
277- findFirst (
278- stmt (canResolveToExpr (Exp),
279- anyOf (
280- // `Exp` is part of the underlying expression of
281- // decltype/typeof if it has an ancestor of
282- // typeLoc.
283- hasAncestor (typeLoc (unless (
284- hasAncestor (unaryExprOrTypeTraitExpr ())))),
285- hasAncestor (expr (anyOf (
286- // `UnaryExprOrTypeTraitExpr` is unevaluated
287- // unless it's sizeof on VLA.
288- unaryExprOrTypeTraitExpr (unless (sizeOfExpr (
289- hasArgumentOfType (variableArrayType ())))),
290- // `CXXTypeidExpr` is unevaluated unless it's
291- // applied to an expression of glvalue of
292- // polymorphic class type.
293- cxxTypeidExpr (
294- unless (isPotentiallyEvaluated ())),
295- // The controlling expression of
296- // `GenericSelectionExpr` is unevaluated.
297- genericSelectionExpr (hasControllingExpr (
298- hasDescendant (equalsNode (Exp)))),
299- cxxNoexceptExpr ())))))
300- .bind (NodeID<Expr>::value)),
301- Stm, Context)) != nullptr ;
302- }
303-
304- bool ExprMutationAnalyzer::Analyzer::isUnevaluated (const Expr *Exp) {
305- return isUnevaluated (Exp, Stm, Context);
271+ bool ExprMutationAnalyzer::isUnevaluated (const Stmt *Stm, ASTContext &Context) {
272+ return !match (stmt (anyOf (
273+ // `Exp` is part of the underlying expression of
274+ // decltype/typeof if it has an ancestor of
275+ // typeLoc.
276+ hasAncestor (typeLoc (
277+ unless (hasAncestor (unaryExprOrTypeTraitExpr ())))),
278+ hasAncestor (expr (anyOf (
279+ // `UnaryExprOrTypeTraitExpr` is unevaluated
280+ // unless it's sizeof on VLA.
281+ unaryExprOrTypeTraitExpr (unless (sizeOfExpr (
282+ hasArgumentOfType (variableArrayType ())))),
283+ // `CXXTypeidExpr` is unevaluated unless it's
284+ // applied to an expression of glvalue of
285+ // polymorphic class type.
286+ cxxTypeidExpr (unless (isPotentiallyEvaluated ())),
287+ // The controlling expression of
288+ // `GenericSelectionExpr` is unevaluated.
289+ genericSelectionExpr (
290+ hasControllingExpr (hasDescendant (equalsNode (Stm)))),
291+ cxxNoexceptExpr ()))))),
292+ *Stm, Context)
293+ .empty ();
306294}
307295
308296const Stmt *
0 commit comments