[cfe-users] Fwd: [cfe-dev] matcher for obj-c variable declarations.

Alfred Zien via cfe-users cfe-users at lists.llvm.org
Fri Sep 16 10:52:48 PDT 2016

cfe-dev was wrong list may be?

> Hi to everyone!
> I'm new to clang and libtooling, and I'm making some cheker tool that emits a error if any obj-c variable declaration doesn't have nullability specifier.
> I have code like this
>   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 (is it a bug?). 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 for any help!
> _______________________________________________
> 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-users/attachments/20160916/7ebad662/attachment.html>

More information about the cfe-users mailing list