diff options
author | Erich Keane <erich.keane@intel.com> | 2018-07-13 15:07:47 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-07-13 15:07:47 +0000 |
commit | e891aa971a70af92042a77ec314e9541a00eeb2c (patch) | |
tree | a8b400d6a8a6861a1e9d14790fa8da286b80fb1c | |
parent | fb0d4e44328910fae3e8c4ac95c8ec01bf3a1b2e (diff) | |
download | llvm-e891aa971a70af92042a77ec314e9541a00eeb2c.zip llvm-e891aa971a70af92042a77ec314e9541a00eeb2c.tar.gz llvm-e891aa971a70af92042a77ec314e9541a00eeb2c.tar.bz2 |
[NFC] Rename clang::AttributeList to clang::ParsedAttr
Since The type no longer contains the 'next' item anymore, it isn't a list,
so rename it to ParsedAttr to be more accurate.
llvm-svn: 337005
26 files changed, 1073 insertions, 1143 deletions
diff --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst index 940d320..7d85d2b 100644 --- a/clang/docs/InternalsManual.rst +++ b/clang/docs/InternalsManual.rst @@ -1664,15 +1664,15 @@ and then the semantic handling of the attribute. Parsing of the attribute is determined by the various syntactic forms attributes can take, such as GNU, C++11, and Microsoft style attributes, as well as other information provided by the table definition of the attribute. Ultimately, the -parsed representation of an attribute object is an ``AttributeList`` object. +parsed representation of an attribute object is an ``ParsedAttr`` object. These parsed attributes chain together as a list of parsed attributes attached to a declarator or declaration specifier. The parsing of attributes is handled automatically by Clang, except for attributes spelled as keywords. When implementing a keyword attribute, the parsing of the keyword and creation of the -``AttributeList`` object must be done manually. +``ParsedAttr`` object must be done manually. Eventually, ``Sema::ProcessDeclAttributeList()`` is called with a ``Decl`` and -an ``AttributeList``, at which point the parsed attribute can be transformed +an ``ParsedAttr``, at which point the parsed attribute can be transformed into a semantic attribute. The process by which a parsed attribute is converted into a semantic attribute depends on the attribute definition and semantic requirements of the attribute. The end result, however, is that the semantic @@ -1751,8 +1751,8 @@ subjects in the list, but a custom diagnostic parameter can also be specified in the ``SubjectList``. The diagnostics generated for subject list violations are either ``diag::warn_attribute_wrong_decl_type`` or ``diag::err_attribute_wrong_decl_type``, and the parameter enumeration is found -in `include/clang/Sema/AttributeList.h -<http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/AttributeList.h?view=markup>`_ +in `include/clang/Sema/ParsedAttr.h +<http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?view=markup>`_ If a previously unused Decl node is added to the ``SubjectList``, the logic used to automatically determine the diagnostic parameter in `utils/TableGen/ClangAttrEmitter.cpp <http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?view=markup>`_ @@ -1887,7 +1887,7 @@ requirements. To support this feature, an attribute inheriting from should be the same value between all arguments sharing a spelling, and corresponds to the parsed attribute's ``Kind`` enumerator. This allows attributes to share a parsed attribute kind, but have distinct semantic -attribute classes. For instance, ``AttributeList::AT_Interrupt`` is the shared +attribute classes. For instance, ``ParsedAttr`` is the shared parsed attribute kind, but ARMInterruptAttr and MSP430InterruptAttr are the semantic attributes generated. diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index c2edbbd..0219c71 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -509,7 +509,7 @@ class TargetSpecificAttr<TargetSpec target> { // "exists" for a given target. So two target-specific attributes can share // the same name when they exist in different targets. To support this, a // Kind can be explicitly specified for a target-specific attribute. This - // corresponds to the AttributeList::AT_* enum that is generated and it + // corresponds to the ParsedAttr::AT_* enum that is generated and it // should contain a shared value between the attributes. // // Target-specific attributes which use this feature should ensure that the diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index f4d9f01..c6ffcde 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -238,7 +238,7 @@ class Parser : public CodeCompletionHandler { unsigned getDepth() const { return Depth; } }; - /// Factory object for creating AttributeList objects. + /// Factory object for creating ParsedAttr objects. AttributeFactory AttrFactory; /// Gathers and cleans up TemplateIdAnnotations when parsing of a @@ -2361,7 +2361,7 @@ private: ParseAttributeArgsCommon(IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); void MaybeParseGNUAttributes(Declarator &D, LateParsedAttrList *LateAttrs = nullptr) { @@ -2384,19 +2384,16 @@ private: Declarator *D = nullptr); void ParseGNUAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc, - ParsedAttributes &Attrs, - SourceLocation *EndLoc, - IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, - AttributeList::Syntax Syntax, - Declarator *D); + ParsedAttributes &Attrs, SourceLocation *EndLoc, + IdentifierInfo *ScopeName, SourceLocation ScopeLoc, + ParsedAttr::Syntax Syntax, Declarator *D); IdentifierLoc *ParseIdentifierLoc(); unsigned ParseClangAttributeArgs(IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); void MaybeParseCXX11Attributes(Declarator &D) { if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) { @@ -2482,7 +2479,7 @@ private: SourceLocation *endLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); Optional<AvailabilitySpec> ParseAvailabilitySpec(); ExprResult ParseAvailabilityCheckExpr(SourceLocation StartLoc); @@ -2493,7 +2490,7 @@ private: SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); void ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated, SourceLocation ObjCBridgeRelatedLoc, @@ -2501,7 +2498,7 @@ private: SourceLocation *endLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); void ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName, SourceLocation AttrNameLoc, @@ -2509,15 +2506,13 @@ private: SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); - - void ParseAttributeWithTypeArg(IdentifierInfo &AttrName, - SourceLocation AttrNameLoc, - ParsedAttributes &Attrs, - SourceLocation *EndLoc, - IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, - AttributeList::Syntax Syntax); + ParsedAttr::Syntax Syntax); + + void + ParseAttributeWithTypeArg(IdentifierInfo &AttrName, + SourceLocation AttrNameLoc, ParsedAttributes &Attrs, + SourceLocation *EndLoc, IdentifierInfo *ScopeName, + SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax); void ParseTypeofSpecifier(DeclSpec &DS); SourceLocation ParseDecltypeSpecifier(DeclSpec &DS); diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 77e90a9..02afb093 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -29,8 +29,8 @@ #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/Specifiers.h" #include "clang/Lex/Token.h" -#include "clang/Sema/AttributeList.h" #include "clang/Sema/Ownership.h" +#include "clang/Sema/ParsedAttr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" @@ -2406,7 +2406,7 @@ public: /// Return a source range list of C++11 attributes associated /// with the declarator. void getCXX11AttributeRanges(SmallVectorImpl<SourceRange> &Ranges) { - for (const AttributeList &AL : Attrs) + for (const ParsedAttr &AL : Attrs) if (AL.isCXX11Attribute()) Ranges.push_back(AL.getRange()); } diff --git a/clang/include/clang/Sema/LoopHint.h b/clang/include/clang/Sema/LoopHint.h index 0da1136..171435e 100644 --- a/clang/include/clang/Sema/LoopHint.h +++ b/clang/include/clang/Sema/LoopHint.h @@ -12,8 +12,8 @@ #include "clang/Basic/IdentifierTable.h" #include "clang/Basic/SourceLocation.h" -#include "clang/Sema/AttributeList.h" #include "clang/Sema/Ownership.h" +#include "clang/Sema/ParsedAttr.h" namespace clang { diff --git a/clang/include/clang/Sema/AttributeList.h b/clang/include/clang/Sema/ParsedAttr.h index 70a0306..3f29324 100644 --- a/clang/include/clang/Sema/AttributeList.h +++ b/clang/include/clang/Sema/ParsedAttr.h @@ -1,4 +1,4 @@ -//===- AttributeList.h - Parsed attribute sets ------------------*- C++ -*-===// +//======- ParsedAttr.h - Parsed attribute sets ------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file defines the AttributeList class, which is used to collect +// This file defines the ParsedAttr class, which is used to collect // parsed attributes. // //===----------------------------------------------------------------------===// @@ -60,7 +60,7 @@ enum AvailabilitySlot { IntroducedSlot, DeprecatedSlot, ObsoletedSlot, NumAvailabilitySlots }; -/// Describes the trailing object for Availability attribute in AttributeList. +/// Describes the trailing object for Availability attribute in ParsedAttr. struct AvailabilityData { AvailabilityChange Changes[NumAvailabilitySlots]; SourceLocation StrictLoc; @@ -89,11 +89,11 @@ struct IdentifierLoc { }; /// A union of the various pointer types that can be passed to an -/// AttributeList as an argument. +/// ParsedAttr as an argument. using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>; using ArgsVector = llvm::SmallVector<ArgsUnion, 12U>; -/// AttributeList - Represents a syntactic attribute. +/// ParsedAttr - Represents a syntactic attribute. /// /// For a GNU attribute, there are four forms of this construct: /// @@ -102,7 +102,7 @@ using ArgsVector = llvm::SmallVector<ArgsUnion, 12U>; /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used. /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used. /// -class AttributeList { // TODO: This should really be called ParsedAttribute +class ParsedAttr { // TODO: This should really be called ParsedAttribute public: /// The style used to specify an attribute. enum Syntax { @@ -215,10 +215,10 @@ private: friend class AttributePool; /// Constructor for attributes with expression arguments. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ArgsUnion *args, unsigned numArgs, - Syntax syntaxUsed, SourceLocation ellipsisLoc) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + ArgsUnion *args, unsigned numArgs, Syntax syntaxUsed, + SourceLocation ellipsisLoc) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), ScopeLoc(scopeLoc), EllipsisLoc(ellipsisLoc), NumArgs(numArgs), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), @@ -229,15 +229,13 @@ private: } /// Constructor for availability attributes. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Parm, const AvailabilityChange &introduced, - const AvailabilityChange &deprecated, - const AvailabilityChange &obsoleted, - SourceLocation unavailable, - const Expr *messageExpr, - Syntax syntaxUsed, SourceLocation strict, - const Expr *replacementExpr) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Parm, const AvailabilityChange &introduced, + const AvailabilityChange &deprecated, + const AvailabilityChange &obsoleted, SourceLocation unavailable, + const Expr *messageExpr, Syntax syntaxUsed, SourceLocation strict, + const Expr *replacementExpr) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(true), @@ -252,12 +250,10 @@ private: } /// Constructor for objc_bridge_related attributes. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Parm1, - IdentifierLoc *Parm2, - IdentifierLoc *Parm3, - Syntax syntaxUsed) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Parm1, IdentifierLoc *Parm2, IdentifierLoc *Parm3, + Syntax syntaxUsed) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), ScopeLoc(scopeLoc), NumArgs(3), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), @@ -271,10 +267,10 @@ private: } /// Constructor for type_tag_for_datatype attribute. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *ArgKind, ParsedType matchingCType, - bool layoutCompatible, bool mustBeNull, Syntax syntaxUsed) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *ArgKind, ParsedType matchingCType, + bool layoutCompatible, bool mustBeNull, Syntax syntaxUsed) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), @@ -290,9 +286,9 @@ private: } /// Constructor for attributes with a single type argument. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ParsedType typeArg, Syntax syntaxUsed) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + ParsedType typeArg, Syntax syntaxUsed) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), @@ -303,13 +299,13 @@ private: } /// Constructor for microsoft __declspec(property) attribute. - AttributeList(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierInfo *getterId, IdentifierInfo *setterId, - Syntax syntaxUsed) + ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierInfo *getterId, IdentifierInfo *setterId, + Syntax syntaxUsed) : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), - ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), - Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), + ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false), + UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false), HasProcessingCache(false) { new (&getPropertyDataBuffer()) PropertyData(getterId, setterId); @@ -350,9 +346,9 @@ private: size_t allocated_size() const; public: - AttributeList(const AttributeList &) = delete; - AttributeList &operator=(const AttributeList &) = delete; - ~AttributeList() = delete; + ParsedAttr(const ParsedAttr &) = delete; + ParsedAttr &operator=(const ParsedAttr &) = delete; + ~ParsedAttr() = delete; void operator delete(void *) = delete; @@ -559,18 +555,17 @@ public: /// The required allocation size of an availability attribute, /// which we want to ensure is a multiple of sizeof(void*). AvailabilityAllocSize = - sizeof(AttributeList) - + ((sizeof(AvailabilityData) + sizeof(void*) + sizeof(ArgsUnion) - 1) - / sizeof(void*) * sizeof(void*)), - TypeTagForDatatypeAllocSize = - sizeof(AttributeList) - + (sizeof(AttributeList::TypeTagForDatatypeData) + sizeof(void *) + - sizeof(ArgsUnion) - 1) - / sizeof(void*) * sizeof(void*), + sizeof(ParsedAttr) + + ((sizeof(AvailabilityData) + sizeof(void *) + sizeof(ArgsUnion) - 1) / + sizeof(void *) * sizeof(void *)), + TypeTagForDatatypeAllocSize = sizeof(ParsedAttr) + + (sizeof(ParsedAttr::TypeTagForDatatypeData) + + sizeof(void *) + sizeof(ArgsUnion) - 1) / + sizeof(void *) * sizeof(void *), PropertyAllocSize = - sizeof(AttributeList) - + (sizeof(AttributeList::PropertyData) + sizeof(void *) - 1) - / sizeof(void*) * sizeof(void*) + sizeof(ParsedAttr) + + (sizeof(ParsedAttr::PropertyData) + sizeof(void *) - 1) / + sizeof(void *) * sizeof(void *) }; private: @@ -581,15 +576,14 @@ private: /// attribute that needs more than that; on x86-64 you'd need 10 /// expression arguments, and on i386 you'd need 19. InlineFreeListsCapacity = - 1 + (AvailabilityAllocSize - sizeof(AttributeList)) / sizeof(void*) + 1 + (AvailabilityAllocSize - sizeof(ParsedAttr)) / sizeof(void *) }; llvm::BumpPtrAllocator Alloc; /// Free lists. The index is determined by the following formula: - /// (size - sizeof(AttributeList)) / sizeof(void*) - SmallVector<SmallVector<AttributeList *, 8>, InlineFreeListsCapacity> - FreeLists; + /// (size - sizeof(ParsedAttr)) / sizeof(void*) + SmallVector<SmallVector<ParsedAttr *, 8>, InlineFreeListsCapacity> FreeLists; // The following are the private interface used by AttributePool. friend class AttributePool; @@ -597,7 +591,7 @@ private: /// Allocate an attribute of the given size. void *allocate(size_t size); - void deallocate(AttributeList *AL); + void deallocate(ParsedAttr *AL); /// Reclaim all the attributes in the given pool chain, which is /// non-empty. Note that the current implementation is safe @@ -614,18 +608,18 @@ public: class AttributePool { friend class AttributeFactory; AttributeFactory &Factory; - llvm::TinyPtrVector<AttributeList *> Attrs; + llvm::TinyPtrVector<ParsedAttr *> Attrs; void *allocate(size_t size) { return Factory.allocate(size); } - AttributeList *add(AttributeList *attr) { + ParsedAttr *add(ParsedAttr *attr) { Attrs.push_back(attr); return attr; } - void remove(AttributeList *attr) { + void remove(ParsedAttr *attr) { assert(llvm::is_contained(Attrs, attr) && "Can't take attribute from a pool that doesn't own it!"); Attrs.erase(llvm::find(Attrs, attr)); @@ -657,97 +651,93 @@ public: pool.Attrs.clear(); } - AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ArgsUnion *args, unsigned numArgs, - AttributeList::Syntax syntax, - SourceLocation ellipsisLoc = SourceLocation()) { - void *memory = - allocate(sizeof(AttributeList) + numArgs * sizeof(ArgsUnion)); - return add(new (memory) - AttributeList(attrName, attrRange, scopeName, scopeLoc, args, - numArgs, syntax, ellipsisLoc)); - } - - AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Param, - const AvailabilityChange &introduced, - const AvailabilityChange &deprecated, - const AvailabilityChange &obsoleted, - SourceLocation unavailable, const Expr *MessageExpr, - AttributeList::Syntax syntax, SourceLocation strict, - const Expr *ReplacementExpr) { + ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + ArgsUnion *args, unsigned numArgs, + ParsedAttr::Syntax syntax, + SourceLocation ellipsisLoc = SourceLocation()) { + void *memory = allocate(sizeof(ParsedAttr) + numArgs * sizeof(ArgsUnion)); + return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, + args, numArgs, syntax, ellipsisLoc)); + } + + ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param, const AvailabilityChange &introduced, + const AvailabilityChange &deprecated, + const AvailabilityChange &obsoleted, + SourceLocation unavailable, const Expr *MessageExpr, + ParsedAttr::Syntax syntax, SourceLocation strict, + const Expr *ReplacementExpr) { void *memory = allocate(AttributeFactory::AvailabilityAllocSize); - return add(new (memory) AttributeList( + return add(new (memory) ParsedAttr( attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated, obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr)); } - AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Param1, IdentifierLoc *Param2, - IdentifierLoc *Param3, AttributeList::Syntax syntax) { - size_t size = sizeof(AttributeList) + 3 * sizeof(ArgsUnion); + ParsedAttr *create(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param1, IdentifierLoc *Param2, + IdentifierLoc *Param3, ParsedAttr::Syntax syntax) { + size_t size = sizeof(ParsedAttr) + 3 * sizeof(ArgsUnion); void *memory = allocate(size); - return add(new (memory) - AttributeList(attrName, attrRange, scopeName, scopeLoc, - Param1, Param2, Param3, syntax)); + return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, + Param1, Param2, Param3, syntax)); } - AttributeList * + ParsedAttr * createTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, - bool mustBeNull, AttributeList::Syntax syntax) { + bool mustBeNull, ParsedAttr::Syntax syntax) { void *memory = allocate(AttributeFactory::TypeTagForDatatypeAllocSize); - return add(new (memory) AttributeList( - attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType, - layoutCompatible, mustBeNull, syntax)); + return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, + argumentKind, matchingCType, + layoutCompatible, mustBeNull, syntax)); } - AttributeList * - createTypeAttribute(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ParsedType typeArg, AttributeList::Syntax syntaxUsed) { - void *memory = allocate(sizeof(AttributeList) + sizeof(void *)); - return add(new (memory) AttributeList(attrName, attrRange, scopeName, - scopeLoc, typeArg, syntaxUsed)); + ParsedAttr *createTypeAttribute(IdentifierInfo *attrName, + SourceRange attrRange, + IdentifierInfo *scopeName, + SourceLocation scopeLoc, ParsedType typeArg, + ParsedAttr::Syntax syntaxUsed) { + void *memory = allocate(sizeof(ParsedAttr) + sizeof(void *)); + return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, + typeArg, syntaxUsed)); } - AttributeList * + ParsedAttr * createPropertyAttribute(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, - AttributeList::Syntax syntaxUsed) { + ParsedAttr::Syntax syntaxUsed) { void *memory = allocate(AttributeFactory::PropertyAllocSize); - return add(new (memory) - AttributeList(attrName, attrRange, scopeName, scopeLoc, - getterId, setterId, syntaxUsed)); + return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc, + getterId, setterId, syntaxUsed)); } }; class ParsedAttributesView { - using VecTy = llvm::TinyPtrVector<AttributeList *>; + using VecTy = llvm::TinyPtrVector<ParsedAttr *>; using SizeType = decltype(std::declval<VecTy>().size()); public: bool empty() const { return AttrList.empty(); } SizeType size() const { return AttrList.size(); } - AttributeList &operator[](SizeType pos) { return *AttrList[pos]; } - const AttributeList &operator[](SizeType pos) const { return *AttrList[pos]; } + ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; } + const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; } - void addAtStart(AttributeList *newAttr) { + void addAtStart(ParsedAttr *newAttr) { assert(newAttr); AttrList.insert(AttrList.begin(), newAttr); } - void addAtEnd(AttributeList *newAttr) { + void addAtEnd(ParsedAttr *newAttr) { assert(newAttr); AttrList.push_back(newAttr); } - void remove(AttributeList *ToBeRemoved) { + void remove(ParsedAttr *ToBeRemoved) { assert(is_contained(AttrList, ToBeRemoved) && "Cannot remove attribute that isn't in the list"); AttrList.erase(llvm::find(AttrList, ToBeRemoved)); @@ -757,7 +747,7 @@ public: struct iterator : llvm::iterator_adaptor_base<iterator, VecTy::iterator, std::random_access_iterator_tag, - AttributeList> { + ParsedAttr> { iterator() : iterator_adaptor_base(nullptr) {} iterator(VecTy::iterator I) : iterator_adaptor_base(I) {} reference operator*() { return **I; } @@ -766,7 +756,7 @@ public: struct const_iterator : llvm::iterator_adaptor_base<const_iterator, VecTy::const_iterator, std::random_access_iterator_tag, - AttributeList> { + ParsedAttr> { const_iterator() : iterator_adaptor_base(nullptr) {} const_iterator(VecTy::const_iterator I) : iterator_adaptor_base(I) {} @@ -795,9 +785,9 @@ public: iterator end() { return iterator(AttrList.end()); } const_iterator end() const { return const_iterator(AttrList.end()); } - bool hasAttribute(AttributeList::Kind K) const { + bool hasAttribute(ParsedAttr::Kind K) const { return llvm::any_of( - AttrList, [K](const AttributeList *AL) { return AL->getKind() == K; }); + AttrList, [K](const ParsedAttr *AL) { return AL->getKind() == K; }); } private: @@ -829,86 +819,76 @@ public: } /// Add attribute with expression arguments. - AttributeList *addNew(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ArgsUnion *args, unsigned numArgs, - AttributeList::Syntax syntax, - SourceLocation ellipsisLoc = SourceLocation()) { - AttributeList *attr = - pool.create(attrName, attrRange, scopeName, scopeLoc, args, numArgs, - syntax, ellipsisLoc); + ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + ArgsUnion *args, unsigned numArgs, + ParsedAttr::Syntax syntax, + SourceLocation ellipsisLoc = SourceLocation()) { + ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc, + args, numArgs, syntax, ellipsisLoc); addAtStart(attr); return attr; } /// Add availability attribute. - AttributeList *addNew(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Param, - const AvailabilityChange &introduced, - const AvailabilityChange &deprecated, - const AvailabilityChange &obsoleted, - SourceLocation unavailable, - const Expr *MessageExpr, - AttributeList::Syntax syntax, - SourceLocation strict, const Expr *ReplacementExpr) { - AttributeList *attr = - pool.create(attrName, attrRange, scopeName, scopeLoc, Param, introduced, - deprecated, obsoleted, unavailable, MessageExpr, syntax, - strict, ReplacementExpr); + ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param, const AvailabilityChange &introduced, + const AvailabilityChange &deprecated, + const AvailabilityChange &obsoleted, + SourceLocation unavailable, const Expr *MessageExpr, + ParsedAttr::Syntax syntax, SourceLocation strict, + const Expr *ReplacementExpr) { + ParsedAttr *attr = pool.create( + attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated, + obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr); addAtStart(attr); return attr; } /// Add objc_bridge_related attribute. - AttributeList *addNew(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *Param1, - IdentifierLoc *Param2, - IdentifierLoc *Param3, - AttributeList::Syntax syntax) { - AttributeList *attr = - pool.create(attrName, attrRange, scopeName, scopeLoc, - Param1, Param2, Param3, syntax); + ParsedAttr *addNew(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param1, IdentifierLoc *Param2, + IdentifierLoc *Param3, ParsedAttr::Syntax syntax) { + ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc, + Param1, Param2, Param3, syntax); addAtStart(attr); return attr; } /// Add type_tag_for_datatype attribute. - AttributeList *addNewTypeTagForDatatype( - IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierLoc *argumentKind, ParsedType matchingCType, - bool layoutCompatible, bool mustBeNull, - AttributeList::Syntax syntax) { - AttributeList *attr = - pool.createTypeTagForDatatype(attrName, attrRange, - scopeName, scopeLoc, - argumentKind, matchingCType, - layoutCompatible, mustBeNull, syntax); + ParsedAttr * + addNewTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *argumentKind, + ParsedType matchingCType, bool layoutCompatible, + bool mustBeNull, ParsedAttr::Syntax syntax) { + ParsedAttr *attr = pool.createTypeTagForDatatype( + attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType, + layoutCompatible, mustBeNull, syntax); addAtStart(attr); return attr; } /// Add an attribute with a single type argument. - AttributeList * - addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - ParsedType typeArg, AttributeList::Syntax syntaxUsed) { - AttributeList *attr = - pool.createTypeAttribute(attrName, attrRange, scopeName, scopeLoc, - typeArg, syntaxUsed); + ParsedAttr *addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + ParsedType typeArg, + ParsedAttr::Syntax syntaxUsed) { + ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName, + scopeLoc, typeArg, syntaxUsed); addAtStart(attr); return attr; } /// Add microsoft __delspec(property) attribute. - AttributeList * + ParsedAttr * addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange, - IdentifierInfo *scopeName, SourceLocation scopeLoc, - IdentifierInfo *getterId, IdentifierInfo *setterId, - AttributeList::Syntax syntaxUsed) { - AttributeList *attr = + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierInfo *getterId, IdentifierInfo *setterId, + ParsedAttr::Syntax syntaxUsed) { + ParsedAttr *attr = pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc, getterId, setterId, syntaxUsed); addAtStart(attr); diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 12a3867..e4e1467 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -76,7 +76,7 @@ namespace clang { class ASTReader; class ASTWriter; class ArrayType; - class AttributeList; + class ParsedAttr; class BindingDecl; class BlockDecl; class CapturedDecl; @@ -494,7 +494,7 @@ public: /// \#pragma clang attribute. struct PragmaAttributeEntry { SourceLocation Loc; - AttributeList *Attribute; + ParsedAttr *Attribute; SmallVector<attr::SubjectMatchRule, 4> MatchRules; bool IsUsed; }; @@ -2224,7 +2224,7 @@ public: Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, - const AttributeList &MSPropertyAttr); + const ParsedAttr &MSPropertyAttr); FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, @@ -3321,11 +3321,10 @@ public: // Helper for delayed processing of attributes. void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList); - void ProcessDeclAttributeList(Scope *S, Decl *D, - const ParsedAttributesView &AL, - bool IncludeCXX11Attributes = true); + void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, + bool IncludeCXX11Attributes = true); bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, - const ParsedAttributesView &AttrList); + const ParsedAttributesView &AttrList); void checkUnusedDeclAttributes(Declarator &D); @@ -3335,13 +3334,13 @@ public: /// type as valid. bool isValidPointerAttrType(QualType T, bool RefOkay = false); - bool CheckRegparmAttr(const AttributeList &attr, unsigned &value); - bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, + bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value); + bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD = nullptr); - bool CheckAttrTarget(const AttributeList &CurrAttr); - bool CheckAttrNoArgs(const AttributeList &CurrAttr); - bool checkStringLiteralArgumentAttr(const AttributeList &Attr, - unsigned ArgNum, StringRef &Str, + bool CheckAttrTarget(const ParsedAttr &CurrAttr); + bool CheckAttrNoArgs(const ParsedAttr &CurrAttr); + bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum, + StringRef &Str, SourceLocation *ArgLocation = nullptr); bool checkSectionName(SourceLocation LiteralLoc, StringRef Str); bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str); @@ -8446,8 +8445,7 @@ public: void AddCFAuditedAttribute(Decl *D); /// Called on well-formed '\#pragma clang attribute push'. - void ActOnPragmaAttributePush(AttributeList &Attribute, - SourceLocation PragmaLoc, + void ActOnPragmaAttributePush(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules); /// Called on well-formed '\#pragma clang attribute pop'. diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 4b6b2b3..9b552e1 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -162,14 +162,14 @@ void Parser::ParseGNUAttributes(ParsedAttributes &attrs, if (Tok.isNot(tok::l_paren)) { attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_GNU); + ParsedAttr::AS_GNU); continue; } // Handle "parameterized" attributes if (!LateAttrs || !isAttributeLateParsed(*AttrName)) { ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc, nullptr, - SourceLocation(), AttributeList::AS_GNU, D); + SourceLocation(), ParsedAttr::AS_GNU, D); continue; } @@ -249,7 +249,7 @@ void Parser::ParseAttributeWithTypeArg(IdentifierInfo &AttrName, SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax) { + ParsedAttr::Syntax Syntax) { BalancedDelimiterTracker Parens(*this, tok::l_paren); Parens.consumeOpen(); @@ -275,7 +275,7 @@ void Parser::ParseAttributeWithTypeArg(IdentifierInfo &AttrName, unsigned Parser::ParseAttributeArgsCommon( IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, AttributeList::Syntax Syntax) { + SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax) { // Ignore the left paren location for now. ConsumeParen(); @@ -283,13 +283,13 @@ unsigned Parser::ParseAttributeArgsCommon( if (Tok.is(tok::identifier)) { // If this attribute wants an 'identifier' argument, make it so. bool IsIdentifierArg = attributeHasIdentifierArg(*AttrName); - AttributeList::Kind AttrKind = - AttributeList::getKind(AttrName, ScopeName, Syntax); + ParsedAttr::Kind AttrKind = + ParsedAttr::getKind(AttrName, ScopeName, Syntax); // If we don't know how to parse this attribute, but this is the only // token in this argument, assume it's meant to be an identifier. - if (AttrKind == AttributeList::UnknownAttribute || - AttrKind == AttributeList::IgnoredAttribute) { + if (AttrKind == ParsedAttr::UnknownAttribute || + AttrKind == ParsedAttr::IgnoredAttribute) { const Token &Next = NextToken(); IsIdentifierArg = Next.isOneOf(tok::r_paren, tok::comma); } @@ -343,27 +343,27 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax, + ParsedAttr::Syntax Syntax, Declarator *D) { assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); - AttributeList::Kind AttrKind = - AttributeList::getKind(AttrName, ScopeName, Syntax); + ParsedAttr::Kind AttrKind = + ParsedAttr::getKind(AttrName, ScopeName, Syntax); - if (AttrKind == AttributeList::AT_Availability) { + if (AttrKind == ParsedAttr::AT_Availability) { ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); return; - } else if (AttrKind == AttributeList::AT_ExternalSourceSymbol) { + } else if (AttrKind == ParsedAttr::AT_ExternalSourceSymbol) { ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); return; - } else if (AttrKind == AttributeList::AT_ObjCBridgeRelated) { + } else if (AttrKind == ParsedAttr::AT_ObjCBridgeRelated) { ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); return; - } else if (AttrKind == AttributeList::AT_TypeTagForDatatype) { + } else if (AttrKind == ParsedAttr::AT_TypeTagForDatatype) { ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); return; @@ -395,29 +395,29 @@ void Parser::ParseGNUAttributeArgs(IdentifierInfo *AttrName, unsigned Parser::ParseClangAttributeArgs( IdentifierInfo *AttrName, SourceLocation AttrNameLoc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, AttributeList::Syntax Syntax) { + SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax) { assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); - AttributeList::Kind AttrKind = - AttributeList::getKind(AttrName, ScopeName, Syntax); + ParsedAttr::Kind AttrKind = + ParsedAttr::getKind(AttrName, ScopeName, Syntax); switch (AttrKind) { default: return ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); - case AttributeList::AT_ExternalSourceSymbol: + case ParsedAttr::AT_ExternalSourceSymbol: ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); break; - case AttributeList::AT_Availability: + case ParsedAttr::AT_Availability: ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); break; - case AttributeList::AT_ObjCBridgeRelated: + case ParsedAttr::AT_ObjCBridgeRelated: ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); break; - case AttributeList::AT_TypeTagForDatatype: + case ParsedAttr::AT_TypeTagForDatatype: ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName, ScopeLoc, Syntax); break; @@ -549,14 +549,14 @@ bool Parser::ParseMicrosoftDeclSpecArgs(IdentifierInfo *AttrName, if (!HasInvalidAccessor) Attrs.addNewPropertyAttr(AttrName, AttrNameLoc, nullptr, SourceLocation(), AccessorNames[AK_Get], AccessorNames[AK_Put], - AttributeList::AS_Declspec); + ParsedAttr::AS_Declspec); T.skipToEnd(); return !HasInvalidAccessor; } unsigned NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, nullptr, nullptr, - SourceLocation(), AttributeList::AS_Declspec); + SourceLocation(), ParsedAttr::AS_Declspec); // If this attribute's args were parsed, and it was expected to have // arguments but none were provided, emit a diagnostic. @@ -631,7 +631,7 @@ void Parser::ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs, if (!AttrHandled) Attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Declspec); + ParsedAttr::AS_Declspec); } T.consumeClose(); if (End) @@ -657,7 +657,7 @@ void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); break; } default: @@ -708,7 +708,7 @@ void Parser::ParseBorlandTypeAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); } } @@ -718,7 +718,7 @@ void Parser::ParseOpenCLKernelAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); } } @@ -726,7 +726,7 @@ void Parser::ParseOpenCLQualifiers(ParsedAttributes &Attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = Tok.getLocation(); Attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); } void Parser::ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs) { @@ -742,7 +742,7 @@ void Parser::ParseNullabilityTypeSpecifiers(ParsedAttributes &attrs) { Diag(AttrNameLoc, diag::ext_nullability) << AttrName; attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); break; } default: @@ -905,7 +905,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, SourceLocation *endLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax) { + ParsedAttr::Syntax Syntax) { enum { Introduced, Deprecated, Obsoleted, Unknown }; AvailabilityChange Changes[Unknown]; ExprResult MessageExpr, ReplacementExpr; @@ -1122,7 +1122,7 @@ void Parser::ParseAvailabilityAttribute(IdentifierInfo &Availability, void Parser::ParseExternalSourceSymbolAttribute( IdentifierInfo &ExternalSourceSymbol, SourceLocation Loc, ParsedAttributes &Attrs, SourceLocation *EndLoc, IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, AttributeList::Syntax Syntax) { + SourceLocation ScopeLoc, ParsedAttr::Syntax Syntax) { // Opening '('. BalancedDelimiterTracker T(*this, tok::l_paren); if (T.expectAndConsume()) @@ -1236,7 +1236,7 @@ void Parser::ParseObjCBridgeRelatedAttribute(IdentifierInfo &ObjCBridgeRelated, SourceLocation *endLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax) { + ParsedAttr::Syntax Syntax) { // Opening '('. BalancedDelimiterTracker T(*this, tok::l_paren); if (T.consumeOpen()) { @@ -1415,7 +1415,7 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA, Actions.ActOnReenterFunctionContext(Actions.CurScope, D); ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc, - nullptr, SourceLocation(), AttributeList::AS_GNU, + nullptr, SourceLocation(), ParsedAttr::AS_GNU, nullptr); if (HasFunScope) { @@ -1429,7 +1429,7 @@ void Parser::ParseLexedAttribute(LateParsedAttribute &LA, // If there are multiple decls, then the decl cannot be within the // function scope. ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc, - nullptr, SourceLocation(), AttributeList::AS_GNU, + nullptr, SourceLocation(), ParsedAttr::AS_GNU, nullptr); } } else { @@ -1459,7 +1459,7 @@ void Parser::ParseTypeTagForDatatypeAttribute(IdentifierInfo &AttrName, SourceLocation *EndLoc, IdentifierInfo *ScopeName, SourceLocation ScopeLoc, - AttributeList::Syntax Syntax) { + ParsedAttr::Syntax Syntax) { assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('"); BalancedDelimiterTracker T(*this, tok::l_paren); @@ -1581,10 +1581,10 @@ void Parser::DiagnoseProhibitedAttributes( void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs, unsigned DiagID) { - for (const AttributeList &AL : Attrs) { + for (const ParsedAttr &AL : Attrs) { if (!AL.isCXX11Attribute() && !AL.isC2xAttribute()) continue; - if (AL.getKind() == AttributeList::UnknownAttribute) + if (AL.getKind() == ParsedAttr::UnknownAttribute) Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName(); else { Diag(AL.getLoc(), DiagID) << AL.getName(); @@ -1606,16 +1606,16 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, if (TUK == Sema::TUK_Reference) return; - llvm::SmallVector<AttributeList *, 1> ToBeMoved; + llvm::SmallVector<ParsedAttr *, 1> ToBeMoved; - for (AttributeList &AL : DS.getAttributes()) { - if ((AL.getKind() == AttributeList::AT_Aligned && + for (ParsedAttr &AL : DS.getAttributes()) { + if ((AL.getKind() == ParsedAttr::AT_Aligned && AL.isDeclspecAttribute()) || AL.isMicrosoftAttribute()) ToBeMoved.push_back(&AL); } - for (AttributeList *AL : ToBeMoved) { + for (ParsedAttr *AL : ToBeMoved) { DS.getAttributes().remove(AL); Attrs.addAtEnd(AL); } @@ -2731,7 +2731,7 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs, ArgsVector ArgExprs; ArgExprs.push_back(ArgExpr.get()); Attrs.addNew(KWName, KWLoc, nullptr, KWLoc, ArgExprs.data(), 1, - AttributeList::AS_Keyword, EllipsisLoc); + ParsedAttr::AS_Keyword, EllipsisLoc); } /// Determine whether we're looking at something that might be a declarator @@ -3321,7 +3321,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = Tok.getLocation(); DS.getAttributes().addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, - nullptr, 0, AttributeList::AS_Keyword); + nullptr, 0, ParsedAttr::AS_Keyword); break; } @@ -3364,7 +3364,7 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, // Objective-C 'kindof' types. case tok::kw___kindof: DS.getAttributes().addNew(Tok.getIdentifierInfo(), Loc, nullptr, Loc, - nullptr, 0, AttributeList::AS_Keyword); + nullptr, 0, ParsedAttr::AS_Keyword); (void)ConsumeToken(); continue; @@ -5195,7 +5195,7 @@ void Parser::ParseTypeQualifierListOpt( // Objective-C 'kindof' types. case tok::kw___kindof: DS.getAttributes().addNew(Tok.getIdentifierInfo(), Loc, nullptr, Loc, - nullptr, 0, AttributeList::AS_Keyword); + nullptr, 0, ParsedAttr::AS_Keyword); (void)ConsumeToken(); continue; diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 166f7a8..7c4c83d 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1206,7 +1206,7 @@ void Parser::ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs) { IdentifierInfo *AttrName = Tok.getIdentifierInfo(); SourceLocation AttrNameLoc = ConsumeToken(); attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_Keyword); + ParsedAttr::AS_Keyword); } } @@ -2284,7 +2284,7 @@ bool Parser::ParseCXXMemberDeclaratorBeforeInitializer( if (!VS.isUnset()) { // If we saw any GNU-style attributes that are known to GCC followed by a // virt-specifier, issue a GCC-compat warning. - for (const AttributeList &AL : DeclaratorInfo.getAttributes()) + for (const ParsedAttr &AL : DeclaratorInfo.getAttributes()) if (AL.isKnownToGCC() && !AL.isCXX11Attribute()) Diag(AL.getLoc(), diag::warn_gcc_attribute_location); @@ -3803,16 +3803,15 @@ IdentifierInfo *Parser::TryParseCXX11AttributeIdentifier(SourceLocation &Loc) { static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName) { - switch (AttributeList::getKind(AttrName, ScopeName, - AttributeList::AS_CXX11)) { - case AttributeList::AT_CarriesDependency: - case AttributeList::AT_Deprecated: - case AttributeList::AT_FallThrough: - case AttributeList::AT_CXX11NoReturn: + switch (ParsedAttr::getKind(AttrName, ScopeName, ParsedAttr::AS_CXX11)) { + case ParsedAttr::AT_CarriesDependency: + case ParsedAttr::AT_Deprecated: + case ParsedAttr::AT_FallThrough: + case ParsedAttr::AT_CXX11NoReturn: return true; - case AttributeList::AT_WarnUnusedResult: + case ParsedAttr::AT_WarnUnusedResult: return !ScopeName && AttrName->getName().equals("nodiscard"); - case AttributeList::AT_Unused: + case ParsedAttr::AT_Unused: return !ScopeName && AttrName->getName().equals("maybe_unused"); default: return false; @@ -3842,8 +3841,8 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName, assert(Tok.is(tok::l_paren) && "Not a C++11 attribute argument list"); SourceLocation LParenLoc = Tok.getLocation(); const LangOptions &LO = getLangOpts(); - AttributeList::Syntax Syntax = - LO.CPlusPlus ? AttributeList::AS_CXX11 : AttributeList::AS_C2x; + ParsedAttr::Syntax Syntax = + LO.CPlusPlus ? ParsedAttr::AS_CXX11 : ParsedAttr::AS_C2x; // If the attribute isn't known, we will not attempt to parse any // arguments. @@ -3876,7 +3875,7 @@ bool Parser::ParseCXX11AttributeArgs(IdentifierInfo *AttrName, if (!Attrs.empty() && IsBuiltInOrStandardCXX11Attribute(AttrName, ScopeName)) { - AttributeList &Attr = *Attrs.begin(); + ParsedAttr &Attr = *Attrs.begin(); // If the attribute is a standard or built-in attribute and we are // parsing an argument list, we need to determine whether this attribute // was allowed to have an argument list (such as [[deprecated]]), and how @@ -4012,8 +4011,7 @@ void Parser::ParseCXX11AttributeSpecifier(ParsedAttributes &attrs, AttrName, SourceRange(ScopeLoc.isValid() ? ScopeLoc : AttrLoc, AttrLoc), ScopeName, ScopeLoc, nullptr, 0, - getLangOpts().CPlusPlus ? AttributeList::AS_CXX11 - : AttributeList::AS_C2x); + getLangOpts().CPlusPlus ? ParsedAttr::AS_CXX11 : ParsedAttr::AS_C2x); if (TryConsumeToken(tok::ellipsis)) Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) @@ -4165,7 +4163,7 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) { if (!T.consumeClose()) { Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), nullptr, SourceLocation(), ArgExprs.data(), ArgExprs.size(), - AttributeList::AS_Microsoft); + ParsedAttr::AS_Microsoft); } } diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index e23581d2..6470697 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1109,10 +1109,10 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer( // after '(...)'. nvcc doesn't accept this. auto WarnIfHasCUDATargetAttr = [&] { if (getLangOpts().CUDA) - for (const AttributeList &A : Attr) - if (A.getKind() == AttributeList::AT_CUDADevice || - A.getKind() == AttributeList::AT_CUDAHost || - A.getKind() == AttributeList::AT_CUDAGlobal) + for (const ParsedAttr &A : Attr) + if (A.getKind() == ParsedAttr::AT_CUDADevice || + A.getKind() == ParsedAttr::AT_CUDAHost || + A.getKind() == ParsedAttr::AT_CUDAGlobal) Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position) << A.getName()->getName(); }; diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 447eb96..5c5b3cd 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -376,10 +376,10 @@ static void addContextSensitiveTypeNullability(Parser &P, SourceLocation nullabilityLoc, bool &addedToDeclSpec) { // Create the attribute. - auto getNullabilityAttr = [&](AttributePool &Pool) -> AttributeList * { + auto getNullabilityAttr = [&](AttributePool &Pool) -> ParsedAttr * { return Pool.create(P.getNullabilityKeyword(nullability), SourceRange(nullabilityLoc), nullptr, SourceLocation(), - nullptr, 0, AttributeList::AS_ContextSensitiveKeyword); + nullptr, 0, ParsedAttr::AS_ContextSensitiveKeyword); }; if (D.getNumTypeObjects() > 0) { diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index 553b490..9a25f9c 100644 --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -1271,7 +1271,7 @@ getAttributeSubjectRulesRecoveryPointForToken(const Token &Tok) { /// suggests the possible attribute subject rules in a fix-it together with /// any other missing tokens. DiagnosticBuilder createExpectedAttributeSubjectRulesTokenDiagnostic( - unsigned DiagID, AttributeList &Attribute, + unsigned DiagID, ParsedAttr &Attribute, MissingAttributeSubjectRulesRecoveryPoint Point, Parser &PRef) { SourceLocation Loc = PRef.getEndOfPreviousToken(); if (Loc.isInvalid()) @@ -1371,12 +1371,11 @@ void Parser::HandlePragmaAttribute() { if (Tok.isNot(tok::l_paren)) Attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, - AttributeList::AS_GNU); + ParsedAttr::AS_GNU); else ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, /*EndLoc=*/nullptr, /*ScopeName=*/nullptr, - /*ScopeLoc=*/SourceLocation(), - AttributeList::AS_GNU, + /*ScopeLoc=*/SourceLocation(), ParsedAttr::AS_GNU, /*Declarator=*/nullptr); if (ExpectAndConsume(tok::r_paren)) @@ -1390,9 +1389,9 @@ void Parser::HandlePragmaAttribute() { if (Tok.getIdentifierInfo()) { // If we suspect that this is an attribute suggest the use of // '__attribute__'. - if (AttributeList::getKind(Tok.getIdentifierInfo(), /*ScopeName=*/nullptr, - AttributeList::AS_GNU) != - AttributeList::UnknownAttribute) { + if (ParsedAttr::getKind(Tok.getIdentifierInfo(), /*ScopeName=*/nullptr, + ParsedAttr::AS_GNU) != + ParsedAttr::UnknownAttribute) { SourceLocation InsertStartLoc = Tok.getLocation(); ConsumeToken(); if (Tok.is(tok::l_paren)) { @@ -1423,7 +1422,7 @@ void Parser::HandlePragmaAttribute() { return; } - AttributeList &Attribute = *Attrs.begin(); + ParsedAttr &Attribute = *Attrs.begin(); if (!Attribute.isSupportedByPragmaAttribute()) { Diag(PragmaLoc, diag::err_pragma_attribute_unsupported_attribute) << Attribute.getName(); diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 1127158..b16ce4f 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -1942,7 +1942,7 @@ StmtResult Parser::ParsePragmaLoopHint(StmtVector &Stmts, ArgsUnion(Hint.ValueExpr)}; TempAttrs.addNew(Hint.PragmaNameLoc->Ident, Hint.Range, nullptr, Hint.PragmaNameLoc->Loc, ArgHints, 4, - AttributeList::AS_Pragma); + ParsedAttr::AS_Pragma); } // Get the next statement. @@ -2267,7 +2267,7 @@ bool Parser::ParseOpenCLUnrollHintAttribute(ParsedAttributes &Attrs) { if (Attrs.empty()) return true; - if (Attrs.begin()->getKind() != AttributeList::AT_OpenCLUnrollHint) + if (Attrs.begin()->getKind() != ParsedAttr::AT_OpenCLUnrollHint) return true; if (!(Tok.is(tok::kw_for) || Tok.is(tok::kw_while) || Tok.is(tok::kw_do))) { diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 7bda21b..7a0b29c 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1089,7 +1089,7 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, // Check to make sure that any normal attributes are allowed to be on // a definition. Late parsed attributes are checked at the end. if (Tok.isNot(tok::equal)) { - for (const AttributeList &AL : D.getAttributes()) + for (const ParsedAttr &AL : D.getAttributes()) if (AL.isKnownToGCC() && !AL.isCXX11Attribute()) Diag(AL.getLoc(), diag::warn_attribute_on_function_definition) << AL.getName(); diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt index 7d9ae62..bad42a2 100644 --- a/clang/lib/Sema/CMakeLists.txt +++ b/clang/lib/Sema/CMakeLists.txt @@ -9,13 +9,13 @@ endif() add_clang_library(clangSema AnalysisBasedWarnings.cpp - AttributeList.cpp CodeCompleteConsumer.cpp DeclSpec.cpp DelayedDiagnostic.cpp IdentifierResolver.cpp JumpDiagnostics.cpp MultiplexExternalSemaSource.cpp + ParsedAttr.cpp Scope.cpp ScopeInfo.cpp Sema.cpp diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 01c9bad..ccca5d3 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -994,7 +994,7 @@ void DeclSpec::SaveWrittenBuiltinSpecs() { writtenBS.Width = getTypeSpecWidth(); writtenBS.Type = getTypeSpecType(); // Search the list of attributes for the presence of a mode attribute. - writtenBS.ModeAttr = getAttributes().hasAttribute(AttributeList::AT_Mode); + writtenBS.ModeAttr = getAttributes().hasAttribute(ParsedAttr::AT_Mode); } /// Finish - This does final analysis of the declspec, rejecting things like diff --git a/clang/lib/Sema/AttributeList.cpp b/clang/lib/Sema/ParsedAttr.cpp index 6d5c6a2..6509df9 100644 --- a/clang/lib/Sema/AttributeList.cpp +++ b/clang/lib/Sema/ParsedAttr.cpp @@ -1,4 +1,4 @@ -//===- AttributeList.cpp --------------------------------------------------===// +//======- ParsedAttr.cpp --------------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,11 +7,11 @@ // //===----------------------------------------------------------------------===// // -// This file defines the AttributeList class implementation +// This file defines the ParsedAttr class implementation // //===----------------------------------------------------------------------===// -#include "clang/Sema/AttributeList.h" +#include "clang/Sema/ParsedAttr.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/AttrSubjectMatchRules.h" #include "clang/Basic/IdentifierTable.h" @@ -34,15 +34,15 @@ IdentifierLoc *IdentifierLoc::create(ASTContext &Ctx, SourceLocation Loc, return Result; } -size_t AttributeList::allocated_size() const { +size_t ParsedAttr::allocated_size() const { if (IsAvailability) return AttributeFactory::AvailabilityAllocSize; else if (IsTypeTagForDatatype) return AttributeFactory::TypeTagForDatatypeAllocSize; else if (IsProperty) return AttributeFactory::PropertyAllocSize; else if (HasParsedType) - return sizeof(AttributeList) + sizeof(void *); - return (sizeof(AttributeList) + NumArgs * sizeof(ArgsUnion)); + return sizeof(ParsedAttr) + sizeof(void *); + return (sizeof(ParsedAttr) + NumArgs * sizeof(ArgsUnion)); } AttributeFactory::AttributeFactory() { @@ -52,16 +52,16 @@ AttributeFactory::AttributeFactory() { AttributeFactory::~AttributeFactory() = default; static size_t getFreeListIndexForSize(size_t size) { - assert(size >= sizeof(AttributeList)); + assert(size >= sizeof(ParsedAttr)); assert((size % sizeof(void*)) == 0); - return ((size - sizeof(AttributeList)) / sizeof(void*)); + return ((size - sizeof(ParsedAttr)) / sizeof(void *)); } void *AttributeFactory::allocate(size_t size) { // Check for a previously reclaimed attribute. size_t index = getFreeListIndexForSize(size); if (index < FreeLists.size() && !FreeLists[index].empty()) { - AttributeList *attr = FreeLists[index].back(); + ParsedAttr *attr = FreeLists[index].back(); FreeLists[index].pop_back(); return attr; } @@ -70,7 +70,7 @@ void *AttributeFactory::allocate(size_t size) { return Alloc.Allocate(size, alignof(AttributeFactory)); } -void AttributeFactory::deallocate(AttributeList *Attr) { +void AttributeFactory::deallocate(ParsedAttr *Attr) { size_t size = Attr->allocated_size(); size_t freeListIndex = getFreeListIndexForSize(size); @@ -88,7 +88,7 @@ void AttributeFactory::deallocate(AttributeList *Attr) { } void AttributeFactory::reclaimPool(AttributePool &cur) { - for (AttributeList *AL : cur.Attrs) + for (ParsedAttr *AL : cur.Attrs) deallocate(AL); } @@ -100,12 +100,13 @@ void AttributePool::takePool(AttributePool &pool) { #include "clang/Sema/AttrParsedAttrKinds.inc" static StringRef normalizeAttrName(StringRef AttrName, StringRef ScopeName, - AttributeList::Syntax SyntaxUsed) { + ParsedAttr::Syntax SyntaxUsed) { // Normalize the attribute name, __foo__ becomes foo. This is only allowable // for GNU attributes. - bool IsGNU = SyntaxUsed == AttributeList::AS_GNU || - ((SyntaxUsed == AttributeList::AS_CXX11 || - SyntaxUsed == AttributeList::AS_C2x) && ScopeName == "gnu"); + bool IsGNU = SyntaxUsed == ParsedAttr::AS_GNU || + ((SyntaxUsed == ParsedAttr::AS_CXX11 || + SyntaxUsed == ParsedAttr::AS_C2x) && + ScopeName == "gnu"); if (IsGNU && AttrName.size() >= 4 && AttrName.startswith("__") && AttrName.endswith("__")) AttrName = AttrName.slice(2, AttrName.size() - 2); @@ -113,9 +114,9 @@ static StringRef normalizeAttrName(StringRef AttrName, StringRef ScopeName, return AttrName; } -AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name, - const IdentifierInfo *ScopeName, - Syntax SyntaxUsed) { +ParsedAttr::Kind ParsedAttr::getKind(const IdentifierInfo *Name, + const IdentifierInfo *ScopeName, + Syntax SyntaxUsed) { StringRef AttrName = Name->getName(); SmallString<64> FullName; @@ -133,12 +134,12 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name, return ::getAttrKind(FullName, SyntaxUsed); } -unsigned AttributeList::getAttributeSpellingListIndex() const { +unsigned ParsedAttr::getAttributeSpellingListIndex() const { // Both variables will be used in tablegen generated // attribute spell list index matching code. StringRef Scope = ScopeName ? ScopeName->getName() : ""; StringRef Name = normalizeAttrName(AttrName->getName(), Scope, - (AttributeList::Syntax)SyntaxUsed); + (ParsedAttr::Syntax)SyntaxUsed); #include "clang/Sema/AttrSpellingListIndex.inc" @@ -154,11 +155,10 @@ struct ParsedAttrInfo { unsigned IsKnownToGCC : 1; unsigned IsSupportedByPragmaAttribute : 1; - bool (*DiagAppertainsToDecl)(Sema &S, const AttributeList &Attr, - const Decl *); - bool (*DiagLangOpts)(Sema &S, const AttributeList &Attr); + bool (*DiagAppertainsToDecl)(Sema &S, const ParsedAttr &Attr, const Decl *); + bool (*DiagLangOpts)(Sema &S, const ParsedAttr &Attr); bool (*ExistsInTarget)(const TargetInfo &Target); - unsigned (*SpellingIndexToSemanticSpelling)(const AttributeList &Attr); + unsigned (*SpellingIndexToSemanticSpelling)(const ParsedAttr &Attr); void (*GetPragmaAttributeMatchRules)( llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &Rules, const LangOptions &LangOpts); @@ -170,71 +170,63 @@ namespace { } // namespace -static const ParsedAttrInfo &getInfo(const AttributeList &A) { +static const ParsedAttrInfo &getInfo(const ParsedAttr &A) { return AttrInfoMap[A.getKind()]; } -unsigned AttributeList::getMinArgs() const { - return getInfo(*this).NumArgs; -} +unsigned ParsedAttr::getMinArgs() const { return getInfo(*this).NumArgs; } -unsigned AttributeList::getMaxArgs() const { +unsigned ParsedAttr::getMaxArgs() const { return getMinArgs() + getInfo(*this).OptArgs; } -bool AttributeList::hasCustomParsing() const { +bool ParsedAttr::hasCustomParsing() const { return getInfo(*this).HasCustomParsing; } -bool AttributeList::diagnoseAppertainsTo(Sema &S, const Decl *D) const { +bool ParsedAttr::diagnoseAppertainsTo(Sema &S, const Decl *D) const { return getInfo(*this).DiagAppertainsToDecl(S, *this, D); } -bool AttributeList::appliesToDecl(const Decl *D, - attr::SubjectMatchRule MatchRule) const { +bool ParsedAttr::appliesToDecl(const Decl *D, + attr::SubjectMatchRule MatchRule) const { return checkAttributeMatchRuleAppliesTo(D, MatchRule); } -void AttributeList::getMatchRules( +void ParsedAttr::getMatchRules( const LangOptions &LangOpts, SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules) const { return getInfo(*this).GetPragmaAttributeMatchRules(MatchRules, LangOpts); } -bool AttributeList::diagnoseLangOpts(Sema &S) const { +bool ParsedAttr::diagnoseLangOpts(Sema &S) const { return getInfo(*this).DiagLangOpts(S, *this); } -bool AttributeList::isTargetSpecificAttr() const { +bool ParsedAttr::isTargetSpecificAttr() const { return getInfo(*this).IsTargetSpecific; } -bool AttributeList::isTypeAttr() const { - return getInfo(*this).IsType; -} +bool ParsedAttr::isTypeAttr() const { return getInfo(*this).IsType; } -bool AttributeList::isStmtAttr() const { - return getInfo(*this).IsStmt; -} +bool ParsedAttr::isStmtAttr() const { return getInfo(*this).IsStmt; } -bool AttributeList::existsInTarget(const TargetInfo &Target) const { +bool ParsedAttr::existsInTarget(const TargetInfo &Target) const { return getInfo(*this).ExistsInTarget(Target); } -bool AttributeList::isKnownToGCC() const { - return getInfo(*this).IsKnownToGCC; -} +bool ParsedAttr::isKnownToGCC() const { return getInfo(*this).IsKnownToGCC; } -bool AttributeList::isSupportedByPragmaAttribute() const { +bool ParsedAttr::isSupportedByPragmaAttribute() const { return getInfo(*this).IsSupportedByPragmaAttribute; } -unsigned AttributeList::getSemanticSpelling() const { +unsigned ParsedAttr::getSemanticSpelling() const { return getInfo(*this).SpellingIndexToSemanticSpelling(*this); } -bool AttributeList::hasVariadicArg() const { +bool ParsedAttr::hasVariadicArg() const { // If the attribute has the maximum number of optional arguments, we will // claim that as being variadic. If we someday get an attribute that // legitimately bumps up against that maximum, we can use another bit to track diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp index cc155b7..4f3cf46 100644 --- a/clang/lib/Sema/SemaAttr.cpp +++ b/clang/lib/Sema/SemaAttr.cpp @@ -520,7 +520,7 @@ attrMatcherRuleListToString(ArrayRef<attr::SubjectMatchRule> Rules) { } // end anonymous namespace -void Sema::ActOnPragmaAttributePush(AttributeList &Attribute, +void Sema::ActOnPragmaAttributePush(ParsedAttr &Attribute, SourceLocation PragmaLoc, attr::ParsedSubjectMatchRuleSet Rules) { SmallVector<attr::SubjectMatchRule, 4> SubjectMatchRules; @@ -645,7 +645,7 @@ void Sema::AddPragmaAttributes(Scope *S, Decl *D) { if (PragmaAttributeStack.empty()) return; for (auto &Entry : PragmaAttributeStack) { - AttributeList *Attribute = Entry.Attribute; + ParsedAttr *Attribute = Entry.Attribute; assert(Attribute && "Expected an attribute"); // Ensure that the attribute can be applied to the given declaration. diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 5b81eb3..13dd8d9 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -61,18 +61,18 @@ Sema::IdentifyCUDATarget(const ParsedAttributesView &Attrs) { bool HasDeviceAttr = false; bool HasGlobalAttr = false; bool HasInvalidTargetAttr = false; - for (const AttributeList &AL : Attrs) { + for (const ParsedAttr &AL : Attrs) { switch (AL.getKind()) { - case AttributeList::AT_CUDAGlobal: + case ParsedAttr::AT_CUDAGlobal: HasGlobalAttr = true; break; - case AttributeList::AT_CUDAHost: + case ParsedAttr::AT_CUDAHost: HasHostAttr = true; break; - case AttributeList::AT_CUDADevice: + case ParsedAttr::AT_CUDADevice: HasDeviceAttr = true; break; - case AttributeList::AT_CUDAInvalidTarget: + case ParsedAttr::AT_CUDAInvalidTarget: HasInvalidTargetAttr = true; break; default: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 1e63fd3..a754cc91 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4447,7 +4447,7 @@ Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, TypeSpecType == DeclSpec::TST_interface || TypeSpecType == DeclSpec::TST_union || TypeSpecType == DeclSpec::TST_enum) { - for (const AttributeList &AL : DS.getAttributes()) + for (const ParsedAttr &AL : DS.getAttributes()) Diag(AL.getLoc(), diag::warn_declspec_attribute_ignored) << AL.getName() << GetDiagnosticTypeSpecifierID(TypeSpecType); } @@ -6204,7 +6204,7 @@ static bool shouldConsiderLinkage(const FunctionDecl *FD) { } static bool hasParsedAttr(Scope *S, const Declarator &PD, - AttributeList::Kind Kind) { + ParsedAttr::Kind Kind) { // Check decl attributes on the DeclSpec. if (PD.getDeclSpec().getAttributes().hasAttribute(Kind)) return true; @@ -6372,8 +6372,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( // dllimport globals without explicit storage class are treated as extern. We // have to change the storage class this early to get the right DeclContext. if (SC == SC_None && !DC->isRecord() && - hasParsedAttr(S, D, AttributeList::AT_DLLImport) && - !hasParsedAttr(S, D, AttributeList::AT_DLLExport)) + hasParsedAttr(S, D, ParsedAttr::AT_DLLImport) && + !hasParsedAttr(S, D, ParsedAttr::AT_DLLExport)) SC = SC_Extern; DeclContext *OriginalDC = DC; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index d352015..47ef872 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -172,13 +172,13 @@ static inline bool isCFStringType(QualType T, ASTContext &Ctx) { return RD->getIdentifier() == &Ctx.Idents.get("__CFString"); } -static unsigned getNumAttributeArgs(const AttributeList &AL) { +static unsigned getNumAttributeArgs(const ParsedAttr &AL) { // FIXME: Include the type in the argument list. return AL.getNumArgs() + AL.hasParsedType(); } template <typename Compare> -static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &AL, +static bool checkAttributeNumArgsImpl(Sema &S, const ParsedAttr &AL, unsigned Num, unsigned Diag, Compare Comp) { if (Comp(getNumAttributeArgs(AL), Num)) { @@ -191,8 +191,7 @@ static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &AL, /// Check if the attribute has exactly as many args as Num. May /// output an error. -static bool checkAttributeNumArgs(Sema &S, const AttributeList &AL, - unsigned Num) { +static bool checkAttributeNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num) { return checkAttributeNumArgsImpl(S, AL, Num, diag::err_attribute_wrong_number_arguments, std::not_equal_to<unsigned>()); @@ -200,7 +199,7 @@ static bool checkAttributeNumArgs(Sema &S, const AttributeList &AL, /// Check if the attribute has at least as many args as Num. May /// output an error. -static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &AL, +static bool checkAttributeAtLeastNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num) { return checkAttributeNumArgsImpl(S, AL, Num, diag::err_attribute_too_few_arguments, @@ -209,34 +208,32 @@ static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &AL, /// Check if the attribute has at most as many args as Num. May /// output an error. -static bool checkAttributeAtMostNumArgs(Sema &S, const AttributeList &AL, - unsigned Num) { +static bool checkAttributeAtMostNumArgs(Sema &S, const ParsedAttr &AL, + unsigned Num) { return checkAttributeNumArgsImpl(S, AL, Num, diag::err_attribute_too_many_arguments, std::greater<unsigned>()); } /// A helper function to provide Attribute Location for the Attr types -/// AND the AttributeList. +/// AND the ParsedAttr. template <typename AttrInfo> static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value, SourceLocation>::type getAttrLoc(const AttrInfo &AL) { return AL.getLocation(); } -static SourceLocation getAttrLoc(const AttributeList &AL) { - return AL.getLoc(); -} +static SourceLocation getAttrLoc(const ParsedAttr &AL) { return AL.getLoc(); } /// A helper function to provide Attribute Name for the Attr types -/// AND the AttributeList. +/// AND the ParsedAttr. template <typename AttrInfo> static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value, const AttrInfo *>::type getAttrName(const AttrInfo &AL) { return &AL; } -static const IdentifierInfo *getAttrName(const AttributeList &AL) { +static const IdentifierInfo *getAttrName(const ParsedAttr &AL) { return AL.getName(); } @@ -355,8 +352,8 @@ static bool checkFunctionOrMethodParameterIndex( /// If not emit an error and return false. If the argument is an identifier it /// will emit an error with a fixit hint and treat it as if it was a string /// literal. -bool Sema::checkStringLiteralArgumentAttr(const AttributeList &AL, - unsigned ArgNum, StringRef &Str, +bool Sema::checkStringLiteralArgumentAttr(const ParsedAttr &AL, unsigned ArgNum, + StringRef &Str, SourceLocation *ArgLocation) { // Look for identifiers. If we have one emit a hint to fix it to a literal. if (AL.isArgIdent(ArgNum)) { @@ -390,14 +387,14 @@ bool Sema::checkStringLiteralArgumentAttr(const AttributeList &AL, /// Applies the given attribute to the Decl without performing any /// additional semantic checking. template <typename AttrType> -static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSimpleAttribute(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) AttrType(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } template <typename AttrType> static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { handleSimpleAttribute<AttrType>(S, D, AL); } @@ -406,7 +403,7 @@ static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, template <typename AttrType, typename IncompatibleAttrType, typename... IncompatibleAttrTypes> static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, AL.getRange(), AL.getName())) return; @@ -441,7 +438,7 @@ static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType* RT) { /// Note that this function may produce an error message. /// \return true if the Decl is a pointer type; false otherwise static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { const auto *VD = cast<ValueDecl>(D); QualType QT = VD->getType(); if (QT->isAnyPointerType()) @@ -561,7 +558,7 @@ static bool isCapabilityExpr(Sema &S, const Expr *Ex) { /// \param ParamIdxOk Whether an argument can be indexing into a function /// parameter list. static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, - const AttributeList &AL, + const ParsedAttr &AL, SmallVectorImpl<Expr *> &Args, int Sidx = 0, bool ParamIdxOk = false) { @@ -637,8 +634,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, // Attribute Implementations //===----------------------------------------------------------------------===// -static void handlePtGuardedVarAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!threadSafetyCheckIsPointer(S, D, AL)) return; @@ -647,7 +643,7 @@ static void handlePtGuardedVarAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const AttributeList &AL, +static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Arg) { SmallVector<Expr *, 1> Args; // check that all arguments are lockable objects @@ -661,7 +657,7 @@ static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const AttributeList &AL, return true; } -static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *Arg = nullptr; if (!checkGuardedByAttrCommon(S, D, AL, Arg)) return; @@ -670,8 +666,7 @@ static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getRange(), S.Context, Arg, AL.getAttributeSpellingListIndex())); } -static void handlePtGuardedByAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *Arg = nullptr; if (!checkGuardedByAttrCommon(S, D, AL, Arg)) return; @@ -683,8 +678,7 @@ static void handlePtGuardedByAttr(Sema &S, Decl *D, AL.getRange(), S.Context, Arg, AL.getAttributeSpellingListIndex())); } -static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, - const AttributeList &AL, +static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl<Expr *> &Args) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return false; @@ -705,8 +699,7 @@ static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, return true; } -static void handleAcquiredAfterAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<Expr *, 1> Args; if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) return; @@ -717,8 +710,7 @@ static void handleAcquiredAfterAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAcquiredBeforeAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<Expr *, 1> Args; if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) return; @@ -729,8 +721,7 @@ static void handleAcquiredBeforeAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static bool checkLockFunAttrCommon(Sema &S, Decl *D, - const AttributeList &AL, +static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl<Expr *> &Args) { // zero or more arguments ok // check that all arguments are lockable objects @@ -739,8 +730,7 @@ static bool checkLockFunAttrCommon(Sema &S, Decl *D, return true; } -static void handleAssertSharedLockAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<Expr *, 1> Args; if (!checkLockFunAttrCommon(S, D, AL, Args)) return; @@ -753,7 +743,7 @@ static void handleAssertSharedLockAttr(Sema &S, Decl *D, } static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { SmallVector<Expr *, 1> Args; if (!checkLockFunAttrCommon(S, D, AL, Args)) return; @@ -790,7 +780,7 @@ static bool checkParamIsIntegerType(Sema &S, const FunctionDecl *FD, return true; } -static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1) || !checkAttributeAtMostNumArgs(S, AL, 2)) return; @@ -828,8 +818,7 @@ static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, - const AttributeList &AL, +static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl<Expr *> &Args) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return false; @@ -847,7 +836,7 @@ static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, } static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { SmallVector<Expr*, 2> Args; if (!checkTryLockFunAttrCommon(S, D, AL, Args)) return; @@ -858,7 +847,7 @@ static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, } static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { SmallVector<Expr*, 2> Args; if (!checkTryLockFunAttrCommon(S, D, AL, Args)) return; @@ -868,8 +857,7 @@ static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, Args.size(), AL.getAttributeSpellingListIndex())); } -static void handleLockReturnedAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // check that the argument is lockable object SmallVector<Expr*, 1> Args; checkAttrArgsAreCapabilityObjs(S, D, AL, Args); @@ -882,8 +870,7 @@ static void handleLockReturnedAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleLocksExcludedAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; @@ -900,8 +887,7 @@ static void handleLocksExcludedAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static bool checkFunctionConditionAttr(Sema &S, Decl *D, - const AttributeList &AL, +static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Cond, StringRef &Msg) { Cond = AL.getArgAsExpr(0); if (!Cond->isTypeDependent()) { @@ -930,7 +916,7 @@ static bool checkFunctionConditionAttr(Sema &S, Decl *D, return true; } -static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Diag(AL.getLoc(), diag::ext_clang_enable_if); Expr *Cond; @@ -987,7 +973,7 @@ public: }; } -static void handleDiagnoseIfAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.Diag(AL.getLoc(), diag::ext_clang_diagnose_if); Expr *Cond; @@ -1014,8 +1000,7 @@ static void handleDiagnoseIfAttr(Sema &S, Decl *D, const AttributeList &AL) { cast<NamedDecl>(D), AL.getAttributeSpellingListIndex())); } -static void handlePassObjectSizeAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->hasAttr<PassObjectSizeAttr>()) { S.Diag(D->getLocStart(), diag::err_attribute_only_once_per_parameter) << AL.getName(); @@ -1050,7 +1035,7 @@ static void handlePassObjectSizeAttr(Sema &S, Decl *D, AL.getRange(), S.Context, (int)Type, AL.getAttributeSpellingListIndex())); } -static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ConsumableAttr::ConsumedState DefaultState; if (AL.isArgIdent(0)) { @@ -1073,7 +1058,7 @@ static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &AL) { } static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, - const AttributeList &AL) { + const ParsedAttr &AL) { ASTContext &CurrContext = S.getASTContext(); QualType ThisType = MD->getThisType(CurrContext)->getPointeeType(); @@ -1089,8 +1074,7 @@ static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, return true; } -static void handleCallableWhenAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; @@ -1127,8 +1111,7 @@ static void handleCallableWhenAttr(Sema &S, Decl *D, States.size(), AL.getAttributeSpellingListIndex())); } -static void handleParamTypestateAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ParamTypestateAttr::ConsumedState ParamState; if (AL.isArgIdent(0)) { @@ -1164,8 +1147,7 @@ static void handleParamTypestateAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleReturnTypestateAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ReturnTypestateAttr::ConsumedState ReturnState; if (AL.isArgIdent(0)) { @@ -1212,7 +1194,7 @@ static void handleReturnTypestateAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) return; @@ -1236,8 +1218,7 @@ static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleTestTypestateAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) return; @@ -1261,12 +1242,12 @@ static void handleTestTypestateAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleExtVectorTypeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Remember this typedef decl, we will need it later for diagnostics. S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D)); } -static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (auto *TD = dyn_cast<TagDecl>(D)) TD->addAttr(::new (S.Context) PackedAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); @@ -1297,7 +1278,7 @@ static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &AL) { S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); } -static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &AL) { +static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) { // The IBOutlet/IBOutletCollection attributes only apply to instance // variables or properties of Objective-C classes. The outlet must also // have an object reference type. @@ -1323,7 +1304,7 @@ static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &AL) { return true; } -static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &AL) { +static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkIBOutletCommon(S, D, AL)) return; @@ -1332,8 +1313,7 @@ static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleIBOutletCollection(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL) { // The iboutletcollection attribute can have zero or one arguments. if (AL.getNumArgs() > 1) { @@ -1403,7 +1383,7 @@ bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) { return T->isAnyPointerType() || T->isBlockPointerType(); } -static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &AL, +static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, SourceRange AttrParmRange, SourceRange TypeRange, bool isReturnValue = false) { @@ -1419,7 +1399,7 @@ static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &AL, return true; } -static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<ParamIdx, 8> NonNullArgs; for (unsigned I = 0; I < AL.getNumArgs(); ++I) { Expr *Ex = AL.getArgAsExpr(I); @@ -1465,7 +1445,7 @@ static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (AL.getNumArgs() > 0) { if (D->getFunctionType()) { handleNonNullAttr(S, D, AL); @@ -1486,8 +1466,7 @@ static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, AL.getAttributeSpellingListIndex())); } -static void handleReturnsNonNullAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { QualType ResultType = getFunctionOrMethodResultType(D); SourceRange SR = getFunctionOrMethodResultSourceRange(D); if (!attrNonNullArgCheck(S, ResultType, AL, SourceRange(), SR, @@ -1499,7 +1478,7 @@ static void handleReturnsNonNullAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleNoEscapeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->isInvalidDecl()) return; @@ -1515,16 +1494,14 @@ static void handleNoEscapeAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } -static void handleAssumeAlignedAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *E = AL.getArgAsExpr(0), *OE = AL.getNumArgs() > 1 ? AL.getArgAsExpr(1) : nullptr; S.AddAssumeAlignedAttr(AL.getRange(), D, E, OE, AL.getAttributeSpellingListIndex()); } -static void handleAllocAlignAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.AddAllocAlignAttr(AL.getRange(), D, AL.getArgAsExpr(0), AL.getAttributeSpellingListIndex()); } @@ -1623,7 +1600,7 @@ static bool normalizeName(StringRef &AttrName) { return false; } -static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // This attribute must be applied to a function declaration. The first // argument to the attribute must be an identifier, the name of the resource, // for example: malloc. The following arguments must be argument indexes, the @@ -1730,7 +1707,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Check the attribute arguments. if (AL.getNumArgs() > 1) { S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) @@ -1792,7 +1769,7 @@ static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { StringRef Str; if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) return; @@ -1808,7 +1785,7 @@ static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { StringRef Str; if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) return; @@ -1841,8 +1818,7 @@ static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleTLSModelAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { StringRef Model; SourceLocation LiteralLoc; // Check that it is a string. @@ -1861,7 +1837,7 @@ static void handleTLSModelAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { QualType ResultType = getFunctionOrMethodResultType(D); if (ResultType->isAnyPointerType() || ResultType->isBlockPointerType()) { D->addAttr(::new (S.Context) RestrictAttr( @@ -1873,7 +1849,7 @@ static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &AL) { << AL.getName() << getFunctionOrMethodResultSourceRange(D); } -static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) << AL.getName() << AttributeLangSupport::Cpp; @@ -1885,7 +1861,7 @@ static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &AL) { D->addAttr(CA); } -static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, AL.getRange(), AL.getName())) return; @@ -1905,7 +1881,7 @@ static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) { +static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { if (hasDeclarator(D)) return; if (!isa<ObjCMethodDecl>(D)) { @@ -1918,14 +1894,14 @@ static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) { Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); } -static void handleNoCfCheckAttr(Sema &S, Decl *D, const AttributeList &Attrs) { +static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { if (!S.getLangOpts().CFProtectionBranch) S.Diag(Attrs.getLoc(), diag::warn_nocf_check_attribute_ignored); else handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs); } -bool Sema::CheckAttrNoArgs(const AttributeList &Attrs) { +bool Sema::CheckAttrNoArgs(const ParsedAttr &Attrs) { if (!checkAttributeNumArgs(*this, Attrs, 0)) { Attrs.setInvalid(); return true; @@ -1934,7 +1910,7 @@ bool Sema::CheckAttrNoArgs(const AttributeList &Attrs) { return false; } -bool Sema::CheckAttrTarget(const AttributeList &AL) { +bool Sema::CheckAttrTarget(const ParsedAttr &AL) { // Check whether the attribute is valid on the current target. if (!AL.existsInTarget(Context.getTargetInfo())) { Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName(); @@ -1945,9 +1921,8 @@ bool Sema::CheckAttrTarget(const AttributeList &AL) { return false; } -static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, - const AttributeList &AL) { - +static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + // The checking path for 'noreturn' and 'analyzer_noreturn' are different // because 'analyzer_noreturn' does not impact the type. if (!isFunctionOrMethodOrBlock(D)) { @@ -1968,30 +1943,31 @@ static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, } // PS3 PPU-specific. -static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &AL) { -/* - Returning a Vector Class in Registers - - According to the PPU ABI specifications, a class with a single member of - vector type is returned in memory when used as the return value of a function. - This results in inefficient code when implementing vector classes. To return - the value in a single vector register, add the vecreturn attribute to the - class definition. This attribute is also applicable to struct types. - - Example: - - struct Vector - { - __vector float xyzw; - } __attribute__((vecreturn)); - - Vector Add(Vector lhs, Vector rhs) - { - Vector result; - result.xyzw = vec_add(lhs.xyzw, rhs.xyzw); - return result; // This will be returned in a register - } -*/ +static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { + /* + Returning a Vector Class in Registers + + According to the PPU ABI specifications, a class with a single member of + vector type is returned in memory when used as the return value of a + function. + This results in inefficient code when implementing vector classes. To return + the value in a single vector register, add the vecreturn attribute to the + class definition. This attribute is also applicable to struct types. + + Example: + + struct Vector + { + __vector float xyzw; + } __attribute__((vecreturn)); + + Vector Add(Vector lhs, Vector rhs) + { + Vector result; + result.xyzw = vec_add(lhs.xyzw, rhs.xyzw); + return result; // This will be returned in a register + } + */ if (VecReturnAttr *A = D->getAttr<VecReturnAttr>()) { S.Diag(AL.getLoc(), diag::err_repeat_attribute) << A; return; @@ -2023,7 +1999,7 @@ static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (isa<ParmVarDecl>(D)) { // [[carries_dependency]] can only be applied to a parameter if it is a // parameter of a function declaration or lambda. @@ -2039,7 +2015,7 @@ static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName(); // If this is spelled as the standard C++17 attribute, but not in C++17, warn @@ -2051,7 +2027,7 @@ static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } -static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t priority = ConstructorAttr::DefaultPriority; if (AL.getNumArgs() && !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority)) @@ -2062,7 +2038,7 @@ static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t priority = DestructorAttr::DefaultPriority; if (AL.getNumArgs() && !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority)) @@ -2074,8 +2050,7 @@ static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &AL) { } template <typename AttrTy> -static void handleAttrWithMessage(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL) { // Handle the case where the attribute has a text message. StringRef Str; if (AL.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(AL, 0, Str)) @@ -2086,7 +2061,7 @@ static void handleAttrWithMessage(Sema &S, Decl *D, } static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) { S.Diag(AL.getLoc(), diag::err_objc_attr_protocol_requires_definition) << AL.getName() << AL.getRange(); @@ -2319,8 +2294,7 @@ AvailabilityAttr *Sema::mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, return nullptr; } -static void handleAvailabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeNumArgs(S, AL, 1)) return; IdentifierLoc *Platform = AL.getArgAsIdent(0); @@ -2435,7 +2409,7 @@ static void handleAvailabilityAttr(Sema &S, Decl *D, } static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; assert(checkAttributeAtMostNumArgs(S, AL, 3) && @@ -2484,7 +2458,7 @@ TypeVisibilityAttr *Sema::mergeTypeVisibilityAttr(Decl *D, SourceRange Range, AttrSpellingListIndex); } -static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &AL, +static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, bool isTypeVisibility) { // Visibility attributes don't mean anything on a typedef. if (isa<TypedefNameDecl>(D)) { @@ -2537,8 +2511,7 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &AL, D->addAttr(newAttr); } -static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL) { const auto *M = cast<ObjCMethodDecl>(D); if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) @@ -2566,7 +2539,7 @@ static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, AL.getRange(), S.Context, F, AL.getAttributeSpellingListIndex())); } -static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &AL) { +static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL) { if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) { QualType T = TD->getUnderlyingType(); if (!T->isCARCBridgableType()) { @@ -2595,7 +2568,7 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &AL) { +static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL) { if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) { QualType T = TD->getUnderlyingType(); if (!T->isObjCObjectPointerType()) { @@ -2611,7 +2584,7 @@ static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &AL AL.getAttributeSpellingListIndex())); } -static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL.getName() << 1 << AANT_ArgumentIdentifier; @@ -2631,7 +2604,7 @@ static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel; if (AL.getNumArgs() > 0) { Expr *E = AL.getArgAsExpr(0); @@ -2722,7 +2695,7 @@ static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &AL) { +static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->getFunctionType() && D->getFunctionType()->getReturnType()->isVoidType()) { S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) @@ -2747,7 +2720,7 @@ static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // weak_import only applies to variable & function declarations. bool isDef = false; if (!D->canBeWeakImported(isDef)) { @@ -2772,8 +2745,7 @@ static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &AL) { // Handles reqd_work_group_size and work_group_size_hint. template <typename WorkGroupAttr> -static void handleWorkGroupSize(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t WGSize[3]; for (unsigned i = 0; i < 3; ++i) { const Expr *E = AL.getArgAsExpr(i); @@ -2798,7 +2770,7 @@ static void handleWorkGroupSize(Sema &S, Decl *D, } // Handles intel_reqd_sub_group_size. -static void handleSubGroupSize(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t SGSize; const Expr *E = AL.getArgAsExpr(0); if (!checkUInt32Argument(S, AL, E, SGSize)) @@ -2819,7 +2791,7 @@ static void handleSubGroupSize(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &AL) { +static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.hasParsedType()) { S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL.getName() << 1; @@ -2873,7 +2845,7 @@ bool Sema::checkSectionName(SourceLocation LiteralLoc, StringRef SecName) { return true; } -static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Make sure that there is a string literal as the sections's single // argument. StringRef Str; @@ -2929,7 +2901,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) { return false; } -static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) { StringRef Str; SourceLocation LiteralLoc; if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) || @@ -2942,7 +2914,7 @@ static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &AL) { D->addAttr(NewAttr); } -static void handleMinVectorWidthAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *E = AL.getArgAsExpr(0); uint32_t VecWidth; if (!checkUInt32Argument(S, AL, E, VecWidth)) { @@ -2961,7 +2933,7 @@ static void handleMinVectorWidthAttr(Sema &S, Decl *D, const AttributeList &AL) AL.getAttributeSpellingListIndex())); } -static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *E = AL.getArgAsExpr(0); SourceLocation Loc = E->getExprLoc(); FunctionDecl *FD = nullptr; @@ -3019,7 +2991,7 @@ static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleEnumExtensibilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL.getName() << 0 << AANT_ArgumentIdentifier; @@ -3042,7 +3014,7 @@ static void handleEnumExtensibilityAttr(Sema &S, Decl *D, /// Handle __attribute__((format_arg((idx)))) attribute based on /// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html -static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) { Expr *IdxExpr = AL.getArgAsExpr(0); ParamIdx Idx; if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, IdxExpr, Idx)) @@ -3108,8 +3080,7 @@ static FormatAttrKind getFormatAttrKind(StringRef Format) { /// Handle __attribute__((init_priority(priority))) attributes based on /// http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html -static void handleInitPriorityAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.getLangOpts().CPlusPlus) { S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName(); return; @@ -3170,7 +3141,7 @@ FormatAttr *Sema::mergeFormatAttr(Decl *D, SourceRange Range, /// Handle __attribute__((format(type,idx,firstarg))) attributes based on /// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html -static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL.getName() << 1 << AANT_ArgumentIdentifier; @@ -3292,8 +3263,7 @@ static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &AL) { D->addAttr(NewAttr); } -static void handleTransparentUnionAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Try to find the underlying union declaration. RecordDecl *RD = nullptr; const auto *TD = dyn_cast<TypedefNameDecl>(D); @@ -3366,7 +3336,7 @@ static void handleTransparentUnionAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Make sure that there is a string literal as the annotation's single // argument. StringRef Str; @@ -3384,8 +3354,7 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleAlignValueAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.AddAlignValueAttr(AL.getRange(), D, AL.getArgAsExpr(0), AL.getAttributeSpellingListIndex()); } @@ -3435,7 +3404,7 @@ void Sema::AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E, D->addAttr(::new (Context) AlignValueAttr(TmpAttr)); } -static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // check the attribute arguments. if (AL.getNumArgs() > 1) { S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) @@ -3715,7 +3684,7 @@ static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, /// Despite what would be logical, the mode attribute is a decl attribute, not a /// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be /// HImode, not an intermediate pointer. -static void handleModeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // This attribute isn't documented, but glibc uses it. It changes // the width of an int or unsigned int to the specified size. if (!AL.isArgIdent(0)) { @@ -3871,7 +3840,7 @@ void Sema::AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, ModeAttr(AttrRange, Context, Name, SpellingListIndex)); } -static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) NoDebugAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); @@ -3963,8 +3932,7 @@ OptimizeNoneAttr *Sema::mergeOptimizeNoneAttr(Decl *D, SourceRange Range, AttrSpellingListIndex); } -static void handleAlwaysInlineAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, AL.getRange(), AL.getName())) return; @@ -3975,20 +3943,19 @@ static void handleAlwaysInlineAttr(Sema &S, Decl *D, D->addAttr(Inline); } -static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (MinSizeAttr *MinSize = S.mergeMinSizeAttr( D, AL.getRange(), AL.getAttributeSpellingListIndex())) D->addAttr(MinSize); } -static void handleOptimizeNoneAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr( D, AL.getRange(), AL.getAttributeSpellingListIndex())) D->addAttr(Optnone); } -static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (checkAttrMutualExclusion<CUDASharedAttr>(S, D, AL.getRange(), AL.getName())) return; @@ -4001,7 +3968,7 @@ static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } -static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (checkAttrMutualExclusion<CUDAConstantAttr>(S, D, AL.getRange(), AL.getName())) return; @@ -4021,7 +3988,7 @@ static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); } -static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, AL.getRange(), AL.getName()) || checkAttrMutualExclusion<CUDAHostAttr>(S, D, AL.getRange(), @@ -4054,7 +4021,7 @@ static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { const auto *Fn = cast<FunctionDecl>(D); if (!Fn->isInlineSpecified()) { S.Diag(AL.getLoc(), diag::warn_gnu_inline_attribute_requires_inline); @@ -4066,7 +4033,7 @@ static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (hasDeclarator(D)) return; // Diagnostic is emitted elsewhere: here we store the (valid) AL @@ -4082,56 +4049,56 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &AL) { } switch (AL.getKind()) { - case AttributeList::AT_FastCall: + case ParsedAttr::AT_FastCall: D->addAttr(::new (S.Context) FastCallAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_StdCall: + case ParsedAttr::AT_StdCall: D->addAttr(::new (S.Context) StdCallAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_ThisCall: + case ParsedAttr::AT_ThisCall: D->addAttr(::new (S.Context) ThisCallAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_CDecl: + case ParsedAttr::AT_CDecl: D->addAttr(::new (S.Context) CDeclAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_Pascal: + case ParsedAttr::AT_Pascal: D->addAttr(::new (S.Context) PascalAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_SwiftCall: + case ParsedAttr::AT_SwiftCall: D->addAttr(::new (S.Context) SwiftCallAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_VectorCall: + case ParsedAttr::AT_VectorCall: D->addAttr(::new (S.Context) VectorCallAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_MSABI: + case ParsedAttr::AT_MSABI: D->addAttr(::new (S.Context) MSABIAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_SysVABI: + case ParsedAttr::AT_SysVABI: D->addAttr(::new (S.Context) SysVABIAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_RegCall: + case ParsedAttr::AT_RegCall: D->addAttr(::new (S.Context) RegCallAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_Pcs: { + case ParsedAttr::AT_Pcs: { PcsAttr::PCSType PCS; switch (CC) { case CC_AAPCS: @@ -4149,16 +4116,16 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); return; } - case AttributeList::AT_IntelOclBicc: + case ParsedAttr::AT_IntelOclBicc: D->addAttr(::new (S.Context) IntelOclBiccAttr(AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_PreserveMost: + case ParsedAttr::AT_PreserveMost: D->addAttr(::new (S.Context) PreserveMostAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_PreserveAll: + case ParsedAttr::AT_PreserveAll: D->addAttr(::new (S.Context) PreserveAllAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; @@ -4167,7 +4134,7 @@ static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &AL) { } } -static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; @@ -4187,7 +4154,7 @@ static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &AL) { DiagnosticIdentifiers.size(), AL.getAttributeSpellingListIndex())); } -bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, +bool Sema::CheckCallingConvAttr(const ParsedAttr &Attrs, CallingConv &CC, const FunctionDecl *FD) { if (Attrs.isInvalid()) return true; @@ -4197,7 +4164,7 @@ bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, return false; } - unsigned ReqArgs = Attrs.getKind() == AttributeList::AT_Pcs ? 1 : 0; + unsigned ReqArgs = Attrs.getKind() == ParsedAttr::AT_Pcs ? 1 : 0; if (!checkAttributeNumArgs(*this, Attrs, ReqArgs)) { Attrs.setInvalid(); return true; @@ -4205,23 +4172,39 @@ bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, // TODO: diagnose uses of these conventions on the wrong target. switch (Attrs.getKind()) { - case AttributeList::AT_CDecl: CC = CC_C; break; - case AttributeList::AT_FastCall: CC = CC_X86FastCall; break; - case AttributeList::AT_StdCall: CC = CC_X86StdCall; break; - case AttributeList::AT_ThisCall: CC = CC_X86ThisCall; break; - case AttributeList::AT_Pascal: CC = CC_X86Pascal; break; - case AttributeList::AT_SwiftCall: CC = CC_Swift; break; - case AttributeList::AT_VectorCall: CC = CC_X86VectorCall; break; - case AttributeList::AT_RegCall: CC = CC_X86RegCall; break; - case AttributeList::AT_MSABI: + case ParsedAttr::AT_CDecl: + CC = CC_C; + break; + case ParsedAttr::AT_FastCall: + CC = CC_X86FastCall; + break; + case ParsedAttr::AT_StdCall: + CC = CC_X86StdCall; + break; + case ParsedAttr::AT_ThisCall: + CC = CC_X86ThisCall; + break; + case ParsedAttr::AT_Pascal: + CC = CC_X86Pascal; + break; + case ParsedAttr::AT_SwiftCall: + CC = CC_Swift; + break; + case ParsedAttr::AT_VectorCall: + CC = CC_X86VectorCall; + break; + case ParsedAttr::AT_RegCall: + CC = CC_X86RegCall; + break; + case ParsedAttr::AT_MSABI: CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_C : CC_Win64; break; - case AttributeList::AT_SysVABI: + case ParsedAttr::AT_SysVABI: CC = Context.getTargetInfo().getTriple().isOSWindows() ? CC_X86_64SysV : CC_C; break; - case AttributeList::AT_Pcs: { + case ParsedAttr::AT_Pcs: { StringRef StrRef; if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) { Attrs.setInvalid(); @@ -4239,9 +4222,15 @@ bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, Diag(Attrs.getLoc(), diag::err_invalid_pcs); return true; } - case AttributeList::AT_IntelOclBicc: CC = CC_IntelOclBicc; break; - case AttributeList::AT_PreserveMost: CC = CC_PreserveMost; break; - case AttributeList::AT_PreserveAll: CC = CC_PreserveAll; break; + case ParsedAttr::AT_IntelOclBicc: + CC = CC_IntelOclBicc; + break; + case ParsedAttr::AT_PreserveMost: + CC = CC_PreserveMost; + break; + case ParsedAttr::AT_PreserveAll: + CC = CC_PreserveAll; + break; default: llvm_unreachable("unexpected attribute kind"); } @@ -4298,7 +4287,7 @@ static bool isValidSwiftErrorResultType(QualType Ty) { return isValidSwiftContextType(Ty); } -static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &Attrs, +static void handleParameterABIAttr(Sema &S, Decl *D, const ParsedAttr &Attrs, ParameterABI Abi) { S.AddParameterABIAttr(Attrs.getRange(), D, Abi, Attrs.getAttributeSpellingListIndex()); @@ -4357,7 +4346,7 @@ void Sema::AddParameterABIAttr(SourceRange range, Decl *D, ParameterABI abi, /// Checks a regparm attribute, returning true if it is ill-formed and /// otherwise setting numParams to the appropriate value. -bool Sema::CheckRegparmAttr(const AttributeList &AL, unsigned &numParams) { +bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) { if (AL.isInvalid()) return true; @@ -4450,8 +4439,7 @@ void Sema::AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex)); } -static void handleLaunchBoundsAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1) || !checkAttributeAtMostNumArgs(S, AL, 2)) return; @@ -4462,7 +4450,7 @@ static void handleLaunchBoundsAttr(Sema &S, Decl *D, } static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL.getName() << /* arg num = */ 1 << AANT_ArgumentIdentifier; @@ -4495,7 +4483,7 @@ static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, } static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!AL.isArgIdent(0)) { S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) << AL.getName() << 1 << AANT_ArgumentIdentifier; @@ -4524,7 +4512,7 @@ static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleXRayLogArgsAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { ParamIdx ArgCount; if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, AL.getArgAsExpr(0), @@ -4556,9 +4544,9 @@ static bool isValidSubjectOfCFAttribute(Sema &S, QualType QT) { isValidSubjectOfNSAttribute(S, QT); } -static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNSConsumedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { S.AddNSConsumedAttr(AL.getRange(), D, AL.getAttributeSpellingListIndex(), - AL.getKind() == AttributeList::AT_NSConsumed, + AL.getKind() == ParsedAttr::AT_NSConsumed, /*template instantiation*/ false); } @@ -4605,13 +4593,13 @@ bool Sema::checkNSReturnsRetainedReturnType(SourceLocation Loc, QualType QT) { } static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { QualType ReturnType; if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) ReturnType = MD->getReturnType(); else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) && - (AL.getKind() == AttributeList::AT_NSReturnsRetained)) + (AL.getKind() == ParsedAttr::AT_NSReturnsRetained)) return; // ignore: was handled as a type attribute else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) ReturnType = PD->getType(); @@ -4631,14 +4619,14 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, AttributeDeclKind ExpectedDeclKind; switch (AL.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsRetained: - case AttributeList::AT_NSReturnsAutoreleased: - case AttributeList::AT_NSReturnsNotRetained: + case ParsedAttr::AT_NSReturnsRetained: + case ParsedAttr::AT_NSReturnsAutoreleased: + case ParsedAttr::AT_NSReturnsNotRetained: ExpectedDeclKind = ExpectedFunctionOrMethod; break; - case AttributeList::AT_CFReturnsRetained: - case AttributeList::AT_CFReturnsNotRetained: + case ParsedAttr::AT_CFReturnsRetained: + case ParsedAttr::AT_CFReturnsNotRetained: ExpectedDeclKind = ExpectedFunctionMethodOrParameter; break; } @@ -4651,19 +4639,19 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, bool Cf; switch (AL.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsRetained: + case ParsedAttr::AT_NSReturnsRetained: TypeOK = isValidSubjectOfNSReturnsRetainedAttribute(ReturnType); Cf = false; break; - - case AttributeList::AT_NSReturnsAutoreleased: - case AttributeList::AT_NSReturnsNotRetained: + + case ParsedAttr::AT_NSReturnsAutoreleased: + case ParsedAttr::AT_NSReturnsNotRetained: TypeOK = isValidSubjectOfNSAttribute(S, ReturnType); Cf = false; break; - case AttributeList::AT_CFReturnsRetained: - case AttributeList::AT_CFReturnsNotRetained: + case ParsedAttr::AT_CFReturnsRetained: + case ParsedAttr::AT_CFReturnsNotRetained: TypeOK = isValidSubjectOfCFAttribute(S, ReturnType); Cf = true; break; @@ -4698,23 +4686,23 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, switch (AL.getKind()) { default: llvm_unreachable("invalid ownership attribute"); - case AttributeList::AT_NSReturnsAutoreleased: + case ParsedAttr::AT_NSReturnsAutoreleased: D->addAttr(::new (S.Context) NSReturnsAutoreleasedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_CFReturnsNotRetained: + case ParsedAttr::AT_CFReturnsNotRetained: D->addAttr(::new (S.Context) CFReturnsNotRetainedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_NSReturnsNotRetained: + case ParsedAttr::AT_NSReturnsNotRetained: D->addAttr(::new (S.Context) NSReturnsNotRetainedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_CFReturnsRetained: + case ParsedAttr::AT_CFReturnsRetained: D->addAttr(::new (S.Context) CFReturnsRetainedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; - case AttributeList::AT_NSReturnsRetained: + case ParsedAttr::AT_NSReturnsRetained: D->addAttr(::new (S.Context) NSReturnsRetainedAttr( AL.getRange(), S.Context, AL.getAttributeSpellingListIndex())); return; @@ -4722,7 +4710,7 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, } static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, - const AttributeList &Attrs) { + const ParsedAttr &Attrs) { const int EP_ObjCMethod = 1; const int EP_ObjCProperty = 2; @@ -4750,7 +4738,7 @@ static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, } static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, - const AttributeList &Attrs) { + const ParsedAttr &Attrs) { const auto *Method = cast<ObjCMethodDecl>(D); const DeclContext *DC = Method->getDeclContext(); @@ -4770,7 +4758,7 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex())); } -static void handleObjCBridgeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr; if (!Parm) { @@ -4800,7 +4788,7 @@ static void handleObjCBridgeAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr; if (!Parm) { @@ -4814,7 +4802,7 @@ static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, } static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { IdentifierInfo *RelatedClass = AL.isArgIdent(0) ? AL.getArgAsIdent(0)->Ident : nullptr; if (!RelatedClass) { @@ -4832,7 +4820,7 @@ static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, } static void handleObjCDesignatedInitializer(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { ObjCInterfaceDecl *IFace; if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(D->getDeclContext())) IFace = CatDecl->getClassInterface(); @@ -4848,8 +4836,7 @@ static void handleObjCDesignatedInitializer(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleObjCRuntimeName(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL) { StringRef MetaDataName; if (!S.checkStringLiteralArgumentAttr(AL, 0, MetaDataName)) return; @@ -4863,7 +4850,7 @@ static void handleObjCRuntimeName(Sema &S, Decl *D, // but they don't have access to the declaration (legacy/third-party code) // then they can 'enable' this feature with a typedef: // typedef struct __attribute((objc_boxable)) legacy_struct legacy_struct; -static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &AL) { +static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL) { bool notify = false; auto *RD = dyn_cast<RecordDecl>(D); @@ -4886,8 +4873,7 @@ static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &AL) { } } -static void handleObjCOwnershipAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (hasDeclarator(D)) return; S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type) @@ -4895,7 +4881,7 @@ static void handleObjCOwnershipAttr(Sema &S, Decl *D, } static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { const auto *VD = cast<ValueDecl>(D); QualType QT = VD->getType(); @@ -4952,7 +4938,7 @@ UuidAttr *Sema::mergeUuidAttr(Decl *D, SourceRange Range, return ::new (Context) UuidAttr(Range, Context, Uuid, AttrSpellingListIndex); } -static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) << AL.getName() << AttributeLangSupport::C; @@ -5002,7 +4988,7 @@ static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &AL) { D->addAttr(UA); } -static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!S.LangOpts.CPlusPlus) { S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) << AL.getName() << AttributeLangSupport::C; @@ -5018,8 +5004,7 @@ static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &AL) { } } -static void handleDeclspecThreadAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL) { const auto *VD = cast<VarDecl>(D); if (!S.Context.getTargetInfo().isTLSSupported()) { S.Diag(AL.getLoc(), diag::err_thread_unsupported); @@ -5037,7 +5022,7 @@ static void handleDeclspecThreadAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<StringRef, 4> Tags; for (unsigned I = 0, E = AL.getNumArgs(); I != E; ++I) { StringRef Tag; @@ -5069,8 +5054,7 @@ static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleARMInterruptAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Check the attribute arguments. if (AL.getNumArgs() > 1) { S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) @@ -5098,8 +5082,7 @@ static void handleARMInterruptAttr(Sema &S, Decl *D, ARMInterruptAttr(AL.getLoc(), S.Context, Kind, Index)); } -static void handleMSP430InterruptAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeNumArgs(S, AL, 1)) return; @@ -5134,8 +5117,7 @@ static void handleMSP430InterruptAttr(Sema &S, Decl *D, D->addAttr(UsedAttr::CreateImplicit(S.Context)); } -static void handleMipsInterruptAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Only one optional argument permitted. if (AL.getNumArgs() > 1) { S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) @@ -5193,8 +5175,7 @@ static void handleMipsInterruptAttr(Sema &S, Decl *D, AL.getLoc(), S.Context, Kind, AL.getAttributeSpellingListIndex())); } -static void handleAnyX86InterruptAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Semantic checks for a function with the 'interrupt' attribute. // a) Must be a function. // b) Must have the 'void' return type. @@ -5259,7 +5240,7 @@ static void handleAnyX86InterruptAttr(Sema &S, Decl *D, D->addAttr(UsedAttr::CreateImplicit(S.Context)); } -static void handleAVRInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!isFunctionOrMethod(D)) { S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) << "'interrupt'" << ExpectedFunction; @@ -5272,7 +5253,7 @@ static void handleAVRInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) { handleSimpleAttribute<AVRInterruptAttr>(S, D, AL); } -static void handleAVRSignalAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!isFunctionOrMethod(D)) { S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) << "'signal'" << ExpectedFunction; @@ -5285,7 +5266,7 @@ static void handleAVRSignalAttr(Sema &S, Decl *D, const AttributeList &AL) { handleSimpleAttribute<AVRSignalAttr>(S, D, AL); } -static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // Dispatch the interrupt attribute based on the current target. switch (S.Context.getTargetInfo().getTriple().getArch()) { case llvm::Triple::msp430: @@ -5309,7 +5290,7 @@ static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { uint32_t Min = 0; Expr *MinExpr = AL.getArgAsExpr(0); if (!checkUInt32Argument(S, AL, MinExpr, Min)) @@ -5336,8 +5317,7 @@ static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t Min = 0; Expr *MinExpr = AL.getArgAsExpr(0); if (!checkUInt32Argument(S, AL, MinExpr, Min)) @@ -5366,8 +5346,7 @@ static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t NumSGPR = 0; Expr *NumSGPRExpr = AL.getArgAsExpr(0); if (!checkUInt32Argument(S, AL, NumSGPRExpr, NumSGPR)) @@ -5378,8 +5357,7 @@ static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t NumVGPR = 0; Expr *NumVGPRExpr = AL.getArgAsExpr(0); if (!checkUInt32Argument(S, AL, NumVGPRExpr, NumVGPR)) @@ -5391,7 +5369,7 @@ static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, } static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, - const AttributeList& AL) { + const ParsedAttr &AL) { // If we try to apply it to a function pointer, don't warn, but don't // do anything, either. It doesn't matter anyway, because there's nothing // special about calling a force_align_arg_pointer function. @@ -5415,7 +5393,7 @@ static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleLayoutVersion(Sema &S, Decl *D, const AttributeList &AL) { +static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL) { uint32_t Version; Expr *VersionExpr = static_cast<Expr *>(AL.getArgAsExpr(0)); if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Version)) @@ -5459,7 +5437,7 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, return ::new (Context) DLLExportAttr(Range, Context, AttrSpellingListIndex); } -static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A) { +static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) { if (isa<ClassTemplatePartialSpecializationDecl>(D) && S.Context.getTargetInfo().getCXXABI().isMicrosoft()) { S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) @@ -5468,7 +5446,7 @@ static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A) { } if (const auto *FD = dyn_cast<FunctionDecl>(D)) { - if (FD->isInlined() && A.getKind() == AttributeList::AT_DLLImport && + if (FD->isInlined() && A.getKind() == ParsedAttr::AT_DLLImport && !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) { // MinGW doesn't allow dllimport on inline functions. S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline) @@ -5486,7 +5464,7 @@ static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A) { } unsigned Index = A.getAttributeSpellingListIndex(); - Attr *NewAttr = A.getKind() == AttributeList::AT_DLLExport + Attr *NewAttr = A.getKind() == ParsedAttr::AT_DLLExport ? (Attr *)S.mergeDLLExportAttr(D, A.getRange(), Index) : (Attr *)S.mergeDLLImportAttr(D, A.getRange(), Index); if (NewAttr) @@ -5529,7 +5507,7 @@ Sema::mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, MSInheritanceAttr(Range, Context, BestCase, AttrSpellingListIndex); } -static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { // The capability attributes take a single string parameter for the name of // the capability they represent. The lockable attribute does not take any // parameters. However, semantically, both attributes represent the same @@ -5540,7 +5518,7 @@ static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &AL) { // literal will be considered a "mutex." StringRef N("mutex"); SourceLocation LiteralLoc; - if (AL.getKind() == AttributeList::AT_Capability && + if (AL.getKind() == ParsedAttr::AT_Capability && !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc)) return; @@ -5553,8 +5531,7 @@ static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &AL) { AL.getAttributeSpellingListIndex())); } -static void handleAssertCapabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { SmallVector<Expr*, 1> Args; if (!checkLockFunAttrCommon(S, D, AL, Args)) return; @@ -5565,7 +5542,7 @@ static void handleAssertCapabilityAttr(Sema &S, Decl *D, } static void handleAcquireCapabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { SmallVector<Expr*, 1> Args; if (!checkLockFunAttrCommon(S, D, AL, Args)) return; @@ -5577,7 +5554,7 @@ static void handleAcquireCapabilityAttr(Sema &S, Decl *D, } static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { SmallVector<Expr*, 2> Args; if (!checkTryLockFunAttrCommon(S, D, AL, Args)) return; @@ -5591,7 +5568,7 @@ static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, } static void handleReleaseCapabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { // Check that all arguments are lockable objects. SmallVector<Expr *, 1> Args; checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true); @@ -5602,7 +5579,7 @@ static void handleReleaseCapabilityAttr(Sema &S, Decl *D, } static void handleRequiresCapabilityAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; @@ -5619,7 +5596,7 @@ static void handleRequiresCapabilityAttr(Sema &S, Decl *D, D->addAttr(RCA); } -static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (const auto *NSD = dyn_cast<NamespaceDecl>(D)) { if (NSD->isAnonymousNamespace()) { S.Diag(AL.getLoc(), diag::warn_deprecated_anonymous_namespace); @@ -5659,7 +5636,7 @@ static bool isGlobalVar(const Decl *D) { return false; } -static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (!checkAttributeAtLeastNumArgs(S, AL, 1)) return; @@ -5686,7 +5663,7 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &AL) { } static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { StringRef AttrName = AL.getName()->getName(); normalizeName(AttrName); StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName) @@ -5702,15 +5679,14 @@ static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, AL.getAttributeSpellingListIndex())); } -static void handleInternalLinkageAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL.getRange(), AL.getName(), AL.getAttributeSpellingListIndex())) D->addAttr(Internal); } -static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &AL) { +static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (S.LangOpts.OpenCLVersion != 200) S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version) << AL.getName() << "2.0" << 0; @@ -5723,13 +5699,13 @@ static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &AL) { /// such as checking whether a parameter was properly specified, or the correct /// number of arguments were passed, etc. static bool handleCommonAttributeFeatures(Sema &S, Decl *D, - const AttributeList &AL) { + const ParsedAttr &AL) { // Several attributes carry different semantics than the parsing requires, so // those are opted out of the common argument checks. // // We also bail on unknown and ignored attributes because those are handled // as part of the target-specific handling logic. - if (AL.getKind() == AttributeList::UnknownAttribute) + if (AL.getKind() == ParsedAttr::UnknownAttribute) return false; // Check whether the attribute requires specific language extensions to be // enabled. @@ -5762,8 +5738,7 @@ static bool handleCommonAttributeFeatures(Sema &S, Decl *D, return false; } -static void handleOpenCLAccessAttr(Sema &S, Decl *D, - const AttributeList &AL) { +static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { if (D->isInvalidDecl()) return; @@ -5804,9 +5779,9 @@ static void handleOpenCLAccessAttr(Sema &S, Decl *D, /// the attribute applies to decls. If the attribute is a type attribute, just /// silently ignore it if a GNU attribute. static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, - const AttributeList &AL, + const ParsedAttr &AL, bool IncludeCXX11Attributes) { - if (AL.isInvalid() || AL.getKind() == AttributeList::IgnoredAttribute) + if (AL.isInvalid() || AL.getKind() == ParsedAttr::IgnoredAttribute) return; // Ignore C++11 attributes on declarator chunks: they appertain to the type @@ -5817,7 +5792,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, // Unknown attributes are automatically warned on. Target-specific attributes // which do not apply to the current target architecture are treated as // though they were unknown attributes. - if (AL.getKind() == AttributeList::UnknownAttribute || + if (AL.getKind() == ParsedAttr::UnknownAttribute || !AL.existsInTarget(S.Context.getTargetInfo())) { S.Diag(AL.getLoc(), AL.isDeclspecAttribute() ? diag::warn_unhandled_ms_attribute_ignored @@ -5839,616 +5814,616 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl) << AL.getName() << D->getLocation(); break; - case AttributeList::AT_Interrupt: + case ParsedAttr::AT_Interrupt: handleInterruptAttr(S, D, AL); break; - case AttributeList::AT_X86ForceAlignArgPointer: + case ParsedAttr::AT_X86ForceAlignArgPointer: handleX86ForceAlignArgPointerAttr(S, D, AL); break; - case AttributeList::AT_DLLExport: - case AttributeList::AT_DLLImport: + case ParsedAttr::AT_DLLExport: + case ParsedAttr::AT_DLLImport: handleDLLAttr(S, D, AL); break; - case AttributeList::AT_Mips16: + case ParsedAttr::AT_Mips16: handleSimpleAttributeWithExclusions<Mips16Attr, MicroMipsAttr, MipsInterruptAttr>(S, D, AL); break; - case AttributeList::AT_NoMips16: + case ParsedAttr::AT_NoMips16: handleSimpleAttribute<NoMips16Attr>(S, D, AL); break; - case AttributeList::AT_MicroMips: + case ParsedAttr::AT_MicroMips: handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, AL); break; - case AttributeList::AT_NoMicroMips: + case ParsedAttr::AT_NoMicroMips: handleSimpleAttribute<NoMicroMipsAttr>(S, D, AL); break; - case AttributeList::AT_MipsLongCall: + case ParsedAttr::AT_MipsLongCall: handleSimpleAttributeWithExclusions<MipsLongCallAttr, MipsShortCallAttr>( S, D, AL); break; - case AttributeList::AT_MipsShortCall: + case ParsedAttr::AT_MipsShortCall: handleSimpleAttributeWithExclusions<MipsShortCallAttr, MipsLongCallAttr>( S, D, AL); break; - case AttributeList::AT_AMDGPUFlatWorkGroupSize: + case ParsedAttr::AT_AMDGPUFlatWorkGroupSize: handleAMDGPUFlatWorkGroupSizeAttr(S, D, AL); break; - case AttributeList::AT_AMDGPUWavesPerEU: + case ParsedAttr::AT_AMDGPUWavesPerEU: handleAMDGPUWavesPerEUAttr(S, D, AL); break; - case AttributeList::AT_AMDGPUNumSGPR: + case ParsedAttr::AT_AMDGPUNumSGPR: handleAMDGPUNumSGPRAttr(S, D, AL); break; - case AttributeList::AT_AMDGPUNumVGPR: + case ParsedAttr::AT_AMDGPUNumVGPR: handleAMDGPUNumVGPRAttr(S, D, AL); break; - case AttributeList::AT_AVRSignal: + case ParsedAttr::AT_AVRSignal: handleAVRSignalAttr(S, D, AL); break; - case AttributeList::AT_IBAction: + case ParsedAttr::AT_IBAction: handleSimpleAttribute<IBActionAttr>(S, D, AL); break; - case AttributeList::AT_IBOutlet: + case ParsedAttr::AT_IBOutlet: handleIBOutlet(S, D, AL); break; - case AttributeList::AT_IBOutletCollection: + case ParsedAttr::AT_IBOutletCollection: handleIBOutletCollection(S, D, AL); break; - case AttributeList::AT_IFunc: + case ParsedAttr::AT_IFunc: handleIFuncAttr(S, D, AL); break; - case AttributeList::AT_Alias: + case ParsedAttr::AT_Alias: handleAliasAttr(S, D, AL); break; - case AttributeList::AT_Aligned: + case ParsedAttr::AT_Aligned: handleAlignedAttr(S, D, AL); break; - case AttributeList::AT_AlignValue: + case ParsedAttr::AT_AlignValue: handleAlignValueAttr(S, D, AL); break; - case AttributeList::AT_AllocSize: + case ParsedAttr::AT_AllocSize: handleAllocSizeAttr(S, D, AL); break; - case AttributeList::AT_AlwaysInline: + case ParsedAttr::AT_AlwaysInline: handleAlwaysInlineAttr(S, D, AL); break; - case AttributeList::AT_Artificial: + case ParsedAttr::AT_Artificial: handleSimpleAttribute<ArtificialAttr>(S, D, AL); break; - case AttributeList::AT_AnalyzerNoReturn: + case ParsedAttr::AT_AnalyzerNoReturn: handleAnalyzerNoReturnAttr(S, D, AL); break; - case AttributeList::AT_TLSModel: + case ParsedAttr::AT_TLSModel: handleTLSModelAttr(S, D, AL); break; - case AttributeList::AT_Annotate: + case ParsedAttr::AT_Annotate: handleAnnotateAttr(S, D, AL); break; - case AttributeList::AT_Availability: + case ParsedAttr::AT_Availability: handleAvailabilityAttr(S, D, AL); break; - case AttributeList::AT_CarriesDependency: + case ParsedAttr::AT_CarriesDependency: handleDependencyAttr(S, scope, D, AL); break; - case AttributeList::AT_Common: + case ParsedAttr::AT_Common: handleCommonAttr(S, D, AL); break; - case AttributeList::AT_CUDAConstant: + case ParsedAttr::AT_CUDAConstant: handleConstantAttr(S, D, AL); break; - case AttributeList::AT_PassObjectSize: + case ParsedAttr::AT_PassObjectSize: handlePassObjectSizeAttr(S, D, AL); break; - case AttributeList::AT_Constructor: + case ParsedAttr::AT_Constructor: handleConstructorAttr(S, D, AL); break; - case AttributeList::AT_CXX11NoReturn: + case ParsedAttr::AT_CXX11NoReturn: handleSimpleAttribute<CXX11NoReturnAttr>(S, D, AL); break; - case AttributeList::AT_Deprecated: + case ParsedAttr::AT_Deprecated: handleDeprecatedAttr(S, D, AL); break; - case AttributeList::AT_Destructor: + case ParsedAttr::AT_Destructor: handleDestructorAttr(S, D, AL); break; - case AttributeList::AT_EnableIf: + case ParsedAttr::AT_EnableIf: handleEnableIfAttr(S, D, AL); break; - case AttributeList::AT_DiagnoseIf: + case ParsedAttr::AT_DiagnoseIf: handleDiagnoseIfAttr(S, D, AL); break; - case AttributeList::AT_ExtVectorType: + case ParsedAttr::AT_ExtVectorType: handleExtVectorTypeAttr(S, D, AL); break; - case AttributeList::AT_ExternalSourceSymbol: + case ParsedAttr::AT_ExternalSourceSymbol: handleExternalSourceSymbolAttr(S, D, AL); break; - case AttributeList::AT_MinSize: + case ParsedAttr::AT_MinSize: handleMinSizeAttr(S, D, AL); break; - case AttributeList::AT_OptimizeNone: + case ParsedAttr::AT_OptimizeNone: handleOptimizeNoneAttr(S, D, AL); break; - case AttributeList::AT_FlagEnum: + case ParsedAttr::AT_FlagEnum: handleSimpleAttribute<FlagEnumAttr>(S, D, AL); break; - case AttributeList::AT_EnumExtensibility: + case ParsedAttr::AT_EnumExtensibility: handleEnumExtensibilityAttr(S, D, AL); break; - case AttributeList::AT_Flatten: + case ParsedAttr::AT_Flatten: handleSimpleAttribute<FlattenAttr>(S, D, AL); break; - case AttributeList::AT_Format: + case ParsedAttr::AT_Format: handleFormatAttr(S, D, AL); break; - case AttributeList::AT_FormatArg: + case ParsedAttr::AT_FormatArg: handleFormatArgAttr(S, D, AL); break; - case AttributeList::AT_CUDAGlobal: + case ParsedAttr::AT_CUDAGlobal: handleGlobalAttr(S, D, AL); break; - case AttributeList::AT_CUDADevice: + case ParsedAttr::AT_CUDADevice: handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(S, D, AL); break; - case AttributeList::AT_CUDAHost: + case ParsedAttr::AT_CUDAHost: handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(S, D, AL); break; - case AttributeList::AT_GNUInline: + case ParsedAttr::AT_GNUInline: handleGNUInlineAttr(S, D, AL); break; - case AttributeList::AT_CUDALaunchBounds: + case ParsedAttr::AT_CUDALaunchBounds: handleLaunchBoundsAttr(S, D, AL); break; - case AttributeList::AT_Restrict: + case ParsedAttr::AT_Restrict: handleRestrictAttr(S, D, AL); break; - case AttributeList::AT_MayAlias: + case ParsedAttr::AT_MayAlias: handleSimpleAttribute<MayAliasAttr>(S, D, AL); break; - case AttributeList::AT_Mode: + case ParsedAttr::AT_Mode: handleModeAttr(S, D, AL); break; - case AttributeList::AT_NoAlias: + case ParsedAttr::AT_NoAlias: handleSimpleAttribute<NoAliasAttr>(S, D, AL); break; - case AttributeList::AT_NoCommon: + case ParsedAttr::AT_NoCommon: handleSimpleAttribute<NoCommonAttr>(S, D, AL); break; - case AttributeList::AT_NoSplitStack: + case ParsedAttr::AT_NoSplitStack: handleSimpleAttribute<NoSplitStackAttr>(S, D, AL); break; - case AttributeList::AT_NonNull: + case ParsedAttr::AT_NonNull: if (auto *PVD = dyn_cast<ParmVarDecl>(D)) handleNonNullAttrParameter(S, PVD, AL); else handleNonNullAttr(S, D, AL); break; - case AttributeList::AT_ReturnsNonNull: + case ParsedAttr::AT_ReturnsNonNull: handleReturnsNonNullAttr(S, D, AL); break; - case AttributeList::AT_NoEscape: + case ParsedAttr::AT_NoEscape: handleNoEscapeAttr(S, D, AL); break; - case AttributeList::AT_AssumeAligned: + case ParsedAttr::AT_AssumeAligned: handleAssumeAlignedAttr(S, D, AL); break; - case AttributeList::AT_AllocAlign: + case ParsedAttr::AT_AllocAlign: handleAllocAlignAttr(S, D, AL); break; - case AttributeList::AT_Overloadable: + case ParsedAttr::AT_Overloadable: handleSimpleAttribute<OverloadableAttr>(S, D, AL); break; - case AttributeList::AT_Ownership: + case ParsedAttr::AT_Ownership: handleOwnershipAttr(S, D, AL); break; - case AttributeList::AT_Cold: + case ParsedAttr::AT_Cold: handleSimpleAttributeWithExclusions<ColdAttr, HotAttr>(S, D, AL); break; - case AttributeList::AT_Hot: + case ParsedAttr::AT_Hot: handleSimpleAttributeWithExclusions<HotAttr, ColdAttr>(S, D, AL); break; - case AttributeList::AT_Naked: + case ParsedAttr::AT_Naked: handleNakedAttr(S, D, AL); break; - case AttributeList::AT_NoReturn: + case ParsedAttr::AT_NoReturn: handleNoReturnAttr(S, D, AL); break; - case AttributeList::AT_AnyX86NoCfCheck: + case ParsedAttr::AT_AnyX86NoCfCheck: handleNoCfCheckAttr(S, D, AL); break; - case AttributeList::AT_NoThrow: + case ParsedAttr::AT_NoThrow: handleSimpleAttribute<NoThrowAttr>(S, D, AL); break; - case AttributeList::AT_CUDAShared: + case ParsedAttr::AT_CUDAShared: handleSharedAttr(S, D, AL); break; - case AttributeList::AT_VecReturn: + case ParsedAttr::AT_VecReturn: handleVecReturnAttr(S, D, AL); break; - case AttributeList::AT_ObjCOwnership: + case ParsedAttr::AT_ObjCOwnership: handleObjCOwnershipAttr(S, D, AL); break; - case AttributeList::AT_ObjCPreciseLifetime: + case ParsedAttr::AT_ObjCPreciseLifetime: handleObjCPreciseLifetimeAttr(S, D, AL); break; - case AttributeList::AT_ObjCReturnsInnerPointer: + case ParsedAttr::AT_ObjCReturnsInnerPointer: handleObjCReturnsInnerPointerAttr(S, D, AL); break; - case AttributeList::AT_ObjCRequiresSuper: + case ParsedAttr::AT_ObjCRequiresSuper: handleObjCRequiresSuperAttr(S, D, AL); break; - case AttributeList::AT_ObjCBridge: + case ParsedAttr::AT_ObjCBridge: handleObjCBridgeAttr(S, D, AL); break; - case AttributeList::AT_ObjCBridgeMutable: + case ParsedAttr::AT_ObjCBridgeMutable: handleObjCBridgeMutableAttr(S, D, AL); break; - case AttributeList::AT_ObjCBridgeRelated: + case ParsedAttr::AT_ObjCBridgeRelated: handleObjCBridgeRelatedAttr(S, D, AL); break; - case AttributeList::AT_ObjCDesignatedInitializer: + case ParsedAttr::AT_ObjCDesignatedInitializer: handleObjCDesignatedInitializer(S, D, AL); break; - case AttributeList::AT_ObjCRuntimeName: + case ParsedAttr::AT_ObjCRuntimeName: handleObjCRuntimeName(S, D, AL); break; - case AttributeList::AT_ObjCRuntimeVisible: - handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, AL); - break; - case AttributeList::AT_ObjCBoxable: + case ParsedAttr::AT_ObjCRuntimeVisible: + handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, AL); + break; + case ParsedAttr::AT_ObjCBoxable: handleObjCBoxable(S, D, AL); break; - case AttributeList::AT_CFAuditedTransfer: + case ParsedAttr::AT_CFAuditedTransfer: handleSimpleAttributeWithExclusions<CFAuditedTransferAttr, CFUnknownTransferAttr>(S, D, AL); break; - case AttributeList::AT_CFUnknownTransfer: + case ParsedAttr::AT_CFUnknownTransfer: handleSimpleAttributeWithExclusions<CFUnknownTransferAttr, CFAuditedTransferAttr>(S, D, AL); break; - case AttributeList::AT_CFConsumed: - case AttributeList::AT_NSConsumed: + case ParsedAttr::AT_CFConsumed: + case ParsedAttr::AT_NSConsumed: handleNSConsumedAttr(S, D, AL); break; - case AttributeList::AT_NSConsumesSelf: + case ParsedAttr::AT_NSConsumesSelf: handleSimpleAttribute<NSConsumesSelfAttr>(S, D, AL); break; - case AttributeList::AT_NSReturnsAutoreleased: - case AttributeList::AT_NSReturnsNotRetained: - case AttributeList::AT_CFReturnsNotRetained: - case AttributeList::AT_NSReturnsRetained: - case AttributeList::AT_CFReturnsRetained: + case ParsedAttr::AT_NSReturnsAutoreleased: + case ParsedAttr::AT_NSReturnsNotRetained: + case ParsedAttr::AT_CFReturnsNotRetained: + case ParsedAttr::AT_NSReturnsRetained: + case ParsedAttr::AT_CFReturnsRetained: handleNSReturnsRetainedAttr(S, D, AL); break; - case AttributeList::AT_WorkGroupSizeHint: + case ParsedAttr::AT_WorkGroupSizeHint: handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL); break; - case AttributeList::AT_ReqdWorkGroupSize: + case ParsedAttr::AT_ReqdWorkGroupSize: handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL); break; - case AttributeList::AT_OpenCLIntelReqdSubGroupSize: + case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize: handleSubGroupSize(S, D, AL); break; - case AttributeList::AT_VecTypeHint: + case ParsedAttr::AT_VecTypeHint: handleVecTypeHint(S, D, AL); break; - case AttributeList::AT_RequireConstantInit: + case ParsedAttr::AT_RequireConstantInit: handleSimpleAttribute<RequireConstantInitAttr>(S, D, AL); break; - case AttributeList::AT_InitPriority: + case ParsedAttr::AT_InitPriority: handleInitPriorityAttr(S, D, AL); break; - case AttributeList::AT_Packed: + case ParsedAttr::AT_Packed: handlePackedAttr(S, D, AL); break; - case AttributeList::AT_Section: + case ParsedAttr::AT_Section: handleSectionAttr(S, D, AL); break; - case AttributeList::AT_Target: + case ParsedAttr::AT_Target: handleTargetAttr(S, D, AL); break; - case AttributeList::AT_MinVectorWidth: + case ParsedAttr::AT_MinVectorWidth: handleMinVectorWidthAttr(S, D, AL); break; - case AttributeList::AT_Unavailable: + case ParsedAttr::AT_Unavailable: handleAttrWithMessage<UnavailableAttr>(S, D, AL); break; - case AttributeList::AT_ArcWeakrefUnavailable: + case ParsedAttr::AT_ArcWeakrefUnavailable: handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, AL); break; - case AttributeList::AT_ObjCRootClass: + case ParsedAttr::AT_ObjCRootClass: handleSimpleAttribute<ObjCRootClassAttr>(S, D, AL); break; - case AttributeList::AT_ObjCSubclassingRestricted: + case ParsedAttr::AT_ObjCSubclassingRestricted: handleSimpleAttribute<ObjCSubclassingRestrictedAttr>(S, D, AL); break; - case AttributeList::AT_ObjCExplicitProtocolImpl: + case ParsedAttr::AT_ObjCExplicitProtocolImpl: handleObjCSuppresProtocolAttr(S, D, AL); break; - case AttributeList::AT_ObjCRequiresPropertyDefs: + case ParsedAttr::AT_ObjCRequiresPropertyDefs: handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, AL); break; - case AttributeList::AT_Unused: + case ParsedAttr::AT_Unused: handleUnusedAttr(S, D, AL); break; - case AttributeList::AT_ReturnsTwice: + case ParsedAttr::AT_ReturnsTwice: handleSimpleAttribute<ReturnsTwiceAttr>(S, D, AL); break; - case AttributeList::AT_NotTailCalled: + case ParsedAttr::AT_NotTailCalled: handleSimpleAttributeWithExclusions<NotTailCalledAttr, AlwaysInlineAttr>( S, D, AL); break; - case AttributeList::AT_DisableTailCalls: + case ParsedAttr::AT_DisableTailCalls: handleSimpleAttributeWithExclusions<DisableTailCallsAttr, NakedAttr>(S, D, AL); break; - case AttributeList::AT_Used: + case ParsedAttr::AT_Used: handleSimpleAttribute<UsedAttr>(S, D, AL); break; - case AttributeList::AT_Visibility: + case ParsedAttr::AT_Visibility: handleVisibilityAttr(S, D, AL, false); break; - case AttributeList::AT_TypeVisibility: + case ParsedAttr::AT_TypeVisibility: handleVisibilityAttr(S, D, AL, true); break; - case AttributeList::AT_WarnUnused: + case ParsedAttr::AT_WarnUnused: handleSimpleAttribute<WarnUnusedAttr>(S, D, AL); break; - case AttributeList::AT_WarnUnusedResult: + case ParsedAttr::AT_WarnUnusedResult: handleWarnUnusedResult(S, D, AL); break; - case AttributeList::AT_Weak: + case ParsedAttr::AT_Weak: handleSimpleAttribute<WeakAttr>(S, D, AL); break; - case AttributeList::AT_WeakRef: + case ParsedAttr::AT_WeakRef: handleWeakRefAttr(S, D, AL); break; - case AttributeList::AT_WeakImport: + case ParsedAttr::AT_WeakImport: handleWeakImportAttr(S, D, AL); break; - case AttributeList::AT_TransparentUnion: + case ParsedAttr::AT_TransparentUnion: handleTransparentUnionAttr(S, D, AL); break; - case AttributeList::AT_ObjCException: + case ParsedAttr::AT_ObjCException: handleSimpleAttribute<ObjCExceptionAttr>(S, D, AL); break; - case AttributeList::AT_ObjCMethodFamily: + case ParsedAttr::AT_ObjCMethodFamily: handleObjCMethodFamilyAttr(S, D, AL); break; - case AttributeList::AT_ObjCNSObject: + case ParsedAttr::AT_ObjCNSObject: handleObjCNSObject(S, D, AL); break; - case AttributeList::AT_ObjCIndependentClass: + case ParsedAttr::AT_ObjCIndependentClass: handleObjCIndependentClass(S, D, AL); break; - case AttributeList::AT_Blocks: + case ParsedAttr::AT_Blocks: handleBlocksAttr(S, D, AL); break; - case AttributeList::AT_Sentinel: + case ParsedAttr::AT_Sentinel: handleSentinelAttr(S, D, AL); break; - case AttributeList::AT_Const: + case ParsedAttr::AT_Const: handleSimpleAttribute<ConstAttr>(S, D, AL); break; - case AttributeList::AT_Pure: + case ParsedAttr::AT_Pure: handleSimpleAttribute<PureAttr>(S, D, AL); break; - case AttributeList::AT_Cleanup: + case ParsedAttr::AT_Cleanup: handleCleanupAttr(S, D, AL); break; - case AttributeList::AT_NoDebug: + case ParsedAttr::AT_NoDebug: handleNoDebugAttr(S, D, AL); break; - case AttributeList::AT_NoDuplicate: + case ParsedAttr::AT_NoDuplicate: handleSimpleAttribute<NoDuplicateAttr>(S, D, AL); break; - case AttributeList::AT_Convergent: + case ParsedAttr::AT_Convergent: handleSimpleAttribute<ConvergentAttr>(S, D, AL); break; - case AttributeList::AT_NoInline: + case ParsedAttr::AT_NoInline: handleSimpleAttribute<NoInlineAttr>(S, D, AL); break; - case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg. + case ParsedAttr::AT_NoInstrumentFunction: // Interacts with -pg. handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, AL); break; - case AttributeList::AT_NoStackProtector: + case ParsedAttr::AT_NoStackProtector: // Interacts with -fstack-protector options. handleSimpleAttribute<NoStackProtectorAttr>(S, D, AL); break; - case AttributeList::AT_StdCall: - case AttributeList::AT_CDecl: - case AttributeList::AT_FastCall: - case AttributeList::AT_ThisCall: - case AttributeList::AT_Pascal: - case AttributeList::AT_RegCall: - case AttributeList::AT_SwiftCall: - case AttributeList::AT_VectorCall: - case AttributeList::AT_MSABI: - case AttributeList::AT_SysVABI: - case AttributeList::AT_Pcs: - case AttributeList::AT_IntelOclBicc: - case AttributeList::AT_PreserveMost: - case AttributeList::AT_PreserveAll: + case ParsedAttr::AT_StdCall: + case ParsedAttr::AT_CDecl: + case ParsedAttr::AT_FastCall: + case ParsedAttr::AT_ThisCall: + case ParsedAttr::AT_Pascal: + case ParsedAttr::AT_RegCall: + case ParsedAttr::AT_SwiftCall: + case ParsedAttr::AT_VectorCall: + case ParsedAttr::AT_MSABI: + case ParsedAttr::AT_SysVABI: + case ParsedAttr::AT_Pcs: + case ParsedAttr::AT_IntelOclBicc: + case ParsedAttr::AT_PreserveMost: + case ParsedAttr::AT_PreserveAll: handleCallConvAttr(S, D, AL); break; - case AttributeList::AT_Suppress: + case ParsedAttr::AT_Suppress: handleSuppressAttr(S, D, AL); break; - case AttributeList::AT_OpenCLKernel: + case ParsedAttr::AT_OpenCLKernel: handleSimpleAttribute<OpenCLKernelAttr>(S, D, AL); break; - case AttributeList::AT_OpenCLAccess: + case ParsedAttr::AT_OpenCLAccess: handleOpenCLAccessAttr(S, D, AL); break; - case AttributeList::AT_OpenCLNoSVM: + case ParsedAttr::AT_OpenCLNoSVM: handleOpenCLNoSVMAttr(S, D, AL); break; - case AttributeList::AT_SwiftContext: + case ParsedAttr::AT_SwiftContext: handleParameterABIAttr(S, D, AL, ParameterABI::SwiftContext); break; - case AttributeList::AT_SwiftErrorResult: + case ParsedAttr::AT_SwiftErrorResult: handleParameterABIAttr(S, D, AL, ParameterABI::SwiftErrorResult); break; - case AttributeList::AT_SwiftIndirectResult: + case ParsedAttr::AT_SwiftIndirectResult: handleParameterABIAttr(S, D, AL, ParameterABI::SwiftIndirectResult); break; - case AttributeList::AT_InternalLinkage: + case ParsedAttr::AT_InternalLinkage: handleInternalLinkageAttr(S, D, AL); break; - case AttributeList::AT_LTOVisibilityPublic: + case ParsedAttr::AT_LTOVisibilityPublic: handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, AL); break; // Microsoft attributes: - case AttributeList::AT_EmptyBases: + case ParsedAttr::AT_EmptyBases: handleSimpleAttribute<EmptyBasesAttr>(S, D, AL); break; - case AttributeList::AT_LayoutVersion: + case ParsedAttr::AT_LayoutVersion: handleLayoutVersion(S, D, AL); break; - case AttributeList::AT_TrivialABI: + case ParsedAttr::AT_TrivialABI: handleSimpleAttribute<TrivialABIAttr>(S, D, AL); break; - case AttributeList::AT_MSNoVTable: + case ParsedAttr::AT_MSNoVTable: handleSimpleAttribute<MSNoVTableAttr>(S, D, AL); break; - case AttributeList::AT_MSStruct: + case ParsedAttr::AT_MSStruct: handleSimpleAttribute<MSStructAttr>(S, D, AL); break; - case AttributeList::AT_Uuid: + case ParsedAttr::AT_Uuid: handleUuidAttr(S, D, AL); break; - case AttributeList::AT_MSInheritance: + case ParsedAttr::AT_MSInheritance: handleMSInheritanceAttr(S, D, AL); break; - case AttributeList::AT_SelectAny: + case ParsedAttr::AT_SelectAny: handleSimpleAttribute<SelectAnyAttr>(S, D, AL); break; - case AttributeList::AT_Thread: + case ParsedAttr::AT_Thread: handleDeclspecThreadAttr(S, D, AL); break; - case AttributeList::AT_AbiTag: + case ParsedAttr::AT_AbiTag: handleAbiTagAttr(S, D, AL); break; // Thread safety attributes: - case AttributeList::AT_AssertExclusiveLock: + case ParsedAttr::AT_AssertExclusiveLock: handleAssertExclusiveLockAttr(S, D, AL); break; - case AttributeList::AT_AssertSharedLock: + case ParsedAttr::AT_AssertSharedLock: handleAssertSharedLockAttr(S, D, AL); break; - case AttributeList::AT_GuardedVar: + case ParsedAttr::AT_GuardedVar: handleSimpleAttribute<GuardedVarAttr>(S, D, AL); break; - case AttributeList::AT_PtGuardedVar: + case ParsedAttr::AT_PtGuardedVar: handlePtGuardedVarAttr(S, D, AL); break; - case AttributeList::AT_ScopedLockable: + case ParsedAttr::AT_ScopedLockable: handleSimpleAttribute<ScopedLockableAttr>(S, D, AL); break; - case AttributeList::AT_NoSanitize: + case ParsedAttr::AT_NoSanitize: handleNoSanitizeAttr(S, D, AL); break; - case AttributeList::AT_NoSanitizeSpecific: + case ParsedAttr::AT_NoSanitizeSpecific: handleNoSanitizeSpecificAttr(S, D, AL); break; - case AttributeList::AT_NoThreadSafetyAnalysis: + case ParsedAttr::AT_NoThreadSafetyAnalysis: handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, AL); break; - case AttributeList::AT_GuardedBy: + case ParsedAttr::AT_GuardedBy: handleGuardedByAttr(S, D, AL); break; - case AttributeList::AT_PtGuardedBy: + case ParsedAttr::AT_PtGuardedBy: handlePtGuardedByAttr(S, D, AL); break; - case AttributeList::AT_ExclusiveTrylockFunction: + case ParsedAttr::AT_ExclusiveTrylockFunction: handleExclusiveTrylockFunctionAttr(S, D, AL); break; - case AttributeList::AT_LockReturned: + case ParsedAttr::AT_LockReturned: handleLockReturnedAttr(S, D, AL); break; - case AttributeList::AT_LocksExcluded: + case ParsedAttr::AT_LocksExcluded: handleLocksExcludedAttr(S, D, AL); break; - case AttributeList::AT_SharedTrylockFunction: + case ParsedAttr::AT_SharedTrylockFunction: handleSharedTrylockFunctionAttr(S, D, AL); break; - case AttributeList::AT_AcquiredBefore: + case ParsedAttr::AT_AcquiredBefore: handleAcquiredBeforeAttr(S, D, AL); break; - case AttributeList::AT_AcquiredAfter: + case ParsedAttr::AT_AcquiredAfter: handleAcquiredAfterAttr(S, D, AL); break; // Capability analysis attributes. - case AttributeList::AT_Capability: - case AttributeList::AT_Lockable: + case ParsedAttr::AT_Capability: + case ParsedAttr::AT_Lockable: handleCapabilityAttr(S, D, AL); break; - case AttributeList::AT_RequiresCapability: + case ParsedAttr::AT_RequiresCapability: handleRequiresCapabilityAttr(S, D, AL); break; - case AttributeList::AT_AssertCapability: + case ParsedAttr::AT_AssertCapability: handleAssertCapabilityAttr(S, D, AL); break; - case AttributeList::AT_AcquireCapability: + case ParsedAttr::AT_AcquireCapability: handleAcquireCapabilityAttr(S, D, AL); break; - case AttributeList::AT_ReleaseCapability: + case ParsedAttr::AT_ReleaseCapability: handleReleaseCapabilityAttr(S, D, AL); break; - case AttributeList::AT_TryAcquireCapability: + case ParsedAttr::AT_TryAcquireCapability: handleTryAcquireCapabilityAttr(S, D, AL); break; // Consumed analysis attributes. - case AttributeList::AT_Consumable: + case ParsedAttr::AT_Consumable: handleConsumableAttr(S, D, AL); break; - case AttributeList::AT_ConsumableAutoCast: + case ParsedAttr::AT_ConsumableAutoCast: handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, AL); break; - case AttributeList::AT_ConsumableSetOnRead: + case ParsedAttr::AT_ConsumableSetOnRead: handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, AL); break; - case AttributeList::AT_CallableWhen: + case ParsedAttr::AT_CallableWhen: handleCallableWhenAttr(S, D, AL); break; - case AttributeList::AT_ParamTypestate: + case ParsedAttr::AT_ParamTypestate: handleParamTypestateAttr(S, D, AL); break; - case AttributeList::AT_ReturnTypestate: + case ParsedAttr::AT_ReturnTypestate: handleReturnTypestateAttr(S, D, AL); break; - case AttributeList::AT_SetTypestate: + case ParsedAttr::AT_SetTypestate: handleSetTypestateAttr(S, D, AL); break; - case AttributeList::AT_TestTypestate: + case ParsedAttr::AT_TestTypestate: handleTestTypestateAttr(S, D, AL); break; // Type safety attributes. - case AttributeList::AT_ArgumentWithTypeTag: + case ParsedAttr::AT_ArgumentWithTypeTag: handleArgumentWithTypeTagAttr(S, D, AL); break; - case AttributeList::AT_TypeTagForDatatype: + case ParsedAttr::AT_TypeTagForDatatype: handleTypeTagForDatatypeAttr(S, D, AL); break; - case AttributeList::AT_AnyX86NoCallerSavedRegisters: + case ParsedAttr::AT_AnyX86NoCallerSavedRegisters: handleSimpleAttribute<AnyX86NoCallerSavedRegistersAttr>(S, D, AL); break; - case AttributeList::AT_RenderScriptKernel: + case ParsedAttr::AT_RenderScriptKernel: handleSimpleAttribute<RenderScriptKernelAttr>(S, D, AL); break; // XRay attributes. - case AttributeList::AT_XRayInstrument: + case ParsedAttr::AT_XRayInstrument: handleSimpleAttribute<XRayInstrumentAttr>(S, D, AL); break; - case AttributeList::AT_XRayLogArgs: + case ParsedAttr::AT_XRayLogArgs: handleXRayLogArgsAttr(S, D, AL); break; } @@ -6462,7 +6437,7 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, if (AttrList.empty()) return; - for (const AttributeList &AL : AttrList) + for (const ParsedAttr &AL : AttrList) ProcessDeclAttribute(*this, S, D, AL, IncludeCXX11Attributes); // FIXME: We should be able to handle these cases in TableGen. @@ -6521,8 +6496,8 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D, // Helper for delayed processing TransparentUnion attribute. void Sema::ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList) { - for (const AttributeList &AL : AttrList) - if (AL.getKind() == AttributeList::AT_TransparentUnion) { + for (const ParsedAttr &AL : AttrList) + if (AL.getKind() == ParsedAttr::AT_TransparentUnion) { handleTransparentUnionAttr(*this, D, AL); break; } @@ -6532,8 +6507,8 @@ void Sema::ProcessDeclAttributeDelayed(Decl *D, // specifier. bool Sema::ProcessAccessDeclAttributeList( AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList) { - for (const AttributeList &AL : AttrList) { - if (AL.getKind() == AttributeList::AT_Annotate) { + for (const ParsedAttr &AL : AttrList) { + if (AL.getKind() == ParsedAttr::AT_Annotate) { ProcessDeclAttribute(*this, nullptr, ASDecl, AL, AL.isCXX11Attribute()); } else { Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec); @@ -6546,14 +6521,14 @@ bool Sema::ProcessAccessDeclAttributeList( /// checkUnusedDeclAttributes - Check a list of attributes to see if it /// contains any decl attributes that we should warn about. static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A) { - for (const AttributeList &AL : A) { + for (const ParsedAttr &AL : A) { // Only warn if the attribute is an unignored, non-type attribute. if (AL.isUsedAsTypeAttr() || AL.isInvalid()) continue; - if (AL.getKind() == AttributeList::IgnoredAttribute) + if (AL.getKind() == ParsedAttr::IgnoredAttribute) continue; - if (AL.getKind() == AttributeList::UnknownAttribute) { + if (AL.getKind() == ParsedAttr::UnknownAttribute) { S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName() << AL.getRange(); } else { diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 6f411ca..63d01c9 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2300,10 +2300,10 @@ Sema::ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, // We do not support any C++11 attributes on base-specifiers yet. // Diagnose any attributes we see. - for (const AttributeList &AL : Attributes) { - if (AL.isInvalid() || AL.getKind() == AttributeList::IgnoredAttribute) + for (const ParsedAttr &AL : Attributes) { + if (AL.isInvalid() || AL.getKind() == ParsedAttr::IgnoredAttribute) continue; - Diag(AL.getLoc(), AL.getKind() == AttributeList::UnknownAttribute + Diag(AL.getLoc(), AL.getKind() == ParsedAttr::UnknownAttribute ? diag::warn_unknown_attribute_ignored : diag::err_base_specifier_attribute) << AL.getName(); @@ -2816,10 +2816,9 @@ static bool InitializationHasSideEffects(const FieldDecl &FD) { return false; } -static const AttributeList * -getMSPropertyAttr(const ParsedAttributesView &list) { +static const ParsedAttr *getMSPropertyAttr(const ParsedAttributesView &list) { ParsedAttributesView::const_iterator Itr = - llvm::find_if(list, [](const AttributeList &AL) { + llvm::find_if(list, [](const ParsedAttr &AL) { return AL.isDeclspecPropertyAttribute(); }); if (Itr != list.end()) @@ -2902,7 +2901,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, assert(!DS.isFriendSpecified()); bool isFunc = D.isDeclarationOfFunction(); - const AttributeList *MSPropertyAttr = + const ParsedAttr *MSPropertyAttr = getMSPropertyAttr(D.getDeclSpec().getAttributes()); if (cast<CXXRecordDecl>(CurContext)->isInterface()) { @@ -7815,8 +7814,8 @@ void Sema::ActOnFinishCXXMemberSpecification( AdjustDeclIfTemplate(TagDecl); - for (const AttributeList &AL : AttrList) { - if (AL.getKind() != AttributeList::AT_Visibility) + for (const ParsedAttr &AL : AttrList) { + if (AL.getKind() != ParsedAttr::AT_Visibility) continue; AL.setInvalid(); Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) @@ -15388,7 +15387,7 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, Expr *BitWidth, InClassInitStyle InitStyle, AccessSpecifier AS, - const AttributeList &MSPropertyAttr) { + const ParsedAttr &MSPropertyAttr) { IdentifierInfo *II = D.getIdentifier(); if (!II) { Diag(DeclStart, diag::err_anonymous_property); @@ -15451,7 +15450,7 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, PrevDecl = nullptr; SourceLocation TSSL = D.getLocStart(); - const AttributeList::PropertyData &Data = MSPropertyAttr.getPropertyData(); + const ParsedAttr::PropertyData &Data = MSPropertyAttr.getPropertyData(); MSPropertyDecl *NewPD = MSPropertyDecl::Create( Context, Record, Loc, II, T, TInfo, TSSL, Data.GetterId, Data.SetterId); ProcessDeclAttributes(TUScope, NewPD, D); diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index dbd967c..e39a65c 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -23,7 +23,7 @@ using namespace clang; using namespace sema; -static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, +static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range) { FallThroughAttr Attr(A.getRange(), S.Context, A.getAttributeSpellingListIndex()); @@ -53,7 +53,7 @@ static Attr *handleFallThroughAttr(Sema &S, Stmt *St, const AttributeList &A, return ::new (S.Context) auto(Attr); } -static Attr *handleSuppressAttr(Sema &S, Stmt *St, const AttributeList &A, +static Attr *handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range) { if (A.getNumArgs() < 1) { S.Diag(A.getLoc(), diag::err_attribute_too_few_arguments) @@ -78,7 +78,7 @@ static Attr *handleSuppressAttr(Sema &S, Stmt *St, const AttributeList &A, DiagnosticIdentifiers.size(), A.getAttributeSpellingListIndex()); } -static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const AttributeList &A, +static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange) { IdentifierLoc *PragmaNameLoc = A.getArgAsIdent(0); IdentifierLoc *OptionLoc = A.getArgAsIdent(1); @@ -246,7 +246,7 @@ CheckForIncompatibleAttributes(Sema &S, } } -static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const AttributeList &A, +static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range) { // Although the feature was introduced only in OpenCL C v2.0 s6.11.5, it's // useful for OpenCL 1.x too and doesn't require HW support. @@ -288,21 +288,21 @@ static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const AttributeList &A, return OpenCLUnrollHintAttr::CreateImplicit(S.Context, UnrollFactor); } -static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const AttributeList &A, +static Attr *ProcessStmtAttribute(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range) { switch (A.getKind()) { - case AttributeList::UnknownAttribute: + case ParsedAttr::UnknownAttribute: S.Diag(A.getLoc(), A.isDeclspecAttribute() ? diag::warn_unhandled_ms_attribute_ignored : diag::warn_unknown_attribute_ignored) << A.getName(); return nullptr; - case AttributeList::AT_FallThrough: + case ParsedAttr::AT_FallThrough: return handleFallThroughAttr(S, St, A, Range); - case AttributeList::AT_LoopHint: + case ParsedAttr::AT_LoopHint: return handleLoopHintAttr(S, St, A, Range); - case AttributeList::AT_OpenCLUnrollHint: + case ParsedAttr::AT_OpenCLUnrollHint: return handleOpenCLUnrollHint(S, St, A, Range); - case AttributeList::AT_Suppress: + case ParsedAttr::AT_Suppress: return handleSuppressAttr(S, St, A, Range); default: // if we're here, then we parsed a known attribute, but didn't recognize @@ -317,7 +317,7 @@ StmtResult Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributesView &AttrList, SourceRange Range) { SmallVector<const Attr*, 8> Attrs; - for (const AttributeList &AL : AttrList) { + for (const ParsedAttr &AL : AttrList) { if (Attr *a = ProcessStmtAttribute(*this, S, AL, Range)) Attrs.push_back(a); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 276a617..e78fd43 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -8599,8 +8599,8 @@ DeclResult Sema::ActOnExplicitInstantiation( if (TSK == TSK_ExplicitInstantiationDeclaration) { // Check for dllexport class template instantiation declarations. - for (const AttributeList &AL : Attr) { - if (AL.getKind() == AttributeList::AT_DLLExport) { + for (const ParsedAttr &AL : Attr) { + if (AL.getKind() == ParsedAttr::AT_DLLExport) { Diag(ExternLoc, diag::warn_attribute_dllexport_explicit_instantiation_decl); Diag(AL.getLoc(), diag::note_attribute); @@ -8623,10 +8623,10 @@ DeclResult Sema::ActOnExplicitInstantiation( // Check for dllimport class template instantiation definitions. bool DLLImport = ClassTemplate->getTemplatedDecl()->getAttr<DLLImportAttr>(); - for (const AttributeList &AL : Attr) { - if (AL.getKind() == AttributeList::AT_DLLImport) + for (const ParsedAttr &AL : Attr) { + if (AL.getKind() == ParsedAttr::AT_DLLImport) DLLImport = true; - if (AL.getKind() == AttributeList::AT_DLLExport) { + if (AL.getKind() == ParsedAttr::AT_DLLExport) { // dllexport trumps dllimport here. DLLImport = false; break; diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 18c5ce7..641a2f5 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -64,13 +64,17 @@ static bool isOmittedBlockReturnType(const Declarator &D) { /// diagnoseBadTypeAttribute - Diagnoses a type attribute which /// doesn't apply to the given type. -static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, +static void diagnoseBadTypeAttribute(Sema &S, const ParsedAttr &attr, QualType type) { TypeDiagSelector WhichType; bool useExpansionLoc = true; switch (attr.getKind()) { - case AttributeList::AT_ObjCGC: WhichType = TDS_Pointer; break; - case AttributeList::AT_ObjCOwnership: WhichType = TDS_ObjCObjOrBlock; break; + case ParsedAttr::AT_ObjCGC: + WhichType = TDS_Pointer; + break; + case ParsedAttr::AT_ObjCOwnership: + WhichType = TDS_ObjCObjOrBlock; + break; default: // Assume everything else was a function attribute. WhichType = TDS_Function; @@ -98,48 +102,48 @@ static void diagnoseBadTypeAttribute(Sema &S, const AttributeList &attr, // objc_gc applies to Objective-C pointers or, otherwise, to the // smallest available pointer type (i.e. 'void*' in 'void**'). -#define OBJC_POINTER_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_ObjCGC: \ - case AttributeList::AT_ObjCOwnership +#define OBJC_POINTER_TYPE_ATTRS_CASELIST \ + case ParsedAttr::AT_ObjCGC: \ + case ParsedAttr::AT_ObjCOwnership // Calling convention attributes. -#define CALLING_CONV_ATTRS_CASELIST \ - case AttributeList::AT_CDecl: \ - case AttributeList::AT_FastCall: \ - case AttributeList::AT_StdCall: \ - case AttributeList::AT_ThisCall: \ - case AttributeList::AT_RegCall: \ - case AttributeList::AT_Pascal: \ - case AttributeList::AT_SwiftCall: \ - case AttributeList::AT_VectorCall: \ - case AttributeList::AT_MSABI: \ - case AttributeList::AT_SysVABI: \ - case AttributeList::AT_Pcs: \ - case AttributeList::AT_IntelOclBicc: \ - case AttributeList::AT_PreserveMost: \ - case AttributeList::AT_PreserveAll +#define CALLING_CONV_ATTRS_CASELIST \ + case ParsedAttr::AT_CDecl: \ + case ParsedAttr::AT_FastCall: \ + case ParsedAttr::AT_StdCall: \ + case ParsedAttr::AT_ThisCall: \ + case ParsedAttr::AT_RegCall: \ + case ParsedAttr::AT_Pascal: \ + case ParsedAttr::AT_SwiftCall: \ + case ParsedAttr::AT_VectorCall: \ + case ParsedAttr::AT_MSABI: \ + case ParsedAttr::AT_SysVABI: \ + case ParsedAttr::AT_Pcs: \ + case ParsedAttr::AT_IntelOclBicc: \ + case ParsedAttr::AT_PreserveMost: \ + case ParsedAttr::AT_PreserveAll // Function type attributes. -#define FUNCTION_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_NSReturnsRetained: \ - case AttributeList::AT_NoReturn: \ - case AttributeList::AT_Regparm: \ - case AttributeList::AT_AnyX86NoCallerSavedRegisters: \ - case AttributeList::AT_AnyX86NoCfCheck: \ +#define FUNCTION_TYPE_ATTRS_CASELIST \ + case ParsedAttr::AT_NSReturnsRetained: \ + case ParsedAttr::AT_NoReturn: \ + case ParsedAttr::AT_Regparm: \ + case ParsedAttr::AT_AnyX86NoCallerSavedRegisters: \ + case ParsedAttr::AT_AnyX86NoCfCheck: \ CALLING_CONV_ATTRS_CASELIST // Microsoft-specific type qualifiers. -#define MS_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_Ptr32: \ - case AttributeList::AT_Ptr64: \ - case AttributeList::AT_SPtr: \ - case AttributeList::AT_UPtr +#define MS_TYPE_ATTRS_CASELIST \ + case ParsedAttr::AT_Ptr32: \ + case ParsedAttr::AT_Ptr64: \ + case ParsedAttr::AT_SPtr: \ + case ParsedAttr::AT_UPtr // Nullability qualifiers. -#define NULLABILITY_TYPE_ATTRS_CASELIST \ - case AttributeList::AT_TypeNonNull: \ - case AttributeList::AT_TypeNullable: \ - case AttributeList::AT_TypeNullUnspecified +#define NULLABILITY_TYPE_ATTRS_CASELIST \ + case ParsedAttr::AT_TypeNonNull: \ + case ParsedAttr::AT_TypeNullable: \ + case ParsedAttr::AT_TypeNullUnspecified namespace { /// An object which stores processing state for the entire @@ -162,11 +166,11 @@ namespace { bool hasSavedAttrs; /// The original set of attributes on the DeclSpec. - SmallVector<AttributeList*, 2> savedAttrs; + SmallVector<ParsedAttr *, 2> savedAttrs; /// A list of attributes to diagnose the uselessness of when the /// processing is complete. - SmallVector<AttributeList*, 2> ignoredTypeAttrs; + SmallVector<ParsedAttr *, 2> ignoredTypeAttrs; public: TypeProcessingState(Sema &sema, Declarator &declarator) @@ -207,7 +211,7 @@ namespace { if (hasSavedAttrs) return; DeclSpec &spec = getMutableDeclSpec(); - for (AttributeList &AL : spec.getAttributes()) + for (ParsedAttr &AL : spec.getAttributes()) savedAttrs.push_back(&AL); trivial &= savedAttrs.empty(); hasSavedAttrs = true; @@ -215,7 +219,7 @@ namespace { /// Record that we had nowhere to put the given type attribute. /// We will diagnose such attributes later. - void addIgnoredTypeAttr(AttributeList &attr) { + void addIgnoredTypeAttr(ParsedAttr &attr) { ignoredTypeAttrs.push_back(&attr); } @@ -241,13 +245,13 @@ namespace { assert(hasSavedAttrs); getMutableDeclSpec().getAttributes().clearListOnly(); - for (AttributeList *AL : savedAttrs) + for (ParsedAttr *AL : savedAttrs) getMutableDeclSpec().getAttributes().addAtStart(AL); } }; } // end anonymous namespace -static void moveAttrFromListToList(AttributeList &attr, +static void moveAttrFromListToList(ParsedAttr &attr, ParsedAttributesView &fromList, ParsedAttributesView &toList) { fromList.remove(&attr); @@ -267,25 +271,23 @@ enum TypeAttrLocation { static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, ParsedAttributesView &attrs); -static bool handleFunctionTypeAttr(TypeProcessingState &state, - AttributeList &attr, +static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type); static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &state, - AttributeList &attr, - QualType &type); + ParsedAttr &attr, QualType &type); -static bool handleObjCGCTypeAttr(TypeProcessingState &state, - AttributeList &attr, QualType &type); +static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, + QualType &type); static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, - AttributeList &attr, QualType &type); + ParsedAttr &attr, QualType &type); static bool handleObjCPointerTypeAttr(TypeProcessingState &state, - AttributeList &attr, QualType &type) { - if (attr.getKind() == AttributeList::AT_ObjCGC) + ParsedAttr &attr, QualType &type) { + if (attr.getKind() == ParsedAttr::AT_ObjCGC) return handleObjCGCTypeAttr(state, attr, type); - assert(attr.getKind() == AttributeList::AT_ObjCOwnership); + assert(attr.getKind() == ParsedAttr::AT_ObjCOwnership); return handleObjCOwnershipTypeAttr(state, attr, type); } @@ -367,8 +369,7 @@ static DeclaratorChunk *maybeMovePastReturnType(Declarator &declarator, /// didn't apply in whatever position it was written in, try to move /// it to a more appropriate position. static void distributeObjCPointerTypeAttr(TypeProcessingState &state, - AttributeList &attr, - QualType type) { + ParsedAttr &attr, QualType type) { Declarator &declarator = state.getDeclarator(); // Move it to the outermost normal or block pointer declarator. @@ -381,7 +382,7 @@ static void distributeObjCPointerTypeAttr(TypeProcessingState &state, // of a block. DeclaratorChunk *destChunk = nullptr; if (state.isProcessingDeclSpec() && - attr.getKind() == AttributeList::AT_ObjCOwnership) + attr.getKind() == ParsedAttr::AT_ObjCOwnership) destChunk = maybeMovePastReturnType(declarator, i - 1, /*onlyBlockPointers=*/true); if (!destChunk) destChunk = &chunk; @@ -398,7 +399,7 @@ static void distributeObjCPointerTypeAttr(TypeProcessingState &state, // We may be starting at the return type of a block. case DeclaratorChunk::Function: if (state.isProcessingDeclSpec() && - attr.getKind() == AttributeList::AT_ObjCOwnership) { + attr.getKind() == ParsedAttr::AT_ObjCOwnership) { if (DeclaratorChunk *dest = maybeMovePastReturnType( declarator, i, /*onlyBlockPointers=*/true)) { @@ -423,10 +424,8 @@ static void distributeObjCPointerTypeAttr(TypeProcessingState &state, /// Distribute an objc_gc type attribute that was written on the /// declarator. -static void -distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, - AttributeList &attr, - QualType &declSpecType) { +static void distributeObjCPointerTypeAttrFromDeclarator( + TypeProcessingState &state, ParsedAttr &attr, QualType &declSpecType) { Declarator &declarator = state.getDeclarator(); // objc_gc goes on the innermost pointer to something that's not a @@ -487,8 +486,7 @@ distributeObjCPointerTypeAttrFromDeclarator(TypeProcessingState &state, /// that it didn't apply in whatever position it was written in, try /// to move it to a more appropriate position. static void distributeFunctionTypeAttr(TypeProcessingState &state, - AttributeList &attr, - QualType type) { + ParsedAttr &attr, QualType type) { Declarator &declarator = state.getDeclarator(); // Try to push the attribute from the return type of a function to @@ -519,7 +517,7 @@ static void distributeFunctionTypeAttr(TypeProcessingState &state, /// function chunk or type. Returns true if the attribute was /// distributed, false if no location was found. static bool distributeFunctionTypeAttrToInnermost( - TypeProcessingState &state, AttributeList &attr, + TypeProcessingState &state, ParsedAttr &attr, ParsedAttributesView &attrList, QualType &declSpecType) { Declarator &declarator = state.getDeclarator(); @@ -537,10 +535,9 @@ static bool distributeFunctionTypeAttrToInnermost( /// A function type attribute was written in the decl spec. Try to /// apply it somewhere. -static void -distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, - AttributeList &attr, - QualType &declSpecType) { +static void distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, + ParsedAttr &attr, + QualType &declSpecType) { state.saveDeclSpecAttrs(); // C++11 attributes before the decl specifiers actually appertain to @@ -564,10 +561,9 @@ distributeFunctionTypeAttrFromDeclSpec(TypeProcessingState &state, /// A function type attribute was written on the declarator. Try to /// apply it somewhere. -static void -distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, - AttributeList &attr, - QualType &declSpecType) { +static void distributeFunctionTypeAttrFromDeclarator(TypeProcessingState &state, + ParsedAttr &attr, + QualType &declSpecType) { Declarator &declarator = state.getDeclarator(); // Try to distribute to the innermost. @@ -599,7 +595,7 @@ static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, // list, so iterating over the existing list isn't possible. Instead, make a // non-owning copy and iterate over that. ParsedAttributesView AttrsCopy{state.getDeclarator().getAttributes()}; - for (AttributeList &attr : AttrsCopy) { + for (ParsedAttr &attr : AttrsCopy) { // Do not distribute C++11 attributes. They have strict rules for what // they appertain to. if (attr.isCXX11Attribute()) @@ -622,7 +618,7 @@ static void distributeTypeAttrsFromDeclarator(TypeProcessingState &state, // Nullability specifiers cannot go after the declarator-id. // Objective-C __kindof does not get distributed. - case AttributeList::AT_ObjCKindOf: + case ParsedAttr::AT_ObjCKindOf: continue; default: @@ -728,8 +724,8 @@ static bool checkOmittedBlockReturnType(Sema &S, Declarator &declarator, return false; // Warn if we see type attributes for omitted return type on a block literal. - SmallVector<AttributeList *, 2> ToBeRemoved; - for (AttributeList &AL : declarator.getMutableDeclSpec().getAttributes()) { + SmallVector<ParsedAttr *, 2> ToBeRemoved; + for (ParsedAttr &AL : declarator.getMutableDeclSpec().getAttributes()) { if (AL.isInvalid() || !AL.isTypeAttr()) continue; S.Diag(AL.getLoc(), @@ -738,7 +734,7 @@ static bool checkOmittedBlockReturnType(Sema &S, Declarator &declarator, ToBeRemoved.push_back(&AL); } // Remove bad attributes from the list. - for (AttributeList *AL : ToBeRemoved) + for (ParsedAttr *AL : ToBeRemoved) declarator.getMutableDeclSpec().getAttributes().remove(AL); // Warn if we see type qualifiers for omitted return type on a block literal. @@ -1169,8 +1165,8 @@ TypeResult Sema::actOnObjCTypeArgsAndProtocolQualifiers( static OpenCLAccessAttr::Spelling getImageAccess(const ParsedAttributesView &Attrs) { - for (const AttributeList &AL : Attrs) - if (AL.getKind() == AttributeList::AT_OpenCLAccess) + for (const ParsedAttr &AL : Attrs) + if (AL.getKind() == ParsedAttr::AT_OpenCLAccess) return static_cast<OpenCLAccessAttr::Spelling>(AL.getSemanticSpelling()); return OpenCLAccessAttr::Keyword_read_only; } @@ -2599,8 +2595,8 @@ static void inferARCWriteback(TypeProcessingState &state, if (chunk.Kind != DeclaratorChunk::Pointer && chunk.Kind != DeclaratorChunk::BlockPointer) return; - for (const AttributeList &AL : chunk.getAttrs()) - if (AL.getKind() == AttributeList::AT_ObjCOwnership) + for (const ParsedAttr &AL : chunk.getAttrs()) + if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) return; transferARCOwnershipToDeclaratorChunk(state, Qualifiers::OCL_Autoreleasing, @@ -3272,7 +3268,7 @@ static CallingConv getCCForDeclaratorChunk( assert(D.getTypeObject(ChunkIndex).Kind == DeclaratorChunk::Function); // Check for an explicit CC attribute. - for (const AttributeList &AL : AttrList) { + for (const ParsedAttr &AL : AttrList) { switch (AL.getKind()) { CALLING_CONV_ATTRS_CASELIST : { // Ignore attributes that don't validate or can't apply to the @@ -3335,8 +3331,8 @@ static CallingConv getCCForDeclaratorChunk( // convention attribute. This is the simplest place to infer // calling convention for OpenCL kernels. if (S.getLangOpts().OpenCL) { - for (const AttributeList &AL : D.getDeclSpec().getAttributes()) { - if (AL.getKind() == AttributeList::AT_OpenCLKernel) { + for (const ParsedAttr &AL : D.getDeclSpec().getAttributes()) { + if (AL.getKind() == ParsedAttr::AT_OpenCLKernel) { CC = CC_OpenCLKernel; break; } @@ -3388,10 +3384,10 @@ IdentifierInfo *Sema::getNSErrorIdent() { /// Check whether there is a nullability attribute of any kind in the given /// attribute list. static bool hasNullabilityAttr(const ParsedAttributesView &attrs) { - for (const AttributeList &AL : attrs) { - if (AL.getKind() == AttributeList::AT_TypeNonNull || - AL.getKind() == AttributeList::AT_TypeNullable || - AL.getKind() == AttributeList::AT_TypeNullUnspecified) + for (const ParsedAttr &AL : attrs) { + if (AL.getKind() == ParsedAttr::AT_TypeNonNull || + AL.getKind() == ParsedAttr::AT_TypeNullable || + AL.getKind() == ParsedAttr::AT_TypeNullUnspecified) return true; } @@ -3995,9 +3991,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // infer the inner pointer as _Nullable. auto hasCFReturnsAttr = [](const ParsedAttributesView &AttrList) -> bool { - return AttrList.hasAttribute(AttributeList::AT_CFReturnsRetained) || - AttrList.hasAttribute( - AttributeList::AT_CFReturnsNotRetained); + return AttrList.hasAttribute(ParsedAttr::AT_CFReturnsRetained) || + AttrList.hasAttribute(ParsedAttr::AT_CFReturnsNotRetained); }; if (const auto *InnermostChunk = D.getInnermostNonParenChunk()) { if (hasCFReturnsAttr(D.getAttributes()) || @@ -4061,7 +4056,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, auto inferPointerNullability = [&](SimplePointerKind pointerKind, SourceLocation pointerLoc, SourceLocation pointerEndLoc, - ParsedAttributesView &attrs) -> AttributeList * { + ParsedAttributesView &attrs) -> ParsedAttr * { // We've seen a pointer. if (NumPointersRemaining > 0) --NumPointersRemaining; @@ -4072,16 +4067,14 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // If we're supposed to infer nullability, do so now. if (inferNullability && !inferNullabilityInnerOnlyComplete) { - AttributeList::Syntax syntax - = inferNullabilityCS ? AttributeList::AS_ContextSensitiveKeyword - : AttributeList::AS_Keyword; - AttributeList *nullabilityAttr = state.getDeclarator().getAttributePool() - .create( - S.getNullabilityKeyword( - *inferNullability), - SourceRange(pointerLoc), - nullptr, SourceLocation(), - nullptr, 0, syntax); + ParsedAttr::Syntax syntax = inferNullabilityCS + ? ParsedAttr::AS_ContextSensitiveKeyword + : ParsedAttr::AS_Keyword; + ParsedAttr *nullabilityAttr = + state.getDeclarator().getAttributePool().create( + S.getNullabilityKeyword(*inferNullability), + SourceRange(pointerLoc), nullptr, SourceLocation(), nullptr, 0, + syntax); attrs.addAtStart(nullabilityAttr); @@ -4474,16 +4467,16 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, SourceLocation AttrLoc; if (chunkIndex + 1 < D.getNumTypeObjects()) { DeclaratorChunk ReturnTypeChunk = D.getTypeObject(chunkIndex + 1); - for (const AttributeList &AL : ReturnTypeChunk.getAttrs()) { - if (AL.getKind() == AttributeList::AT_ObjCOwnership) { + for (const ParsedAttr &AL : ReturnTypeChunk.getAttrs()) { + if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) { AttrLoc = AL.getLoc(); break; } } } if (AttrLoc.isInvalid()) { - for (const AttributeList &AL : D.getDeclSpec().getAttributes()) { - if (AL.getKind() == AttributeList::AT_ObjCOwnership) { + for (const ParsedAttr &AL : D.getDeclSpec().getAttributes()) { + if (AL.getKind() == ParsedAttr::AT_ObjCOwnership) { AttrLoc = AL.getLoc(); break; } @@ -4536,7 +4529,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // function is marked with the "overloadable" attribute. Scan // for this attribute now. if (!FTI.NumParams && FTI.isVariadic && !LangOpts.CPlusPlus) - if (!D.getAttributes().hasAttribute(AttributeList::AT_Overloadable)) + if (!D.getAttributes().hasAttribute(ParsedAttr::AT_Overloadable)) S.Diag(FTI.getEllipsisLoc(), diag::err_ellipsis_first_param); if (FTI.NumParams && FTI.Params[0].Param == nullptr) { @@ -5024,7 +5017,7 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, // Look for an explicit lifetime attribute. DeclaratorChunk &chunk = D.getTypeObject(chunkIndex); - if (chunk.getAttrs().hasAttribute(AttributeList::AT_ObjCOwnership)) + if (chunk.getAttrs().hasAttribute(ParsedAttr::AT_ObjCOwnership)) return; const char *attrStr = nullptr; @@ -5044,10 +5037,10 @@ static void transferARCOwnershipToDeclaratorChunk(TypeProcessingState &state, // If there wasn't one, add one (with an invalid source location // so that we don't make an AttributedType for it). - AttributeList *attr = D.getAttributePool() - .create(&S.Context.Idents.get("objc_ownership"), SourceLocation(), - /*scope*/ nullptr, SourceLocation(), - /*args*/ &Args, 1, AttributeList::AS_GNU); + ParsedAttr *attr = D.getAttributePool().create( + &S.Context.Idents.get("objc_ownership"), SourceLocation(), + /*scope*/ nullptr, SourceLocation(), + /*args*/ &Args, 1, ParsedAttr::AS_GNU); chunk.getAttrs().addAtStart(attr); // TODO: mark whether we did this inference? } @@ -5119,81 +5112,80 @@ TypeSourceInfo *Sema::GetTypeForDeclaratorCast(Declarator &D, QualType FromTy) { return GetFullTypeForDeclarator(state, declSpecTy, ReturnTypeInfo); } -/// Map an AttributedType::Kind to an AttributeList::Kind. -static AttributeList::Kind getAttrListKind(AttributedType::Kind kind) { +/// Map an AttributedType::Kind to an ParsedAttr::Kind. +static ParsedAttr::Kind getAttrListKind(AttributedType::Kind kind) { switch (kind) { case AttributedType::attr_address_space: - return AttributeList::AT_AddressSpace; + return ParsedAttr::AT_AddressSpace; case AttributedType::attr_regparm: - return AttributeList::AT_Regparm; + return ParsedAttr::AT_Regparm; case AttributedType::attr_vector_size: - return AttributeList::AT_VectorSize; + return ParsedAttr::AT_VectorSize; case AttributedType::attr_neon_vector_type: - return AttributeList::AT_NeonVectorType; + return ParsedAttr::AT_NeonVectorType; case AttributedType::attr_neon_polyvector_type: - return AttributeList::AT_NeonPolyVectorType; + return ParsedAttr::AT_NeonPolyVectorType; case AttributedType::attr_objc_gc: - return AttributeList::AT_ObjCGC; + return ParsedAttr::AT_ObjCGC; case AttributedType::attr_objc_ownership: case AttributedType::attr_objc_inert_unsafe_unretained: - return AttributeList::AT_ObjCOwnership; + return ParsedAttr::AT_ObjCOwnership; case AttributedType::attr_noreturn: - return AttributeList::AT_NoReturn; + return ParsedAttr::AT_NoReturn; case AttributedType::attr_nocf_check: - return AttributeList::AT_AnyX86NoCfCheck; + return ParsedAttr::AT_AnyX86NoCfCheck; case AttributedType::attr_cdecl: - return AttributeList::AT_CDecl; + return ParsedAttr::AT_CDecl; case AttributedType::attr_fastcall: - return AttributeList::AT_FastCall; + return ParsedAttr::AT_FastCall; case AttributedType::attr_stdcall: - return AttributeList::AT_StdCall; + return ParsedAttr::AT_StdCall; case AttributedType::attr_thiscall: - return AttributeList::AT_ThisCall; + return ParsedAttr::AT_ThisCall; case AttributedType::attr_regcall: - return AttributeList::AT_RegCall; + return ParsedAttr::AT_RegCall; case AttributedType::attr_pascal: - return AttributeList::AT_Pascal; + return ParsedAttr::AT_Pascal; case AttributedType::attr_swiftcall: - return AttributeList::AT_SwiftCall; + return ParsedAttr::AT_SwiftCall; case AttributedType::attr_vectorcall: - return AttributeList::AT_VectorCall; + return ParsedAttr::AT_VectorCall; case AttributedType::attr_pcs: case AttributedType::attr_pcs_vfp: - return AttributeList::AT_Pcs; + return ParsedAttr::AT_Pcs; case AttributedType::attr_inteloclbicc: - return AttributeList::AT_IntelOclBicc; + return ParsedAttr::AT_IntelOclBicc; case AttributedType::attr_ms_abi: - return AttributeList::AT_MSABI; + return ParsedAttr::AT_MSABI; case AttributedType::attr_sysv_abi: - return AttributeList::AT_SysVABI; + return ParsedAttr::AT_SysVABI; case AttributedType::attr_preserve_most: - return AttributeList::AT_PreserveMost; + return ParsedAttr::AT_PreserveMost; case AttributedType::attr_preserve_all: - return AttributeList::AT_PreserveAll; + return ParsedAttr::AT_PreserveAll; case AttributedType::attr_ptr32: - return AttributeList::AT_Ptr32; + return ParsedAttr::AT_Ptr32; case AttributedType::attr_ptr64: - return AttributeList::AT_Ptr64; + return ParsedAttr::AT_Ptr64; case AttributedType::attr_sptr: - return AttributeList::AT_SPtr; + return ParsedAttr::AT_SPtr; case AttributedType::attr_uptr: - return AttributeList::AT_UPtr; + return ParsedAttr::AT_UPtr; case AttributedType::attr_nonnull: - return AttributeList::AT_TypeNonNull; + return ParsedAttr::AT_TypeNonNull; case AttributedType::attr_nullable: - return AttributeList::AT_TypeNullable; + return ParsedAttr::AT_TypeNullable; case AttributedType::attr_null_unspecified: - return AttributeList::AT_TypeNullUnspecified; + return ParsedAttr::AT_TypeNullUnspecified; case AttributedType::attr_objc_kindof: - return AttributeList::AT_ObjCKindOf; + return ParsedAttr::AT_ObjCKindOf; case AttributedType::attr_ns_returns_retained: - return AttributeList::AT_NSReturnsRetained; + return ParsedAttr::AT_NSReturnsRetained; } llvm_unreachable("unexpected attribute kind!"); } -static void setAttributedTypeLoc(AttributedTypeLoc TL, - const AttributeList &attr) { +static void setAttributedTypeLoc(AttributedTypeLoc TL, const ParsedAttr &attr) { TL.setAttrNameLoc(attr.getLoc()); if (TL.hasAttrExprOperand()) { assert(attr.isArgExpr(0) && "mismatched attribute operand kind"); @@ -5219,13 +5211,13 @@ static void fillAttributedTypeLoc(AttributedTypeLoc TL, assert((!Attrs.empty() || !DeclAttrs.empty()) && "no type attributes in the expected location!"); - AttributeList::Kind parsedKind = getAttrListKind(TL.getAttrKind()); + ParsedAttr::Kind parsedKind = getAttrListKind(TL.getAttrKind()); // Try to search for an attribute of matching kind in Attrs list. - for (const AttributeList &AL : Attrs) + for (const ParsedAttr &AL : Attrs) if (AL.getKind() == parsedKind) return setAttributedTypeLoc(TL, AL); - for (const AttributeList &AL : DeclAttrs) + for (const ParsedAttr &AL : DeclAttrs) if (AL.isCXX11Attribute() || AL.getKind() == parsedKind) return setAttributedTypeLoc(TL, AL); llvm_unreachable("no matching type attribute in expected location!"); @@ -5549,8 +5541,8 @@ static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) { static void fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL, const ParsedAttributesView &Attrs) { - for (const AttributeList &AL : Attrs) { - if (AL.getKind() == AttributeList::AT_AddressSpace) { + for (const ParsedAttr &AL : Attrs) { + if (AL.getKind() == ParsedAttr::AT_AddressSpace) { DASTL.setAttrNameLoc(AL.getLoc()); DASTL.setAttrExprOperand(AL.getArgAsExpr(0)); DASTL.setAttrOperandParensRange(SourceRange()); @@ -5755,7 +5747,7 @@ QualType Sema::BuildAddressSpaceAttr(QualType &T, Expr *AddrSpace, /// specified type. The attribute contains 1 argument, the id of the address /// space for the type. static void HandleAddressSpaceTypeAttribute(QualType &Type, - const AttributeList &Attr, Sema &S){ + const ParsedAttr &Attr, Sema &S) { // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be // qualified by an address-space qualifier." if (Type->isFunctionType()) { @@ -5765,7 +5757,7 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type, } LangAS ASIdx; - if (Attr.getKind() == AttributeList::AT_AddressSpace) { + if (Attr.getKind() == ParsedAttr::AT_AddressSpace) { // Check the attribute arguments. if (Attr.getNumArgs() != 1) { @@ -5804,15 +5796,15 @@ static void HandleAddressSpaceTypeAttribute(QualType &Type, } else { // The keyword-based type attributes imply which address space to use. switch (Attr.getKind()) { - case AttributeList::AT_OpenCLGlobalAddressSpace: + case ParsedAttr::AT_OpenCLGlobalAddressSpace: ASIdx = LangAS::opencl_global; break; - case AttributeList::AT_OpenCLLocalAddressSpace: + case ParsedAttr::AT_OpenCLLocalAddressSpace: ASIdx = LangAS::opencl_local; break; - case AttributeList::AT_OpenCLConstantAddressSpace: + case ParsedAttr::AT_OpenCLConstantAddressSpace: ASIdx = LangAS::opencl_constant; break; - case AttributeList::AT_OpenCLGenericAddressSpace: + case ParsedAttr::AT_OpenCLGenericAddressSpace: ASIdx = LangAS::opencl_generic; break; - case AttributeList::AT_OpenCLPrivateAddressSpace: + case ParsedAttr::AT_OpenCLPrivateAddressSpace: ASIdx = LangAS::opencl_private; break; default: llvm_unreachable("Invalid address space"); @@ -5872,8 +5864,7 @@ static bool hasDirectOwnershipQualifier(QualType type) { /// /// Returns 'true' if the attribute was handled. static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, - AttributeList &attr, - QualType &type) { + ParsedAttr &attr, QualType &type) { bool NonObjCPointer = false; if (!type->isDependentType() && !type->isUndeducedType()) { @@ -6058,8 +6049,7 @@ static bool handleObjCOwnershipTypeAttr(TypeProcessingState &state, /// attribute on the specified type. Returns true to indicate that /// the attribute was handled, false to indicate that the type does /// not permit the attribute. -static bool handleObjCGCTypeAttr(TypeProcessingState &state, - AttributeList &attr, +static bool handleObjCGCTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type) { Sema &S = state.getSema(); @@ -6251,11 +6241,10 @@ namespace { } // end anonymous namespace static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State, - AttributeList &Attr, - QualType &Type) { + ParsedAttr &Attr, QualType &Type) { Sema &S = State.getSema(); - AttributeList::Kind Kind = Attr.getKind(); + ParsedAttr::Kind Kind = Attr.getKind(); QualType Desugared = Type; const AttributedType *AT = dyn_cast<AttributedType>(Type); while (AT) { @@ -6272,16 +6261,16 @@ static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State, // You cannot have both __sptr and __uptr on the same type, nor can you // have __ptr32 and __ptr64. if ((CurAttrKind == AttributedType::attr_ptr32 && - Kind == AttributeList::AT_Ptr64) || + Kind == ParsedAttr::AT_Ptr64) || (CurAttrKind == AttributedType::attr_ptr64 && - Kind == AttributeList::AT_Ptr32)) { + Kind == ParsedAttr::AT_Ptr32)) { S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible) << "'__ptr32'" << "'__ptr64'"; return true; } else if ((CurAttrKind == AttributedType::attr_sptr && - Kind == AttributeList::AT_UPtr) || + Kind == ParsedAttr::AT_UPtr) || (CurAttrKind == AttributedType::attr_uptr && - Kind == AttributeList::AT_SPtr)) { + Kind == ParsedAttr::AT_SPtr)) { S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible) << "'__sptr'" << "'__uptr'"; return true; @@ -6306,10 +6295,18 @@ static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State, AttributedType::Kind TAK; switch (Kind) { default: llvm_unreachable("Unknown attribute kind"); - case AttributeList::AT_Ptr32: TAK = AttributedType::attr_ptr32; break; - case AttributeList::AT_Ptr64: TAK = AttributedType::attr_ptr64; break; - case AttributeList::AT_SPtr: TAK = AttributedType::attr_sptr; break; - case AttributeList::AT_UPtr: TAK = AttributedType::attr_uptr; break; + case ParsedAttr::AT_Ptr32: + TAK = AttributedType::attr_ptr32; + break; + case ParsedAttr::AT_Ptr64: + TAK = AttributedType::attr_ptr64; + break; + case ParsedAttr::AT_SPtr: + TAK = AttributedType::attr_sptr; + break; + case ParsedAttr::AT_UPtr: + TAK = AttributedType::attr_uptr; + break; } Type = S.Context.getAttributedType(TAK, Type, Type); @@ -6460,15 +6457,15 @@ bool Sema::checkObjCKindOfType(QualType &type, SourceLocation loc) { } /// Map a nullability attribute kind to a nullability kind. -static NullabilityKind mapNullabilityAttrKind(AttributeList::Kind kind) { +static NullabilityKind mapNullabilityAttrKind(ParsedAttr::Kind kind) { switch (kind) { - case AttributeList::AT_TypeNonNull: + case ParsedAttr::AT_TypeNonNull: return NullabilityKind::NonNull; - case AttributeList::AT_TypeNullable: + case ParsedAttr::AT_TypeNullable: return NullabilityKind::Nullable; - case AttributeList::AT_TypeNullUnspecified: + case ParsedAttr::AT_TypeNullUnspecified: return NullabilityKind::Unspecified; default: @@ -6483,8 +6480,7 @@ static NullabilityKind mapNullabilityAttrKind(AttributeList::Kind kind) { /// \returns true if the nullability annotation was distributed, false /// otherwise. static bool distributeNullabilityTypeAttr(TypeProcessingState &state, - QualType type, - AttributeList &attr) { + QualType type, ParsedAttr &attr) { Declarator &declarator = state.getDeclarator(); /// Attempt to move the attribute to the specified chunk. @@ -6564,28 +6560,28 @@ static bool distributeNullabilityTypeAttr(TypeProcessingState &state, return false; } -static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr) { +static AttributedType::Kind getCCTypeAttrKind(ParsedAttr &Attr) { assert(!Attr.isInvalid()); switch (Attr.getKind()) { default: llvm_unreachable("not a calling convention attribute"); - case AttributeList::AT_CDecl: + case ParsedAttr::AT_CDecl: return AttributedType::attr_cdecl; - case AttributeList::AT_FastCall: + case ParsedAttr::AT_FastCall: return AttributedType::attr_fastcall; - case AttributeList::AT_StdCall: + case ParsedAttr::AT_StdCall: return AttributedType::attr_stdcall; - case AttributeList::AT_ThisCall: + case ParsedAttr::AT_ThisCall: return AttributedType::attr_thiscall; - case AttributeList::AT_RegCall: + case ParsedAttr::AT_RegCall: return AttributedType::attr_regcall; - case AttributeList::AT_Pascal: + case ParsedAttr::AT_Pascal: return AttributedType::attr_pascal; - case AttributeList::AT_SwiftCall: + case ParsedAttr::AT_SwiftCall: return AttributedType::attr_swiftcall; - case AttributeList::AT_VectorCall: + case ParsedAttr::AT_VectorCall: return AttributedType::attr_vectorcall; - case AttributeList::AT_Pcs: { + case ParsedAttr::AT_Pcs: { // The attribute may have had a fixit applied where we treated an // identifier as a string literal. The contents of the string are valid, // but the form may not be. @@ -6598,15 +6594,15 @@ static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr) { .Case("aapcs", AttributedType::attr_pcs) .Case("aapcs-vfp", AttributedType::attr_pcs_vfp); } - case AttributeList::AT_IntelOclBicc: + case ParsedAttr::AT_IntelOclBicc: return AttributedType::attr_inteloclbicc; - case AttributeList::AT_MSABI: + case ParsedAttr::AT_MSABI: return AttributedType::attr_ms_abi; - case AttributeList::AT_SysVABI: + case ParsedAttr::AT_SysVABI: return AttributedType::attr_sysv_abi; - case AttributeList::AT_PreserveMost: + case ParsedAttr::AT_PreserveMost: return AttributedType::attr_preserve_most; - case AttributeList::AT_PreserveAll: + case ParsedAttr::AT_PreserveAll: return AttributedType::attr_preserve_all; } llvm_unreachable("unexpected attribute kind!"); @@ -6614,14 +6610,13 @@ static AttributedType::Kind getCCTypeAttrKind(AttributeList &Attr) { /// Process an individual function attribute. Returns true to /// indicate that the attribute was handled, false if it wasn't. -static bool handleFunctionTypeAttr(TypeProcessingState &state, - AttributeList &attr, +static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr, QualType &type) { Sema &S = state.getSema(); FunctionTypeUnwrapper unwrapped(S, type); - if (attr.getKind() == AttributeList::AT_NoReturn) { + if (attr.getKind() == ParsedAttr::AT_NoReturn) { if (S.CheckAttrNoArgs(attr)) return true; @@ -6637,7 +6632,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, // ns_returns_retained is not always a type attribute, but if we got // here, we're treating it as one right now. - if (attr.getKind() == AttributeList::AT_NSReturnsRetained) { + if (attr.getKind() == ParsedAttr::AT_NSReturnsRetained) { if (attr.getNumArgs()) return true; // Delay if this is not a function type. @@ -6661,7 +6656,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, return true; } - if (attr.getKind() == AttributeList::AT_AnyX86NoCallerSavedRegisters) { + if (attr.getKind() == ParsedAttr::AT_AnyX86NoCallerSavedRegisters) { if (S.CheckAttrTarget(attr) || S.CheckAttrNoArgs(attr)) return true; @@ -6675,7 +6670,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, return true; } - if (attr.getKind() == AttributeList::AT_AnyX86NoCfCheck) { + if (attr.getKind() == ParsedAttr::AT_AnyX86NoCfCheck) { if (!S.getLangOpts().CFProtectionBranch) { S.Diag(attr.getLoc(), diag::warn_nocf_check_attribute_ignored); attr.setInvalid(); @@ -6696,7 +6691,7 @@ static bool handleFunctionTypeAttr(TypeProcessingState &state, return true; } - if (attr.getKind() == AttributeList::AT_Regparm) { + if (attr.getKind() == ParsedAttr::AT_Regparm) { unsigned value; if (S.CheckRegparmAttr(attr, value)) return true; @@ -6853,7 +6848,7 @@ void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor, /// The raw attribute should contain precisely 1 argument, the vector size for /// the variable, measured in bytes. If curType and rawAttr are well formed, /// this routine will return a new vector type. -static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr, +static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S) { // Check the attribute arguments. if (Attr.getNumArgs() != 1) { @@ -6912,8 +6907,7 @@ static void HandleVectorSizeAttr(QualType& CurType, const AttributeList &Attr, /// Process the OpenCL-like ext_vector_type attribute when it occurs on /// a type. -static void HandleExtVectorTypeAttr(QualType &CurType, - const AttributeList &Attr, +static void HandleExtVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S) { // check the attribute arguments. if (Attr.getNumArgs() != 1) { @@ -7002,9 +6996,8 @@ static bool isPermittedNeonBaseType(QualType &Ty, /// the argument to these Neon attributes is the number of vector elements, /// not the vector size in bytes. The vector width and element type must /// match one of the standard Neon vector types. -static void HandleNeonVectorTypeAttr(QualType& CurType, - const AttributeList &Attr, Sema &S, - VectorType::VectorKind VecKind) { +static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr, + Sema &S, VectorType::VectorKind VecKind) { // Target must have NEON if (!S.Context.getTargetInfo().hasFeature("neon")) { S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr.getName(); @@ -7050,7 +7043,7 @@ static void HandleNeonVectorTypeAttr(QualType& CurType, } /// Handle OpenCL Access Qualifier Attribute. -static void HandleOpenCLAccessAttr(QualType &CurType, const AttributeList &Attr, +static void HandleOpenCLAccessAttr(QualType &CurType, const ParsedAttr &Attr, Sema &S) { // OpenCL v2.0 s6.6 - Access qualifier can be used only for image and pipe type. if (!(CurType->isImageType() || CurType->isPipeType())) { @@ -7183,7 +7176,7 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, // sure we visit every element once. Copy the attributes list, and iterate // over that. ParsedAttributesView AttrsCopy{attrs}; - for (AttributeList &attr : AttrsCopy) { + for (ParsedAttr &attr : AttrsCopy) { // Skip attributes that were marked to be invalid. if (attr.isInvalid()) @@ -7224,27 +7217,27 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, } break; - case AttributeList::UnknownAttribute: + case ParsedAttr::UnknownAttribute: if (attr.isCXX11Attribute() && TAL == TAL_DeclChunk) state.getSema().Diag(attr.getLoc(), diag::warn_unknown_attribute_ignored) << attr.getName(); break; - case AttributeList::IgnoredAttribute: + case ParsedAttr::IgnoredAttribute: break; - case AttributeList::AT_MayAlias: + case ParsedAttr::AT_MayAlias: // FIXME: This attribute needs to actually be handled, but if we ignore // it it breaks large amounts of Linux software. attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_OpenCLPrivateAddressSpace: - case AttributeList::AT_OpenCLGlobalAddressSpace: - case AttributeList::AT_OpenCLLocalAddressSpace: - case AttributeList::AT_OpenCLConstantAddressSpace: - case AttributeList::AT_OpenCLGenericAddressSpace: - case AttributeList::AT_AddressSpace: + case ParsedAttr::AT_OpenCLPrivateAddressSpace: + case ParsedAttr::AT_OpenCLGlobalAddressSpace: + case ParsedAttr::AT_OpenCLLocalAddressSpace: + case ParsedAttr::AT_OpenCLConstantAddressSpace: + case ParsedAttr::AT_OpenCLGenericAddressSpace: + case ParsedAttr::AT_AddressSpace: HandleAddressSpaceTypeAttribute(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; @@ -7253,25 +7246,25 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, distributeObjCPointerTypeAttr(state, attr, type); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_VectorSize: + case ParsedAttr::AT_VectorSize: HandleVectorSizeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_ExtVectorType: + case ParsedAttr::AT_ExtVectorType: HandleExtVectorTypeAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_NeonVectorType: + case ParsedAttr::AT_NeonVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonVector); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_NeonPolyVectorType: + case ParsedAttr::AT_NeonPolyVectorType: HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorType::NeonPolyVector); attr.setUsedAsTypeAttr(); break; - case AttributeList::AT_OpenCLAccess: + case ParsedAttr::AT_OpenCLAccess: HandleOpenCLAccessAttr(type, attr, state.getSema()); attr.setUsedAsTypeAttr(); break; @@ -7310,7 +7303,7 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, } break; - case AttributeList::AT_ObjCKindOf: + case ParsedAttr::AT_ObjCKindOf: // '__kindof' must be part of the decl-specifiers. switch (TAL) { case TAL_DeclSpec: diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 712a854..bddd51e 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -3132,7 +3132,7 @@ static void emitArgInfo(const Record &R, raw_ostream &OS) { } static void GenerateDefaultAppertainsTo(raw_ostream &OS) { - OS << "static bool defaultAppertainsTo(Sema &, const AttributeList &,"; + OS << "static bool defaultAppertainsTo(Sema &, const ParsedAttr &,"; OS << "const Decl *) {\n"; OS << " return true;\n"; OS << "}\n\n"; @@ -3270,7 +3270,7 @@ static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) { // name of that check to the caller. std::string FnName = "check" + Attr.getName().str() + "AppertainsTo"; std::stringstream SS; - SS << "static bool " << FnName << "(Sema &S, const AttributeList &Attr, "; + SS << "static bool " << FnName << "(Sema &S, const ParsedAttr &Attr, "; SS << "const Decl *D) {\n"; SS << " if ("; for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) { @@ -3342,7 +3342,7 @@ emitAttributeMatchRules(PragmaClangAttributeSupport &PragmaAttributeSupport, static void GenerateDefaultLangOptRequirements(raw_ostream &OS) { OS << "static bool defaultDiagnoseLangOpts(Sema &, "; - OS << "const AttributeList &) {\n"; + OS << "const ParsedAttr &) {\n"; OS << " return true;\n"; OS << "}\n\n"; } @@ -3381,7 +3381,7 @@ static std::string GenerateLangOptRequirements(const Record &R, if (I != CustomLangOptsSet.end()) return *I; - OS << "static bool " << FnName << "(Sema &S, const AttributeList &Attr) {\n"; + OS << "static bool " << FnName << "(Sema &S, const ParsedAttr &Attr) {\n"; OS << " if (" << Test << ")\n"; OS << " return true;\n\n"; OS << " S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) "; @@ -3414,7 +3414,7 @@ static std::string GenerateTargetRequirements(const Record &Attr, // If there are other attributes which share the same parsed attribute kind, // such as target-specific attributes with a shared spelling, collapse the // duplicate architectures. This is required because a shared target-specific - // attribute has only one AttributeList::Kind enumeration value, but it + // attribute has only one ParsedAttr::Kind enumeration value, but it // applies to multiple target architectures. In order for the attribute to be // considered valid, all of its architectures need to be included. if (!Attr.isValueUnset("ParseKind")) { @@ -3451,7 +3451,7 @@ static std::string GenerateTargetRequirements(const Record &Attr, static void GenerateDefaultSpellingIndexToSemanticSpelling(raw_ostream &OS) { OS << "static unsigned defaultSpellingIndexToSemanticSpelling(" - << "const AttributeList &Attr) {\n"; + << "const ParsedAttr &Attr) {\n"; OS << " return UINT_MAX;\n"; OS << "}\n\n"; } @@ -3474,7 +3474,7 @@ static std::string GenerateSpellingIndexToSemanticSpelling(const Record &Attr, std::string Enum = CreateSemanticSpellings(Spellings, SemanticToSyntacticMap); std::string Name = Attr.getName().str() + "AttrSpellingMap"; - OS << "static unsigned " << Name << "(const AttributeList &Attr) {\n"; + OS << "static unsigned " << Name << "(const ParsedAttr &Attr) {\n"; OS << Enum; OS << " unsigned Idx = Attr.getAttributeSpellingListIndex();\n"; WriteSemanticSpellingSwitch("Idx", SemanticToSyntacticMap, OS); @@ -3524,7 +3524,7 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) { // the spellings are identical, and custom parsing rules match, etc. // We need to generate struct instances based off ParsedAttrInfo from - // AttributeList.cpp. + // ParsedAttr.cpp. SS << " { "; emitArgInfo(*I->second, SS); SS << ", " << I->second->getValueAsBit("HasCustomParsing"); @@ -3549,7 +3549,8 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) { SS << " // AT_" << I->first << "\n"; } - OS << "static const ParsedAttrInfo AttrInfoMap[AttributeList::UnknownAttribute + 1] = {\n"; + OS << "static const ParsedAttrInfo AttrInfoMap[ParsedAttr::UnknownAttribute " + "+ 1] = {\n"; OS << SS.str(); OS << "};\n\n"; @@ -3577,7 +3578,7 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { // specific attribute, or MSP430-specific attribute. Additionally, an // attribute can be spelled GNU<"dllexport"> and Declspec<"dllexport"> // for the same semantic attribute. Ultimately, we need to map each of - // these to a single AttributeList::Kind value, but the StringMatcher + // these to a single ParsedAttr::Kind value, but the StringMatcher // class cannot handle duplicate match strings. So we generate a list of // string to match based on the syntax, and emit multiple string matchers // depending on the syntax used. @@ -3624,34 +3625,34 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) { Spelling += RawSpelling; if (SemaHandler) - Matches->push_back(StringMatcher::StringPair(Spelling, - "return AttributeList::AT_" + AttrName + ";")); + Matches->push_back(StringMatcher::StringPair( + Spelling, "return ParsedAttr::AT_" + AttrName + ";")); else - Matches->push_back(StringMatcher::StringPair(Spelling, - "return AttributeList::IgnoredAttribute;")); + Matches->push_back(StringMatcher::StringPair( + Spelling, "return ParsedAttr::IgnoredAttribute;")); } } } - - OS << "static AttributeList::Kind getAttrKind(StringRef Name, "; - OS << "AttributeList::Syntax Syntax) {\n"; - OS << " if (AttributeList::AS_GNU == Syntax) {\n"; + + OS << "static ParsedAttr::Kind getAttrKind(StringRef Name, "; + OS << "ParsedAttr::Syntax Syntax) {\n"; + OS << " if (ParsedAttr::AS_GNU == Syntax) {\n"; StringMatcher("Name", GNU, OS).Emit(); - OS << " } else if (AttributeList::AS_Declspec == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_Declspec == Syntax) {\n"; StringMatcher("Name", Declspec, OS).Emit(); - OS << " } else if (AttributeList::AS_Microsoft == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_Microsoft == Syntax) {\n"; StringMatcher("Name", Microsoft, OS).Emit(); - OS << " } else if (AttributeList::AS_CXX11 == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_CXX11 == Syntax) {\n"; StringMatcher("Name", CXX11, OS).Emit(); - OS << " } else if (AttributeList::AS_C2x == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_C2x == Syntax) {\n"; StringMatcher("Name", C2x, OS).Emit(); - OS << " } else if (AttributeList::AS_Keyword == Syntax || "; - OS << "AttributeList::AS_ContextSensitiveKeyword == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_Keyword == Syntax || "; + OS << "ParsedAttr::AS_ContextSensitiveKeyword == Syntax) {\n"; StringMatcher("Name", Keywords, OS).Emit(); - OS << " } else if (AttributeList::AS_Pragma == Syntax) {\n"; + OS << " } else if (ParsedAttr::AS_Pragma == Syntax) {\n"; StringMatcher("Name", Pragma, OS).Emit(); OS << " }\n"; - OS << " return AttributeList::UnknownAttribute;\n" + OS << " return ParsedAttr::UnknownAttribute;\n" << "}\n"; } |