[all-commits] [llvm/llvm-project] 6a5f74: format_arg attribute should allow instancetype in ...
apple-fcloutier via All-commits
all-commits at lists.llvm.org
Thu Oct 28 20:32:55 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6a5f7437720ea0fa184469584600c27a1a912a41
https://github.com/llvm/llvm-project/commit/6a5f7437720ea0fa184469584600c27a1a912a41
Author: FĂ©lix Cloutier <fcloutier at apple.com>
Date: 2021-10-28 (Thu, 28 Oct 2021)
Changed paths:
M clang/lib/Sema/SemaDeclAttr.cpp
M clang/test/SemaObjC/format-arg-attribute.m
Log Message:
-----------
format_arg attribute should allow instancetype in NSString definition
- [[format_arg(N)]] tells Clang that a method returns a format string with
specifiers equivalent to those passed in the string at argument #N. It
obviously requires the argument and the return type to be strings both.
- `instancetype` is a special return type available in Objective-C class
definitions that Clang expands to the most-derived statically known type on
use.
- In Objective-C mode, NSString is allowed in lieu of a C string, both as input
and output. However, _in the definition of NSString_, Clang rejects format_arg
on methods that return NSString. This PR addresses this issue by substituting
`instancetype` with the enclosing definition's type during the validation of
`format_arg`.
Reviewed By: ahatanak
Differential Revision: https://reviews.llvm.org/D112670
Radar-Id: rdar://84729746
More information about the All-commits
mailing list