This is an archive of the discontinued LLVM Phabricator instance.

Warn if _Optional used at top-level of decl
Needs ReviewPublic

Authored by chrisbazley on Jan 27 2023, 8:51 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

Parameter declarations using [] syntax can be
written more naturally using an _Optional
qualifier than using Clang's _Nullable
annotation, e.g.

void myfunc(_Optional const char s[]);
// s may be a null pointer

With the above exception, it isn't useful to
declare a non-pointed-to object as _Optional
(although so-qualified types exist during
expression evaluation). Such declarations are
therefore disallowed, like equivalent abuse of
the restrict qualifier, to avoid confusion.

Diff Detail