[cfe-dev] AST Matcher for Type Traits

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 20 02:50:18 PDT 2018


This works for me:
loc(qualType(hasDeclaration(classTemplateDecl(hasName("std::enable_if")))))


On Fri, Apr 20, 2018 at 12:21 AM David Lai via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
>
>
> I am trying to write a matcher to change
>
>
>
> template <typename T>
>
> typename std::enable_if<std::is_reference<T>::value, bool>::type is_ref()
> { return true; }
>
>
>
> to
>
>
>
> template <typename T>
>
> std::enable_if_t<std::is_reference<T>::value, bool> is_ref() { return
> true; }
>
>
>
> I have been struggling to write a match for the “typename std::enable_if…”
> line.
>
> I am able to match the template <…> line using “typeAliasTemplateDecl” and
> perhaps just retrieve the next line and check if it has “typename …”.
>
> I was wondering if you could give me pointers to write a better matcher?
>
>
>
>
>
> Thanks,
>
> David Lai
>
>
>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180420/9f562d11/attachment.html>


More information about the cfe-dev mailing list