summaryrefslogtreecommitdiffstats
path: root/clang/docs/LibASTMatchersReference.html
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-06-21 09:59:59 +0000
committerManuel Klimek <klimek@google.com>2013-06-21 09:59:59 +0000
commitcd5e7998337f4a7e78086abf6ac902f5e296ce1e (patch)
tree47c8f9d212c9f389d864a4058bd8f7b0cff39eb3 /clang/docs/LibASTMatchersReference.html
parent8dba9fb1a209eadb0bcc1a3cf487b2ee49d0ae38 (diff)
downloadbcm5719-llvm-cd5e7998337f4a7e78086abf6ac902f5e296ce1e.tar.gz
bcm5719-llvm-cd5e7998337f4a7e78086abf6ac902f5e296ce1e.zip
Improve documentation for AST matchers.
llvm-svn: 184538
Diffstat (limited to 'clang/docs/LibASTMatchersReference.html')
-rw-r--r--clang/docs/LibASTMatchersReference.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html
index 50ff38edfad..7b70f118454 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -57,6 +57,18 @@ find all matchers that can be used to match on Stmt nodes.</p>
<p>The exception to that rule are matchers that can match on any node. Those
are marked with a * and are listed in the beginning of each category.</p>
+<p>Note that the categorization of matchers is a great help when you combine
+them into matcher expressions. You will usually want to form matcher expressions
+that read like english sentences by alternating between node matchers and
+narrowing or traversal matchers, like this:
+<pre>
+recordDecl(hasDescendant(
+ ifStmt(hasTrueExpression(
+ expr(hasDescendant(
+ ifStmt()))))))
+</pre>
+</p>
+
<!-- ======================================================================= -->
<h2 id="decl-matchers">Node Matchers</h2>
<!-- ======================================================================= -->
@@ -73,6 +85,17 @@ and implicitly act as allOf matchers.</p>
bind the matched node to the given string, to be later retrieved from the
match callback.</p>
+<p>It is important to remember that the arguments to node matchers are
+predicates on the same node, just with additional information about the type.
+This is often useful to make matcher expression more readable by inlining bind
+calls into redundant node matchers inside another node matcher:
+<pre>
+// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
+// the same node.
+recordDecl(decl().bind("id"), hasName("::MyClass"))
+</pre>
+</p>
+
<table>
<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
<!-- START_DECL_MATCHERS -->
OpenPOWER on IntegriCloud