[PATCH] D91311: Add new 'preferred_name' attribute.

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 16 14:13:59 PST 2020


ldionne added a comment.

What the attribute achieves is great, however I must say I'm really with Arthur's original comment regarding the ergonomics of it.

IMO, it makes a lot more sense to permit the typedef author to pick how their typedef is going to be "named" by the compiler. If they pick something crazy or misleading, it's really their problem.

I think that the fact we need to re declare everything shows how the ergonomics would be better if we could just add the attribute to the typedef. See for example how we're re-declaring a bunch of stuff in `<iosfwd>`. How bad of an idea is it to try putting the attribute on typedefs instead, and how strongly are you opposed to it? Because from a naive user perspective, having to redeclare the class with a closed set of preferred names feels awkward (IMO, of course).



================
Comment at: libcxx/include/__config:1343
+#if __has_attribute(__preferred_name__)
+#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
+#else
----------------
Can you please indent inside the `#if`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91311/new/

https://reviews.llvm.org/D91311



More information about the cfe-commits mailing list