Page MenuHomePhabricator

Updated CheckAddressOfOperand
Needs ReviewPublic

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



The semantics of the unary & operator are modified
so that if its operand has type "type" then its
result has type "pointer to type", with the omission
of any _Optional qualifier of the pointed-to type.

Also added a new helper method,


A new idiom &* is proposed to allow removal of the
_Optional qualifier from a pointee whilst allowing
static analyzers to check the validity of such
conversions. This is merely the simplest expression
that incorporates a semantic dereference without
actually accessing the pointed-to object.

There is only one way to get the address of an object
(excepting arithmetic), whereas there are many ways
to dereference a pointer. This is why the semantics
of & are modified rather than modifying *, [] and ->.
The operand of & is already treated specially, being
exempt from implicit conversion of an array type into
a pointer, for example.

Diff Detail