[cfe-dev] Matching DeclRefExpr of type T (clang-tidy)

George Burgess IV via cfe-dev cfe-dev at lists.llvm.org
Tue May 9 20:44:33 PDT 2017


Hello!

Apologies for the late reply, but in case it's helpful, it looks like the
following may be a good (though moderately verbose) starting point :)

declRefExpr(hasType(pointsTo(templateSpecializationType(hasDeclaration(
  typeAliasTemplateDecl(hasName("Addr32")))))))


George

On Tue, Apr 25, 2017 at 3:54 AM, Patrik Eklöf via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
>
>
> I’m trying to match certain expressions with clang-tidy, see code:
>
>
>
> template<typename T>
>
> using Addr32 = T;
>
>
>
> Addr32<int>* p32 = nullptr;
>
> int* p64 = p32;                      // I want to match this
>
> int* pTestNative = p64;              // I don't want to match this
>
>
>
> int main()
>
> {
>
> }
>
>
>
> So I want to match any DeclRefExpr whose type is Addr32<T>, but I can’t
> figure out how.
>
> The closest I’ve gotten using clang-query is match declRefExpr(hasType(
> asString("Addr32<int> *") )), but I don’t want to have the specify the type
> int. I want to match all possible types Addr32<T>.
>
> Any ideas?
>
> Regards,
>
> *Patrik Eklöf*
> Programmer
> *patrik.eklof at vmssoftware.com <patrik.eklof at vmssoftware.com>*
>
> [image: cid:BE4BF572-C003-4AAA-B3E1-F94F88D12D24 at netgear.local]
>
>
> *VMS Software, inc.*
>
> Skeppsgatan 19, SE-211 11 Malmö Sweden
> *http://vmssoftware.com/ <http://vmssoftware.com/>*
>
>
>
>
>
>
>
> _______________________________________________
> 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/20170509/601dacb6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 3421 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170509/601dacb6/attachment.gif>


More information about the cfe-dev mailing list