[clang] [clang-format] Add first support for reflection (PR #193794)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 06:30:33 PDT 2026
AaronBallman wrote:
> > > It's not a bug but a feature request as you marked. See also [#192040 (comment)](https://github.com/llvm/llvm-project/issues/192040#issuecomment-4320823241).
> >
> >
> > Fair, I marked as a feature request, because we didn't have reflection in before. Still real world usage will rise once GCC 16 is released (I include myself into that group).
>
> Still, formatting spaces before `[:` (and within `[:` and `:]`) is just a nice feature/option to have.
>
> > > > It would be a shame if a modern code base will (partially) disable clang-format, just because we detect the code wrongfully as objective c once they start using reflection.
> > >
> > >
> > > Can you elaborate with an example or a GitHub issue?
> >
> >
> > I can't. But in the current state there's a good chance that you need `// clang-format off` your reflection code. And when that becomes the case more often one could get annoyed to the point of stopping using clang-format.
>
> But that wouldn't be an issue unless it's a `.h` file, and the user can add `// clang-format Language: Cpp` at the top of the file instead. We can also add the option mentioned [here](https://github.com/llvm/llvm-project/issues/191295#issuecomment-4228702589) if there's a strong demand.
>
> > I did a quick research and it seems we can be waiting on reflection in clang a bit longer:
> >
> > * No active PR for reflection
> > * This thread hasn't been updated since February: https://discourse.llvm.org/t/dedicated-meeting-for-c-26-reflection/88927
> >
> > I would really like to get clang-format to handle reflection and don't see a big risk in merging the tokens.
>
> We don't need to wait for clang to catch up with gcc, but I do think we should wait at least until clang lexer implements the splicers. (Maybe @AaronBallman knows when it might happen?)
Work is ongoing, but I believe we're focusing on getting std::meta::info working first and generative stuff will come later, so I don't expect Clang to support this for a while still. It likely makes sense to wait for the lexer changes before working on clang-format for it. CC @nhat-nguyen @cor3ntin @Endilll
https://github.com/llvm/llvm-project/pull/193794
More information about the cfe-commits
mailing list