clang  9.0.0svn
ParsedAttr.h
Go to the documentation of this file.
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 
18 #include "clang/Basic/Diagnostic.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 
32 namespace clang {
33 
34 class ASTContext;
35 class Decl;
36 class Expr;
37 class IdentifierInfo;
38 class 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.
44  /// The location of the keyword indicating the kind of change.
46 
47  /// The version number at which the change occurred.
48  VersionTuple Version;
49 
50  /// The source range covering the version number.
52 
53  /// Determine whether this availability change is valid.
54  bool isValid() const { return !Version.empty(); }
55 };
56 
57 namespace detail {
60 };
61 
62 /// Describes the trailing object for Availability attribute in ParsedAttr.
66  const Expr *Replacement;
67 
69  const AvailabilityChange &Deprecated,
70  const AvailabilityChange &Obsoleted,
71  SourceLocation Strict, const Expr *ReplaceExpr)
72  : StrictLoc(Strict), Replacement(ReplaceExpr) {
73  Changes[IntroducedSlot] = Introduced;
74  Changes[DeprecatedSlot] = Deprecated;
75  Changes[ObsoletedSlot] = Obsoleted;
76  }
77 };
78 
81  unsigned LayoutCompatible : 1;
82  unsigned MustBeNull : 1;
83 };
84 struct PropertyData {
85  IdentifierInfo *GetterId, *SetterId;
86 
88  : GetterId(getterId), SetterId(setterId) {}
89 };
90 
91 } // namespace
92 
93 /// Wraps an identifier and optional source location for the identifier.
94 struct IdentifierLoc {
97 
99  IdentifierInfo *Ident);
100 };
101 
102 /// A union of the various pointer types that can be passed to an
103 /// ParsedAttr as an argument.
104 using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;
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 ///
116 class 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 
137 public:
138  /// The style used to specify an attribute.
139  enum Syntax {
140  /// __attribute__((...))
142 
143  /// [[...]]
145 
146  /// [[...]]
148 
149  /// __declspec(...)
151 
152  /// [uuid("...")] class Foo
154 
155  /// __ptr16, alignas(...), etc.
157 
158  /// #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.
165  };
166 
167 private:
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 
231 private:
232  friend class AttributeFactory;
233  friend class AttributePool;
234 
235  /// Constructor for attributes with expression arguments.
236  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
237  IdentifierInfo *scopeName, SourceLocation scopeLoc,
238  ArgsUnion *args, unsigned numArgs, Syntax 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 *attrName, SourceRange attrRange,
252  IdentifierInfo *scopeName, SourceLocation scopeLoc,
253  IdentifierLoc *Parm, const AvailabilityChange &introduced,
254  const AvailabilityChange &deprecated,
255  const AvailabilityChange &obsoleted, SourceLocation unavailable,
256  const Expr *messageExpr, Syntax syntaxUsed, SourceLocation 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  introduced, deprecated, obsoleted, strict, replacementExpr);
268  AttrKind = getKind(getName(), getScopeName(), syntaxUsed);
269  }
270 
271  /// Constructor for objc_bridge_related attributes.
272  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
273  IdentifierInfo *scopeName, SourceLocation scopeLoc,
274  IdentifierLoc *Parm1, IdentifierLoc *Parm2, IdentifierLoc *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 *attrName, SourceRange attrRange,
290  IdentifierInfo *scopeName, SourceLocation scopeLoc,
291  IdentifierLoc *ArgKind, ParsedType matchingCType,
292  bool layoutCompatible, bool mustBeNull, Syntax 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.MatchingCType) ParsedType(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 *attrName, SourceRange attrRange,
309  IdentifierInfo *scopeName, SourceLocation scopeLoc,
310  ParsedType typeArg, Syntax 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 *attrName, SourceRange attrRange,
322  IdentifierInfo *scopeName, SourceLocation scopeLoc,
323  IdentifierInfo *getterId, IdentifierInfo *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(getterId, setterId);
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 
364 public:
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
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?
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 
422  return SyntaxUsed == AS_ContextSensitiveKeyword;
423  }
424 
425  bool isInvalid() const { return Invalid; }
426  void setInvalid(bool b = true) const { 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 value) const {
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 *Name, const 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  assert(Arg < NumArgs && "Arg access out of range!");
461  return getArgsBuffer()[Arg];
462  }
463 
464  bool isArgExpr(unsigned Arg) const {
465  return Arg < NumArgs && getArg(Arg).is<Expr*>();
466  }
467 
468  Expr *getArgAsExpr(unsigned Arg) const {
469  return getArg(Arg).get<Expr*>();
470  }
471 
472  bool isArgIdent(unsigned Arg) const {
473  return Arg < NumArgs && getArg(Arg).is<IdentifierLoc*>();
474  }
475 
476  IdentifierLoc *getArgAsIdent(unsigned Arg) const {
477  return getArg(Arg).get<IdentifierLoc*>();
478  }
479 
481  assert(getKind() == AT_Availability && "Not an availability attribute");
482  return getAvailabilityData()->Changes[detail::IntroducedSlot];
483  }
484 
486  assert(getKind() == AT_Availability && "Not an availability attribute");
487  return getAvailabilityData()->Changes[detail::DeprecatedSlot];
488  }
489 
491  assert(getKind() == AT_Availability && "Not an availability attribute");
492  return getAvailabilityData()->Changes[detail::ObsoletedSlot];
493  }
494 
496  assert(getKind() == AT_Availability && "Not an availability attribute");
497  return getAvailabilityData()->StrictLoc;
498  }
499 
501  assert(getKind() == AT_Availability && "Not an availability attribute");
502  return UnavailableLoc;
503  }
504 
505  const Expr * getMessageExpr() const {
506  assert(getKind() == AT_Availability && "Not an availability attribute");
507  return MessageExpr;
508  }
509 
510  const Expr *getReplacementExpr() const {
511  assert(getKind() == AT_Availability && "Not an availability attribute");
512  return getAvailabilityData()->Replacement;
513  }
514 
515  const ParsedType &getMatchingCType() const {
516  assert(getKind() == AT_TypeTagForDatatype &&
517  "Not a type_tag_for_datatype attribute");
518  return getTypeTagForDatatypeDataSlot().MatchingCType;
519  }
520 
521  bool getLayoutCompatible() const {
522  assert(getKind() == AT_TypeTagForDatatype &&
523  "Not a type_tag_for_datatype attribute");
524  return getTypeTagForDatatypeDataSlot().LayoutCompatible;
525  }
526 
527  bool getMustBeNull() const {
528  assert(getKind() == AT_TypeTagForDatatype &&
529  "Not a type_tag_for_datatype attribute");
530  return getTypeTagForDatatypeDataSlot().MustBeNull;
531  }
532 
533  const ParsedType &getTypeArg() const {
534  assert(HasParsedType && "Not a type attribute");
535  return getTypeBuffer();
536  }
537 
539  assert(isDeclspecPropertyAttribute() &&
540  "Not a __delcspec(property) attribute");
541  return getPropertyDataBuffer().GetterId;
542  }
543 
545  assert(isDeclspecPropertyAttribute() &&
546  "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 &S, const Decl *D) const;
564  bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const;
565  void getMatchRules(const LangOptions &LangOpts,
566  SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>>
567  &MatchRules) const;
568  bool diagnoseLangOpts(class Sema &S) const;
569  bool existsInTarget(const TargetInfo &Target) const;
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.
583  switch (getKind()) {
584  case ParsedAttr::AT_OpenCLConstantAddressSpace:
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 
600 class 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.
607 public:
608  enum {
609  AvailabilityAllocSize =
610  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
612  detail::PropertyData>(1, 1, 0, 0, 0),
613  TypeTagForDatatypeAllocSize =
614  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
615  detail::TypeTagForDatatypeData, ParsedType,
616  detail::PropertyData>(1, 0, 1, 0, 0),
617  PropertyAllocSize =
618  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
619  detail::TypeTagForDatatypeData, ParsedType,
620  detail::PropertyData>(0, 0, 0, 0, 1),
621  };
622 
623 private:
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>, InlineFreeListsCapacity> FreeLists;
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 
655 public:
657  ~AttributeFactory();
658 };
659 
661  friend class AttributeFactory;
662  friend class ParsedAttributes;
663  AttributeFactory &Factory;
664  llvm::TinyPtrVector<ParsedAttr *> Attrs;
665 
666  void *allocate(size_t size) {
667  return Factory.allocate(size);
668  }
669 
670  ParsedAttr *add(ParsedAttr *attr) {
671  Attrs.push_back(attr);
672  return attr;
673  }
674 
675  void remove(ParsedAttr *attr) {
676  assert(llvm::is_contained(Attrs, attr) &&
677  "Can't take attribute from a pool that doesn't own it!");
678  Attrs.erase(llvm::find(Attrs, attr));
679  }
680 
681  void takePool(AttributePool &pool);
682 
683 public:
684  /// Create a new pool for a factory.
685  AttributePool(AttributeFactory &factory) : Factory(factory) {}
686 
687  AttributePool(const AttributePool &) = delete;
688 
689  ~AttributePool() { Factory.reclaimPool(*this); }
690 
691  /// Move the given pool's allocations to this pool.
692  AttributePool(AttributePool &&pool) = default;
693 
694  AttributeFactory &getFactory() const { return Factory; }
695 
696  void clear() {
697  Factory.reclaimPool(*this);
698  Attrs.clear();
699  }
700 
701  /// Take the given pool's allocations and add them to this pool.
703  takePool(pool);
704  pool.Attrs.clear();
705  }
706 
708  IdentifierInfo *scopeName, SourceLocation scopeLoc,
709  ArgsUnion *args, unsigned numArgs,
710  ParsedAttr::Syntax syntax,
711  SourceLocation ellipsisLoc = SourceLocation()) {
712  size_t temp =
713  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
715  detail::PropertyData>(numArgs, 0, 0, 0, 0);
716  (void)temp;
717  void *memory = allocate(
718  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
719  detail::TypeTagForDatatypeData, ParsedType,
720  detail::PropertyData>(numArgs, 0, 0, 0,
721  0));
722  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
723  args, numArgs, syntax, ellipsisLoc));
724  }
725 
727  IdentifierInfo *scopeName, SourceLocation scopeLoc,
728  IdentifierLoc *Param, const AvailabilityChange &introduced,
729  const AvailabilityChange &deprecated,
730  const AvailabilityChange &obsoleted,
731  SourceLocation unavailable, const Expr *MessageExpr,
732  ParsedAttr::Syntax syntax, SourceLocation strict,
733  const Expr *ReplacementExpr) {
734  void *memory = allocate(AttributeFactory::AvailabilityAllocSize);
735  return add(new (memory) ParsedAttr(
736  attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
737  obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr));
738  }
739 
741  IdentifierInfo *scopeName, SourceLocation scopeLoc,
742  IdentifierLoc *Param1, IdentifierLoc *Param2,
743  IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
744  void *memory = allocate(
745  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
747  detail::PropertyData>(3, 0, 0, 0, 0));
748  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
749  Param1, Param2, Param3, syntax));
750  }
751 
752  ParsedAttr *
754  IdentifierInfo *scopeName, SourceLocation scopeLoc,
755  IdentifierLoc *argumentKind,
756  ParsedType matchingCType, bool layoutCompatible,
757  bool mustBeNull, ParsedAttr::Syntax syntax) {
758  void *memory = allocate(AttributeFactory::TypeTagForDatatypeAllocSize);
759  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
760  argumentKind, matchingCType,
761  layoutCompatible, mustBeNull, syntax));
762  }
763 
765  SourceRange attrRange,
766  IdentifierInfo *scopeName,
767  SourceLocation scopeLoc, ParsedType typeArg,
768  ParsedAttr::Syntax syntaxUsed) {
769  void *memory = allocate(
770  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
772  detail::PropertyData>(0, 0, 0, 1, 0));
773  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
774  typeArg, syntaxUsed));
775  }
776 
777  ParsedAttr *
779  IdentifierInfo *scopeName, SourceLocation scopeLoc,
780  IdentifierInfo *getterId, IdentifierInfo *setterId,
781  ParsedAttr::Syntax syntaxUsed) {
782  void *memory = allocate(AttributeFactory::PropertyAllocSize);
783  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
784  getterId, setterId, syntaxUsed));
785  }
786 };
787 
789  using VecTy = llvm::TinyPtrVector<ParsedAttr *>;
790  using SizeType = decltype(std::declval<VecTy>().size());
791 
792 public:
793  bool empty() const { return AttrList.empty(); }
794  SizeType size() const { return AttrList.size(); }
795  ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; }
796  const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; }
797 
798  void addAtEnd(ParsedAttr *newAttr) {
799  assert(newAttr);
800  AttrList.push_back(newAttr);
801  }
802 
803  void remove(ParsedAttr *ToBeRemoved) {
804  assert(is_contained(AttrList, ToBeRemoved) &&
805  "Cannot remove attribute that isn't in the list");
806  AttrList.erase(llvm::find(AttrList, ToBeRemoved));
807  }
808 
809  void clearListOnly() { AttrList.clear(); }
810 
811  struct iterator : llvm::iterator_adaptor_base<iterator, VecTy::iterator,
812  std::random_access_iterator_tag,
813  ParsedAttr> {
814  iterator() : iterator_adaptor_base(nullptr) {}
815  iterator(VecTy::iterator I) : iterator_adaptor_base(I) {}
816  reference operator*() { return **I; }
817  friend class ParsedAttributesView;
818  };
820  : llvm::iterator_adaptor_base<const_iterator, VecTy::const_iterator,
821  std::random_access_iterator_tag,
822  ParsedAttr> {
823  const_iterator() : iterator_adaptor_base(nullptr) {}
824  const_iterator(VecTy::const_iterator I) : iterator_adaptor_base(I) {}
825 
826  reference operator*() const { return **I; }
827  friend class ParsedAttributesView;
828  };
829 
830  void addAll(iterator B, iterator E) {
831  AttrList.insert(AttrList.begin(), B.I, E.I);
832  }
833 
835  AttrList.insert(AttrList.begin(), B.I, E.I);
836  }
837 
839  AttrList.insert(AttrList.end(), B.I, E.I);
840  }
841 
843  AttrList.insert(AttrList.end(), B.I, E.I);
844  }
845 
846  iterator begin() { return iterator(AttrList.begin()); }
847  const_iterator begin() const { return const_iterator(AttrList.begin()); }
848  iterator end() { return iterator(AttrList.end()); }
849  const_iterator end() const { return const_iterator(AttrList.end()); }
850 
852  assert(!empty());
853  return *AttrList.front();
854  }
855  const ParsedAttr &front() const {
856  assert(!empty());
857  return *AttrList.front();
858  }
860  assert(!empty());
861  return *AttrList.back();
862  }
863  const ParsedAttr &back() const {
864  assert(!empty());
865  return *AttrList.back();
866  }
867 
869  return llvm::any_of(
870  AttrList, [K](const ParsedAttr *AL) { return AL->getKind() == K; });
871  }
872 
873 private:
874  VecTy AttrList;
875 };
876 
877 /// ParsedAttributes - A collection of parsed attributes. Currently
878 /// we don't differentiate between the various attribute syntaxes,
879 /// which is basically silly.
880 ///
881 /// Right now this is a very lightweight container, but the expectation
882 /// is that this will become significantly more serious.
884 public:
885  ParsedAttributes(AttributeFactory &factory) : pool(factory) {}
886  ParsedAttributes(const ParsedAttributes &) = delete;
887 
888  AttributePool &getPool() const { return pool; }
889 
891  addAll(attrs.begin(), attrs.end());
892  attrs.clearListOnly();
893  pool.takeAllFrom(attrs.pool);
894  }
895 
897  Attrs.getPool().remove(PA);
898  Attrs.remove(PA);
899  getPool().add(PA);
900  addAtEnd(PA);
901  }
902 
903  void clear() {
904  clearListOnly();
905  pool.clear();
906  }
907 
908  /// Add attribute with expression arguments.
910  IdentifierInfo *scopeName, SourceLocation scopeLoc,
911  ArgsUnion *args, unsigned numArgs,
912  ParsedAttr::Syntax syntax,
913  SourceLocation ellipsisLoc = SourceLocation()) {
914  ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
915  args, numArgs, syntax, ellipsisLoc);
916  addAtEnd(attr);
917  return attr;
918  }
919 
920  /// Add availability attribute.
922  IdentifierInfo *scopeName, SourceLocation scopeLoc,
923  IdentifierLoc *Param, const AvailabilityChange &introduced,
924  const AvailabilityChange &deprecated,
925  const AvailabilityChange &obsoleted,
926  SourceLocation unavailable, const Expr *MessageExpr,
927  ParsedAttr::Syntax syntax, SourceLocation strict,
928  const Expr *ReplacementExpr) {
929  ParsedAttr *attr = pool.create(
930  attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
931  obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr);
932  addAtEnd(attr);
933  return attr;
934  }
935 
936  /// Add objc_bridge_related attribute.
938  IdentifierInfo *scopeName, SourceLocation scopeLoc,
939  IdentifierLoc *Param1, IdentifierLoc *Param2,
940  IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
941  ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
942  Param1, Param2, Param3, syntax);
943  addAtEnd(attr);
944  return attr;
945  }
946 
947  /// Add type_tag_for_datatype attribute.
948  ParsedAttr *
950  IdentifierInfo *scopeName, SourceLocation scopeLoc,
951  IdentifierLoc *argumentKind,
952  ParsedType matchingCType, bool layoutCompatible,
953  bool mustBeNull, ParsedAttr::Syntax syntax) {
954  ParsedAttr *attr = pool.createTypeTagForDatatype(
955  attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType,
956  layoutCompatible, mustBeNull, syntax);
957  addAtEnd(attr);
958  return attr;
959  }
960 
961  /// Add an attribute with a single type argument.
963  IdentifierInfo *scopeName, SourceLocation scopeLoc,
964  ParsedType typeArg,
965  ParsedAttr::Syntax syntaxUsed) {
966  ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName,
967  scopeLoc, typeArg, syntaxUsed);
968  addAtEnd(attr);
969  return attr;
970  }
971 
972  /// Add microsoft __delspec(property) attribute.
973  ParsedAttr *
975  IdentifierInfo *scopeName, SourceLocation scopeLoc,
976  IdentifierInfo *getterId, IdentifierInfo *setterId,
977  ParsedAttr::Syntax syntaxUsed) {
978  ParsedAttr *attr =
979  pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc,
980  getterId, setterId, syntaxUsed);
981  addAtEnd(attr);
982  return attr;
983  }
984 
985 private:
986  mutable AttributePool pool;
987 };
988 
989 /// These constants match the enumerated choices of
990 /// err_attribute_argument_n_type and err_attribute_argument_type.
996 };
997 
998 /// These constants match the enumerated choices of
999 /// warn_attribute_wrong_decl_type and err_attribute_wrong_decl_type.
1014 };
1015 
1017  const ParsedAttr &At) {
1018  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1020  return DB;
1021 }
1022 
1024  const ParsedAttr &At) {
1025  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At.getName()),
1027  return PD;
1028 }
1029 
1031  const ParsedAttr *At) {
1032  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1034  return DB;
1035 }
1036 
1038  const ParsedAttr *At) {
1039  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At->getName()),
1041  return PD;
1042 }
1043 
1044 } // namespace clang
1045 
1046 #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H
ParsedAttr * createTypeAttribute(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, ParsedAttr::Syntax syntaxUsed)
Definition: ParsedAttr.h:764
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *Param1, IdentifierLoc *Param2, IdentifierLoc *Param3, ParsedAttr::Syntax syntax)
Definition: ParsedAttr.h:740
bool isAlignasAttribute() const
Definition: ParsedAttr.h:401
const_iterator end() const
Definition: ParsedAttr.h:849
bool isDeclspecAttribute() const
Definition: ParsedAttr.h:406
const_iterator(VecTy::const_iterator I)
Definition: ParsedAttr.h:824
SizeType size() const
Definition: ParsedAttr.h:794
ParsedAttributes(AttributeFactory &factory)
Definition: ParsedAttr.h:885
void takeOneFrom(ParsedAttributes &Attrs, ParsedAttr *PA)
Definition: ParsedAttr.h:896
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:104
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:96
Expr * getArgAsExpr(unsigned Arg) const
Definition: ParsedAttr.h:468
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
Definition: Attr.h:335
bool getMustBeNull() const
Definition: ParsedAttr.h:527
void setUsedAsTypeAttr()
Definition: ParsedAttr.h:441
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool hasParsedType() const
Definition: ParsedAttr.h:394
IdentifierInfo * getPropertyDataGetter() const
Definition: ParsedAttr.h:538
const_iterator begin() const
Definition: ParsedAttr.h:847
bool hasAttribute(ParsedAttr::Kind K) const
Definition: ParsedAttr.h:868
IdentifierInfo * getPropertyDataSetter() const
Definition: ParsedAttr.h:544
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
attribute((...))
Definition: ParsedAttr.h:141
bool isCXX11Attribute() const
Definition: ParsedAttr.h:409
ParsedAttr & operator[](SizeType pos)
Definition: ParsedAttr.h:795
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
SourceLocation Loc
Definition: ParsedAttr.h:95
const ParsedType & getMatchingCType() const
Definition: ParsedAttr.h:515
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
Definition: Diagnostic.h:1157
One of these records is kept for each identifier that is lexed.
SubjectMatchRule
A list of all the recognized kinds of attributes.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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:855
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:244
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
Definition: ParsedAttr.h:456
void setIsPragmaClangAttribute()
Definition: ParsedAttr.h:446
AttributeArgumentNType
These constants match the enumerated choices of err_attribute_argument_n_type and err_attribute_argum...
Definition: ParsedAttr.h:991
void takeAllFrom(ParsedAttributes &attrs)
Definition: ParsedAttr.h:890
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:43
bool isGNUScope() const
Definition: ParsedAttr.h:389
void addAtEnd(ParsedAttr *newAttr)
Definition: ParsedAttr.h:798
VersionTuple Version
The version number at which the change occurred.
Definition: ParsedAttr.h:48
void setInvalid(bool b=true) const
Definition: ParsedAttr.h:426
bool isDeclspecPropertyAttribute() const
Is this the Microsoft __declspec(property) attribute?
Definition: ParsedAttr.h:397
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:328
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1044
AvailabilityData(const AvailabilityChange &Introduced, const AvailabilityChange &Deprecated, const AvailabilityChange &Obsoleted, SourceLocation Strict, const Expr *ReplaceExpr)
Definition: ParsedAttr.h:68
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:949
void addAllAtEnd(const_iterator B, const_iterator E)
Definition: ParsedAttr.h:842
Exposes information about the current target.
Definition: TargetInfo.h:161
SourceLocation getScopeLoc() const
Definition: ParsedAttr.h:387
This represents one expression.
Definition: Expr.h:108
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:974
bool isC2xAttribute() const
Definition: ParsedAttr.h:413
Kind getKind() const
Definition: ParsedAttr.h:451
const AvailabilityChange & getAvailabilityObsoleted() const
Definition: ParsedAttr.h:490
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:921
AttributeFactory & getFactory() const
Definition: ParsedAttr.h:694
void addAllAtEnd(iterator B, iterator E)
Definition: ParsedAttr.h:838
void addAll(iterator B, iterator E)
Definition: ParsedAttr.h:830
SourceLocation KeywordLoc
The location of the keyword indicating the kind of change.
Definition: ParsedAttr.h:45
bool isValid() const
Determine whether this availability change is valid.
Definition: ParsedAttr.h:54
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:94
SourceRange VersionRange
The source range covering the version number.
Definition: ParsedAttr.h:51
bool getLayoutCompatible() const
Definition: ParsedAttr.h:521
SourceLocation getEllipsisLoc() const
Definition: ParsedAttr.h:449
ParsedAttr * createPropertyAttribute(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, ParsedAttr::Syntax syntaxUsed)
Definition: ParsedAttr.h:778
#define false
Definition: stdbool.h:17
Kind
Encodes a location in the source.
const ParsedType & getTypeArg() const
Definition: ParsedAttr.h:533
void addAll(const_iterator B, const_iterator E)
Definition: ParsedAttr.h:834
Syntax
The style used to specify an attribute.
Definition: ParsedAttr.h:139
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:116
const ParsedAttr & back() const
Definition: ParsedAttr.h:863
const ParsedAttr & operator[](SizeType pos) const
Definition: ParsedAttr.h:796
bool hasProcessingCache() const
Definition: ParsedAttr.h:428
bool isUsedAsTypeAttr() const
Definition: ParsedAttr.h:440
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:909
void remove(ParsedAttr *ToBeRemoved)
Definition: ParsedAttr.h:803
bool isContextSensitiveKeywordAttribute() const
Definition: ParsedAttr.h:421
bool isArgExpr(unsigned Arg) const
Definition: ParsedAttr.h:464
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Describes the trailing object for Availability attribute in ParsedAttr.
Definition: ParsedAttr.h:63
SourceRange getRange() const
Definition: ParsedAttr.h:383
void setProcessingCache(unsigned value) const
Definition: ParsedAttr.h:435
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
Definition: ParsedAttr.h:459
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
const AvailabilityChange & getAvailabilityIntroduced() const
Definition: ParsedAttr.h:480
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:417
bool isPackExpansion() const
Definition: ParsedAttr.h:448
bool isMicrosoftAttribute() const
Definition: ParsedAttr.h:407
SourceLocation getLoc() const
Definition: ParsedAttr.h:382
void takeAllFrom(AttributePool &pool)
Take the given pool&#39;s allocations and add them to this pool.
Definition: ParsedAttr.h:702
SourceLocation getStrictLoc() const
Definition: ParsedAttr.h:495
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Definition: ParsedAttr.h:707
AttributePool(AttributeFactory &factory)
Create a new pool for a factory.
Definition: ParsedAttr.h:685
IdentifierInfo * getName() const
Definition: ParsedAttr.h:381
ParsedAttr * createTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, bool mustBeNull, ParsedAttr::Syntax syntax)
Definition: ParsedAttr.h:753
const AvailabilityChange & getAvailabilityDeprecated() const
Definition: ParsedAttr.h:485
bool hasScope() const
Definition: ParsedAttr.h:385
friend TrailingObjects
Definition: OpenMPClause.h:98
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:937
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:962
bool isInvalid() const
Definition: ParsedAttr.h:425
Context-sensitive version of a keyword attribute.
Definition: ParsedAttr.h:164
LangAS asOpenCLLangAS() const
If this is an OpenCL addr space attribute returns its representation in LangAS, otherwise returns def...
Definition: ParsedAttr.h:582
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:606
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:726
[uuid("...")] class Foo
Definition: ParsedAttr.h:153
AttributePool & getPool() const
Definition: ParsedAttr.h:888
const Expr * getMessageExpr() const
Definition: ParsedAttr.h:505
Defines the clang::TargetInfo interface.
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:957
#define true
Definition: stdbool.h:16
bool isArgIdent(unsigned Arg) const
Definition: ParsedAttr.h:472
A trivial tuple used to represent a source range.
__ptr16, alignas(...), etc.
Definition: ParsedAttr.h:156
bool isPragmaClangAttribute() const
True if the attribute is specified using &#39;#pragma clang attribute&#39;.
Definition: ParsedAttr.h:444
SourceLocation getBegin() const
SourceLocation getUnavailableLoc() const
Definition: ParsedAttr.h:500
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:883
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
Definition: ParsedAttr.h:1000
IdentifierLoc * getArgAsIdent(unsigned Arg) const
Definition: ParsedAttr.h:476
IdentifierInfo * getScopeName() const
Definition: ParsedAttr.h:386
IdentifierInfo * SetterId
Definition: ParsedAttr.h:85
unsigned getProcessingCache() const
Definition: ParsedAttr.h:430
const Expr * getReplacementExpr() const
Definition: ParsedAttr.h:510
PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId)
Definition: ParsedAttr.h:87