[PATCH] D72532: Make the ExprMutationAnalyzer explicit about how it traverses the AST

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 11:56:01 PST 2020


steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72532

Files:
  clang/lib/Analysis/ExprMutationAnalyzer.cpp


Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===================================================================
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -284,11 +284,12 @@
                                                 maybeEvalCommaExpr(equalsNode(Exp))));
 
   const auto Matches =
-      match(findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
+      match(traverse(ast_type_traits::TK_AsIs,
+        findAll(stmt(anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
                                AsAmpersandOperand, AsPointerFromArrayDecay,
                                AsOperatorArrowThis, AsNonConstRefArg,
                                AsLambdaRefCaptureInit, AsNonConstRefReturn))
-                        .bind("stmt")),
+                        .bind("stmt"))),
             Stm, Context);
   return selectFirst<Stmt>("stmt", Matches);
 }
@@ -387,13 +388,13 @@
       parmVarDecl(hasType(nonConstReferenceType())).bind("parm"));
   const auto IsInstantiated = hasDeclaration(isInstantiated());
   const auto FuncDecl = hasDeclaration(functionDecl().bind("func"));
-  const auto Matches = match(
+  const auto Matches = match(traverse(ast_type_traits::TK_AsIs,
       findAll(expr(anyOf(callExpr(NonConstRefParam, IsInstantiated, FuncDecl,
                                   unless(callee(namedDecl(hasAnyName(
                                       "::std::move", "::std::forward"))))),
                          cxxConstructExpr(NonConstRefParam, IsInstantiated,
                                           FuncDecl)))
-                  .bind(NodeID<Expr>::value)),
+                  .bind(NodeID<Expr>::value))),
       Stm, Context);
   for (const auto &Nodes : Matches) {
     const auto *Exp = Nodes.getNodeAs<Expr>(NodeID<Expr>::value);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72532.237408.patch
Type: text/x-patch
Size: 1850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200110/64de30e6/attachment.bin>


More information about the cfe-commits mailing list