[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-07-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf4c40af813: Make RecursiveASTVisitor call WalkUpFrom for 
operators when the data recursion… (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82889/new/

https://reviews.llvm.org/D82889

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@
 WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromBinAdd BinaryOperator(+)
+WalkUpFromExpr BinaryOperator(+)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
@@ -1396,8 +1398,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // CompoundAssignOperator(+=).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1405,6 +1405,7 @@
 TraverseBinAddAssign CompoundAssignOperator(+=)
   WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1470,7 +1471,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAddAssign.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1481,6 +1481,9 @@
 WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromBinAddAssign CompoundAssignOperator(+=)
+WalkUpFromExpr CompoundAssignOperator(+=)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -412,6 +412,8 @@
 if (!getDerived().shouldTraversePostOrder())   \
   TRY_TO(WalkUpFromUnary##NAME(S));\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  \
+if (!Queue && getDerived().shouldTraversePostOrder())  \
+  TRY_TO(WalkUpFromUnary##NAME(S));\
 return true;   \
   }\
   bool 

[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:416
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromUnary##NAME(S));
\
 return true;   
\

As a review aid, compare the implementation of this function with the 
definition of the DEF_TRAVERSE_STMT macro.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82889/new/

https://reviews.llvm.org/D82889



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-06-30 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added reviewers: eduucaldas, ymandel, rsmith.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82889

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@
 WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromBinAdd BinaryOperator(+)
+WalkUpFromExpr BinaryOperator(+)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
@@ -1396,8 +1398,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // CompoundAssignOperator(+=).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1405,6 +1405,7 @@
 TraverseBinAddAssign CompoundAssignOperator(+=)
   WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1470,7 +1471,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAddAssign.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1481,6 +1481,9 @@
 WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromBinAddAssign CompoundAssignOperator(+=)
+WalkUpFromExpr CompoundAssignOperator(+=)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -412,6 +412,8 @@
 if (!getDerived().shouldTraversePostOrder())   \
   TRY_TO(WalkUpFromUnary##NAME(S));\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  \
+if (!Queue && getDerived().shouldTraversePostOrder())  \
+  TRY_TO(WalkUpFromUnary##NAME(S));\
 return true;   \
   }\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   \
@@ -433,6 +435,8 @@