This is unrelated to Swift. That file is in clang; it's a test of clang's static analyzer.
__attribute__((sentinel)) is identical to __attribute__((sentinel(0, 0))). The difference between sentinel(n, 0) and sentinel(n, 1) has to do with the handling of the last named parameter before the variadic arguments.
(n, 0) means the last named parameter is not part of the null-terminated list; the required sentinel must come after the last named parameter.
(n, 1) means the last named parameter is part of the null-terminated list; passing null to the last named parameter will satisfy -Wsentinel.
n is the number of non-null arguments that must follow the null sentinel. This is used for functions like execle() which passes envp after the null at the end of argv.
On Sep 6, 2016, at 6:50 PM, 哀殿 via swift-users <firstname.lastname@example.org> wrote:
Hello Swift community,
I found `__attribute__((sentinel(0,1)))` at https://github.com/apple/swift-clang/blob/c52d85ede49adaec457400697b1d4c1b7ea12881/test/Analysis/variadic-method-types.m#L46.
But I can't imagine how different it is from the `__attribute__((sentinel))`.
So,why we need `__attribute__((sentinel(0,1)))`?
Greg Parker email@example.com <mailto:firstname.lastname@example.org> Runtime Wrangler