[PATCH] ASTMatcher for Attr

Aaron Ballman aaron at aaronballman.com
Fri Aug 22 05:55:59 PDT 2014


LGTM, with one incredibly minor nit:

> -/// \brief Matches declaration that has CUDA device attribute.
> -///
>  /// Given
>  /// \code
>  ///   __attribute__((device)) void f() { ... }
>  /// \endcode
> -/// matches the function declaration of f.
> -AST_MATCHER(Decl, hasCudaDeviceAttr) {
> -  return Node.hasAttr<clang::CUDADeviceAttr>();
> +/// decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
> +/// f.
> +AST_MATCHER_P(Decl, hasAttr, attr::Kind, AttrKind) {
> +  for (auto Attr : Node.attrs()) {

const auto *Attr

> +    if (Attr->getKind() == AttrKind)
> +      return true;
> +  }
> +  return false;
>  }

~Aaron

On Thu, Aug 21, 2014 at 8:41 PM, Jacques Pienaar <jpienaar at google.com> wrote:
> Moved getAttrKind to a private method of ArgTypeTraints<attr::Kind>.
>
> http://reviews.llvm.org/D4996
>
> Files:
>   docs/LibASTMatchersReference.html
>   include/clang/ASTMatchers/ASTMatchers.h
>   lib/ASTMatchers/Dynamic/Marshallers.h
>   lib/ASTMatchers/Dynamic/Registry.cpp
>   unittests/ASTMatchers/ASTMatchersTest.cpp
>   unittests/ASTMatchers/Dynamic/RegistryTest.cpp
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



More information about the cfe-commits mailing list