Clang Project

clang_source_code/include/clang/Sema/ParsedAttr.h
1//======- ParsedAttr.h - Parsed attribute sets ------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the ParsedAttr class, which is used to collect
10// parsed attributes.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_SEMA_ATTRIBUTELIST_H
15#define LLVM_CLANG_SEMA_ATTRIBUTELIST_H
16
17#include "clang/Basic/AttrSubjectMatchRules.h"
18#include "clang/Basic/Diagnostic.h"
19#include "clang/Basic/SourceLocation.h"
20#include "clang/Basic/TargetInfo.h"
21#include "clang/Sema/Ownership.h"
22#include "llvm/ADT/PointerUnion.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/TinyPtrVector.h"
25#include "llvm/Support/Allocator.h"
26#include "llvm/Support/VersionTuple.h"
27#include <cassert>
28#include <cstddef>
29#include <cstring>
30#include <utility>
31
32namespace clang {
33
34class ASTContext;
35class Decl;
36class Expr;
37class IdentifierInfo;
38class LangOptions;
39
40/// Represents information about a change in availability for
41/// an entity, which is part of the encoding of the 'availability'
42/// attribute.
43struct AvailabilityChange {
44  /// The location of the keyword indicating the kind of change.
45  SourceLocation KeywordLoc;
46
47  /// The version number at which the change occurred.
48  VersionTuple Version;
49
50  /// The source range covering the version number.
51  SourceRange VersionRange;
52
53  /// Determine whether this availability change is valid.
54  bool isValid() const { return !Version.empty(); }
55};
56
57namespace detail {
58enum AvailabilitySlot {
59  IntroducedSlotDeprecatedSlotObsoletedSlotNumAvailabilitySlots
60};
61
62/// Describes the trailing object for Availability attribute in ParsedAttr.
63struct AvailabilityData {
64  AvailabilityChange Changes[NumAvailabilitySlots];
65  SourceLocation StrictLoc;
66  const Expr *Replacement;
67
68  AvailabilityData(const AvailabilityChange &Introduced,
69                   const AvailabilityChange &Deprecated,
70                   const AvailabilityChange &Obsoleted,
71                   SourceLocation Strictconst Expr *ReplaceExpr)
72    : StrictLoc(Strict), Replacement(ReplaceExpr) {
73    Changes[IntroducedSlot] = Introduced;
74    Changes[DeprecatedSlot] = Deprecated;
75    Changes[ObsoletedSlot] = Obsoleted;
76  }
77};
78
79struct TypeTagForDatatypeData {
80  ParsedType MatchingCType;
81  unsigned LayoutCompatible : 1;
82  unsigned MustBeNull : 1;
83};
84struct PropertyData {
85  IdentifierInfo *GetterId, *SetterId;
86
87  PropertyData(IdentifierInfo *getterIdIdentifierInfo *setterId)
88      : GetterId(getterId), SetterId(setterId) {}
89};
90
91// namespace
92
93/// Wraps an identifier and optional source location for the identifier.
94struct IdentifierLoc {
95  SourceLocation Loc;
96  IdentifierInfo *Ident;
97
98  static IdentifierLoc *create(ASTContext &CtxSourceLocation Loc,
99                               IdentifierInfo *Ident);
100};
101
102/// A union of the various pointer types that can be passed to an
103/// ParsedAttr as an argument.
104using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;
105using ArgsVector = llvm::SmallVector<ArgsUnion, 12U>;
106
107/// ParsedAttr - Represents a syntactic attribute.
108///
109/// For a GNU attribute, there are four forms of this construct:
110///
111/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
112/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
113/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
114/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
115///
116class ParsedAttr final
117    : private llvm::TrailingObjects<
118          ParsedAttr, ArgsUnion, detail::AvailabilityData,
119          detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
120  friend TrailingObjects;
121
122  size_t numTrailingObjects(OverloadToken<ArgsUnion>) const { return NumArgs; }
123  size_t numTrailingObjects(OverloadToken<detail::AvailabilityData>) const {
124    return IsAvailability;
125  }
126  size_t
127      numTrailingObjects(OverloadToken<detail::TypeTagForDatatypeData>) const {
128    return IsTypeTagForDatatype;
129  }
130  size_t numTrailingObjects(OverloadToken<ParsedType>) const {
131    return HasParsedType;
132  }
133  size_t numTrailingObjects(OverloadToken<detail::PropertyData>) const {
134    return IsProperty;
135  }
136
137public:
138  /// The style used to specify an attribute.
139  enum Syntax {
140    /// __attribute__((...))
141    AS_GNU,
142
143    /// [[...]]
144    AS_CXX11,
145
146    /// [[...]]
147    AS_C2x,
148
149    /// __declspec(...)
150    AS_Declspec,
151
152    /// [uuid("...")] class Foo
153    AS_Microsoft,
154
155    /// __ptr16, alignas(...), etc.
156    AS_Keyword,
157
158    /// #pragma ...
159    AS_Pragma,
160
161    // Note TableGen depends on the order above.  Do not add or change the order
162    // without adding related code to TableGen/ClangAttrEmitter.cpp.
163    /// Context-sensitive version of a keyword attribute.
164    AS_ContextSensitiveKeyword,
165  };
166
167private:
168  IdentifierInfo *AttrName;
169  IdentifierInfo *ScopeName;
170  SourceRange AttrRange;
171  SourceLocation ScopeLoc;
172  SourceLocation EllipsisLoc;
173
174  unsigned AttrKind : 16;
175
176  /// The number of expression arguments this attribute has.
177  /// The expressions themselves are stored after the object.
178  unsigned NumArgs : 16;
179
180  /// Corresponds to the Syntax enum.
181  unsigned SyntaxUsed : 3;
182
183  /// True if already diagnosed as invalid.
184  mutable unsigned Invalid : 1;
185
186  /// True if this attribute was used as a type attribute.
187  mutable unsigned UsedAsTypeAttr : 1;
188
189  /// True if this has the extra information associated with an
190  /// availability attribute.
191  unsigned IsAvailability : 1;
192
193  /// True if this has extra information associated with a
194  /// type_tag_for_datatype attribute.
195  unsigned IsTypeTagForDatatype : 1;
196
197  /// True if this has extra information associated with a
198  /// Microsoft __delcspec(property) attribute.
199  unsigned IsProperty : 1;
200
201  /// True if this has a ParsedType
202  unsigned HasParsedType : 1;
203
204  /// True if the processing cache is valid.
205  mutable unsigned HasProcessingCache : 1;
206
207  /// A cached value.
208  mutable unsigned ProcessingCache : 8;
209
210  /// True if the attribute is specified using '#pragma clang attribute'.
211  mutable unsigned IsPragmaClangAttribute : 1;
212
213  /// The location of the 'unavailable' keyword in an
214  /// availability attribute.
215  SourceLocation UnavailableLoc;
216
217  const Expr *MessageExpr;
218
219  ArgsUnion *getArgsBuffer() { return getTrailingObjects<ArgsUnion>(); }
220  ArgsUnion const *getArgsBuffer() const {
221    return getTrailingObjects<ArgsUnion>();
222  }
223
224  detail::AvailabilityData *getAvailabilityData() {
225    return getTrailingObjects<detail::AvailabilityData>();
226  }
227  const detail::AvailabilityData *getAvailabilityData() const {
228    return getTrailingObjects<detail::AvailabilityData>();
229  }
230
231private:
232  friend class AttributeFactory;
233  friend class AttributePool;
234
235  /// Constructor for attributes with expression arguments.
236  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
237             IdentifierInfo *scopeNameSourceLocation scopeLoc,
238             ArgsUnion *argsunsigned numArgsSyntax syntaxUsed,
239             SourceLocation ellipsisLoc)
240      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
241        ScopeLoc(scopeLoc), EllipsisLoc(ellipsisLoc), NumArgs(numArgs),
242        SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false),
243        IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
244        HasParsedType(false), HasProcessingCache(false),
245        IsPragmaClangAttribute(false) {
246    if (numArgs) memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion));
247    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
248  }
249
250  /// Constructor for availability attributes.
251  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
252             IdentifierInfo *scopeNameSourceLocation scopeLoc,
253             IdentifierLoc *Parmconst AvailabilityChange &introduced,
254             const AvailabilityChange &deprecated,
255             const AvailabilityChange &obsoletedSourceLocation unavailable,
256             const Expr *messageExprSyntax syntaxUsedSourceLocation strict,
257             const Expr *replacementExpr)
258      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
259        ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false),
260        UsedAsTypeAttr(false), IsAvailability(true),
261        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
262        HasProcessingCache(false), IsPragmaClangAttribute(false),
263        UnavailableLoc(unavailable), MessageExpr(messageExpr) {
264    ArgsUnion PVal(Parm);
265    memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
266    new (getAvailabilityData()) detail::AvailabilityData(
267        introduceddeprecatedobsoletedstrictreplacementExpr);
268    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
269  }
270
271  /// Constructor for objc_bridge_related attributes.
272  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
273             IdentifierInfo *scopeNameSourceLocation scopeLoc,
274             IdentifierLoc *Parm1IdentifierLoc *Parm2IdentifierLoc *Parm3,
275             Syntax syntaxUsed)
276      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
277        ScopeLoc(scopeLoc), NumArgs(3), SyntaxUsed(syntaxUsed), Invalid(false),
278        UsedAsTypeAttr(false), IsAvailability(false),
279        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
280        HasProcessingCache(false), IsPragmaClangAttribute(false) {
281    ArgsUnion *Args = getArgsBuffer();
282    Args[0] = Parm1;
283    Args[1] = Parm2;
284    Args[2] = Parm3;
285    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
286  }
287
288  /// Constructor for type_tag_for_datatype attribute.
289  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
290             IdentifierInfo *scopeNameSourceLocation scopeLoc,
291             IdentifierLoc *ArgKindParsedType matchingCType,
292             bool layoutCompatiblebool mustBeNullSyntax syntaxUsed)
293      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
294        ScopeLoc(scopeLoc), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false),
295        UsedAsTypeAttr(false), IsAvailability(false),
296        IsTypeTagForDatatype(true), IsProperty(false), HasParsedType(false),
297        HasProcessingCache(false), IsPragmaClangAttribute(false) {
298    ArgsUnion PVal(ArgKind);
299    memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
300    detail::TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot();
301    new (&ExtraData.MatchingCTypeParsedType(matchingCType);
302    ExtraData.LayoutCompatible = layoutCompatible;
303    ExtraData.MustBeNull = mustBeNull;
304    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
305  }
306
307  /// Constructor for attributes with a single type argument.
308  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
309             IdentifierInfo *scopeNameSourceLocation scopeLoc,
310             ParsedType typeArgSyntax syntaxUsed)
311      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
312        ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false),
313        UsedAsTypeAttr(false), IsAvailability(false),
314        IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(true),
315        HasProcessingCache(false), IsPragmaClangAttribute(false) {
316    new (&getTypeBuffer()) ParsedType(typeArg);
317    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
318  }
319
320  /// Constructor for microsoft __declspec(property) attribute.
321  ParsedAttr(IdentifierInfo *attrNameSourceRange attrRange,
322             IdentifierInfo *scopeNameSourceLocation scopeLoc,
323             IdentifierInfo *getterIdIdentifierInfo *setterId,
324             Syntax syntaxUsed)
325      : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange),
326        ScopeLoc(scopeLoc), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false),
327        UsedAsTypeAttr(false), IsAvailability(false),
328        IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false),
329        HasProcessingCache(false), IsPragmaClangAttribute(false) {
330    new (&getPropertyDataBuffer()) detail::PropertyData(getterIdsetterId);
331    AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
332  }
333
334  /// Type tag information is stored immediately following the arguments, if
335  /// any, at the end of the object.  They are mutually exclusive with
336  /// availability slots.
337  detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() {
338    return *getTrailingObjects<detail::TypeTagForDatatypeData>();
339  }
340  const detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() const {
341    return *getTrailingObjects<detail::TypeTagForDatatypeData>();
342  }
343
344  /// The type buffer immediately follows the object and are mutually exclusive
345  /// with arguments.
346  ParsedType &getTypeBuffer() { return *getTrailingObjects<ParsedType>(); }
347  const ParsedType &getTypeBuffer() const {
348    return *getTrailingObjects<ParsedType>();
349  }
350
351  /// The property data immediately follows the object is is mutually exclusive
352  /// with arguments.
353  detail::PropertyData &getPropertyDataBuffer() {
354    assert(IsProperty);
355    return *getTrailingObjects<detail::PropertyData>();
356  }
357  const detail::PropertyData &getPropertyDataBuffer() const {
358    assert(IsProperty);
359    return *getTrailingObjects<detail::PropertyData>();
360  }
361
362  size_t allocated_size() const;
363
364public:
365  ParsedAttr(const ParsedAttr &) = delete;
366  ParsedAttr(ParsedAttr &&) = delete;
367  ParsedAttr &operator=(const ParsedAttr &) = delete;
368  ParsedAttr &operator=(ParsedAttr &&) = delete;
369  ~ParsedAttr() = delete;
370
371  void operator delete(void *) = delete;
372
373  enum Kind {
374    #define PARSED_ATTR(NAME) AT_##NAME,
375    #include "clang/Sema/AttrParsedAttrList.inc"
376    #undef PARSED_ATTR
377    IgnoredAttribute,
378    UnknownAttribute
379  };
380
381  IdentifierInfo *getName() const { return AttrName; }
382  SourceLocation getLoc() const { return AttrRange.getBegin(); }
383  SourceRange getRange() const { return AttrRange; }
384
385  bool hasScope() const { return ScopeName; }
386  IdentifierInfo *getScopeName() const { return ScopeName; }
387  SourceLocation getScopeLoc() const { return ScopeLoc; }
388
389  bool isGNUScope() const {
390    return ScopeName &&
391           (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"));
392  }
393
394  bool hasParsedType() const { return HasParsedType; }
395
396  /// Is this the Microsoft __declspec(property) attribute?
397  bool isDeclspecPropertyAttribute() const  {
398    return IsProperty;
399  }
400
401  bool isAlignasAttribute() const {
402    // FIXME: Use a better mechanism to determine this.
403    return getKind() == AT_Aligned && isKeywordAttribute();
404  }
405
406  bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
407  bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }
408
409  bool isCXX11Attribute() const {
410    return SyntaxUsed == AS_CXX11 || isAlignasAttribute();
411  }
412
413  bool isC2xAttribute() const {
414    return SyntaxUsed == AS_C2x;
415  }
416
417  bool isKeywordAttribute() const {
418    return SyntaxUsed == AS_Keyword || SyntaxUsed == AS_ContextSensitiveKeyword;
419  }
420
421  bool isContextSensitiveKeywordAttribute() const {
422    return SyntaxUsed == AS_ContextSensitiveKeyword;
423  }
424
425  bool isInvalid() const { return Invalid; }
426  void setInvalid(bool b = trueconst { Invalid = b; }
427
428  bool hasProcessingCache() const { return HasProcessingCache; }
429
430  unsigned getProcessingCache() const {
431    assert(hasProcessingCache());
432    return ProcessingCache;
433  }
434
435  void setProcessingCache(unsigned valueconst {
436    ProcessingCache = value;
437    HasProcessingCache = true;
438  }
439
440  bool isUsedAsTypeAttr() const { return UsedAsTypeAttr; }
441  void setUsedAsTypeAttr() { UsedAsTypeAttr = true; }
442
443  /// True if the attribute is specified using '#pragma clang attribute'.
444  bool isPragmaClangAttribute() const { return IsPragmaClangAttribute; }
445
446  void setIsPragmaClangAttribute() { IsPragmaClangAttribute = true; }
447
448  bool isPackExpansion() const { return EllipsisLoc.isValid(); }
449  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
450
451  Kind getKind() const { return Kind(AttrKind); }
452  static Kind getKind(const IdentifierInfo *Nameconst IdentifierInfo *Scope,
453                      Syntax SyntaxUsed);
454
455  /// getNumArgs - Return the number of actual arguments to this attribute.
456  unsigned getNumArgs() const { return NumArgs; }
457
458  /// getArg - Return the specified argument.
459  ArgsUnion getArg(unsigned Arg) const {
460     (0) . __assert_fail ("Arg < NumArgs && \"Arg access out of range!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 460, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(Arg < NumArgs && "Arg access out of range!");
461    return getArgsBuffer()[Arg];
462  }
463
464  bool isArgExpr(unsigned Argconst {
465    return Arg < NumArgs && getArg(Arg).is<Expr*>();
466  }
467
468  Expr *getArgAsExpr(unsigned Argconst {
469    return getArg(Arg).get<Expr*>();
470  }
471
472  bool isArgIdent(unsigned Argconst {
473    return Arg < NumArgs && getArg(Arg).is<IdentifierLoc*>();
474  }
475
476  IdentifierLoc *getArgAsIdent(unsigned Argconst {
477    return getArg(Arg).get<IdentifierLoc*>();
478  }
479
480  const AvailabilityChange &getAvailabilityIntroduced() const {
481     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 481, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
482    return getAvailabilityData()->Changes[detail::IntroducedSlot];
483  }
484
485  const AvailabilityChange &getAvailabilityDeprecated() const {
486     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 486, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
487    return getAvailabilityData()->Changes[detail::DeprecatedSlot];
488  }
489
490  const AvailabilityChange &getAvailabilityObsoleted() const {
491     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 491, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
492    return getAvailabilityData()->Changes[detail::ObsoletedSlot];
493  }
494
495  SourceLocation getStrictLoc() const {
496     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 496, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
497    return getAvailabilityData()->StrictLoc;
498  }
499
500  SourceLocation getUnavailableLoc() const {
501     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 501, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
502    return UnavailableLoc;
503  }
504
505  const Expr * getMessageExpr() const {
506     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 506, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
507    return MessageExpr;
508  }
509
510  const Expr *getReplacementExpr() const {
511     (0) . __assert_fail ("getKind() == AT_Availability && \"Not an availability attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 511, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_Availability && "Not an availability attribute");
512    return getAvailabilityData()->Replacement;
513  }
514
515  const ParsedType &getMatchingCType() const {
516     (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 517, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_TypeTagForDatatype &&
517 (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 517, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Not a type_tag_for_datatype attribute");
518    return getTypeTagForDatatypeDataSlot().MatchingCType;
519  }
520
521  bool getLayoutCompatible() const {
522     (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 523, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_TypeTagForDatatype &&
523 (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 523, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Not a type_tag_for_datatype attribute");
524    return getTypeTagForDatatypeDataSlot().LayoutCompatible;
525  }
526
527  bool getMustBeNull() const {
528     (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 529, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(getKind() == AT_TypeTagForDatatype &&
529 (0) . __assert_fail ("getKind() == AT_TypeTagForDatatype && \"Not a type_tag_for_datatype attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 529, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Not a type_tag_for_datatype attribute");
530    return getTypeTagForDatatypeDataSlot().MustBeNull;
531  }
532
533  const ParsedType &getTypeArg() const {
534     (0) . __assert_fail ("HasParsedType && \"Not a type attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 534, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(HasParsedType && "Not a type attribute");
535    return getTypeBuffer();
536  }
537
538  IdentifierInfo *getPropertyDataGetter() const {
539     (0) . __assert_fail ("isDeclspecPropertyAttribute() && \"Not a __delcspec(property) attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 540, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isDeclspecPropertyAttribute() &&
540 (0) . __assert_fail ("isDeclspecPropertyAttribute() && \"Not a __delcspec(property) attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 540, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Not a __delcspec(property) attribute");
541    return getPropertyDataBuffer().GetterId;
542  }
543
544  IdentifierInfo *getPropertyDataSetter() const {
545     (0) . __assert_fail ("isDeclspecPropertyAttribute() && \"Not a __delcspec(property) attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 546, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isDeclspecPropertyAttribute() &&
546 (0) . __assert_fail ("isDeclspecPropertyAttribute() && \"Not a __delcspec(property) attribute\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 546, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Not a __delcspec(property) attribute");
547    return getPropertyDataBuffer().SetterId;
548  }
549
550  /// Get an index into the attribute spelling list
551  /// defined in Attr.td. This index is used by an attribute
552  /// to pretty print itself.
553  unsigned getAttributeSpellingListIndex() const;
554
555  bool isTargetSpecificAttr() const;
556  bool isTypeAttr() const;
557  bool isStmtAttr() const;
558
559  bool hasCustomParsing() const;
560  unsigned getMinArgs() const;
561  unsigned getMaxArgs() const;
562  bool hasVariadicArg() const;
563  bool diagnoseAppertainsTo(class Sema &Sconst Decl *Dconst;
564  bool appliesToDecl(const Decl *Dattr::SubjectMatchRule MatchRuleconst;
565  void getMatchRules(const LangOptions &LangOpts,
566                     SmallVectorImpl<std::pair<attr::SubjectMatchRulebool>>
567                         &MatchRulesconst;
568  bool diagnoseLangOpts(class Sema &Sconst;
569  bool existsInTarget(const TargetInfo &Targetconst;
570  bool isKnownToGCC() const;
571  bool isSupportedByPragmaAttribute() const;
572
573  /// If the parsed attribute has a semantic equivalent, and it would
574  /// have a semantic Spelling enumeration (due to having semantically-distinct
575  /// spelling variations), return the value of that semantic spelling. If the
576  /// parsed attribute does not have a semantic equivalent, or would not have
577  /// a Spelling enumeration, the value UINT_MAX is returned.
578  unsigned getSemanticSpelling() const;
579
580  /// If this is an OpenCL addr space attribute returns its representation
581  /// in LangAS, otherwise returns default addr space.
582  LangAS asOpenCLLangAS() const {
583    switch (getKind()) {
584    case ParsedAttr::AT_OpenCLConstantAddressSpace:
585      return LangAS::opencl_constant;
586    case ParsedAttr::AT_OpenCLGlobalAddressSpace:
587      return LangAS::opencl_global;
588    case ParsedAttr::AT_OpenCLLocalAddressSpace:
589      return LangAS::opencl_local;
590    case ParsedAttr::AT_OpenCLPrivateAddressSpace:
591      return LangAS::opencl_private;
592    case ParsedAttr::AT_OpenCLGenericAddressSpace:
593      return LangAS::opencl_generic;
594    default:
595      return LangAS::Default;
596    }
597  }
598};
599
600class AttributePool;
601/// A factory, from which one makes pools, from which one creates
602/// individual attributes which are deallocated with the pool.
603///
604/// Note that it's tolerably cheap to create and destroy one of
605/// these as long as you don't actually allocate anything in it.
606class AttributeFactory {
607public:
608  enum {
609    AvailabilityAllocSize =
610        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
611                                     detail::TypeTagForDatatypeData, ParsedType,
612                                     detail::PropertyData>(11000),
613    TypeTagForDatatypeAllocSize =
614        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
615                                     detail::TypeTagForDatatypeData, ParsedType,
616                                     detail::PropertyData>(10100),
617    PropertyAllocSize =
618        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
619                                     detail::TypeTagForDatatypeData, ParsedType,
620                                     detail::PropertyData>(00001),
621  };
622
623private:
624  enum {
625    /// The number of free lists we want to be sure to support
626    /// inline.  This is just enough that availability attributes
627    /// don't surpass it.  It's actually very unlikely we'll see an
628    /// attribute that needs more than that; on x86-64 you'd need 10
629    /// expression arguments, and on i386 you'd need 19.
630    InlineFreeListsCapacity =
631        1 + (AvailabilityAllocSize - sizeof(ParsedAttr)) / sizeof(void *)
632  };
633
634  llvm::BumpPtrAllocator Alloc;
635
636  /// Free lists.  The index is determined by the following formula:
637  ///   (size - sizeof(ParsedAttr)) / sizeof(void*)
638  SmallVector<SmallVector<ParsedAttr *, 8>, InlineFreeListsCapacityFreeLists;
639
640  // The following are the private interface used by AttributePool.
641  friend class AttributePool;
642
643  /// Allocate an attribute of the given size.
644  void *allocate(size_t size);
645
646  void deallocate(ParsedAttr *AL);
647
648  /// Reclaim all the attributes in the given pool chain, which is
649  /// non-empty.  Note that the current implementation is safe
650  /// against reclaiming things which were not actually allocated
651  /// with the allocator, although of course it's important to make
652  /// sure that their allocator lives at least as long as this one.
653  void reclaimPool(AttributePool &head);
654
655public:
656  AttributeFactory();
657  ~AttributeFactory();
658};
659
660class AttributePool {
661  friend class AttributeFactory;
662  AttributeFactory &Factory;
663  llvm::TinyPtrVector<ParsedAttr *> Attrs;
664
665  void *allocate(size_t size) {
666    return Factory.allocate(size);
667  }
668
669  ParsedAttr *add(ParsedAttr *attr) {
670    Attrs.push_back(attr);
671    return attr;
672  }
673
674  void remove(ParsedAttr *attr) {
675     (0) . __assert_fail ("llvm..is_contained(Attrs, attr) && \"Can't take attribute from a pool that doesn't own it!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 676, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(llvm::is_contained(Attrs, attr) &&
676 (0) . __assert_fail ("llvm..is_contained(Attrs, attr) && \"Can't take attribute from a pool that doesn't own it!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 676, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Can't take attribute from a pool that doesn't own it!");
677    Attrs.erase(llvm::find(Attrs, attr));
678  }
679
680  void takePool(AttributePool &pool);
681
682public:
683  /// Create a new pool for a factory.
684  AttributePool(AttributeFactory &factory) : Factory(factory) {}
685
686  AttributePool(const AttributePool &) = delete;
687
688  ~AttributePool() { Factory.reclaimPool(*this); }
689
690  /// Move the given pool's allocations to this pool.
691  AttributePool(AttributePool &&pool) = default;
692
693  AttributeFactory &getFactory() const { return Factory; }
694
695  void clear() {
696    Factory.reclaimPool(*this);
697    Attrs.clear();
698  }
699
700  /// Take the given pool's allocations and add them to this pool.
701  void takeAllFrom(AttributePool &pool) {
702    takePool(pool);
703    pool.Attrs.clear();
704  }
705
706  ParsedAttr *create(IdentifierInfo *attrNameSourceRange attrRange,
707                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
708                     ArgsUnion *argsunsigned numArgs,
709                     ParsedAttr::Syntax syntax,
710                     SourceLocation ellipsisLoc = SourceLocation()) {
711    size_t temp =
712        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
713                                     detail::TypeTagForDatatypeData, ParsedType,
714                                     detail::PropertyData>(numArgs, 0000);
715    (void)temp;
716    void *memory = allocate(
717        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
718                                     detail::TypeTagForDatatypeData, ParsedType,
719                                     detail::PropertyData>(numArgs, 000,
720                                                           0));
721    return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
722                                       args, numArgs, syntax, ellipsisLoc));
723  }
724
725  ParsedAttr *create(IdentifierInfo *attrNameSourceRange attrRange,
726                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
727                     IdentifierLoc *Paramconst AvailabilityChange &introduced,
728                     const AvailabilityChange &deprecated,
729                     const AvailabilityChange &obsoleted,
730                     SourceLocation unavailableconst Expr *MessageExpr,
731                     ParsedAttr::Syntax syntaxSourceLocation strict,
732                     const Expr *ReplacementExpr) {
733    void *memory = allocate(AttributeFactory::AvailabilityAllocSize);
734    return add(new (memoryParsedAttr(
735        attrNameattrRangescopeNamescopeLocParamintroduceddeprecated,
736        obsoletedunavailableMessageExprsyntaxstrictReplacementExpr));
737  }
738
739  ParsedAttr *create(IdentifierInfo *attrNameSourceRange attrRange,
740                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
741                     IdentifierLoc *Param1IdentifierLoc *Param2,
742                     IdentifierLoc *Param3ParsedAttr::Syntax syntax) {
743    void *memory = allocate(
744        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
745                                     detail::TypeTagForDatatypeData, ParsedType,
746                                     detail::PropertyData>(30000));
747    return add(new (memoryParsedAttr(attrNameattrRangescopeNamescopeLoc,
748                                       Param1Param2Param3syntax));
749  }
750
751  ParsedAttr *
752  createTypeTagForDatatype(IdentifierInfo *attrNameSourceRange attrRange,
753                           IdentifierInfo *scopeNameSourceLocation scopeLoc,
754                           IdentifierLoc *argumentKind,
755                           ParsedType matchingCTypebool layoutCompatible,
756                           bool mustBeNullParsedAttr::Syntax syntax) {
757    void *memory = allocate(AttributeFactory::TypeTagForDatatypeAllocSize);
758    return add(new (memoryParsedAttr(attrNameattrRangescopeNamescopeLoc,
759                                       argumentKindmatchingCType,
760                                       layoutCompatiblemustBeNullsyntax));
761  }
762
763  ParsedAttr *createTypeAttribute(IdentifierInfo *attrName,
764                                  SourceRange attrRange,
765                                  IdentifierInfo *scopeName,
766                                  SourceLocation scopeLocParsedType typeArg,
767                                  ParsedAttr::Syntax syntaxUsed) {
768    void *memory = allocate(
769        ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
770                                     detail::TypeTagForDatatypeData, ParsedType,
771                                     detail::PropertyData>(00010));
772    return add(new (memoryParsedAttr(attrNameattrRangescopeNamescopeLoc,
773                                       typeArgsyntaxUsed));
774  }
775
776  ParsedAttr *
777  createPropertyAttribute(IdentifierInfo *attrNameSourceRange attrRange,
778                          IdentifierInfo *scopeNameSourceLocation scopeLoc,
779                          IdentifierInfo *getterIdIdentifierInfo *setterId,
780                          ParsedAttr::Syntax syntaxUsed) {
781    void *memory = allocate(AttributeFactory::PropertyAllocSize);
782    return add(new (memoryParsedAttr(attrNameattrRangescopeNamescopeLoc,
783                                       getterIdsetterIdsyntaxUsed));
784  }
785};
786
787class ParsedAttributesView {
788  using VecTy = llvm::TinyPtrVector<ParsedAttr *>;
789  using SizeType = decltype(std::declval<VecTy>().size());
790
791public:
792  bool empty() const { return AttrList.empty(); }
793  SizeType size() const { return AttrList.size(); }
794  ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; }
795  const ParsedAttr &operator[](SizeType posconst { return *AttrList[pos]; }
796
797  void addAtEnd(ParsedAttr *newAttr) {
798    assert(newAttr);
799    AttrList.push_back(newAttr);
800  }
801
802  void remove(ParsedAttr *ToBeRemoved) {
803     (0) . __assert_fail ("is_contained(AttrList, ToBeRemoved) && \"Cannot remove attribute that isn't in the list\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 804, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(is_contained(AttrList, ToBeRemoved) &&
804 (0) . __assert_fail ("is_contained(AttrList, ToBeRemoved) && \"Cannot remove attribute that isn't in the list\"", "/home/seafit/code_projects/clang_source/clang/include/clang/Sema/ParsedAttr.h", 804, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">           "Cannot remove attribute that isn't in the list");
805    AttrList.erase(llvm::find(AttrList, ToBeRemoved));
806  }
807
808  void clearListOnly() { AttrList.clear(); }
809
810  struct iterator : llvm::iterator_adaptor_base<iterator, VecTy::iterator,
811                                                std::random_access_iterator_tag,
812                                                ParsedAttr> {
813    iterator() : iterator_adaptor_base(nullptr) {}
814    iterator(VecTy::iterator I) : iterator_adaptor_base(I) {}
815    reference operator*() { return **I; }
816    friend class ParsedAttributesView;
817  };
818  struct const_iterator
819      : llvm::iterator_adaptor_base<const_iterator, VecTy::const_iterator,
820                                    std::random_access_iterator_tag,
821                                    ParsedAttr> {
822    const_iterator() : iterator_adaptor_base(nullptr) {}
823    const_iterator(VecTy::const_iterator I) : iterator_adaptor_base(I) {}
824
825    reference operator*() const { return **I; }
826    friend class ParsedAttributesView;
827  };
828
829  void addAll(iterator Biterator E) {
830    AttrList.insert(AttrList.begin(), B.I, E.I);
831  }
832
833  void addAll(const_iterator Bconst_iterator E) {
834    AttrList.insert(AttrList.begin(), B.I, E.I);
835  }
836
837  void addAllAtEnd(iterator Biterator E) {
838    AttrList.insert(AttrList.end(), B.I, E.I);
839  }
840
841  void addAllAtEnd(const_iterator Bconst_iterator E) {
842    AttrList.insert(AttrList.end(), B.I, E.I);
843  }
844
845  iterator begin() { return iterator(AttrList.begin()); }
846  const_iterator begin() const { return const_iterator(AttrList.begin()); }
847  iterator end() { return iterator(AttrList.end()); }
848  const_iterator end() const { return const_iterator(AttrList.end()); }
849
850  ParsedAttr &front() {
851    assert(!empty());
852    return *AttrList.front();
853  }
854  const ParsedAttr &front() const {
855    assert(!empty());
856    return *AttrList.front();
857  }
858  ParsedAttr &back() {
859    assert(!empty());
860    return *AttrList.back();
861  }
862  const ParsedAttr &back() const {
863    assert(!empty());
864    return *AttrList.back();
865  }
866
867  bool hasAttribute(ParsedAttr::Kind Kconst {
868    return llvm::any_of(
869        AttrList, [K](const ParsedAttr *AL) { return AL->getKind() == K; });
870  }
871
872private:
873  VecTy AttrList;
874};
875
876/// ParsedAttributes - A collection of parsed attributes.  Currently
877/// we don't differentiate between the various attribute syntaxes,
878/// which is basically silly.
879///
880/// Right now this is a very lightweight container, but the expectation
881/// is that this will become significantly more serious.
882class ParsedAttributes : public ParsedAttributesView {
883public:
884  ParsedAttributes(AttributeFactory &factory) : pool(factory) {}
885  ParsedAttributes(const ParsedAttributes &) = delete;
886
887  AttributePool &getPool() const { return pool; }
888
889  void takeAllFrom(ParsedAttributes &attrs) {
890    addAll(attrs.begin(), attrs.end());
891    attrs.clearListOnly();
892    pool.takeAllFrom(attrs.pool);
893  }
894
895  void clear() {
896    clearListOnly();
897    pool.clear();
898  }
899
900  /// Add attribute with expression arguments.
901  ParsedAttr *addNew(IdentifierInfo *attrNameSourceRange attrRange,
902                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
903                     ArgsUnion *argsunsigned numArgs,
904                     ParsedAttr::Syntax syntax,
905                     SourceLocation ellipsisLoc = SourceLocation()) {
906    ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
907                                   args, numArgs, syntax, ellipsisLoc);
908    addAtEnd(attr);
909    return attr;
910  }
911
912  /// Add availability attribute.
913  ParsedAttr *addNew(IdentifierInfo *attrNameSourceRange attrRange,
914                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
915                     IdentifierLoc *Paramconst AvailabilityChange &introduced,
916                     const AvailabilityChange &deprecated,
917                     const AvailabilityChange &obsoleted,
918                     SourceLocation unavailableconst Expr *MessageExpr,
919                     ParsedAttr::Syntax syntaxSourceLocation strict,
920                     const Expr *ReplacementExpr) {
921    ParsedAttr *attr = pool.create(
922        attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
923        obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr);
924    addAtEnd(attr);
925    return attr;
926  }
927
928  /// Add objc_bridge_related attribute.
929  ParsedAttr *addNew(IdentifierInfo *attrNameSourceRange attrRange,
930                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
931                     IdentifierLoc *Param1IdentifierLoc *Param2,
932                     IdentifierLoc *Param3ParsedAttr::Syntax syntax) {
933    ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
934                                   Param1, Param2, Param3, syntax);
935    addAtEnd(attr);
936    return attr;
937  }
938
939  /// Add type_tag_for_datatype attribute.
940  ParsedAttr *
941  addNewTypeTagForDatatype(IdentifierInfo *attrNameSourceRange attrRange,
942                           IdentifierInfo *scopeNameSourceLocation scopeLoc,
943                           IdentifierLoc *argumentKind,
944                           ParsedType matchingCTypebool layoutCompatible,
945                           bool mustBeNullParsedAttr::Syntax syntax) {
946    ParsedAttr *attr = pool.createTypeTagForDatatype(
947        attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType,
948        layoutCompatible, mustBeNull, syntax);
949    addAtEnd(attr);
950    return attr;
951  }
952
953  /// Add an attribute with a single type argument.
954  ParsedAttr *addNewTypeAttr(IdentifierInfo *attrNameSourceRange attrRange,
955                             IdentifierInfo *scopeNameSourceLocation scopeLoc,
956                             ParsedType typeArg,
957                             ParsedAttr::Syntax syntaxUsed) {
958    ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName,
959                                                scopeLoc, typeArg, syntaxUsed);
960    addAtEnd(attr);
961    return attr;
962  }
963
964  /// Add microsoft __delspec(property) attribute.
965  ParsedAttr *
966  addNewPropertyAttr(IdentifierInfo *attrNameSourceRange attrRange,
967                     IdentifierInfo *scopeNameSourceLocation scopeLoc,
968                     IdentifierInfo *getterIdIdentifierInfo *setterId,
969                     ParsedAttr::Syntax syntaxUsed) {
970    ParsedAttr *attr =
971        pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc,
972                                     getterId, setterId, syntaxUsed);
973    addAtEnd(attr);
974    return attr;
975  }
976
977private:
978  mutable AttributePool pool;
979};
980
981/// These constants match the enumerated choices of
982/// err_attribute_argument_n_type and err_attribute_argument_type.
983enum AttributeArgumentNType {
984  AANT_ArgumentIntOrBool,
985  AANT_ArgumentIntegerConstant,
986  AANT_ArgumentString,
987  AANT_ArgumentIdentifier
988};
989
990/// These constants match the enumerated choices of
991/// warn_attribute_wrong_decl_type and err_attribute_wrong_decl_type.
992enum AttributeDeclKind {
993  ExpectedFunction,
994  ExpectedUnion,
995  ExpectedVariableOrFunction,
996  ExpectedFunctionOrMethod,
997  ExpectedFunctionMethodOrBlock,
998  ExpectedFunctionMethodOrParameter,
999  ExpectedVariable,
1000  ExpectedVariableOrField,
1001  ExpectedVariableFieldOrTag,
1002  ExpectedTypeOrNamespace,
1003  ExpectedFunctionVariableOrClass,
1004  ExpectedKernelFunction,
1005  ExpectedFunctionWithProtoType,
1006};
1007
1008inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1009                                           const ParsedAttr &At) {
1010  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1011                  DiagnosticsEngine::ak_identifierinfo);
1012  return DB;
1013}
1014
1015inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
1016                                           const ParsedAttr &At) {
1017  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1018                  DiagnosticsEngine::ak_identifierinfo);
1019  return PD;
1020}
1021
1022inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
1023                                           const ParsedAttr *At) {
1024  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1025                  DiagnosticsEngine::ak_identifierinfo);
1026  return DB;
1027}
1028
1029inline const PartialDiagnostic &operator<<(const PartialDiagnostic &PD,
1030                                           const ParsedAttr *At) {
1031  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1032                  DiagnosticsEngine::ak_identifierinfo);
1033  return PD;
1034}
1035
1036// namespace clang
1037
1038#endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H
1039
clang::AvailabilityChange::KeywordLoc
clang::AvailabilityChange::Version
clang::AvailabilityChange::VersionRange
clang::AvailabilityChange::isValid
clang::detail::AvailabilityData::Changes
clang::detail::AvailabilityData::StrictLoc
clang::detail::AvailabilityData::Replacement
clang::detail::TypeTagForDatatypeData::MatchingCType
clang::detail::TypeTagForDatatypeData::LayoutCompatible
clang::detail::TypeTagForDatatypeData::MustBeNull
clang::detail::PropertyData::GetterId
clang::detail::PropertyData::SetterId
clang::IdentifierLoc::Loc
clang::IdentifierLoc::Ident
clang::IdentifierLoc::create
clang::ParsedAttr::numTrailingObjects
clang::ParsedAttr::Syntax
clang::ParsedAttr::AttrName
clang::ParsedAttr::ScopeName
clang::ParsedAttr::AttrRange
clang::ParsedAttr::ScopeLoc
clang::ParsedAttr::EllipsisLoc
clang::ParsedAttr::AttrKind
clang::ParsedAttr::NumArgs
clang::ParsedAttr::SyntaxUsed
clang::ParsedAttr::Invalid
clang::ParsedAttr::UsedAsTypeAttr
clang::ParsedAttr::IsAvailability
clang::ParsedAttr::IsTypeTagForDatatype
clang::ParsedAttr::IsProperty
clang::ParsedAttr::HasParsedType
clang::ParsedAttr::HasProcessingCache
clang::ParsedAttr::ProcessingCache
clang::ParsedAttr::IsPragmaClangAttribute
clang::ParsedAttr::UnavailableLoc
clang::ParsedAttr::MessageExpr
clang::ParsedAttr::getArgsBuffer
clang::ParsedAttr::getArgsBuffer
clang::ParsedAttr::getAvailabilityData
clang::ParsedAttr::getAvailabilityData
clang::ParsedAttr::getTypeTagForDatatypeDataSlot
clang::ParsedAttr::getTypeTagForDatatypeDataSlot
clang::ParsedAttr::getTypeBuffer
clang::ParsedAttr::getTypeBuffer
clang::ParsedAttr::getPropertyDataBuffer
clang::ParsedAttr::getPropertyDataBuffer
clang::ParsedAttr::allocated_size
clang::ParsedAttr::Kind
clang::ParsedAttr::getName
clang::ParsedAttr::getLoc
clang::ParsedAttr::getRange
clang::ParsedAttr::hasScope
clang::ParsedAttr::getScopeName
clang::ParsedAttr::getScopeLoc
clang::ParsedAttr::isGNUScope
clang::ParsedAttr::hasParsedType
clang::ParsedAttr::isDeclspecPropertyAttribute
clang::ParsedAttr::isAlignasAttribute
clang::ParsedAttr::isDeclspecAttribute
clang::ParsedAttr::isMicrosoftAttribute
clang::ParsedAttr::isCXX11Attribute
clang::ParsedAttr::isC2xAttribute
clang::ParsedAttr::isKeywordAttribute
clang::ParsedAttr::isContextSensitiveKeywordAttribute
clang::ParsedAttr::isInvalid
clang::ParsedAttr::setInvalid
clang::ParsedAttr::hasProcessingCache
clang::ParsedAttr::getProcessingCache
clang::ParsedAttr::setProcessingCache
clang::ParsedAttr::isUsedAsTypeAttr
clang::ParsedAttr::setUsedAsTypeAttr
clang::ParsedAttr::isPragmaClangAttribute
clang::ParsedAttr::setIsPragmaClangAttribute
clang::ParsedAttr::isPackExpansion
clang::ParsedAttr::getEllipsisLoc
clang::ParsedAttr::getKind
clang::ParsedAttr::getKind
clang::ParsedAttr::getNumArgs
clang::ParsedAttr::getArg
clang::ParsedAttr::isArgExpr
clang::ParsedAttr::getArgAsExpr
clang::ParsedAttr::isArgIdent
clang::ParsedAttr::getArgAsIdent
clang::ParsedAttr::getAvailabilityIntroduced
clang::ParsedAttr::getAvailabilityDeprecated
clang::ParsedAttr::getAvailabilityObsoleted
clang::ParsedAttr::getStrictLoc
clang::ParsedAttr::getUnavailableLoc
clang::ParsedAttr::getMessageExpr
clang::ParsedAttr::getReplacementExpr
clang::ParsedAttr::getMatchingCType
clang::ParsedAttr::getLayoutCompatible
clang::ParsedAttr::getMustBeNull
clang::ParsedAttr::getTypeArg
clang::ParsedAttr::getPropertyDataGetter
clang::ParsedAttr::getPropertyDataSetter
clang::ParsedAttr::getAttributeSpellingListIndex
clang::ParsedAttr::isTargetSpecificAttr
clang::ParsedAttr::isTypeAttr
clang::ParsedAttr::isStmtAttr
clang::ParsedAttr::hasCustomParsing
clang::ParsedAttr::getMinArgs
clang::ParsedAttr::getMaxArgs
clang::ParsedAttr::hasVariadicArg
clang::ParsedAttr::diagnoseAppertainsTo
clang::ParsedAttr::appliesToDecl
clang::ParsedAttr::getMatchRules
clang::ParsedAttr::diagnoseLangOpts
clang::ParsedAttr::existsInTarget
clang::ParsedAttr::isKnownToGCC
clang::ParsedAttr::isSupportedByPragmaAttribute
clang::ParsedAttr::getSemanticSpelling
clang::ParsedAttr::asOpenCLLangAS
clang::AttributeFactory::Alloc
clang::AttributeFactory::FreeLists
clang::AttributeFactory::allocate
clang::AttributeFactory::deallocate
clang::AttributeFactory::reclaimPool
clang::AttributePool::Factory
clang::AttributePool::Attrs
clang::AttributePool::allocate
clang::AttributePool::add
clang::AttributePool::remove
clang::AttributePool::takePool
clang::AttributePool::getFactory
clang::AttributePool::clear
clang::AttributePool::takeAllFrom
clang::AttributePool::create
clang::AttributePool::create
clang::AttributePool::create
clang::AttributePool::createTypeTagForDatatype
clang::AttributePool::createTypeAttribute
clang::AttributePool::createPropertyAttribute
clang::ParsedAttributesView::empty
clang::ParsedAttributesView::size
clang::ParsedAttributesView::addAtEnd
clang::ParsedAttributesView::remove
clang::ParsedAttributesView::clearListOnly
clang::ParsedAttributesView::iterator
clang::ParsedAttributesView::const_iterator
clang::ParsedAttributesView::addAll
clang::ParsedAttributesView::addAll
clang::ParsedAttributesView::addAllAtEnd
clang::ParsedAttributesView::addAllAtEnd
clang::ParsedAttributesView::begin
clang::ParsedAttributesView::begin
clang::ParsedAttributesView::end
clang::ParsedAttributesView::end
clang::ParsedAttributesView::front
clang::ParsedAttributesView::front
clang::ParsedAttributesView::back
clang::ParsedAttributesView::back
clang::ParsedAttributesView::hasAttribute
clang::ParsedAttributesView::AttrList
clang::ParsedAttributes::getPool
clang::ParsedAttributes::takeAllFrom
clang::ParsedAttributes::clear
clang::ParsedAttributes::addNew
clang::ParsedAttributes::addNew
clang::ParsedAttributes::addNew
clang::ParsedAttributes::addNewTypeTagForDatatype
clang::ParsedAttributes::addNewTypeAttr
clang::ParsedAttributes::addNewPropertyAttr
clang::ParsedAttributes::pool