[PATCH] D77571: [clang-tidy] Add check to find calls to NSInvocation methods under ARC that don't have proper object argument lifetimes.

Michael Wyman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 13:37:52 PDT 2020


mwyman marked an inline comment as done.
mwyman added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:71-73
+  // Currently there is no way to directly get the source range for the
+  // __weak/__strong ObjC lifetime qualifiers, so it's necessary to string
+  // search in the source code.
----------------
benhamilton wrote:
> Is there a bug filed for this? Seems like an oversight.
> 
Maybe I'm incorrectly reading this, but per the comment on QualifiedTypeLoc it seems like this is intentional at this time: https://github.com/llvm/llvm-project/blob/549e87f3d04bbae91bc7bc38609ce7073e2c8a6d/clang/include/clang/AST/TypeLoc.h#L275


================
Comment at: clang-tools-extra/clang-tidy/objc/NsinvocationArgumentLifetimeCheck.cpp:116
+  auto Diag = diag(MatchedExpr->getArg(0)->getBeginLoc(),
+                   "NSInvocation's %0 should only pass pointers to "
+                   "objects with ownership __unsafe_unretained")
----------------
benhamilton wrote:
> -[NSInvocation %0] should
> 
Tweaked the format string so it now outputs "NSInvocation '-…'", since the diagnostic formatter inserts single-quotes, which would otherwise make it read "-[NSInvocation 'getArgument:atIndex:']", which seems weirder.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77571/new/

https://reviews.llvm.org/D77571





More information about the cfe-commits mailing list