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

Patrik Eklöf via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 25 03:54:23 PDT 2017


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
 <mailto:patrik.eklof at vmssoftware.com> patrik.eklof at vmssoftware.com




VMS Software, inc.

Skeppsgatan 19, SE-211 11 Malmö Sweden
 <http://vmssoftware.com/> http://vmssoftware.com/

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170425/5b2ed14c/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/20170425/5b2ed14c/attachment.gif>


More information about the cfe-dev mailing list