Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 1 | //======- ParsedAttr.cpp --------------------------------------------------===// |
Steve Naroff | b8371e1 | 2007-06-09 03:39:29 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5b12ab8 | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Steve Naroff | b8371e1 | 2007-06-09 03:39:29 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 10 | // This file defines the ParsedAttr class implementation |
Steve Naroff | b8371e1 | 2007-06-09 03:39:29 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 14 | #include "clang/Sema/ParsedAttr.h" |
Benjamin Kramer | 1ea8e09 | 2012-07-04 17:04:04 +0000 | [diff] [blame] | 15 | #include "clang/AST/ASTContext.h" |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 16 | #include "clang/Basic/AttrSubjectMatchRules.h" |
Chris Lattner | 7e0fe44 | 2009-04-11 18:48:18 +0000 | [diff] [blame] | 17 | #include "clang/Basic/IdentifierTable.h" |
Bob Wilson | 7c73083 | 2015-07-20 22:57:31 +0000 | [diff] [blame] | 18 | #include "clang/Basic/TargetInfo.h" |
Chandler Carruth | 5553d0d | 2014-01-07 11:51:46 +0000 | [diff] [blame] | 19 | #include "clang/Sema/SemaInternal.h" |
Richard Smith | 84837d5 | 2012-05-03 18:27:39 +0000 | [diff] [blame] | 20 | #include "llvm/ADT/SmallString.h" |
Eugene Zelenko | 711964d | 2018-02-20 02:16:28 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/SmallVector.h" |
| 22 | #include "llvm/ADT/StringRef.h" |
| 23 | #include <cassert> |
| 24 | #include <cstddef> |
| 25 | #include <utility> |
| 26 | |
Steve Naroff | b8371e1 | 2007-06-09 03:39:29 +0000 | [diff] [blame] | 27 | using namespace clang; |
| 28 | |
Richard Smith | feefaf5 | 2013-09-03 18:01:40 +0000 | [diff] [blame] | 29 | IdentifierLoc *IdentifierLoc::create(ASTContext &Ctx, SourceLocation Loc, |
| 30 | IdentifierInfo *Ident) { |
| 31 | IdentifierLoc *Result = new (Ctx) IdentifierLoc; |
| 32 | Result->Loc = Loc; |
| 33 | Result->Ident = Ident; |
| 34 | return Result; |
| 35 | } |
| 36 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 37 | size_t ParsedAttr::allocated_size() const { |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 38 | if (IsAvailability) return AttributeFactory::AvailabilityAllocSize; |
Dmitri Gribenko | e4a5a90 | 2012-08-17 00:08:38 +0000 | [diff] [blame] | 39 | else if (IsTypeTagForDatatype) |
| 40 | return AttributeFactory::TypeTagForDatatypeAllocSize; |
John McCall | 5e77d76 | 2013-04-16 07:28:30 +0000 | [diff] [blame] | 41 | else if (IsProperty) |
| 42 | return AttributeFactory::PropertyAllocSize; |
Erich Keane | 87cfcfd | 2018-06-22 17:34:44 +0000 | [diff] [blame] | 43 | else if (HasParsedType) |
Erich Keane | 03406c5 | 2018-08-09 20:25:12 +0000 | [diff] [blame] | 44 | return totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, |
| 45 | detail::TypeTagForDatatypeData, ParsedType, |
| 46 | detail::PropertyData>(0, 0, 0, 1, 0); |
| 47 | return totalSizeToAlloc<ArgsUnion, detail::AvailabilityData, |
| 48 | detail::TypeTagForDatatypeData, ParsedType, |
| 49 | detail::PropertyData>(NumArgs, 0, 0, 0, 0); |
Steve Naroff | b8371e1 | 2007-06-09 03:39:29 +0000 | [diff] [blame] | 50 | } |
Chris Lattner | f18c743 | 2008-02-20 23:14:47 +0000 | [diff] [blame] | 51 | |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 52 | AttributeFactory::AttributeFactory() { |
| 53 | // Go ahead and configure all the inline capacity. This is just a memset. |
| 54 | FreeLists.resize(InlineFreeListsCapacity); |
| 55 | } |
Eugene Zelenko | 711964d | 2018-02-20 02:16:28 +0000 | [diff] [blame] | 56 | AttributeFactory::~AttributeFactory() = default; |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 57 | |
| 58 | static size_t getFreeListIndexForSize(size_t size) { |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 59 | assert(size >= sizeof(ParsedAttr)); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 60 | assert((size % sizeof(void*)) == 0); |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 61 | return ((size - sizeof(ParsedAttr)) / sizeof(void *)); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void *AttributeFactory::allocate(size_t size) { |
| 65 | // Check for a previously reclaimed attribute. |
| 66 | size_t index = getFreeListIndexForSize(size); |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 67 | if (index < FreeLists.size() && !FreeLists[index].empty()) { |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 68 | ParsedAttr *attr = FreeLists[index].back(); |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 69 | FreeLists[index].pop_back(); |
| 70 | return attr; |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | // Otherwise, allocate something new. |
Benjamin Kramer | c3f8925 | 2016-10-20 14:27:22 +0000 | [diff] [blame] | 74 | return Alloc.Allocate(size, alignof(AttributeFactory)); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 75 | } |
| 76 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 77 | void AttributeFactory::deallocate(ParsedAttr *Attr) { |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 78 | size_t size = Attr->allocated_size(); |
| 79 | size_t freeListIndex = getFreeListIndexForSize(size); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 80 | |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 81 | // Expand FreeLists to the appropriate size, if required. |
| 82 | if (freeListIndex >= FreeLists.size()) |
| 83 | FreeLists.resize(freeListIndex + 1); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 84 | |
Sven van Haastregt | 7b39a08 | 2018-09-24 12:12:03 +0000 | [diff] [blame] | 85 | #ifndef NDEBUG |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 86 | // In debug mode, zero out the attribute to help find memory overwriting. |
| 87 | memset(Attr, 0, size); |
| 88 | #endif |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 89 | |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 90 | // Add 'Attr' to the appropriate free-list. |
| 91 | FreeLists[freeListIndex].push_back(Attr); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 94 | void AttributeFactory::reclaimPool(AttributePool &cur) { |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 95 | for (ParsedAttr *AL : cur.Attrs) |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 96 | deallocate(AL); |
| 97 | } |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 98 | |
Erich Keane | c480f30 | 2018-07-12 21:09:05 +0000 | [diff] [blame] | 99 | void AttributePool::takePool(AttributePool &pool) { |
| 100 | Attrs.insert(Attrs.end(), pool.Attrs.begin(), pool.Attrs.end()); |
| 101 | pool.Attrs.clear(); |
John McCall | 084e83d | 2011-03-24 11:26:52 +0000 | [diff] [blame] | 102 | } |
| 103 | |
Douglas Gregor | 377f99b | 2012-05-02 17:33:51 +0000 | [diff] [blame] | 104 | #include "clang/Sema/AttrParsedAttrKinds.inc" |
| 105 | |
Aaron Ballman | ad672ff | 2018-10-24 12:26:23 +0000 | [diff] [blame] | 106 | static StringRef normalizeAttrScopeName(StringRef ScopeName, |
| 107 | ParsedAttr::Syntax SyntaxUsed) { |
Aaron Ballman | c44c1742 | 2018-11-09 17:19:45 +0000 | [diff] [blame] | 108 | // Normalize the "__gnu__" scope name to be "gnu" and the "_Clang" scope name |
| 109 | // to be "clang". |
| 110 | if (SyntaxUsed == ParsedAttr::AS_CXX11 || |
| 111 | SyntaxUsed == ParsedAttr::AS_C2x) { |
| 112 | if (ScopeName == "__gnu__") |
| 113 | ScopeName = "gnu"; |
| 114 | else if (ScopeName == "_Clang") |
| 115 | ScopeName = "clang"; |
| 116 | } |
Aaron Ballman | ad672ff | 2018-10-24 12:26:23 +0000 | [diff] [blame] | 117 | return ScopeName; |
| 118 | } |
| 119 | |
| 120 | static StringRef normalizeAttrName(StringRef AttrName, |
| 121 | StringRef NormalizedScopeName, |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 122 | ParsedAttr::Syntax SyntaxUsed) { |
David Majnemer | a94e7b6 | 2015-08-25 16:44:38 +0000 | [diff] [blame] | 123 | // Normalize the attribute name, __foo__ becomes foo. This is only allowable |
Aaron Ballman | ad672ff | 2018-10-24 12:26:23 +0000 | [diff] [blame] | 124 | // for GNU attributes, and attributes using the double square bracket syntax. |
Aaron Ballman | ac77dcd | 2018-11-09 19:37:18 +0000 | [diff] [blame] | 125 | bool ShouldNormalize = |
| 126 | SyntaxUsed == ParsedAttr::AS_GNU || |
| 127 | ((SyntaxUsed == ParsedAttr::AS_CXX11 || |
| 128 | SyntaxUsed == ParsedAttr::AS_C2x) && |
| 129 | (NormalizedScopeName == "gnu" || NormalizedScopeName == "clang")); |
| 130 | if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") && |
David Majnemer | a94e7b6 | 2015-08-25 16:44:38 +0000 | [diff] [blame] | 131 | AttrName.endswith("__")) |
| 132 | AttrName = AttrName.slice(2, AttrName.size() - 2); |
| 133 | |
| 134 | return AttrName; |
| 135 | } |
| 136 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 137 | ParsedAttr::Kind ParsedAttr::getKind(const IdentifierInfo *Name, |
| 138 | const IdentifierInfo *ScopeName, |
| 139 | Syntax SyntaxUsed) { |
Chris Lattner | 0e62c1c | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 140 | StringRef AttrName = Name->getName(); |
Chris Lattner | f18c743 | 2008-02-20 23:14:47 +0000 | [diff] [blame] | 141 | |
Aaron Ballman | c698809 | 2013-12-11 22:27:44 +0000 | [diff] [blame] | 142 | SmallString<64> FullName; |
Richard Smith | 84837d5 | 2012-05-03 18:27:39 +0000 | [diff] [blame] | 143 | if (ScopeName) |
Aaron Ballman | ad672ff | 2018-10-24 12:26:23 +0000 | [diff] [blame] | 144 | FullName += normalizeAttrScopeName(ScopeName->getName(), SyntaxUsed); |
Aaron Ballman | c698809 | 2013-12-11 22:27:44 +0000 | [diff] [blame] | 145 | |
David Majnemer | a94e7b6 | 2015-08-25 16:44:38 +0000 | [diff] [blame] | 146 | AttrName = normalizeAttrName(AttrName, FullName, SyntaxUsed); |
Aaron Ballman | c698809 | 2013-12-11 22:27:44 +0000 | [diff] [blame] | 147 | |
Alexis Hunt | a0e54d4 | 2012-06-18 16:13:52 +0000 | [diff] [blame] | 148 | // Ensure that in the case of C++11 attributes, we look for '::foo' if it is |
| 149 | // unscoped. |
Aaron Ballman | 606093a | 2017-10-15 15:01:42 +0000 | [diff] [blame] | 150 | if (ScopeName || SyntaxUsed == AS_CXX11 || SyntaxUsed == AS_C2x) |
Aaron Ballman | c698809 | 2013-12-11 22:27:44 +0000 | [diff] [blame] | 151 | FullName += "::"; |
| 152 | FullName += AttrName; |
Richard Smith | 84837d5 | 2012-05-03 18:27:39 +0000 | [diff] [blame] | 153 | |
Aaron Ballman | 09e98ff | 2014-01-13 21:42:39 +0000 | [diff] [blame] | 154 | return ::getAttrKind(FullName, SyntaxUsed); |
Chris Lattner | f18c743 | 2008-02-20 23:14:47 +0000 | [diff] [blame] | 155 | } |
Michael Han | 9931593 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 156 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 157 | unsigned ParsedAttr::getAttributeSpellingListIndex() const { |
Michael Han | 9931593 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 158 | // Both variables will be used in tablegen generated |
| 159 | // attribute spell list index matching code. |
Aaron Ballman | ad672ff | 2018-10-24 12:26:23 +0000 | [diff] [blame] | 160 | auto Syntax = static_cast<ParsedAttr::Syntax>(SyntaxUsed); |
| 161 | StringRef Scope = |
| 162 | ScopeName ? normalizeAttrScopeName(ScopeName->getName(), Syntax) : ""; |
| 163 | StringRef Name = normalizeAttrName(AttrName->getName(), Scope, Syntax); |
Michael Han | 9931593 | 2013-01-24 16:46:58 +0000 | [diff] [blame] | 164 | |
| 165 | #include "clang/Sema/AttrSpellingListIndex.inc" |
| 166 | |
| 167 | } |
| 168 | |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 169 | struct ParsedAttrInfo { |
| 170 | unsigned NumArgs : 4; |
| 171 | unsigned OptArgs : 4; |
| 172 | unsigned HasCustomParsing : 1; |
Aaron Ballman | ab7691c | 2014-01-09 22:48:32 +0000 | [diff] [blame] | 173 | unsigned IsTargetSpecific : 1; |
| 174 | unsigned IsType : 1; |
Richard Smith | 4f902c7 | 2016-03-08 00:32:55 +0000 | [diff] [blame] | 175 | unsigned IsStmt : 1; |
Aaron Ballman | c669cc0 | 2014-01-27 22:10:04 +0000 | [diff] [blame] | 176 | unsigned IsKnownToGCC : 1; |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 177 | unsigned IsSupportedByPragmaAttribute : 1; |
Aaron Ballman | 74eeeae | 2013-11-27 13:27:02 +0000 | [diff] [blame] | 178 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 179 | bool (*DiagAppertainsToDecl)(Sema &S, const ParsedAttr &Attr, const Decl *); |
| 180 | bool (*DiagLangOpts)(Sema &S, const ParsedAttr &Attr); |
Bob Wilson | 7c73083 | 2015-07-20 22:57:31 +0000 | [diff] [blame] | 181 | bool (*ExistsInTarget)(const TargetInfo &Target); |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 182 | unsigned (*SpellingIndexToSemanticSpelling)(const ParsedAttr &Attr); |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 183 | void (*GetPragmaAttributeMatchRules)( |
| 184 | llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &Rules, |
| 185 | const LangOptions &LangOpts); |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | namespace { |
Eugene Zelenko | 711964d | 2018-02-20 02:16:28 +0000 | [diff] [blame] | 189 | |
| 190 | #include "clang/Sema/AttrParsedAttrImpl.inc" |
| 191 | |
| 192 | } // namespace |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 193 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 194 | static const ParsedAttrInfo &getInfo(const ParsedAttr &A) { |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 195 | return AttrInfoMap[A.getKind()]; |
| 196 | } |
| 197 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 198 | unsigned ParsedAttr::getMinArgs() const { return getInfo(*this).NumArgs; } |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 199 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 200 | unsigned ParsedAttr::getMaxArgs() const { |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 201 | return getMinArgs() + getInfo(*this).OptArgs; |
| 202 | } |
| 203 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 204 | bool ParsedAttr::hasCustomParsing() const { |
Aaron Ballman | 8ee40b7 | 2013-09-09 23:33:17 +0000 | [diff] [blame] | 205 | return getInfo(*this).HasCustomParsing; |
| 206 | } |
Aaron Ballman | 74eeeae | 2013-11-27 13:27:02 +0000 | [diff] [blame] | 207 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 208 | bool ParsedAttr::diagnoseAppertainsTo(Sema &S, const Decl *D) const { |
Aaron Ballman | 74eeeae | 2013-11-27 13:27:02 +0000 | [diff] [blame] | 209 | return getInfo(*this).DiagAppertainsToDecl(S, *this, D); |
| 210 | } |
Aaron Ballman | 3aff633 | 2013-12-02 19:30:36 +0000 | [diff] [blame] | 211 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 212 | bool ParsedAttr::appliesToDecl(const Decl *D, |
| 213 | attr::SubjectMatchRule MatchRule) const { |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 214 | return checkAttributeMatchRuleAppliesTo(D, MatchRule); |
| 215 | } |
| 216 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 217 | void ParsedAttr::getMatchRules( |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 218 | const LangOptions &LangOpts, |
| 219 | SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules) |
| 220 | const { |
| 221 | return getInfo(*this).GetPragmaAttributeMatchRules(MatchRules, LangOpts); |
| 222 | } |
| 223 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 224 | bool ParsedAttr::diagnoseLangOpts(Sema &S) const { |
Aaron Ballman | 3aff633 | 2013-12-02 19:30:36 +0000 | [diff] [blame] | 225 | return getInfo(*this).DiagLangOpts(S, *this); |
| 226 | } |
Aaron Ballman | ab7691c | 2014-01-09 22:48:32 +0000 | [diff] [blame] | 227 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 228 | bool ParsedAttr::isTargetSpecificAttr() const { |
Aaron Ballman | ab7691c | 2014-01-09 22:48:32 +0000 | [diff] [blame] | 229 | return getInfo(*this).IsTargetSpecific; |
| 230 | } |
| 231 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 232 | bool ParsedAttr::isTypeAttr() const { return getInfo(*this).IsType; } |
Aaron Ballman | ab7691c | 2014-01-09 22:48:32 +0000 | [diff] [blame] | 233 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 234 | bool ParsedAttr::isStmtAttr() const { return getInfo(*this).IsStmt; } |
Richard Smith | 4f902c7 | 2016-03-08 00:32:55 +0000 | [diff] [blame] | 235 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 236 | bool ParsedAttr::existsInTarget(const TargetInfo &Target) const { |
Bob Wilson | 7c73083 | 2015-07-20 22:57:31 +0000 | [diff] [blame] | 237 | return getInfo(*this).ExistsInTarget(Target); |
Aaron Ballman | ab7691c | 2014-01-09 22:48:32 +0000 | [diff] [blame] | 238 | } |
Aaron Ballman | 9a99e0d | 2014-01-20 17:18:35 +0000 | [diff] [blame] | 239 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 240 | bool ParsedAttr::isKnownToGCC() const { return getInfo(*this).IsKnownToGCC; } |
Aaron Ballman | 81cb8cb | 2014-01-24 21:32:49 +0000 | [diff] [blame] | 241 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 242 | bool ParsedAttr::isSupportedByPragmaAttribute() const { |
Alex Lorenz | 9e7bf16 | 2017-04-18 14:33:39 +0000 | [diff] [blame] | 243 | return getInfo(*this).IsSupportedByPragmaAttribute; |
| 244 | } |
| 245 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 246 | unsigned ParsedAttr::getSemanticSpelling() const { |
Aaron Ballman | 81cb8cb | 2014-01-24 21:32:49 +0000 | [diff] [blame] | 247 | return getInfo(*this).SpellingIndexToSemanticSpelling(*this); |
| 248 | } |
Aaron Ballman | 8ed8dbd | 2014-07-31 16:37:04 +0000 | [diff] [blame] | 249 | |
Erich Keane | e891aa9 | 2018-07-13 15:07:47 +0000 | [diff] [blame] | 250 | bool ParsedAttr::hasVariadicArg() const { |
Aaron Ballman | 8ed8dbd | 2014-07-31 16:37:04 +0000 | [diff] [blame] | 251 | // If the attribute has the maximum number of optional arguments, we will |
| 252 | // claim that as being variadic. If we someday get an attribute that |
| 253 | // legitimately bumps up against that maximum, we can use another bit to track |
| 254 | // whether it's truly variadic or not. |
| 255 | return getInfo(*this).OptArgs == 15; |
| 256 | } |