[clang] [Clang] Allow parsing arbitrary order of attributes for declarations (PR #133107)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 06:01:03 PDT 2025


erichkeane wrote:

> > Yeah, I think I can live with this. I think not supporting the arbitrary order is more annoying to users than a slight degradation in source location reporting.
> 
> The point @kadircet brings up about tooling is a good one, though. I'm not certain we need to revert the patch, but breaking a bunch of tools and making them cope with the source location change is pretty disruptive. I think we may need to consider refactoring source location handling for attributes more broadly to solve the underlying concerns. Thoughts @erichkeane?
> 
> Related, this issue just was filed today: #140020

I wouldn't be opposed to SOME sort of improvement in attributes handling.  We flatten the list of attributes unfortunately, so we couldn't add source location to each group in any way....

My one immediate thought is: What if we added ONE extra source-location to `AttrCommonInfo`?  The FIRST in each group gets the 'begin' location, and the 'LAST' in each group gets the 'end' location.  Everyone else gets an empty source location. We could make it private, then just accessible via functions from Decl.  Since we maintain order of attributes, we'd get them reasonably well.

WDYT?

I don't really have the time/ability to do so, but am definitely willing to review something like this.

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


More information about the cfe-commits mailing list