[all-commits] [llvm/llvm-project] 246b42: [AST] Ignore implicit nodes in IgnoreUnlessSpelled...
Stephen Kelly via All-commits
all-commits at lists.llvm.org
Tue Nov 17 08:50:57 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 246b428fb3b5d58685064966bcea6592f8839b7e
https://github.com/llvm/llvm-project/commit/246b428fb3b5d58685064966bcea6592f8839b7e
Author: Stephen Kelly <steveire at gmail.com>
Date: 2020-11-17 (Tue, 17 Nov 2020)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/AST/ASTNodeTraverser.h
M clang/lib/ASTMatchers/ASTMatchFinder.cpp
M clang/unittests/AST/ASTTraverserTest.cpp
M clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
M clang/unittests/Tooling/TransformerTest.cpp
Log Message:
-----------
[AST] Ignore implicit nodes in IgnoreUnlessSpelledInSource mode
Update the ASTNodeTraverser to dump only nodes spelled in source. There
are only a few which need to be handled, but Decl nodes for which
isImplicit() is true are handled together.
Update the RAV instances used in ASTMatchFinder to ignore the nodes too.
As with handling of template instantiations, it is necessary to allow
the RAV to process the implicit nodes because they need to be visitable
before the first traverse() matcher is encountered. An exception to
this is in the MatchChildASTVisitor, because we sometimes wish to make a
node matchable but make its children not-matchable. This is the case
for defaulted CXXMethodDecls for example.
Extend TransformerTests to illustrate the kinds of problems that can
arise when performing source code rewriting due to matching implicit
nodes.
This change accounts for handling nodes not spelled in source when using
direct matching of nodes, and when using the has() and hasDescendant()
matchers. Other matchers such as
cxxRecordDecl(hasMethod(cxxMethodDecl())) still succeed for
compiler-generated methods for example after this change. Updating the
implementations of hasMethod() and other matchers is for a follow-up
patch.
Differential Revision: https://reviews.llvm.org/D90982
Commit: 4cadb66b490e3323f79a89120c3442456e4c24fa
https://github.com/llvm/llvm-project/commit/4cadb66b490e3323f79a89120c3442456e4c24fa
Author: Stephen Kelly <steveire at gmail.com>
Date: 2020-11-17 (Tue, 17 Nov 2020)
Changed paths:
M clang/include/clang/ASTMatchers/ASTMatchers.h
M clang/include/clang/ASTMatchers/ASTMatchersInternal.h
M clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
M clang/unittests/Tooling/TransformerTest.cpp
Log Message:
-----------
[AST] Update matchers to be traverse-aware
Don't match Stmt or Decl nodes not spelled in the source when using
TK_IgnoreUnlessSpelledInSource. This prevents accidental modification
of source code at incorrect locations.
Differential Revision: https://reviews.llvm.org/D90984
Compare: https://github.com/llvm/llvm-project/compare/34c0f3cbf1ee...4cadb66b490e
More information about the All-commits
mailing list