[all-commits] [llvm/llvm-project] 798896: Added tests for RecursiveASTVisitor for AST nodes ...

Dmitri Gribenko via All-commits all-commits at lists.llvm.org
Fri Jul 3 04:05:41 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 79889691430d8e76e908706170102a8b46432a07
      https://github.com/llvm/llvm-project/commit/79889691430d8e76e908706170102a8b46432a07
  Author: Dmitri Gribenko <gribozavr at gmail.com>
  Date:   2020-07-03 (Fri, 03 Jul 2020)

  Changed paths:
    M clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

  Log Message:
  -----------
  Added tests for RecursiveASTVisitor for AST nodes that are special cased

Summary:
RecursiveASTVisitor has special code for handling operator AST nodes,
specifically, unary, binary, and compound assignment operators. In this
change I'm adding tests for operator AST nodes that follow the existing
pattern of tests for the CallExpr node (an AST node that triggers the
common code path).

Reviewers: ymandel, eduucaldas

Reviewed By: ymandel, eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82875


  Commit: 94454442c3c15a67ae70ef3a73616632968973fc
      https://github.com/llvm/llvm-project/commit/94454442c3c15a67ae70ef3a73616632968973fc
  Author: Dmitri Gribenko <gribozavr at gmail.com>
  Date:   2020-07-03 (Fri, 03 Jul 2020)

  Changed paths:
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/lib/Tooling/Syntax/BuildTree.cpp
    M clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

  Log Message:
  -----------
  RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

Summary:
How does RecursiveASTVisitor call the WalkUp callback for expressions?

* In pre-order traversal mode, RecursiveASTVisitor calls the WalkUp
  callback from the default implementation of Traverse callbacks.

* In post-order traversal mode when we don't have a DataRecursionQueue,
  RecursiveASTVisitor also calls the WalkUp callback from the default
  implementation of Traverse callbacks.

* However, in post-order traversal mode when we have a DataRecursionQueue,
  RecursiveASTVisitor calls the WalkUp callback from PostVisitStmt.

As a result, when the user overrides the Traverse callback, in pre-order
traversal mode they never get the corresponding WalkUp callback. However
in the post-order traversal mode the WalkUp callback is invoked or not
depending on whether the data recursion optimization could be applied.

I had to adjust the implementation of TraverseCXXForRangeStmt in the
syntax tree builder to call the WalkUp method directly, as it was
relying on this behavior. There is an existing test for this
functionality and it prompted me to make this extra fix.

In addition, I had to fix the default implementation implementation of
RecursiveASTVisitor::TraverseSynOrSemInitListExpr to call WalkUpFrom in
the same manner as the implementation generated by the DEF_TRAVERSE_STMT
macro. Without this fix, the InitListExprIsPostOrderNoQueueVisitedTwice
test was failing because WalkUpFromInitListExpr was never called.

Reviewers: eduucaldas, ymandel

Reviewed By: eduucaldas, ymandel

Subscribers: gribozavr2, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82486


  Commit: 7b0be962d681c408c8ecf7180c6ad8f9fbcdaf2d
      https://github.com/llvm/llvm-project/commit/7b0be962d681c408c8ecf7180c6ad8f9fbcdaf2d
  Author: Dmitri Gribenko <gribozavr at gmail.com>
  Date:   2020-07-03 (Fri, 03 Jul 2020)

  Changed paths:
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

  Log Message:
  -----------
  Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode

Reviewers: ymandel, eduucaldas, rsmith

Reviewed By: eduucaldas, rsmith

Subscribers: gribozavr2, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82787


  Commit: 8bf4c40af813e73de77739b33b8808f6bd13497b
      https://github.com/llvm/llvm-project/commit/8bf4c40af813e73de77739b33b8808f6bd13497b
  Author: Dmitri Gribenko <gribozavr at gmail.com>
  Date:   2020-07-03 (Fri, 03 Jul 2020)

  Changed paths:
    M clang/include/clang/AST/RecursiveASTVisitor.h
    M clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

  Log Message:
  -----------
  Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

Reviewers: eduucaldas, ymandel, rsmith

Reviewed By: eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D82889


Compare: https://github.com/llvm/llvm-project/compare/8aff6891646a...8bf4c40af813


More information about the All-commits mailing list