[PATCH] D50214: Add inherited attributes before parsed attributes.

Michael Kruse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 3 20:08:00 PDT 2018


Meinersbur added a comment.

For this patch the goal is to have the attributes in the AST in an order that is less surprising to consumers (including out-of-tree). If we change it now, new/revised code/diagnostics will be written to match this order.

I agree that ideally, most attributes (exceptions are e.g. `enable_if`) should be more like a set than a list, but I don't think we can get rid of the 'ordered-ness' in general.

I though about ordering by SourceLocation as well and could be implemented like this:
Add all SLoc's sequences for two SourceLocation to lists. Start comparing from the bottom (=> the translation units) until there is a difference.

However, I dislike the idea that the result could potentially depend on SourceLocation that previously was only used when emitting diagnostics.



================
Comment at: test/Misc/ast-dump-attr.cpp:228-230
+// CHECK-NEXT: DeprecatedAttr{{.*}} Inherited
+// CHECK-NEXT: WarnUnusedResultAttr{{.*}} Inherited
+// CHECK-NEXT: AnnotateAttr{{.*}} Inherited
----------------
Note that before rC338800, these were mixed-up (not even the reverse order)


================
Comment at: test/Sema/attr-availability-ios.c:10
 void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
-void f6(int) __attribute__((availability(ios,deprecated=3.0)));
-void f6(int) __attribute__((availability(iOS,introduced=2.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(iOS,introduced=2.0)));
----------------
Note that the deprecated marker moved to the line that actually declares the function as deprecated.


Repository:
  rC Clang

https://reviews.llvm.org/D50214





More information about the cfe-commits mailing list