Commit 7d180948 authored by Erik Pilkington's avatar Erik Pilkington
Browse files

Revert "Revert "Support for groups of attributes in #pragma clang attribute""

This reverts commit r345487, which reverted r345486. I think the crashes were
caused by an OOM on the builder, trying again to confirm...

llvm-svn: 345517
parent e9d85264
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -2651,10 +2651,12 @@ Specifying an attribute for multiple declarations (#pragma clang attribute)

The ``#pragma clang attribute`` directive can be used to apply an attribute to
multiple declarations. The ``#pragma clang attribute push`` variation of the
directive pushes a new attribute to the attribute stack. The declarations that
follow the pragma receive the attributes that are on the attribute stack, until
the stack is cleared using a ``#pragma clang attribute pop`` directive. Multiple
push directives can be nested inside each other.
directive pushes a new "scope" of ``#pragma clang attribute`` that attributes
can be added to. The ``#pragma clang attribute (...)`` variation adds an
attribute to that scope, and the ``#pragma clang attribute pop`` variation pops
the scope. You can also use ``#pragma clang attribute push (...)``, which is a
shorthand for when you want to add one attribute to a new scope. Multiple push
directives can be nested inside each other.

The attributes that are used in the ``#pragma clang attribute`` directives
can be written using the GNU-style syntax:
+2 −2
Original line number Diff line number Diff line
@@ -86,8 +86,8 @@ Modified Compiler Flags
New Pragmas in Clang
--------------------

Clang now supports the ...

- Clang now supports adding multiple `#pragma clang attribute` attributes into
  a scope of pushed attributes.

Attribute Changes in Clang
--------------------------
+2 −2
Original line number Diff line number Diff line
@@ -1032,8 +1032,8 @@ def err_pragma_optimize_invalid_argument : Error<
def err_pragma_optimize_extra_argument : Error<
  "unexpected extra argument '%0' to '#pragma clang optimize'">;
// - #pragma clang attribute
def err_pragma_attribute_expected_push_pop : Error<
  "expected 'push' or 'pop' after '#pragma clang attribute'">;
def err_pragma_attribute_expected_push_pop_paren : Error<
  "expected 'push', 'pop', or '(' after '#pragma clang attribute'">;
def err_pragma_attribute_invalid_argument : Error<
  "unexpected argument '%0' to '#pragma clang attribute'; "
  "expected 'push' or 'pop'">;
+3 −0
Original line number Diff line number Diff line
@@ -851,6 +851,9 @@ def err_pragma_attribute_no_pop_eof : Error<"unterminated "
  "'#pragma clang attribute push' at end of file">;
def note_pragma_attribute_applied_decl_here : Note<
  "when applied to this declaration">;
def err_pragma_attr_attr_no_push : Error<
  "'#pragma clang attribute' attribute with no matching "
  "'#pragma clang attribute push'">;

/// Objective-C parser diagnostics
def err_duplicate_class_def : Error<
+14 −6
Original line number Diff line number Diff line
@@ -491,15 +491,22 @@ public:
  /// VisContext - Manages the stack for \#pragma GCC visibility.
  void *VisContext; // Really a "PragmaVisStack*"

  /// This represents the stack of attributes that were pushed by
  /// \#pragma clang attribute.
  /// This an attribute introduced by \#pragma clang attribute.
  struct PragmaAttributeEntry {
    SourceLocation Loc;
    ParsedAttr *Attribute;
    SmallVector<attr::SubjectMatchRule, 4> MatchRules;
    bool IsUsed;
  };
  SmallVector<PragmaAttributeEntry, 2> PragmaAttributeStack;

  /// A push'd group of PragmaAttributeEntries.
  struct PragmaAttributeGroup {
    /// The location of the push attribute.
    SourceLocation Loc;
    SmallVector<PragmaAttributeEntry, 2> Entries;
  };

  SmallVector<PragmaAttributeGroup, 2> PragmaAttributeStack;

  /// The declaration that is currently receiving an attribute from the
  /// #pragma attribute stack.
@@ -8470,9 +8477,10 @@ public:
  /// the appropriate attribute.
  void AddCFAuditedAttribute(Decl *D);

  /// Called on well-formed '\#pragma clang attribute push'.
  void ActOnPragmaAttributePush(ParsedAttr &Attribute, SourceLocation PragmaLoc,
  void ActOnPragmaAttributeAttribute(ParsedAttr &Attribute,
                                     SourceLocation PragmaLoc,
                                     attr::ParsedSubjectMatchRuleSet Rules);
  void ActOnPragmaAttributeEmptyPush(SourceLocation PragmaLoc);

  /// Called on well-formed '\#pragma clang attribute pop'.
  void ActOnPragmaAttributePop(SourceLocation PragmaLoc);
Loading