format_arg attribute does not support nullable instancetype return type
authorFélix Cloutier <fcloutier@apple.com>
Thu, 11 Nov 2021 02:03:36 +0000 (18:03 -0800)
committerFélix Cloutier <fcloutier@apple.com>
Fri, 12 Nov 2021 21:35:43 +0000 (13:35 -0800)
commit12ab3e6c8402078f58959847277858eb47a43a19
tree7a9fda42979c3654d45f12c4e26333e5de170538
parent4602f52d482c5752d6a4c13108f29f0be39598c8
format_arg attribute does not support nullable instancetype return type

* The format_arg attribute tells the compiler that the attributed function
  returns a format string that is compatible with a format string that is being
  passed as a specific argument.
* Several NSString methods return copies of their input, so they would ideally
  have the format_arg attribute. A previous differential (D112670) added
  support for instancetype methods having the format_arg attribute when used
  in the context of NSString method declarations.
D112670 failed to account that instancetype can be sugared in certain narrow
  (but critical) scenarios, like by using nullability specifiers. This patch
  resolves this problem.

Differential Revision: https://reviews.llvm.org/D113636
Reviewed By: ahatanak

Radar-Id: rdar://85278860
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaObjC/format-arg-attribute.m