rapidsna wrote:

FWIW, in the context of `-fbounds-safety` 
(https://github.com/llvm/llvm-project/blob/main/clang/docs/BoundsSafety.rst), I 
think the best is to have the bounds-annotated types to be part of the 
canonical type system because they affect the semantics and the codegen (again 
with `-fbounds-safety`) and the annotations should also apply to rvalues (e.g., 
function return types).

That said, sugar types happen to work fine overall because where the compiler 
is about to lose the type sugar (e.g., assigning it to a variable with type 
that doesn't have the same attribute), the model naturally prevented it by 
either emitting an error for incompatible type conversion, or promoting the 
type into a wide pointer type (i.e., `__bidi_indexable` for lvalue-to-rvalue 
conversion on `__counted_by`). That being said, we still encountered some cases 
where the type sugars are lost inconsistently due to implementation issues 
(e.g., getting unqualified type also removes the type sugar depending on the 
position it appertains to). So again, ideally, I like it to be part of the type 
system.

However, without `-fbounds-safety`, `__counted_by` is merely used as a helper 
for sanitizers and the `__builtin_dynamic_object_size`, so it would make more 
sense to be a sugar type. Then, the question is whether we want the attribute 
to be parsed different with or without `-fbounds-safety` and would that be a 
problem.

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

Reply via email to