[PATCH] D30009: Add support for '#pragma clang attribute'

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 16 13:05:35 PST 2017


efriedma added inline comments.


================
Comment at: docs/LanguageExtensions.rst:2349
+attribute is supported by the pragma by referring to the
+:doc:`individual documentation for that attribute <AttributeReference>`.
----------------
arphaman wrote:
> arphaman wrote:
> > efriedma wrote:
> > > I'm wondering if we can tweak the approach so that we don't have to separately define how this works for each attribute; for example, `#pragma clang attribute_function_declaration push(...)` would apply to each function declaration, `#pragma clang attribute_global_variable_declaration push(...)` would apply to each global variable declaration, etc.
> > I agree with this idea, I think it would be useful to have the ability to specify the target declarations. I do think it would be better to use the 'clang attribute' umbrella pragma, and maybe add an extra argument to the 'push', e.g.:
> > 
> > ```
> > #pragma attribute push (annotate("functions-only"), applicable_to=function) // or maybe received_by=?
> > #pragma attribute push (annotate("struct+enum"), applicable_to=struct, applicable_to=enum)
> > ```
> I think that the further tweaks that control which declarations receive the attributes should be kept for a follow-up patch.
I'm not sure we can wait to address this, especially if we're turning this on for all attributes by default.  There's a compatibility hazard here: if the push doesn't specify what declarations it applies to, we can never change AttributeAppliesToDecl for any existing attribute.


Repository:
  rL LLVM

https://reviews.llvm.org/D30009





More information about the cfe-commits mailing list