llvm-project
llvm-project copied to clipboard
[BoundsSafety] `counted_by`/`ended_by` strip nullability attributes inside typedefs
For the following input:
typedef int * _Nonnull foo_t;
void single(foo_t __single p); // Ok, always retains nullability attribute
void bar(int len, foo_t __counted_by(len) p); // drops nullability attribute in attribute-only mode
We see the following in the AST dump, when compiled with -fbounds-safety:
`-FunctionDecl 0x8c11f9600 <line:6:1, col:46> col:6 bar 'void (int, int *__single __counted_by(len) _Nonnull)'
|-ParmVarDecl 0x8c11f9260 <col:12, col:16> col:16 used len 'int'
| `-DependerDeclsAttr 0x8c11f94b0 <<invalid sloc>> Implicit 0x8c11f92d8 0
`-ParmVarDecl 0x8c11f92d8 <col:21, col:45> col:45 p 'int *__single __counted_by(len) _Nonnull':'int *__single'
But when compiled with -fexperimental-bounds-safety-attributes, we get:
`-FunctionDecl 0xc3f431590 <line:6:1, col:46> col:6 bar 'void (int, int * __counted_by(len))'
|-ParmVarDecl 0xc3f4312c0 <col:12, col:16> col:16 used len 'int'
| `-DependerDeclsAttr 0xc3f431448 <<invalid sloc>> Implicit 0xc3f431338 0
`-ParmVarDecl 0xc3f431338 <col:21, col:45> col:45 p 'int * __counted_by(len)':'int *'
That is, with -fexperimental-bounds-safety-attributes it drops the AttributedType node containing the _Nonnull info.
I'm interested in fixing this issue!