Match Objective-C object pointer type with nullability specificator in Clang's LibTooling

131 Views Asked by At

Lets say I have such code:

A* a = [[A alloc] init];
B* _Null_unspecified b = [[B alloc] init];
C* _Nullable c = [[C alloc] init];
D* _Nonnull d = [[D alloc] init];

Now, I want to create a matcher to match variables declaration.

Currently I have something like this:

StatementMatcher NullUnspecifiedMatcher = 
  declStmt(hasSingleDecl(varDecl(hasType(objcObjectPointerType()))))`

There is objcObjectPointerType() but it matches only a. There are some pointers/references matchers, but they don't work on those variable declarations at all. Also, I tried isAnyPointer() but it works on any pointer, obj-c or not.

I tried type() to ensure, that I'm doing everything correctly, and it works.

So, how can I match only obj-c variable declarations, with or without nullability specifier?

Thanks!

0

There are 0 best solutions below