-
- Downloads
[Clang] Fix 'counted_by' for nested struct pointers (#110497)
Fix counted_by attribute for cases where the flexible array member is accessed through struct pointer inside another struct: ``` struct variable { int a; int b; int length; short array[] __attribute__((counted_by(length))); }; struct bucket { int a; struct variable *growable; int b; }; ``` __builtin_dynamic_object_size(p->growable->array, 0); This commit makes sure that if the StructBase is both a MemberExpr and a pointer, it is treated as a pointer. Otherwise clang will generate to code to access the address of p->growable intead of loading the value of p->growable->length. Fixes #110385
Showing
- clang/lib/CodeGen/CGExpr.cpp 7 additions, 9 deletionsclang/lib/CodeGen/CGExpr.cpp
- clang/test/CodeGen/attr-counted-by-pr110385.c 70 additions, 0 deletionsclang/test/CodeGen/attr-counted-by-pr110385.c
- clang/test/CodeGen/attr-counted-by.c 40 additions, 40 deletionsclang/test/CodeGen/attr-counted-by.c
Loading
Please register or sign in to comment