[PATCH] Introduction of ASTMatcher sub-expression references

Edwin Vane edwin.vane at intel.com
Fri May 3 13:58:35 PDT 2013


Hi klimek, doug.gregor, gribozavr,

To support finding bound nodes found anywhere previously in the match
expression from a matcher that was provided a BoundNodesTreeBuilder
building a sub-tree of the full bound-nodes tree, every Builder
requires:
1) A pointer back to the root
2) A way of building a bound-nodes tree of results *so far* where these
results may be later thrown away.

Item 1 is handled by adding a root pointer to each builder. To make
interface harder to mis-use Builders can only be created by a static
'root creator' function or by Grafters.
Item 2 is handled by the introduction of the "Grafter" class. It
represents 'temporary' results which may appear in a tree created from
a Builder. If a Grafter is discarded, the results are thrown away.
Grafter is intrusively ref-counted so that it can serve as an RAII
object but still be created by a Builder and ownership passed to the
caller (auto_ptr would have worked but llvm::OwningPtr will not).

This revision introduces the "equalsBoundNode()" matcher currently
implemented for QualType, Stmt, and Decl which allows it to replace
existing "equalsNode()" uses.

http://llvm-reviews.chandlerc.com/D740

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/ASTMatchFinder.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D740.1.patch
Type: text/x-patch
Size: 26361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130503/9f1e3654/attachment.bin>


More information about the cfe-commits mailing list