rjmccall wrote:

> > Oliver is right that we need custom checking in SemaChecking akin to the 
> > other builtins, e.g. to validate that the keys are constants. The pattern 
> > should be straightforward to follow. Otherwise the frontend changes LGTM 
> > except as noted.
> 
> When I noticed that I did wonder why we need custom type checking? we've 
> typed the definition of the builtin and I recall a pile of very same-y custom 
> checks in other builtins - is it just propagating types or is it something 
> more complicated? (If there are some common idioms I'd be willing to spend 
> some time adding support for them)

Yeah, so it's three things:
- keys must be constant expressions
- discriminators are allowed to be either integers or pointers
- for all the normal sign/auth/resign builtins, the type of the input pointer 
should generally be the return type

The third doesn't apply in this case, since it's unlikely to be useful to make 
the result type the same as the input pointer; unless we add a type argument, 
this should just be a `void*`. However, we do have an extra semantic constraint 
that we need to enforce here, which is that the offset has to be a constant 
expression.

https://github.com/llvm/llvm-project/pull/142047
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to