Matching DeclRefExpr of type T (clang-tidy)

Hi,

I’m trying to match certain expressions with clang-tidy, see code:

template

using Addr32 = T;

Addr32* 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, but I can’t figure out how.

The closest I’ve gotten using clang-query is match declRefExpr(hasType( asString(“Addr32 *”) )), but I don’t want to have the specify the type int. I want to match all possible types Addr32.

Any ideas?

Regards,

  • | - |

Patrik Eklöf
Programmer
patrik.eklof@vmssoftware.com

image001.gif

VMS Software, inc.

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

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 :slight_smile:

declRefExpr(hasType(pointsTo(templateSpecializationType(hasDeclaration(

typeAliasTemplateDecl(hasName(“Addr32”)))))))

George

image001.gif