From b85be665b0b2bbe6d21452831e21f8e7ea89b6d5 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 11 Sep 2015 11:51:24 +0000 Subject: Fixed HasDeclarationMatcher to properly convert all types into decls where possible. Added objcObjectPointerType(), objcInterfaceDecl(), templateTypeParmType(), injectedClassNameType(), and unresolvedUsingTypenameDecl(). Updated documentation for pointerType() to call out that it does not match ObjCObjectPointerType types. Changed pointsTo() to handle ObjCObjectPointerType as well as PointerType. While this may seem like a lot of unrelated changes, they all relate back to fixing HasDeclarationMatcher. This now allows us to write a matcher like: varDecl(hasType(namedDecl(hasName("Foo")))) that matches code using typedefs, objc interfaces, template type parameters, injected class names, or unresolved using typenames. llvm-svn: 247404 --- clang/docs/LibASTMatchersReference.html | 72 +++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'clang/docs/LibASTMatchersReference.html') diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 7e979a1b248..80f22fa6d17 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -307,6 +307,15 @@ namespaceDecl() +Matcher<Decl>objcInterfaceDeclMatcher<ObjCInterfaceDecl>... +
Matches Objective-C interface declarations.
+
+Example matches Foo
+  @interface Foo
+  @end
+
+ + Matcher<Decl>parmVarDeclMatcher<ParmVarDecl>...
Matches parameter variable declarations.
 
@@ -364,6 +373,22 @@ typedefDecl()
 
+Matcher<Decl>unresolvedUsingTypenameDeclMatcher<UnresolvedUsingTypenameDecl>... +
Matches unresolved using value declarations that involve the
+typename.
+
+Given
+  template <typename T>
+  struct Base { typedef T Foo; };
+
+  template<typename T>
+  struct S : private Base<T> {
+    using typename Base<T>::Foo;
+  };
+unresolvedUsingTypenameDecl()
+  matches using Base<T>::Foo 
+ + Matcher<Decl>unresolvedUsingValueDeclMatcher<UnresolvedUsingValueDecl>...
Matches unresolved using value declarations.
 
@@ -1254,6 +1279,18 @@ incompleteArrayType()
 
+Matcher<Type>injectedClassNameTypeMatcher<InjectedClassNameType>... +
Matches injected class name types.
+
+Example matches S s, but not S<T> s.
+    (matcher = parmVarDecl(hasType(injectedClassNameType())))
+  template <typename T> struct S {
+    void f(S s);
+    void g(S<T> s);
+  };
+
+ + Matcher<Type>lValueReferenceTypeMatcher<LValueReferenceType>...
Matches lvalue reference types.
 
@@ -1281,6 +1318,21 @@ memberPointerType()
 
+Matcher<Type>objcObjectPointerTypeMatcher<ObjCObjectPointerType>... +
Matches an Objective-C object pointer type, which is different from
+a pointer type, despite being syntactically similar.
+
+Given
+  int *a;
+
+  @interface Foo
+  @end
+  Foo *f;
+pointerType()
+  matches "Foo *f", but does not match "int *a".
+
+ + Matcher<Type>parenTypeMatcher<ParenType>...
Matches ParenType nodes.
 
@@ -1294,14 +1346,19 @@ array_of_ptrs.
 
 
 Matcher<Type>pointerTypeMatcher<PointerType>...
-
Matches pointer types.
+
Matches pointer types, but does not match Objective-C object pointer
+types.
 
 Given
   int *a;
   int &b = *a;
   int c = 5;
+
+  @interface Foo
+  @end
+  Foo *f;
 pointerType()
-  matches "int *a"
+  matches "int *a", but does not match "Foo *f".
 
@@ -1382,6 +1439,15 @@ instantiation in A and the type of the variable declaration in B.
+Matcher<Type>templateTypeParmTypeMatcher<TemplateTypeParmType>... +
Matches template type parameter types.
+
+Example matches T, but not int.
+    (matcher = templateTypeParmType())
+  template <typename T> void f(int i);
+
+ + Matcher<Type>typeMatcher<Type>...
Matches Types in the clang AST.
 
@@ -2280,7 +2346,7 @@ a substring matched by the given RegExp. Matcher<ObjCMessageExpr>numSelectorArgsunsigned N
Matches when the selector has the specified number of arguments
 
- matcher = objCMessageExpr(numSelectorArgs(1));
+ matcher = objCMessageExpr(numSelectorArgs(0));
  matches self.bodyView in the code below
 
  matcher = objCMessageExpr(numSelectorArgs(2));
-- 
cgit v1.2.3