[clang] [libcxxabi] [llvm] [clang] Generalize static within array brackets (PR #244642)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 04:48:05 PST 2026
AaronBallman wrote:
> Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n4018.htm Cc: @uecker, @AaronBallman
> ...
> @AaronBallman would you mind helping a little bit?
This feature wasn't adopted by WG14 and there were no polls to gauge committee sentiment from, so it's premature to add this. We could add it as a conforming extension, but given that it's effectively the same as `[static 0]` which was adopted for C2y (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3989.htm), there's not a particularly compelling reason to rush anything here IMO (it'd require everyone to go through more process than just putting up a PR, might as well just wait to see what the committee says first because that could obviate some of the process work).
47 files is a surprisingly large patch; was an LLM used in creating this patch? If so, please familiarize yourself with https://llvm.org/docs/AIToolPolicy.html and ensure you're aligned with the policy. But given the above, the size of the PR, and that this is still a draft, I won't have time to give this proper review, just a cursory glance (still have a LOT of work to dig out from under from being gone for WG14 and WG21 meetings last week).
> I'm aware of the build issues. I'm trying to understand how to fix them, but I couldn't understand it so far.
Two of the failures are in LLDB and appear to be straightforward code changes because the internal Clang API changed. The AST reader failure within Clang is because of table-generated code that also needs to be updated:
https://github.com/llvm/llvm-project/blob/1f484d33a1e7b8318cc95abbc622737b26799d39/clang/include/clang/AST/TypeProperties.td#L142
https://github.com/llvm/llvm-project/blob/1f484d33a1e7b8318cc95abbc622737b26799d39/clang/include/clang/AST/TypeProperties.td#L150
High-level feedback on the approach is: I'm not keen on having to update a bajillion places because we're making the interface for creating a constant array more complicated for C-specific features like array star sizes and static array extents. I wonder if it makes sense to do some refactoring (in a separate PR which lands before this one) to add overloaded interfaces for the `ArraySizeModifier::Normal` case that dominates the changes in this PR? Basically, most of the calls today look like:
```
DeclType = SemaRef.Context.getConstantArrayType(
elementType, maxElements, nullptr, ArraySizeModifier::Normal, 0);
```
and I think most of those could change to be:
```
DeclType = SemaRef.Context.getConstantArrayType(elementType, maxElements);
```
because (outside of parsing or AST serialization) most places will not want to add array size modifiers or qualifiers to the array index expression. Then when you add the split between `static` and `star`, you'll have to update far fewer places across the code base. This could also be a chance to clean up some interfaces that don't make sense -- e.g., you cannot have an incomplete array type with a static or star modifier or qualifiers.
CC @cor3ntin @erichkeane @Sirraide @Fznamznon for some additional opinions on whether this is a good idea or a wild goose chase. Note, others are also getting back from standards meetings and it's a holiday week here in the US, so you may not get a timely response.
https://github.com/llvm/llvm-project/pull/244642
More information about the cfe-commits
mailing list