[clang] Sort attributes according to source position before printing (PR #162556)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 9 09:14:34 PDT 2025


erichkeane wrote:

> > @AaronBallman : curious of your thoughts.
> 
> I think we could either go with a one-off fix that's specific to `asm` (which closes the linked issue), or we could explore the more general solution of how to handle attributes with custom parsing logic. My gut feeling is that the general solution will be tricky to solve though; printing logic isn't trivial because you've got things like `constinit`, `asm`, calling conventions like `__cdecl`, oddities like `_Noreturn`, etc.

I find myself wondering if instead of just 'addAttr' doing a 'push_back' there should be some sort of 'insert sorted' instead?  It would avoid the partition problem above (and it is only a couple of checks?).  Not sure if it is worth the perf hit though vs just modifying the printing.  

https://github.com/llvm/llvm-project/pull/162556


More information about the cfe-commits mailing list