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