clang  11.0.0git
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 
19 #include "clang/Basic/Diagnostic.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/Registry.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 class ParsedAttr;
41 class Sema;
42 class TargetInfo;
43 
45  /// Corresponds to the Kind enum.
46  unsigned AttrKind : 16;
47  /// The number of required arguments of this attribute.
48  unsigned NumArgs : 4;
49  /// The number of optional arguments of this attributes.
50  unsigned OptArgs : 4;
51  /// True if the parsing does not match the semantic content.
52  unsigned HasCustomParsing : 1;
53  /// True if this attribute is only available for certain targets.
54  unsigned IsTargetSpecific : 1;
55  /// True if this attribute applies to types.
56  unsigned IsType : 1;
57  /// True if this attribute applies to statements.
58  unsigned IsStmt : 1;
59  /// True if this attribute has any spellings that are known to gcc.
60  unsigned IsKnownToGCC : 1;
61  /// True if this attribute is supported by #pragma clang attribute.
63  /// The syntaxes supported by this attribute and how they're spelled.
64  struct Spelling {
66  const char *NormalizedFullName;
67  };
69 
75 
76  virtual ~ParsedAttrInfo() = default;
77 
78  /// Check if this attribute appertains to D, and issue a diagnostic if not.
79  virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
80  const Decl *D) const {
81  return true;
82  }
83  /// Check if this attribute is allowed by the language we are compiling, and
84  /// issue a diagnostic if not.
85  virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const {
86  return true;
87  }
88  /// Check if this attribute is allowed when compiling for the given target.
89  virtual bool existsInTarget(const TargetInfo &Target) const {
90  return true;
91  }
92  /// Convert the spelling index of Attr to a semantic spelling enum value.
93  virtual unsigned
95  return UINT_MAX;
96  }
97  /// Populate Rules with the match rules of this attribute.
99  llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &Rules,
100  const LangOptions &LangOpts) const {
101  }
106  };
107  /// If this ParsedAttrInfo knows how to handle this ParsedAttr applied to this
108  /// Decl then do so and return either AttributeApplied if it was applied or
109  /// AttributeNotApplied if it wasn't. Otherwise return NotHandled.
111  const ParsedAttr &Attr) const {
112  return NotHandled;
113  }
114 
115  static const ParsedAttrInfo &get(const AttributeCommonInfo &A);
116 };
117 
118 typedef llvm::Registry<ParsedAttrInfo> ParsedAttrInfoRegistry;
119 
120 /// Represents information about a change in availability for
121 /// an entity, which is part of the encoding of the 'availability'
122 /// attribute.
124  /// The location of the keyword indicating the kind of change.
126 
127  /// The version number at which the change occurred.
128  VersionTuple Version;
129 
130  /// The source range covering the version number.
132 
133  /// Determine whether this availability change is valid.
134  bool isValid() const { return !Version.empty(); }
135 };
136 
137 namespace detail {
140 };
141 
142 /// Describes the trailing object for Availability attribute in ParsedAttr.
147 
149  const AvailabilityChange &Deprecated,
150  const AvailabilityChange &Obsoleted,
151  SourceLocation Strict, const Expr *ReplaceExpr)
152  : StrictLoc(Strict), Replacement(ReplaceExpr) {
153  Changes[IntroducedSlot] = Introduced;
154  Changes[DeprecatedSlot] = Deprecated;
155  Changes[ObsoletedSlot] = Obsoleted;
156  }
157 };
158 
161  unsigned LayoutCompatible : 1;
162  unsigned MustBeNull : 1;
163 };
164 struct PropertyData {
166 
168  : GetterId(getterId), SetterId(setterId) {}
169 };
170 
171 } // namespace
172 
173 /// Wraps an identifier and optional source location for the identifier.
177 
178  static IdentifierLoc *create(ASTContext &Ctx, SourceLocation Loc,
179  IdentifierInfo *Ident);
180 };
181 
182 /// A union of the various pointer types that can be passed to an
183 /// ParsedAttr as an argument.
184 using ArgsUnion = llvm::PointerUnion<Expr *, IdentifierLoc *>;
186 
187 /// ParsedAttr - Represents a syntactic attribute.
188 ///
189 /// For a GNU attribute, there are four forms of this construct:
190 ///
191 /// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
192 /// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
193 /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
194 /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
195 ///
196 class ParsedAttr final
197  : public AttributeCommonInfo,
198  private llvm::TrailingObjects<
199  ParsedAttr, ArgsUnion, detail::AvailabilityData,
200  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
201  friend TrailingObjects;
202 
203  size_t numTrailingObjects(OverloadToken<ArgsUnion>) const { return NumArgs; }
204  size_t numTrailingObjects(OverloadToken<detail::AvailabilityData>) const {
205  return IsAvailability;
206  }
207  size_t
208  numTrailingObjects(OverloadToken<detail::TypeTagForDatatypeData>) const {
209  return IsTypeTagForDatatype;
210  }
211  size_t numTrailingObjects(OverloadToken<ParsedType>) const {
212  return HasParsedType;
213  }
214  size_t numTrailingObjects(OverloadToken<detail::PropertyData>) const {
215  return IsProperty;
216  }
217 
218 private:
219  IdentifierInfo *MacroII = nullptr;
220  SourceLocation MacroExpansionLoc;
221  SourceLocation EllipsisLoc;
222 
223  /// The number of expression arguments this attribute has.
224  /// The expressions themselves are stored after the object.
225  unsigned NumArgs : 16;
226 
227  /// True if already diagnosed as invalid.
228  mutable unsigned Invalid : 1;
229 
230  /// True if this attribute was used as a type attribute.
231  mutable unsigned UsedAsTypeAttr : 1;
232 
233  /// True if this has the extra information associated with an
234  /// availability attribute.
235  unsigned IsAvailability : 1;
236 
237  /// True if this has extra information associated with a
238  /// type_tag_for_datatype attribute.
239  unsigned IsTypeTagForDatatype : 1;
240 
241  /// True if this has extra information associated with a
242  /// Microsoft __delcspec(property) attribute.
243  unsigned IsProperty : 1;
244 
245  /// True if this has a ParsedType
246  unsigned HasParsedType : 1;
247 
248  /// True if the processing cache is valid.
249  mutable unsigned HasProcessingCache : 1;
250 
251  /// A cached value.
252  mutable unsigned ProcessingCache : 8;
253 
254  /// True if the attribute is specified using '#pragma clang attribute'.
255  mutable unsigned IsPragmaClangAttribute : 1;
256 
257  /// The location of the 'unavailable' keyword in an
258  /// availability attribute.
259  SourceLocation UnavailableLoc;
260 
261  const Expr *MessageExpr;
262 
263  const ParsedAttrInfo &Info;
264 
265  ArgsUnion *getArgsBuffer() { return getTrailingObjects<ArgsUnion>(); }
266  ArgsUnion const *getArgsBuffer() const {
267  return getTrailingObjects<ArgsUnion>();
268  }
269 
270  detail::AvailabilityData *getAvailabilityData() {
271  return getTrailingObjects<detail::AvailabilityData>();
272  }
273  const detail::AvailabilityData *getAvailabilityData() const {
274  return getTrailingObjects<detail::AvailabilityData>();
275  }
276 
277 private:
278  friend class AttributeFactory;
279  friend class AttributePool;
280 
281  /// Constructor for attributes with expression arguments.
282  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
283  IdentifierInfo *scopeName, SourceLocation scopeLoc,
284  ArgsUnion *args, unsigned numArgs, Syntax syntaxUsed,
285  SourceLocation ellipsisLoc)
286  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
287  syntaxUsed),
288  EllipsisLoc(ellipsisLoc), NumArgs(numArgs), Invalid(false),
289  UsedAsTypeAttr(false), IsAvailability(false),
290  IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
291  HasProcessingCache(false), IsPragmaClangAttribute(false),
292  Info(ParsedAttrInfo::get(*this)) {
293  if (numArgs)
294  memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion));
295  }
296 
297  /// Constructor for availability attributes.
298  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
299  IdentifierInfo *scopeName, SourceLocation scopeLoc,
300  IdentifierLoc *Parm, const AvailabilityChange &introduced,
301  const AvailabilityChange &deprecated,
302  const AvailabilityChange &obsoleted, SourceLocation unavailable,
303  const Expr *messageExpr, Syntax syntaxUsed, SourceLocation strict,
304  const Expr *replacementExpr)
305  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
306  syntaxUsed),
307  NumArgs(1), Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
308  IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
309  HasProcessingCache(false), IsPragmaClangAttribute(false),
310  UnavailableLoc(unavailable), MessageExpr(messageExpr),
311  Info(ParsedAttrInfo::get(*this)) {
312  ArgsUnion PVal(Parm);
313  memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
314  new (getAvailabilityData()) detail::AvailabilityData(
315  introduced, deprecated, obsoleted, strict, replacementExpr);
316  }
317 
318  /// Constructor for objc_bridge_related attributes.
319  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
320  IdentifierInfo *scopeName, SourceLocation scopeLoc,
321  IdentifierLoc *Parm1, IdentifierLoc *Parm2, IdentifierLoc *Parm3,
322  Syntax syntaxUsed)
323  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
324  syntaxUsed),
325  NumArgs(3), Invalid(false), UsedAsTypeAttr(false),
326  IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
327  HasParsedType(false), HasProcessingCache(false),
328  IsPragmaClangAttribute(false), Info(ParsedAttrInfo::get(*this)) {
329  ArgsUnion *Args = getArgsBuffer();
330  Args[0] = Parm1;
331  Args[1] = Parm2;
332  Args[2] = Parm3;
333  }
334 
335  /// Constructor for type_tag_for_datatype attribute.
336  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
337  IdentifierInfo *scopeName, SourceLocation scopeLoc,
338  IdentifierLoc *ArgKind, ParsedType matchingCType,
339  bool layoutCompatible, bool mustBeNull, Syntax syntaxUsed)
340  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
341  syntaxUsed),
342  NumArgs(1), Invalid(false), UsedAsTypeAttr(false),
343  IsAvailability(false), IsTypeTagForDatatype(true), IsProperty(false),
344  HasParsedType(false), HasProcessingCache(false),
345  IsPragmaClangAttribute(false), Info(ParsedAttrInfo::get(*this)) {
346  ArgsUnion PVal(ArgKind);
347  memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion));
348  detail::TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot();
349  new (&ExtraData.MatchingCType) ParsedType(matchingCType);
350  ExtraData.LayoutCompatible = layoutCompatible;
351  ExtraData.MustBeNull = mustBeNull;
352  }
353 
354  /// Constructor for attributes with a single type argument.
355  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
356  IdentifierInfo *scopeName, SourceLocation scopeLoc,
357  ParsedType typeArg, Syntax syntaxUsed)
358  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
359  syntaxUsed),
360  NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
361  IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
362  HasParsedType(true), HasProcessingCache(false),
363  IsPragmaClangAttribute(false), Info(ParsedAttrInfo::get(*this)) {
364  new (&getTypeBuffer()) ParsedType(typeArg);
365  }
366 
367  /// Constructor for microsoft __declspec(property) attribute.
368  ParsedAttr(IdentifierInfo *attrName, SourceRange attrRange,
369  IdentifierInfo *scopeName, SourceLocation scopeLoc,
370  IdentifierInfo *getterId, IdentifierInfo *setterId,
371  Syntax syntaxUsed)
372  : AttributeCommonInfo(attrName, scopeName, attrRange, scopeLoc,
373  syntaxUsed),
374  NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
375  IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(true),
376  HasParsedType(false), HasProcessingCache(false),
377  IsPragmaClangAttribute(false), Info(ParsedAttrInfo::get(*this)) {
378  new (&getPropertyDataBuffer()) detail::PropertyData(getterId, setterId);
379  }
380 
381  /// Type tag information is stored immediately following the arguments, if
382  /// any, at the end of the object. They are mutually exclusive with
383  /// availability slots.
384  detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() {
385  return *getTrailingObjects<detail::TypeTagForDatatypeData>();
386  }
387  const detail::TypeTagForDatatypeData &getTypeTagForDatatypeDataSlot() const {
388  return *getTrailingObjects<detail::TypeTagForDatatypeData>();
389  }
390 
391  /// The type buffer immediately follows the object and are mutually exclusive
392  /// with arguments.
393  ParsedType &getTypeBuffer() { return *getTrailingObjects<ParsedType>(); }
394  const ParsedType &getTypeBuffer() const {
395  return *getTrailingObjects<ParsedType>();
396  }
397 
398  /// The property data immediately follows the object is is mutually exclusive
399  /// with arguments.
400  detail::PropertyData &getPropertyDataBuffer() {
401  assert(IsProperty);
402  return *getTrailingObjects<detail::PropertyData>();
403  }
404  const detail::PropertyData &getPropertyDataBuffer() const {
405  assert(IsProperty);
406  return *getTrailingObjects<detail::PropertyData>();
407  }
408 
409  size_t allocated_size() const;
410 
411 public:
412  ParsedAttr(const ParsedAttr &) = delete;
413  ParsedAttr(ParsedAttr &&) = delete;
414  ParsedAttr &operator=(const ParsedAttr &) = delete;
415  ParsedAttr &operator=(ParsedAttr &&) = delete;
416  ~ParsedAttr() = delete;
417 
418  void operator delete(void *) = delete;
419 
420  bool hasParsedType() const { return HasParsedType; }
421 
422  /// Is this the Microsoft __declspec(property) attribute?
424  return IsProperty;
425  }
426 
427  bool isInvalid() const { return Invalid; }
428  void setInvalid(bool b = true) const { Invalid = b; }
429 
430  bool hasProcessingCache() const { return HasProcessingCache; }
431 
432  unsigned getProcessingCache() const {
433  assert(hasProcessingCache());
434  return ProcessingCache;
435  }
436 
437  void setProcessingCache(unsigned value) const {
438  ProcessingCache = value;
439  HasProcessingCache = true;
440  }
441 
442  bool isUsedAsTypeAttr() const { return UsedAsTypeAttr; }
443  void setUsedAsTypeAttr(bool Used = true) { UsedAsTypeAttr = Used; }
444 
445  /// True if the attribute is specified using '#pragma clang attribute'.
446  bool isPragmaClangAttribute() const { return IsPragmaClangAttribute; }
447 
448  void setIsPragmaClangAttribute() { IsPragmaClangAttribute = true; }
449 
450  bool isPackExpansion() const { return EllipsisLoc.isValid(); }
451  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
452 
453  /// getNumArgs - Return the number of actual arguments to this attribute.
454  unsigned getNumArgs() const { return NumArgs; }
455 
456  /// getArg - Return the specified argument.
457  ArgsUnion getArg(unsigned Arg) const {
458  assert(Arg < NumArgs && "Arg access out of range!");
459  return getArgsBuffer()[Arg];
460  }
461 
462  bool isArgExpr(unsigned Arg) const {
463  return Arg < NumArgs && getArg(Arg).is<Expr*>();
464  }
465 
466  Expr *getArgAsExpr(unsigned Arg) const {
467  return getArg(Arg).get<Expr*>();
468  }
469 
470  bool isArgIdent(unsigned Arg) const {
471  return Arg < NumArgs && getArg(Arg).is<IdentifierLoc*>();
472  }
473 
474  IdentifierLoc *getArgAsIdent(unsigned Arg) const {
475  return getArg(Arg).get<IdentifierLoc*>();
476  }
477 
479  assert(getParsedKind() == AT_Availability &&
480  "Not an availability attribute");
481  return getAvailabilityData()->Changes[detail::IntroducedSlot];
482  }
483 
485  assert(getParsedKind() == AT_Availability &&
486  "Not an availability attribute");
487  return getAvailabilityData()->Changes[detail::DeprecatedSlot];
488  }
489 
491  assert(getParsedKind() == AT_Availability &&
492  "Not an availability attribute");
493  return getAvailabilityData()->Changes[detail::ObsoletedSlot];
494  }
495 
497  assert(getParsedKind() == AT_Availability &&
498  "Not an availability attribute");
499  return getAvailabilityData()->StrictLoc;
500  }
501 
503  assert(getParsedKind() == AT_Availability &&
504  "Not an availability attribute");
505  return UnavailableLoc;
506  }
507 
508  const Expr * getMessageExpr() const {
509  assert(getParsedKind() == AT_Availability &&
510  "Not an availability attribute");
511  return MessageExpr;
512  }
513 
514  const Expr *getReplacementExpr() const {
515  assert(getParsedKind() == AT_Availability &&
516  "Not an availability attribute");
517  return getAvailabilityData()->Replacement;
518  }
519 
520  const ParsedType &getMatchingCType() const {
521  assert(getParsedKind() == AT_TypeTagForDatatype &&
522  "Not a type_tag_for_datatype attribute");
523  return getTypeTagForDatatypeDataSlot().MatchingCType;
524  }
525 
526  bool getLayoutCompatible() const {
527  assert(getParsedKind() == AT_TypeTagForDatatype &&
528  "Not a type_tag_for_datatype attribute");
529  return getTypeTagForDatatypeDataSlot().LayoutCompatible;
530  }
531 
532  bool getMustBeNull() const {
533  assert(getParsedKind() == AT_TypeTagForDatatype &&
534  "Not a type_tag_for_datatype attribute");
535  return getTypeTagForDatatypeDataSlot().MustBeNull;
536  }
537 
538  const ParsedType &getTypeArg() const {
539  assert(HasParsedType && "Not a type attribute");
540  return getTypeBuffer();
541  }
542 
544  assert(isDeclspecPropertyAttribute() &&
545  "Not a __delcspec(property) attribute");
546  return getPropertyDataBuffer().GetterId;
547  }
548 
550  assert(isDeclspecPropertyAttribute() &&
551  "Not a __delcspec(property) attribute");
552  return getPropertyDataBuffer().SetterId;
553  }
554 
555  /// Set the macro identifier info object that this parsed attribute was
556  /// declared in if it was declared in a macro. Also set the expansion location
557  /// of the macro.
559  MacroII = MacroName;
560  MacroExpansionLoc = Loc;
561  }
562 
563  /// Returns true if this attribute was declared in a macro.
564  bool hasMacroIdentifier() const { return MacroII != nullptr; }
565 
566  /// Return the macro identifier if this attribute was declared in a macro.
567  /// nullptr is returned if it was not declared in a macro.
568  IdentifierInfo *getMacroIdentifier() const { return MacroII; }
569 
571  assert(hasMacroIdentifier() && "Can only get the macro expansion location "
572  "if this attribute has a macro identifier.");
573  return MacroExpansionLoc;
574  }
575 
576  bool isTargetSpecificAttr() const;
577  bool isTypeAttr() const;
578  bool isStmtAttr() const;
579 
580  bool hasCustomParsing() const;
581  unsigned getMinArgs() const;
582  unsigned getMaxArgs() const;
583  bool hasVariadicArg() const;
584  bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const;
585  bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const;
586  void getMatchRules(const LangOptions &LangOpts,
587  SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>>
588  &MatchRules) const;
589  bool diagnoseLangOpts(class Sema &S) const;
590  bool existsInTarget(const TargetInfo &Target) const;
591  bool isKnownToGCC() const;
592  bool isSupportedByPragmaAttribute() const;
593 
594  /// If the parsed attribute has a semantic equivalent, and it would
595  /// have a semantic Spelling enumeration (due to having semantically-distinct
596  /// spelling variations), return the value of that semantic spelling. If the
597  /// parsed attribute does not have a semantic equivalent, or would not have
598  /// a Spelling enumeration, the value UINT_MAX is returned.
599  unsigned getSemanticSpelling() const;
600 
601  /// If this is an OpenCL addr space attribute returns its representation
602  /// in LangAS, otherwise returns default addr space.
604  switch (getParsedKind()) {
605  case ParsedAttr::AT_OpenCLConstantAddressSpace:
607  case ParsedAttr::AT_OpenCLGlobalAddressSpace:
608  return LangAS::opencl_global;
609  case ParsedAttr::AT_OpenCLLocalAddressSpace:
610  return LangAS::opencl_local;
611  case ParsedAttr::AT_OpenCLPrivateAddressSpace:
612  return LangAS::opencl_private;
613  case ParsedAttr::AT_OpenCLGenericAddressSpace:
614  return LangAS::opencl_generic;
615  default:
616  return LangAS::Default;
617  }
618  }
619 
621  return AttributeCommonInfo::Kind(Info.AttrKind);
622  }
623  const ParsedAttrInfo &getInfo() const { return Info; }
624 };
625 
626 class AttributePool;
627 /// A factory, from which one makes pools, from which one creates
628 /// individual attributes which are deallocated with the pool.
629 ///
630 /// Note that it's tolerably cheap to create and destroy one of
631 /// these as long as you don't actually allocate anything in it.
633 public:
634  enum {
635  AvailabilityAllocSize =
636  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
638  detail::PropertyData>(1, 1, 0, 0, 0),
639  TypeTagForDatatypeAllocSize =
640  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
641  detail::TypeTagForDatatypeData, ParsedType,
642  detail::PropertyData>(1, 0, 1, 0, 0),
643  PropertyAllocSize =
644  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
645  detail::TypeTagForDatatypeData, ParsedType,
646  detail::PropertyData>(0, 0, 0, 0, 1),
647  };
648 
649 private:
650  enum {
651  /// The number of free lists we want to be sure to support
652  /// inline. This is just enough that availability attributes
653  /// don't surpass it. It's actually very unlikely we'll see an
654  /// attribute that needs more than that; on x86-64 you'd need 10
655  /// expression arguments, and on i386 you'd need 19.
656  InlineFreeListsCapacity =
657  1 + (AvailabilityAllocSize - sizeof(ParsedAttr)) / sizeof(void *)
658  };
659 
660  llvm::BumpPtrAllocator Alloc;
661 
662  /// Free lists. The index is determined by the following formula:
663  /// (size - sizeof(ParsedAttr)) / sizeof(void*)
664  SmallVector<SmallVector<ParsedAttr *, 8>, InlineFreeListsCapacity> FreeLists;
665 
666  // The following are the private interface used by AttributePool.
667  friend class AttributePool;
668 
669  /// Allocate an attribute of the given size.
670  void *allocate(size_t size);
671 
672  void deallocate(ParsedAttr *AL);
673 
674  /// Reclaim all the attributes in the given pool chain, which is
675  /// non-empty. Note that the current implementation is safe
676  /// against reclaiming things which were not actually allocated
677  /// with the allocator, although of course it's important to make
678  /// sure that their allocator lives at least as long as this one.
679  void reclaimPool(AttributePool &head);
680 
681 public:
683  ~AttributeFactory();
684 };
685 
687  friend class AttributeFactory;
688  friend class ParsedAttributes;
689  AttributeFactory &Factory;
690  llvm::TinyPtrVector<ParsedAttr *> Attrs;
691 
692  void *allocate(size_t size) {
693  return Factory.allocate(size);
694  }
695 
696  ParsedAttr *add(ParsedAttr *attr) {
697  Attrs.push_back(attr);
698  return attr;
699  }
700 
701  void remove(ParsedAttr *attr) {
702  assert(llvm::is_contained(Attrs, attr) &&
703  "Can't take attribute from a pool that doesn't own it!");
704  Attrs.erase(llvm::find(Attrs, attr));
705  }
706 
707  void takePool(AttributePool &pool);
708 
709 public:
710  /// Create a new pool for a factory.
711  AttributePool(AttributeFactory &factory) : Factory(factory) {}
712 
713  AttributePool(const AttributePool &) = delete;
714 
715  ~AttributePool() { Factory.reclaimPool(*this); }
716 
717  /// Move the given pool's allocations to this pool.
718  AttributePool(AttributePool &&pool) = default;
719 
720  AttributeFactory &getFactory() const { return Factory; }
721 
722  void clear() {
723  Factory.reclaimPool(*this);
724  Attrs.clear();
725  }
726 
727  /// Take the given pool's allocations and add them to this pool.
729  takePool(pool);
730  pool.Attrs.clear();
731  }
732 
734  IdentifierInfo *scopeName, SourceLocation scopeLoc,
735  ArgsUnion *args, unsigned numArgs,
736  ParsedAttr::Syntax syntax,
737  SourceLocation ellipsisLoc = SourceLocation()) {
738  size_t temp =
739  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
741  detail::PropertyData>(numArgs, 0, 0, 0, 0);
742  (void)temp;
743  void *memory = allocate(
744  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
745  detail::TypeTagForDatatypeData, ParsedType,
746  detail::PropertyData>(numArgs, 0, 0, 0,
747  0));
748  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
749  args, numArgs, syntax, ellipsisLoc));
750  }
751 
753  IdentifierInfo *scopeName, SourceLocation scopeLoc,
754  IdentifierLoc *Param, const AvailabilityChange &introduced,
755  const AvailabilityChange &deprecated,
756  const AvailabilityChange &obsoleted,
757  SourceLocation unavailable, const Expr *MessageExpr,
758  ParsedAttr::Syntax syntax, SourceLocation strict,
759  const Expr *ReplacementExpr) {
760  void *memory = allocate(AttributeFactory::AvailabilityAllocSize);
761  return add(new (memory) ParsedAttr(
762  attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
763  obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr));
764  }
765 
767  IdentifierInfo *scopeName, SourceLocation scopeLoc,
768  IdentifierLoc *Param1, IdentifierLoc *Param2,
769  IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
770  void *memory = allocate(
771  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
773  detail::PropertyData>(3, 0, 0, 0, 0));
774  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
775  Param1, Param2, Param3, syntax));
776  }
777 
778  ParsedAttr *
780  IdentifierInfo *scopeName, SourceLocation scopeLoc,
781  IdentifierLoc *argumentKind,
782  ParsedType matchingCType, bool layoutCompatible,
783  bool mustBeNull, ParsedAttr::Syntax syntax) {
784  void *memory = allocate(AttributeFactory::TypeTagForDatatypeAllocSize);
785  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
786  argumentKind, matchingCType,
787  layoutCompatible, mustBeNull, syntax));
788  }
789 
791  SourceRange attrRange,
792  IdentifierInfo *scopeName,
793  SourceLocation scopeLoc, ParsedType typeArg,
794  ParsedAttr::Syntax syntaxUsed) {
795  void *memory = allocate(
796  ParsedAttr::totalSizeToAlloc<ArgsUnion, detail::AvailabilityData,
798  detail::PropertyData>(0, 0, 0, 1, 0));
799  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
800  typeArg, syntaxUsed));
801  }
802 
803  ParsedAttr *
805  IdentifierInfo *scopeName, SourceLocation scopeLoc,
806  IdentifierInfo *getterId, IdentifierInfo *setterId,
807  ParsedAttr::Syntax syntaxUsed) {
808  void *memory = allocate(AttributeFactory::PropertyAllocSize);
809  return add(new (memory) ParsedAttr(attrName, attrRange, scopeName, scopeLoc,
810  getterId, setterId, syntaxUsed));
811  }
812 };
813 
815  using VecTy = llvm::TinyPtrVector<ParsedAttr *>;
816  using SizeType = decltype(std::declval<VecTy>().size());
817 
818 public:
819  bool empty() const { return AttrList.empty(); }
820  SizeType size() const { return AttrList.size(); }
821  ParsedAttr &operator[](SizeType pos) { return *AttrList[pos]; }
822  const ParsedAttr &operator[](SizeType pos) const { return *AttrList[pos]; }
823 
824  void addAtEnd(ParsedAttr *newAttr) {
825  assert(newAttr);
826  AttrList.push_back(newAttr);
827  }
828 
829  void remove(ParsedAttr *ToBeRemoved) {
830  assert(is_contained(AttrList, ToBeRemoved) &&
831  "Cannot remove attribute that isn't in the list");
832  AttrList.erase(llvm::find(AttrList, ToBeRemoved));
833  }
834 
835  void clearListOnly() { AttrList.clear(); }
836 
837  struct iterator : llvm::iterator_adaptor_base<iterator, VecTy::iterator,
838  std::random_access_iterator_tag,
839  ParsedAttr> {
840  iterator() : iterator_adaptor_base(nullptr) {}
841  iterator(VecTy::iterator I) : iterator_adaptor_base(I) {}
842  reference operator*() { return **I; }
843  friend class ParsedAttributesView;
844  };
846  : llvm::iterator_adaptor_base<const_iterator, VecTy::const_iterator,
847  std::random_access_iterator_tag,
848  ParsedAttr> {
849  const_iterator() : iterator_adaptor_base(nullptr) {}
850  const_iterator(VecTy::const_iterator I) : iterator_adaptor_base(I) {}
851 
852  reference operator*() const { return **I; }
853  friend class ParsedAttributesView;
854  };
855 
856  void addAll(iterator B, iterator E) {
857  AttrList.insert(AttrList.begin(), B.I, E.I);
858  }
859 
861  AttrList.insert(AttrList.begin(), B.I, E.I);
862  }
863 
865  AttrList.insert(AttrList.end(), B.I, E.I);
866  }
867 
869  AttrList.insert(AttrList.end(), B.I, E.I);
870  }
871 
872  iterator begin() { return iterator(AttrList.begin()); }
873  const_iterator begin() const { return const_iterator(AttrList.begin()); }
874  iterator end() { return iterator(AttrList.end()); }
875  const_iterator end() const { return const_iterator(AttrList.end()); }
876 
878  assert(!empty());
879  return *AttrList.front();
880  }
881  const ParsedAttr &front() const {
882  assert(!empty());
883  return *AttrList.front();
884  }
886  assert(!empty());
887  return *AttrList.back();
888  }
889  const ParsedAttr &back() const {
890  assert(!empty());
891  return *AttrList.back();
892  }
893 
895  return llvm::any_of(AttrList, [K](const ParsedAttr *AL) {
896  return AL->getParsedKind() == K;
897  });
898  }
899 
900 private:
901  VecTy AttrList;
902 };
903 
904 /// ParsedAttributes - A collection of parsed attributes. Currently
905 /// we don't differentiate between the various attribute syntaxes,
906 /// which is basically silly.
907 ///
908 /// Right now this is a very lightweight container, but the expectation
909 /// is that this will become significantly more serious.
911 public:
912  ParsedAttributes(AttributeFactory &factory) : pool(factory) {}
913  ParsedAttributes(const ParsedAttributes &) = delete;
914 
915  AttributePool &getPool() const { return pool; }
916 
918  addAll(attrs.begin(), attrs.end());
919  attrs.clearListOnly();
920  pool.takeAllFrom(attrs.pool);
921  }
922 
924  Attrs.getPool().remove(PA);
925  Attrs.remove(PA);
926  getPool().add(PA);
927  addAtEnd(PA);
928  }
929 
930  void clear() {
931  clearListOnly();
932  pool.clear();
933  }
934 
935  /// Add attribute with expression arguments.
937  IdentifierInfo *scopeName, SourceLocation scopeLoc,
938  ArgsUnion *args, unsigned numArgs,
939  ParsedAttr::Syntax syntax,
940  SourceLocation ellipsisLoc = SourceLocation()) {
941  ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
942  args, numArgs, syntax, ellipsisLoc);
943  addAtEnd(attr);
944  return attr;
945  }
946 
947  /// Add availability attribute.
949  IdentifierInfo *scopeName, SourceLocation scopeLoc,
950  IdentifierLoc *Param, const AvailabilityChange &introduced,
951  const AvailabilityChange &deprecated,
952  const AvailabilityChange &obsoleted,
953  SourceLocation unavailable, const Expr *MessageExpr,
954  ParsedAttr::Syntax syntax, SourceLocation strict,
955  const Expr *ReplacementExpr) {
956  ParsedAttr *attr = pool.create(
957  attrName, attrRange, scopeName, scopeLoc, Param, introduced, deprecated,
958  obsoleted, unavailable, MessageExpr, syntax, strict, ReplacementExpr);
959  addAtEnd(attr);
960  return attr;
961  }
962 
963  /// Add objc_bridge_related attribute.
965  IdentifierInfo *scopeName, SourceLocation scopeLoc,
966  IdentifierLoc *Param1, IdentifierLoc *Param2,
967  IdentifierLoc *Param3, ParsedAttr::Syntax syntax) {
968  ParsedAttr *attr = pool.create(attrName, attrRange, scopeName, scopeLoc,
969  Param1, Param2, Param3, syntax);
970  addAtEnd(attr);
971  return attr;
972  }
973 
974  /// Add type_tag_for_datatype attribute.
975  ParsedAttr *
977  IdentifierInfo *scopeName, SourceLocation scopeLoc,
978  IdentifierLoc *argumentKind,
979  ParsedType matchingCType, bool layoutCompatible,
980  bool mustBeNull, ParsedAttr::Syntax syntax) {
981  ParsedAttr *attr = pool.createTypeTagForDatatype(
982  attrName, attrRange, scopeName, scopeLoc, argumentKind, matchingCType,
983  layoutCompatible, mustBeNull, syntax);
984  addAtEnd(attr);
985  return attr;
986  }
987 
988  /// Add an attribute with a single type argument.
990  IdentifierInfo *scopeName, SourceLocation scopeLoc,
991  ParsedType typeArg,
992  ParsedAttr::Syntax syntaxUsed) {
993  ParsedAttr *attr = pool.createTypeAttribute(attrName, attrRange, scopeName,
994  scopeLoc, typeArg, syntaxUsed);
995  addAtEnd(attr);
996  return attr;
997  }
998 
999  /// Add microsoft __delspec(property) attribute.
1000  ParsedAttr *
1002  IdentifierInfo *scopeName, SourceLocation scopeLoc,
1003  IdentifierInfo *getterId, IdentifierInfo *setterId,
1004  ParsedAttr::Syntax syntaxUsed) {
1005  ParsedAttr *attr =
1006  pool.createPropertyAttribute(attrName, attrRange, scopeName, scopeLoc,
1007  getterId, setterId, syntaxUsed);
1008  addAtEnd(attr);
1009  return attr;
1010  }
1011 
1012 private:
1013  mutable AttributePool pool;
1014 };
1015 
1016 /// These constants match the enumerated choices of
1017 /// err_attribute_argument_n_type and err_attribute_argument_type.
1023 };
1024 
1025 /// These constants match the enumerated choices of
1026 /// warn_attribute_wrong_decl_type and err_attribute_wrong_decl_type.
1041 };
1042 
1044  const ParsedAttr &At) {
1045  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At.getAttrName()),
1047  return DB;
1048 }
1049 
1051  const ParsedAttr &At) {
1052  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At.getAttrName()),
1054  return PD;
1055 }
1056 
1058  const ParsedAttr *At) {
1059  DB.AddTaggedVal(reinterpret_cast<intptr_t>(At->getAttrName()),
1061  return DB;
1062 }
1063 
1065  const ParsedAttr *At) {
1066  PD.AddTaggedVal(reinterpret_cast<intptr_t>(At->getAttrName()),
1068  return PD;
1069 }
1070 
1071 } // namespace clang
1072 
1073 #endif // LLVM_CLANG_SEMA_ATTRIBUTELIST_H
ParsedAttr * createTypeAttribute(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, ParsedAttr::Syntax syntaxUsed)
Definition: ParsedAttr.h:790
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *Param1, IdentifierLoc *Param2, IdentifierLoc *Param3, ParsedAttr::Syntax syntax)
Definition: ParsedAttr.h:766
static const ParsedAttrInfo & get(const AttributeCommonInfo &A)
Definition: ParsedAttr.cpp:112
const_iterator end() const
Definition: ParsedAttr.h:875
virtual unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const
Convert the spelling index of Attr to a semantic spelling enum value.
Definition: ParsedAttr.h:94
const_iterator(VecTy::const_iterator I)
Definition: ParsedAttr.h:850
SizeType size() const
Definition: ParsedAttr.h:820
ParsedAttributes(AttributeFactory &factory)
Definition: ParsedAttr.h:912
void takeOneFrom(ParsedAttributes &Attrs, ParsedAttr *PA)
Definition: ParsedAttr.h:923
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:184
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
Syntax
The style used to specify an attribute.
IdentifierInfo * Ident
Definition: ParsedAttr.h:176
virtual bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const
Check if this attribute appertains to D, and issue a diagnostic if not.
Definition: ParsedAttr.h:79
Expr * getArgAsExpr(unsigned Arg) const
Definition: ParsedAttr.h:466
bool getMustBeNull() const
Definition: ParsedAttr.h:532
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
bool hasParsedType() const
Definition: ParsedAttr.h:420
IdentifierInfo * getPropertyDataGetter() const
Definition: ParsedAttr.h:543
const_iterator begin() const
Definition: ParsedAttr.h:873
bool hasAttribute(ParsedAttr::Kind K) const
Definition: ParsedAttr.h:894
IdentifierInfo * getPropertyDataSetter() const
Definition: ParsedAttr.h:549
unsigned AttrKind
Corresponds to the Kind enum.
Definition: ParsedAttr.h:46
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
unsigned IsTargetSpecific
True if this attribute is only available for certain targets.
Definition: ParsedAttr.h:54
ParsedAttr & operator[](SizeType pos)
Definition: ParsedAttr.h:821
SourceLocation Loc
Definition: ParsedAttr.h:175
const ParsedType & getMatchingCType() const
Definition: ParsedAttr.h:520
void AddTaggedVal(intptr_t V, DiagnosticsEngine::ArgumentKind Kind) const
Definition: Diagnostic.h:1170
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:174
unsigned NumArgs
The number of required arguments of this attribute.
Definition: ParsedAttr.h:48
const ParsedAttr & front() const
Definition: ParsedAttr.h:881
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:54
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
Definition: ParsedAttr.h:454
AttributeCommonInfo::Kind getKind() const
Definition: ParsedAttr.h:620
void setIsPragmaClangAttribute()
Definition: ParsedAttr.h:448
AttributeArgumentNType
These constants match the enumerated choices of err_attribute_argument_n_type and err_attribute_argum...
Definition: ParsedAttr.h:1018
virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D, const ParsedAttr &Attr) const
If this ParsedAttrInfo knows how to handle this ParsedAttr applied to this Decl then do so and return...
Definition: ParsedAttr.h:110
llvm::Registry< ParsedAttrInfo > ParsedAttrInfoRegistry
Definition: ParsedAttr.h:118
void takeAllFrom(ParsedAttributes &attrs)
Definition: ParsedAttr.h:917
Defines the Diagnostic-related interfaces.
void setUsedAsTypeAttr(bool Used=true)
Definition: ParsedAttr.h:443
__device__ __2f16 b
Represents information about a change in availability for an entity, which is part of the encoding of...
Definition: ParsedAttr.h:123
IdentifierInfo * getMacroIdentifier() const
Return the macro identifier if this attribute was declared in a macro.
Definition: ParsedAttr.h:568
#define UINT_MAX
Definition: limits.h:56
void addAtEnd(ParsedAttr *newAttr)
Definition: ParsedAttr.h:824
const IdentifierInfo * getAttrName() const
VersionTuple Version
The version number at which the change occurred.
Definition: ParsedAttr.h:128
void setInvalid(bool b=true) const
Definition: ParsedAttr.h:428
virtual void getPragmaAttributeMatchRules(llvm::SmallVectorImpl< std::pair< attr::SubjectMatchRule, bool >> &Rules, const LangOptions &LangOpts) const
Populate Rules with the match rules of this attribute.
Definition: ParsedAttr.h:98
bool isDeclspecPropertyAttribute() const
Is this the Microsoft __declspec(property) attribute?
Definition: ParsedAttr.h:423
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:340
unsigned IsSupportedByPragmaAttribute
True if this attribute is supported by #pragma clang attribute.
Definition: ParsedAttr.h:62
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1062
AvailabilityData(const AvailabilityChange &Introduced, const AvailabilityChange &Deprecated, const AvailabilityChange &Obsoleted, SourceLocation Strict, const Expr *ReplaceExpr)
Definition: ParsedAttr.h:148
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:976
unsigned HasCustomParsing
True if the parsing does not match the semantic content.
Definition: ParsedAttr.h:52
void addAllAtEnd(const_iterator B, const_iterator E)
Definition: ParsedAttr.h:868
Exposes information about the current target.
Definition: TargetInfo.h:179
void setMacroIdentifier(IdentifierInfo *MacroName, SourceLocation Loc)
Set the macro identifier info object that this parsed attribute was declared in if it was declared in...
Definition: ParsedAttr.h:558
This represents one expression.
Definition: Expr.h:110
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:1001
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:948
AttributeFactory & getFactory() const
Definition: ParsedAttr.h:720
void addAllAtEnd(iterator B, iterator E)
Definition: ParsedAttr.h:864
void addAll(iterator B, iterator E)
Definition: ParsedAttr.h:856
SourceLocation KeywordLoc
The location of the keyword indicating the kind of change.
Definition: ParsedAttr.h:125
bool isValid() const
Determine whether this availability change is valid.
Definition: ParsedAttr.h:134
unsigned IsKnownToGCC
True if this attribute has any spellings that are known to gcc.
Definition: ParsedAttr.h:60
virtual bool existsInTarget(const TargetInfo &Target) const
Check if this attribute is allowed when compiling for the given target.
Definition: ParsedAttr.h:89
ArrayRef< Spelling > Spellings
Definition: ParsedAttr.h:68
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:174
SourceRange VersionRange
The source range covering the version number.
Definition: ParsedAttr.h:131
unsigned OptArgs
The number of optional arguments of this attributes.
Definition: ParsedAttr.h:50
bool getLayoutCompatible() const
Definition: ParsedAttr.h:526
SourceLocation getEllipsisLoc() const
Definition: ParsedAttr.h:451
ParsedAttr * createPropertyAttribute(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, ParsedAttr::Syntax syntaxUsed)
Definition: ParsedAttr.h:804
const ParsedAttrInfo & getInfo() const
Definition: ParsedAttr.h:623
#define false
Definition: stdbool.h:17
Encodes a location in the source.
unsigned IsType
True if this attribute applies to types.
Definition: ParsedAttr.h:56
const ParsedType & getTypeArg() const
Definition: ParsedAttr.h:538
void addAll(const_iterator B, const_iterator E)
Definition: ParsedAttr.h:860
SourceLocation getMacroExpansionLoc() const
Definition: ParsedAttr.h:570
bool hasMacroIdentifier() const
Returns true if this attribute was declared in a macro.
Definition: ParsedAttr.h:564
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:196
const ParsedAttr & back() const
Definition: ParsedAttr.h:889
const ParsedAttr & operator[](SizeType pos) const
Definition: ParsedAttr.h:822
bool hasProcessingCache() const
Definition: ParsedAttr.h:430
bool isUsedAsTypeAttr() const
Definition: ParsedAttr.h:442
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:936
void remove(ParsedAttr *ToBeRemoved)
Definition: ParsedAttr.h:829
bool isArgExpr(unsigned Arg) const
Definition: ParsedAttr.h:462
unsigned IsStmt
True if this attribute applies to statements.
Definition: ParsedAttr.h:58
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
Describes the trailing object for Availability attribute in ParsedAttr.
Definition: ParsedAttr.h:143
void setProcessingCache(unsigned value) const
Definition: ParsedAttr.h:437
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
Definition: ParsedAttr.h:457
The syntaxes supported by this attribute and how they&#39;re spelled.
Definition: ParsedAttr.h:64
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
const AvailabilityChange & getAvailabilityIntroduced() const
Definition: ParsedAttr.h:478
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
bool isPackExpansion() const
Definition: ParsedAttr.h:450
void takeAllFrom(AttributePool &pool)
Take the given pool&#39;s allocations and add them to this pool.
Definition: ParsedAttr.h:728
SourceLocation getStrictLoc() const
Definition: ParsedAttr.h:496
ParsedAttr * create(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Definition: ParsedAttr.h:733
AttributePool(AttributeFactory &factory)
Create a new pool for a factory.
Definition: ParsedAttr.h:711
ParsedAttr * createTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, bool mustBeNull, ParsedAttr::Syntax syntax)
Definition: ParsedAttr.h:779
const AvailabilityChange & getAvailabilityDeprecated() const
Definition: ParsedAttr.h:484
virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const
Check if this attribute is allowed by the language we are compiling, and issue a diagnostic if not...
Definition: ParsedAttr.h:85
friend TrailingObjects
ParsedAttrInfo(AttributeCommonInfo::Kind AttrKind=AttributeCommonInfo::NoSemaHandlerAttribute)
Definition: ParsedAttr.h:70
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:964
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:989
bool isInvalid() const
Definition: ParsedAttr.h:427
LangAS asOpenCLLangAS() const
If this is an OpenCL addr space attribute returns its representation in LangAS, otherwise returns def...
Definition: ParsedAttr.h:603
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:632
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:752
AttributePool & getPool() const
Definition: ParsedAttr.h:915
const Expr * getMessageExpr() const
Definition: ParsedAttr.h:508
virtual ~ParsedAttrInfo()=default
#define true
Definition: stdbool.h:16
bool isArgIdent(unsigned Arg) const
Definition: ParsedAttr.h:470
A trivial tuple used to represent a source range.
bool isPragmaClangAttribute() const
True if the attribute is specified using &#39;#pragma clang attribute&#39;.
Definition: ParsedAttr.h:446
AttributeCommonInfo::Syntax Syntax
Definition: ParsedAttr.h:65
SourceLocation getUnavailableLoc() const
Definition: ParsedAttr.h:502
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:910
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
Definition: ParsedAttr.h:1027
IdentifierLoc * getArgAsIdent(unsigned Arg) const
Definition: ParsedAttr.h:474
Attr - This represents one attribute.
Definition: Attr.h:46
IdentifierInfo * SetterId
Definition: ParsedAttr.h:165
unsigned getProcessingCache() const
Definition: ParsedAttr.h:432
const Expr * getReplacementExpr() const
Definition: ParsedAttr.h:514
PropertyData(IdentifierInfo *getterId, IdentifierInfo *setterId)
Definition: ParsedAttr.h:167