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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu May 1 08:47:11 PDT 2025


================
@@ -24,7 +24,7 @@ int templateFunction(T value) __attribute__((annotate("works")));
 
 // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
 // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
-// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
+// CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:46 - 5:60]
----------------
AaronBallman wrote:

I think the underlying issue is that we're using in-band information about source ranges that's no longer true. We used to be able to rely on the source range because the order was more strict, but as we've relaxed it, you can now mix declaration and decl specifier attributes in more exotic ways.

However, addressing that may be quite involved. So I think we should probably accept this as-is; pointing to the start of the list is better than pointing to the type.

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


More information about the cfe-commits mailing list