clang  5.0.0
DeclSpec.h
Go to the documentation of this file.
1 //===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief This file defines the classes used to store parsed information about
12 /// declaration-specifiers and declarators.
13 ///
14 /// \verbatim
15 /// static const int volatile x, *y, *(*(*z)[10])(const void *x);
16 /// ------------------------- - -- ---------------------------
17 /// declaration-specifiers \ | /
18 /// declarators
19 /// \endverbatim
20 ///
21 //===----------------------------------------------------------------------===//
22 
23 #ifndef LLVM_CLANG_SEMA_DECLSPEC_H
24 #define LLVM_CLANG_SEMA_DECLSPEC_H
25 
28 #include "clang/Basic/Lambda.h"
30 #include "clang/Basic/Specifiers.h"
31 #include "clang/Lex/Token.h"
33 #include "clang/Sema/Ownership.h"
34 #include "llvm/ADT/SmallVector.h"
35 #include "llvm/Support/Compiler.h"
36 #include "llvm/Support/ErrorHandling.h"
37 
38 namespace clang {
39  class ASTContext;
40  class CXXRecordDecl;
41  class TypeLoc;
42  class LangOptions;
43  class IdentifierInfo;
44  class NamespaceAliasDecl;
45  class NamespaceDecl;
46  class ObjCDeclSpec;
47  class Sema;
48  class Declarator;
49  struct TemplateIdAnnotation;
50 
51 /// \brief Represents a C++ nested-name-specifier or a global scope specifier.
52 ///
53 /// These can be in 3 states:
54 /// 1) Not present, identified by isEmpty()
55 /// 2) Present, identified by isNotEmpty()
56 /// 2.a) Valid, identified by isValid()
57 /// 2.b) Invalid, identified by isInvalid().
58 ///
59 /// isSet() is deprecated because it mostly corresponded to "valid" but was
60 /// often used as if it meant "present".
61 ///
62 /// The actual scope is described by getScopeRep().
63 class CXXScopeSpec {
64  SourceRange Range;
66 
67 public:
68  SourceRange getRange() const { return Range; }
69  void setRange(SourceRange R) { Range = R; }
70  void setBeginLoc(SourceLocation Loc) { Range.setBegin(Loc); }
71  void setEndLoc(SourceLocation Loc) { Range.setEnd(Loc); }
72  SourceLocation getBeginLoc() const { return Range.getBegin(); }
73  SourceLocation getEndLoc() const { return Range.getEnd(); }
74 
75  /// \brief Retrieve the representation of the nested-name-specifier.
77  return Builder.getRepresentation();
78  }
79 
80  /// \brief Extend the current nested-name-specifier by another
81  /// nested-name-specifier component of the form 'type::'.
82  ///
83  /// \param Context The AST context in which this nested-name-specifier
84  /// resides.
85  ///
86  /// \param TemplateKWLoc The location of the 'template' keyword, if present.
87  ///
88  /// \param TL The TypeLoc that describes the type preceding the '::'.
89  ///
90  /// \param ColonColonLoc The location of the trailing '::'.
91  void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL,
92  SourceLocation ColonColonLoc);
93 
94  /// \brief Extend the current nested-name-specifier by another
95  /// nested-name-specifier component of the form 'identifier::'.
96  ///
97  /// \param Context The AST context in which this nested-name-specifier
98  /// resides.
99  ///
100  /// \param Identifier The identifier.
101  ///
102  /// \param IdentifierLoc The location of the identifier.
103  ///
104  /// \param ColonColonLoc The location of the trailing '::'.
105  void Extend(ASTContext &Context, IdentifierInfo *Identifier,
107 
108  /// \brief Extend the current nested-name-specifier by another
109  /// nested-name-specifier component of the form 'namespace::'.
110  ///
111  /// \param Context The AST context in which this nested-name-specifier
112  /// resides.
113  ///
114  /// \param Namespace The namespace.
115  ///
116  /// \param NamespaceLoc The location of the namespace name.
117  ///
118  /// \param ColonColonLoc The location of the trailing '::'.
119  void Extend(ASTContext &Context, NamespaceDecl *Namespace,
120  SourceLocation NamespaceLoc, SourceLocation ColonColonLoc);
121 
122  /// \brief Extend the current nested-name-specifier by another
123  /// nested-name-specifier component of the form 'namespace-alias::'.
124  ///
125  /// \param Context The AST context in which this nested-name-specifier
126  /// resides.
127  ///
128  /// \param Alias The namespace alias.
129  ///
130  /// \param AliasLoc The location of the namespace alias
131  /// name.
132  ///
133  /// \param ColonColonLoc The location of the trailing '::'.
135  SourceLocation AliasLoc, SourceLocation ColonColonLoc);
136 
137  /// \brief Turn this (empty) nested-name-specifier into the global
138  /// nested-name-specifier '::'.
139  void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc);
140 
141  /// \brief Turns this (empty) nested-name-specifier into '__super'
142  /// nested-name-specifier.
143  ///
144  /// \param Context The AST context in which this nested-name-specifier
145  /// resides.
146  ///
147  /// \param RD The declaration of the class in which nested-name-specifier
148  /// appeared.
149  ///
150  /// \param SuperLoc The location of the '__super' keyword.
151  /// name.
152  ///
153  /// \param ColonColonLoc The location of the trailing '::'.
155  SourceLocation SuperLoc, SourceLocation ColonColonLoc);
156 
157  /// \brief Make a new nested-name-specifier from incomplete source-location
158  /// information.
159  ///
160  /// FIXME: This routine should be used very, very rarely, in cases where we
161  /// need to synthesize a nested-name-specifier. Most code should instead use
162  /// \c Adopt() with a proper \c NestedNameSpecifierLoc.
164  SourceRange R);
165 
166  /// \brief Adopt an existing nested-name-specifier (with source-range
167  /// information).
168  void Adopt(NestedNameSpecifierLoc Other);
169 
170  /// \brief Retrieve a nested-name-specifier with location information, copied
171  /// into the given AST context.
172  ///
173  /// \param Context The context into which this nested-name-specifier will be
174  /// copied.
176 
177  /// \brief Retrieve the location of the name in the last qualifier
178  /// in this nested name specifier.
179  ///
180  /// For example, the location of \c bar
181  /// in
182  /// \verbatim
183  /// \::foo::bar<0>::
184  /// ^~~
185  /// \endverbatim
187 
188  /// No scope specifier.
189  bool isEmpty() const { return !Range.isValid(); }
190  /// A scope specifier is present, but may be valid or invalid.
191  bool isNotEmpty() const { return !isEmpty(); }
192 
193  /// An error occurred during parsing of the scope specifier.
194  bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; }
195  /// A scope specifier is present, and it refers to a real scope.
196  bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; }
197 
198  /// \brief Indicate that this nested-name-specifier is invalid.
200  assert(R.isValid() && "Must have a valid source range");
201  if (Range.getBegin().isInvalid())
202  Range.setBegin(R.getBegin());
203  Range.setEnd(R.getEnd());
204  Builder.Clear();
205  }
206 
207  /// Deprecated. Some call sites intend isNotEmpty() while others intend
208  /// isValid().
209  bool isSet() const { return getScopeRep() != nullptr; }
210 
211  void clear() {
212  Range = SourceRange();
213  Builder.Clear();
214  }
215 
216  /// \brief Retrieve the data associated with the source-location information.
217  char *location_data() const { return Builder.getBuffer().first; }
218 
219  /// \brief Retrieve the size of the data associated with source-location
220  /// information.
221  unsigned location_size() const { return Builder.getBuffer().second; }
222 };
223 
224 /// \brief Captures information about "declaration specifiers".
225 ///
226 /// "Declaration specifiers" encompasses storage-class-specifiers,
227 /// type-specifiers, type-qualifiers, and function-specifiers.
228 class DeclSpec {
229 public:
230  /// \brief storage-class-specifier
231  /// \note The order of these enumerators is important for diagnostics.
232  enum SCS {
241  };
242 
243  // Import thread storage class specifier enumeration and constants.
244  // These can be combined with SCS_extern and SCS_static.
250 
251  // Import type specifier width enumeration and constants.
255  static const TSW TSW_long = clang::TSW_long;
257 
258  enum TSC {
262  };
263 
264  // Import type specifier sign enumeration and constants.
269 
270  // Import type specifier type enumeration and constants.
273  static const TST TST_void = clang::TST_void;
274  static const TST TST_char = clang::TST_char;
278  static const TST TST_int = clang::TST_int;
280  static const TST TST_half = clang::TST_half;
284  static const TST TST_bool = clang::TST_bool;
288  static const TST TST_enum = clang::TST_enum;
299  static const TST TST_auto = clang::TST_auto;
303 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
304  static const TST TST_##ImgType##_t = clang::TST_##ImgType##_t;
305 #include "clang/Basic/OpenCLImageTypes.def"
307 
308  // type-qualifiers
309  enum TQ { // NOTE: These flags must be kept in sync with Qualifiers::TQ.
311  TQ_const = 1,
315  // This has no corresponding Qualifiers::TQ value, because it's not treated
316  // as a qualifier in our type system.
318  };
319 
320  /// ParsedSpecifiers - Flags to query which specifiers were applied. This is
321  /// returned by getParsedSpecifiers.
323  PQ_None = 0,
328  };
329 
330 private:
331  // storage-class-specifier
332  /*SCS*/unsigned StorageClassSpec : 3;
333  /*TSCS*/unsigned ThreadStorageClassSpec : 2;
334  unsigned SCS_extern_in_linkage_spec : 1;
335 
336  // type-specifier
337  /*TSW*/unsigned TypeSpecWidth : 2;
338  /*TSC*/unsigned TypeSpecComplex : 2;
339  /*TSS*/unsigned TypeSpecSign : 2;
340  /*TST*/unsigned TypeSpecType : 6;
341  unsigned TypeAltiVecVector : 1;
342  unsigned TypeAltiVecPixel : 1;
343  unsigned TypeAltiVecBool : 1;
344  unsigned TypeSpecOwned : 1;
345  unsigned TypeSpecPipe : 1;
346 
347  // type-qualifiers
348  unsigned TypeQualifiers : 5; // Bitwise OR of TQ.
349 
350  // function-specifier
351  unsigned FS_inline_specified : 1;
352  unsigned FS_forceinline_specified: 1;
353  unsigned FS_virtual_specified : 1;
354  unsigned FS_explicit_specified : 1;
355  unsigned FS_noreturn_specified : 1;
356 
357  // friend-specifier
358  unsigned Friend_specified : 1;
359 
360  // constexpr-specifier
361  unsigned Constexpr_specified : 1;
362 
363  // concept-specifier
364  unsigned Concept_specified : 1;
365 
366  union {
370  };
371 
372  // attributes.
373  ParsedAttributes Attrs;
374 
375  // Scope specifier for the type spec, if applicable.
376  CXXScopeSpec TypeScope;
377 
378  // SourceLocation info. These are null if the item wasn't specified or if
379  // the setting was synthesized.
380  SourceRange Range;
381 
382  SourceLocation StorageClassSpecLoc, ThreadStorageClassSpecLoc;
383  SourceRange TSWRange;
384  SourceLocation TSCLoc, TSSLoc, TSTLoc, AltiVecLoc;
385  /// TSTNameLoc - If TypeSpecType is any of class, enum, struct, union,
386  /// typename, then this is the location of the named type (if present);
387  /// otherwise, it is the same as TSTLoc. Hence, the pair TSTLoc and
388  /// TSTNameLoc provides source range info for tag types.
389  SourceLocation TSTNameLoc;
390  SourceRange TypeofParensRange;
391  SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
392  TQ_unalignedLoc;
393  SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc;
394  SourceLocation FS_forceinlineLoc;
395  SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc, ConceptLoc;
396  SourceLocation TQ_pipeLoc;
397 
398  WrittenBuiltinSpecs writtenBS;
399  void SaveWrittenBuiltinSpecs();
400 
401  ObjCDeclSpec *ObjCQualifiers;
402 
403  static bool isTypeRep(TST T) {
404  return (T == TST_typename || T == TST_typeofType ||
405  T == TST_underlyingType || T == TST_atomic);
406  }
407  static bool isExprRep(TST T) {
408  return (T == TST_typeofExpr || T == TST_decltype);
409  }
410 
411  DeclSpec(const DeclSpec &) = delete;
412  void operator=(const DeclSpec &) = delete;
413 public:
414  static bool isDeclRep(TST T) {
415  return (T == TST_enum || T == TST_struct ||
416  T == TST_interface || T == TST_union ||
417  T == TST_class);
418  }
419 
421  : StorageClassSpec(SCS_unspecified),
422  ThreadStorageClassSpec(TSCS_unspecified),
423  SCS_extern_in_linkage_spec(false),
424  TypeSpecWidth(TSW_unspecified),
425  TypeSpecComplex(TSC_unspecified),
426  TypeSpecSign(TSS_unspecified),
427  TypeSpecType(TST_unspecified),
428  TypeAltiVecVector(false),
429  TypeAltiVecPixel(false),
430  TypeAltiVecBool(false),
431  TypeSpecOwned(false),
432  TypeSpecPipe(false),
433  TypeQualifiers(TQ_unspecified),
434  FS_inline_specified(false),
435  FS_forceinline_specified(false),
436  FS_virtual_specified(false),
437  FS_explicit_specified(false),
438  FS_noreturn_specified(false),
439  Friend_specified(false),
440  Constexpr_specified(false),
441  Concept_specified(false),
442  Attrs(attrFactory),
443  writtenBS(),
444  ObjCQualifiers(nullptr) {
445  }
446 
447  // storage-class-specifier
448  SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
450  return (TSCS)ThreadStorageClassSpec;
451  }
452  bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
454  SCS_extern_in_linkage_spec = Value;
455  }
456 
457  SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
459  return ThreadStorageClassSpecLoc;
460  }
461 
463  StorageClassSpec = DeclSpec::SCS_unspecified;
464  ThreadStorageClassSpec = DeclSpec::TSCS_unspecified;
465  SCS_extern_in_linkage_spec = false;
466  StorageClassSpecLoc = SourceLocation();
467  ThreadStorageClassSpecLoc = SourceLocation();
468  }
469 
471  TypeSpecType = DeclSpec::TST_unspecified;
472  TypeSpecOwned = false;
473  TSTLoc = SourceLocation();
474  }
475 
476  // type-specifier
477  TSW getTypeSpecWidth() const { return (TSW)TypeSpecWidth; }
478  TSC getTypeSpecComplex() const { return (TSC)TypeSpecComplex; }
479  TSS getTypeSpecSign() const { return (TSS)TypeSpecSign; }
480  TST getTypeSpecType() const { return (TST)TypeSpecType; }
481  bool isTypeAltiVecVector() const { return TypeAltiVecVector; }
482  bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; }
483  bool isTypeAltiVecBool() const { return TypeAltiVecBool; }
484  bool isTypeSpecOwned() const { return TypeSpecOwned; }
485  bool isTypeRep() const { return isTypeRep((TST) TypeSpecType); }
486  bool isTypeSpecPipe() const { return TypeSpecPipe; }
487 
489  assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
490  return TypeRep;
491  }
492  Decl *getRepAsDecl() const {
493  assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
494  return DeclRep;
495  }
496  Expr *getRepAsExpr() const {
497  assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
498  return ExprRep;
499  }
500  CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
501  const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
502 
503  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
504  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
505  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
506 
507  SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); }
508  SourceRange getTypeSpecWidthRange() const { return TSWRange; }
509  SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
510  SourceLocation getTypeSpecSignLoc() const { return TSSLoc; }
511  SourceLocation getTypeSpecTypeLoc() const { return TSTLoc; }
512  SourceLocation getAltiVecLoc() const { return AltiVecLoc; }
513 
515  assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
516  return TSTNameLoc;
517  }
518 
519  SourceRange getTypeofParensRange() const { return TypeofParensRange; }
520  void setTypeofParensRange(SourceRange range) { TypeofParensRange = range; }
521 
522  bool hasAutoTypeSpec() const {
523  return (TypeSpecType == TST_auto || TypeSpecType == TST_auto_type ||
524  TypeSpecType == TST_decltype_auto);
525  }
526 
527  bool hasTagDefinition() const;
528 
529  /// \brief Turn a type-specifier-type into a string like "_Bool" or "union".
530  static const char *getSpecifierName(DeclSpec::TST T,
531  const PrintingPolicy &Policy);
532  static const char *getSpecifierName(DeclSpec::TQ Q);
533  static const char *getSpecifierName(DeclSpec::TSS S);
534  static const char *getSpecifierName(DeclSpec::TSC C);
535  static const char *getSpecifierName(DeclSpec::TSW W);
536  static const char *getSpecifierName(DeclSpec::SCS S);
537  static const char *getSpecifierName(DeclSpec::TSCS S);
538 
539  // type-qualifiers
540 
541  /// getTypeQualifiers - Return a set of TQs.
542  unsigned getTypeQualifiers() const { return TypeQualifiers; }
543  SourceLocation getConstSpecLoc() const { return TQ_constLoc; }
544  SourceLocation getRestrictSpecLoc() const { return TQ_restrictLoc; }
545  SourceLocation getVolatileSpecLoc() const { return TQ_volatileLoc; }
546  SourceLocation getAtomicSpecLoc() const { return TQ_atomicLoc; }
547  SourceLocation getUnalignedSpecLoc() const { return TQ_unalignedLoc; }
548  SourceLocation getPipeLoc() const { return TQ_pipeLoc; }
549 
550  /// \brief Clear out all of the type qualifiers.
552  TypeQualifiers = 0;
553  TQ_constLoc = SourceLocation();
554  TQ_restrictLoc = SourceLocation();
555  TQ_volatileLoc = SourceLocation();
556  TQ_atomicLoc = SourceLocation();
557  TQ_unalignedLoc = SourceLocation();
558  TQ_pipeLoc = SourceLocation();
559  }
560 
561  // function-specifier
562  bool isInlineSpecified() const {
563  return FS_inline_specified | FS_forceinline_specified;
564  }
566  return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
567  }
568 
569  bool isVirtualSpecified() const { return FS_virtual_specified; }
570  SourceLocation getVirtualSpecLoc() const { return FS_virtualLoc; }
571 
572  bool isExplicitSpecified() const { return FS_explicit_specified; }
573  SourceLocation getExplicitSpecLoc() const { return FS_explicitLoc; }
574 
575  bool isNoreturnSpecified() const { return FS_noreturn_specified; }
576  SourceLocation getNoreturnSpecLoc() const { return FS_noreturnLoc; }
577 
579  FS_inline_specified = false;
580  FS_inlineLoc = SourceLocation();
581  FS_forceinline_specified = false;
582  FS_forceinlineLoc = SourceLocation();
583  FS_virtual_specified = false;
584  FS_virtualLoc = SourceLocation();
585  FS_explicit_specified = false;
586  FS_explicitLoc = SourceLocation();
587  FS_noreturn_specified = false;
588  FS_noreturnLoc = SourceLocation();
589  }
590 
591  /// \brief Return true if any type-specifier has been found.
592  bool hasTypeSpecifier() const {
597  }
598 
599  /// \brief Return a bitmask of which flavors of specifiers this
600  /// DeclSpec includes.
601  unsigned getParsedSpecifiers() const;
602 
603  /// isEmpty - Return true if this declaration specifier is completely empty:
604  /// no tokens were parsed in the production of it.
605  bool isEmpty() const {
607  }
608 
609  void SetRangeStart(SourceLocation Loc) { Range.setBegin(Loc); }
610  void SetRangeEnd(SourceLocation Loc) { Range.setEnd(Loc); }
611 
612  /// These methods set the specified attribute of the DeclSpec and
613  /// return false if there was no error. If an error occurs (for
614  /// example, if we tried to set "auto" on a spec with "extern"
615  /// already set), they return true and set PrevSpec and DiagID
616  /// such that
617  /// Diag(Loc, DiagID) << PrevSpec;
618  /// will yield a useful result.
619  ///
620  /// TODO: use a more general approach that still allows these
621  /// diagnostics to be ignored when desired.
623  const char *&PrevSpec, unsigned &DiagID,
624  const PrintingPolicy &Policy);
626  const char *&PrevSpec, unsigned &DiagID);
627  bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec,
628  unsigned &DiagID, const PrintingPolicy &Policy);
629  bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec,
630  unsigned &DiagID);
631  bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
632  unsigned &DiagID);
633  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
634  unsigned &DiagID, const PrintingPolicy &Policy);
635  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
636  unsigned &DiagID, ParsedType Rep,
637  const PrintingPolicy &Policy);
638  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
639  unsigned &DiagID, Decl *Rep, bool Owned,
640  const PrintingPolicy &Policy);
641  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
642  SourceLocation TagNameLoc, const char *&PrevSpec,
643  unsigned &DiagID, ParsedType Rep,
644  const PrintingPolicy &Policy);
645  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
646  SourceLocation TagNameLoc, const char *&PrevSpec,
647  unsigned &DiagID, Decl *Rep, bool Owned,
648  const PrintingPolicy &Policy);
649 
650  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
651  unsigned &DiagID, Expr *Rep,
652  const PrintingPolicy &policy);
653  bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
654  const char *&PrevSpec, unsigned &DiagID,
655  const PrintingPolicy &Policy);
656  bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
657  const char *&PrevSpec, unsigned &DiagID,
658  const PrintingPolicy &Policy);
659  bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
660  const char *&PrevSpec, unsigned &DiagID,
661  const PrintingPolicy &Policy);
662  bool SetTypePipe(bool isPipe, SourceLocation Loc,
663  const char *&PrevSpec, unsigned &DiagID,
664  const PrintingPolicy &Policy);
665  bool SetTypeSpecError();
666  void UpdateDeclRep(Decl *Rep) {
667  assert(isDeclRep((TST) TypeSpecType));
668  DeclRep = Rep;
669  }
671  assert(isTypeRep((TST) TypeSpecType));
672  TypeRep = Rep;
673  }
674  void UpdateExprRep(Expr *Rep) {
675  assert(isExprRep((TST) TypeSpecType));
676  ExprRep = Rep;
677  }
678 
679  bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
680  unsigned &DiagID, const LangOptions &Lang);
681 
682  bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
683  unsigned &DiagID);
684  bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
685  unsigned &DiagID);
686  bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec,
687  unsigned &DiagID);
688  bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec,
689  unsigned &DiagID);
690  bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec,
691  unsigned &DiagID);
692 
693  bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
694  unsigned &DiagID);
695  bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
696  unsigned &DiagID);
697  bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
698  unsigned &DiagID);
699  bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec,
700  unsigned &DiagID);
701 
702  bool isFriendSpecified() const { return Friend_specified; }
703  SourceLocation getFriendSpecLoc() const { return FriendLoc; }
704 
705  bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); }
706  SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; }
707 
708  bool isConstexprSpecified() const { return Constexpr_specified; }
709  SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; }
710 
711  bool isConceptSpecified() const { return Concept_specified; }
712  SourceLocation getConceptSpecLoc() const { return ConceptLoc; }
713 
715  Constexpr_specified = false;
716  ConstexprLoc = SourceLocation();
717  }
718 
720  Concept_specified = false;
721  ConceptLoc = SourceLocation();
722  }
723 
725  return Attrs.getPool();
726  }
727 
728  /// \brief Concatenates two attribute lists.
729  ///
730  /// The GCC attribute syntax allows for the following:
731  ///
732  /// \code
733  /// short __attribute__(( unused, deprecated ))
734  /// int __attribute__(( may_alias, aligned(16) )) var;
735  /// \endcode
736  ///
737  /// This declares 4 attributes using 2 lists. The following syntax is
738  /// also allowed and equivalent to the previous declaration.
739  ///
740  /// \code
741  /// short __attribute__((unused)) __attribute__((deprecated))
742  /// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
743  /// \endcode
744  ///
746  Attrs.addAll(AL);
747  }
748 
749  bool hasAttributes() const { return !Attrs.empty(); }
750 
751  ParsedAttributes &getAttributes() { return Attrs; }
752  const ParsedAttributes &getAttributes() const { return Attrs; }
753 
755  Attrs.takeAllFrom(attrs);
756  }
757 
758  /// Finish - This does final analysis of the declspec, issuing diagnostics for
759  /// things like "_Imaginary" (lacking an FP type). After calling this method,
760  /// DeclSpec is guaranteed self-consistent, even if an error occurred.
761  void Finish(Sema &S, const PrintingPolicy &Policy);
762 
764  return writtenBS;
765  }
766 
767  ObjCDeclSpec *getObjCQualifiers() const { return ObjCQualifiers; }
768  void setObjCQualifiers(ObjCDeclSpec *quals) { ObjCQualifiers = quals; }
769 
770  /// \brief Checks if this DeclSpec can stand alone, without a Declarator.
771  ///
772  /// Only tag declspecs can stand alone.
773  bool isMissingDeclaratorOk();
774 };
775 
776 /// \brief Captures information about "declaration specifiers" specific to
777 /// Objective-C.
779 public:
780  /// ObjCDeclQualifier - Qualifier used on types in method
781  /// declarations. Not all combinations are sensible. Parameters
782  /// can be one of { in, out, inout } with one of { bycopy, byref }.
783  /// Returns can either be { oneway } or not.
784  ///
785  /// This should be kept in sync with Decl::ObjCDeclQualifier.
787  DQ_None = 0x0,
788  DQ_In = 0x1,
789  DQ_Inout = 0x2,
790  DQ_Out = 0x4,
791  DQ_Bycopy = 0x8,
792  DQ_Byref = 0x10,
793  DQ_Oneway = 0x20,
795  };
796 
797  /// PropertyAttributeKind - list of property attributes.
798  /// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.
802  DQ_PR_getter = 0x02,
803  DQ_PR_assign = 0x04,
805  DQ_PR_retain = 0x10,
806  DQ_PR_copy = 0x20,
808  DQ_PR_setter = 0x80,
809  DQ_PR_atomic = 0x100,
810  DQ_PR_weak = 0x200,
811  DQ_PR_strong = 0x400,
815  DQ_PR_class = 0x4000
816  };
817 
819  : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
820  Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
821 
823  return (ObjCDeclQualifier)objcDeclQualifier;
824  }
826  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
827  }
829  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
830  }
831 
833  return ObjCPropertyAttributeKind(PropertyAttributes);
834  }
836  PropertyAttributes =
837  (ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
838  }
839 
841  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
843  "Objective-C declspec doesn't have nullability");
844  return static_cast<NullabilityKind>(Nullability);
845  }
846 
848  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
850  "Objective-C declspec doesn't have nullability");
851  return NullabilityLoc;
852  }
853 
855  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
857  "Set the nullability declspec or property attribute first");
858  Nullability = static_cast<unsigned>(kind);
859  NullabilityLoc = loc;
860  }
861 
862  const IdentifierInfo *getGetterName() const { return GetterName; }
863  IdentifierInfo *getGetterName() { return GetterName; }
864  SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
866  GetterName = name;
867  GetterNameLoc = loc;
868  }
869 
870  const IdentifierInfo *getSetterName() const { return SetterName; }
871  IdentifierInfo *getSetterName() { return SetterName; }
872  SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
874  SetterName = name;
875  SetterNameLoc = loc;
876  }
877 
878 private:
879  // FIXME: These two are unrelated and mutually exclusive. So perhaps
880  // we can put them in a union to reflect their mutual exclusivity
881  // (space saving is negligible).
882  unsigned objcDeclQualifier : 7;
883 
884  // NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind
885  unsigned PropertyAttributes : 15;
886 
887  unsigned Nullability : 2;
888 
889  SourceLocation NullabilityLoc;
890 
891  IdentifierInfo *GetterName; // getter name or NULL if no getter
892  IdentifierInfo *SetterName; // setter name or NULL if no setter
893  SourceLocation GetterNameLoc; // location of the getter attribute's value
894  SourceLocation SetterNameLoc; // location of the setter attribute's value
895 
896 };
897 
898 /// \brief Represents a C++ unqualified-id that has been parsed.
900 private:
901  UnqualifiedId(const UnqualifiedId &Other) = delete;
902  const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
903 
904 public:
905  /// \brief Describes the kind of unqualified-id parsed.
906  enum IdKind {
907  /// \brief An identifier.
909  /// \brief An overloaded operator name, e.g., operator+.
911  /// \brief A conversion function name, e.g., operator int.
913  /// \brief A user-defined literal name, e.g., operator "" _i.
915  /// \brief A constructor name.
917  /// \brief A constructor named via a template-id.
919  /// \brief A destructor name.
921  /// \brief A template-id, e.g., f<int>.
923  /// \brief An implicit 'self' parameter
925  /// \brief A deduction-guide name (a template-name)
927  } Kind;
928 
929  struct OFI {
930  /// \brief The kind of overloaded operator.
932 
933  /// \brief The source locations of the individual tokens that name
934  /// the operator, e.g., the "new", "[", and "]" tokens in
935  /// operator new [].
936  ///
937  /// Different operators have different numbers of tokens in their name,
938  /// up to three. Any remaining source locations in this array will be
939  /// set to an invalid value for operators with fewer than three tokens.
940  unsigned SymbolLocations[3];
941  };
942 
943  /// \brief Anonymous union that holds extra data associated with the
944  /// parsed unqualified-id.
945  union {
946  /// \brief When Kind == IK_Identifier, the parsed identifier, or when
947  /// Kind == IK_UserLiteralId, the identifier suffix.
949 
950  /// \brief When Kind == IK_OperatorFunctionId, the overloaded operator
951  /// that we parsed.
953 
954  /// \brief When Kind == IK_ConversionFunctionId, the type that the
955  /// conversion function names.
957 
958  /// \brief When Kind == IK_ConstructorName, the class-name of the type
959  /// whose constructor is being referenced.
961 
962  /// \brief When Kind == IK_DestructorName, the type referred to by the
963  /// class-name.
965 
966  /// \brief When Kind == IK_DeductionGuideName, the parsed template-name.
968 
969  /// \brief When Kind == IK_TemplateId or IK_ConstructorTemplateId,
970  /// the template-id annotation that contains the template name and
971  /// template arguments.
973  };
974 
975  /// \brief The location of the first token that describes this unqualified-id,
976  /// which will be the location of the identifier, "operator" keyword,
977  /// tilde (for a destructor), or the template name of a template-id.
979 
980  /// \brief The location of the last token that describes this unqualified-id.
982 
984 
985  /// \brief Clear out this unqualified-id, setting it to default (invalid)
986  /// state.
987  void clear() {
989  Identifier = nullptr;
992  }
993 
994  /// \brief Determine whether this unqualified-id refers to a valid name.
995  bool isValid() const { return StartLocation.isValid(); }
996 
997  /// \brief Determine whether this unqualified-id refers to an invalid name.
998  bool isInvalid() const { return !isValid(); }
999 
1000  /// \brief Determine what kind of name we have.
1001  IdKind getKind() const { return Kind; }
1002  void setKind(IdKind kind) { Kind = kind; }
1003 
1004  /// \brief Specify that this unqualified-id was parsed as an identifier.
1005  ///
1006  /// \param Id the parsed identifier.
1007  /// \param IdLoc the location of the parsed identifier.
1009  Kind = IK_Identifier;
1010  Identifier = const_cast<IdentifierInfo *>(Id);
1011  StartLocation = EndLocation = IdLoc;
1012  }
1013 
1014  /// \brief Specify that this unqualified-id was parsed as an
1015  /// operator-function-id.
1016  ///
1017  /// \param OperatorLoc the location of the 'operator' keyword.
1018  ///
1019  /// \param Op the overloaded operator.
1020  ///
1021  /// \param SymbolLocations the locations of the individual operator symbols
1022  /// in the operator.
1023  void setOperatorFunctionId(SourceLocation OperatorLoc,
1025  SourceLocation SymbolLocations[3]);
1026 
1027  /// \brief Specify that this unqualified-id was parsed as a
1028  /// conversion-function-id.
1029  ///
1030  /// \param OperatorLoc the location of the 'operator' keyword.
1031  ///
1032  /// \param Ty the type to which this conversion function is converting.
1033  ///
1034  /// \param EndLoc the location of the last token that makes up the type name.
1036  ParsedType Ty,
1037  SourceLocation EndLoc) {
1039  StartLocation = OperatorLoc;
1040  EndLocation = EndLoc;
1041  ConversionFunctionId = Ty;
1042  }
1043 
1044  /// \brief Specific that this unqualified-id was parsed as a
1045  /// literal-operator-id.
1046  ///
1047  /// \param Id the parsed identifier.
1048  ///
1049  /// \param OpLoc the location of the 'operator' keyword.
1050  ///
1051  /// \param IdLoc the location of the identifier.
1053  SourceLocation IdLoc) {
1055  Identifier = const_cast<IdentifierInfo *>(Id);
1056  StartLocation = OpLoc;
1057  EndLocation = IdLoc;
1058  }
1059 
1060  /// \brief Specify that this unqualified-id was parsed as a constructor name.
1061  ///
1062  /// \param ClassType the class type referred to by the constructor name.
1063  ///
1064  /// \param ClassNameLoc the location of the class name.
1065  ///
1066  /// \param EndLoc the location of the last token that makes up the type name.
1068  SourceLocation ClassNameLoc,
1069  SourceLocation EndLoc) {
1071  StartLocation = ClassNameLoc;
1072  EndLocation = EndLoc;
1073  ConstructorName = ClassType;
1074  }
1075 
1076  /// \brief Specify that this unqualified-id was parsed as a
1077  /// template-id that names a constructor.
1078  ///
1079  /// \param TemplateId the template-id annotation that describes the parsed
1080  /// template-id. This UnqualifiedId instance will take ownership of the
1081  /// \p TemplateId and will free it on destruction.
1083 
1084  /// \brief Specify that this unqualified-id was parsed as a destructor name.
1085  ///
1086  /// \param TildeLoc the location of the '~' that introduces the destructor
1087  /// name.
1088  ///
1089  /// \param ClassType the name of the class referred to by the destructor name.
1091  ParsedType ClassType,
1092  SourceLocation EndLoc) {
1094  StartLocation = TildeLoc;
1095  EndLocation = EndLoc;
1096  DestructorName = ClassType;
1097  }
1098 
1099  /// \brief Specify that this unqualified-id was parsed as a template-id.
1100  ///
1101  /// \param TemplateId the template-id annotation that describes the parsed
1102  /// template-id. This UnqualifiedId instance will take ownership of the
1103  /// \p TemplateId and will free it on destruction.
1105 
1106  /// \brief Specify that this unqualified-id was parsed as a template-name for
1107  /// a deduction-guide.
1108  ///
1109  /// \param Template The parsed template-name.
1110  /// \param TemplateLoc The location of the parsed template-name.
1112  SourceLocation TemplateLoc) {
1114  TemplateName = Template;
1115  StartLocation = EndLocation = TemplateLoc;
1116  }
1117 
1118  /// \brief Return the source range that covers this unqualified-id.
1119  SourceRange getSourceRange() const LLVM_READONLY {
1121  }
1122  SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
1123  SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
1124 };
1125 
1126 /// \brief A set of tokens that has been cached for later parsing.
1128 
1129 /// \brief One instance of this struct is used for each type in a
1130 /// declarator that is parsed.
1131 ///
1132 /// This is intended to be a small value object.
1134  enum {
1136  } Kind;
1137 
1138  /// Loc - The place where this type was defined.
1140  /// EndLoc - If valid, the place where this chunck ends.
1142 
1144  if (EndLoc.isInvalid())
1145  return SourceRange(Loc, Loc);
1146  return SourceRange(Loc, EndLoc);
1147  }
1148 
1151  };
1152 
1154  /// The type qualifiers: const/volatile/restrict/unaligned/atomic.
1155  unsigned TypeQuals : 5;
1156 
1157  /// The location of the const-qualifier, if any.
1158  unsigned ConstQualLoc;
1159 
1160  /// The location of the volatile-qualifier, if any.
1162 
1163  /// The location of the restrict-qualifier, if any.
1165 
1166  /// The location of the _Atomic-qualifier, if any.
1167  unsigned AtomicQualLoc;
1168 
1169  /// The location of the __unaligned-qualifier, if any.
1171 
1172  void destroy() {
1173  }
1174  };
1175 
1177  /// The type qualifier: restrict. [GNU] C++ extension
1178  bool HasRestrict : 1;
1179  /// True if this is an lvalue reference, false if it's an rvalue reference.
1180  bool LValueRef : 1;
1181  void destroy() {
1182  }
1183  };
1184 
1186  /// The type qualifiers for the array:
1187  /// const/volatile/restrict/__unaligned/_Atomic.
1188  unsigned TypeQuals : 5;
1189 
1190  /// True if this dimension included the 'static' keyword.
1191  unsigned hasStatic : 1;
1192 
1193  /// True if this dimension was [*]. In this case, NumElts is null.
1194  unsigned isStar : 1;
1195 
1196  /// This is the size of the array, or null if [] or [*] was specified.
1197  /// Since the parser is multi-purpose, and we don't want to impose a root
1198  /// expression class on all clients, NumElts is untyped.
1200 
1201  void destroy() {}
1202  };
1203 
1204  /// ParamInfo - An array of paraminfo objects is allocated whenever a function
1205  /// declarator is parsed. There are two interesting styles of parameters
1206  /// here:
1207  /// K&R-style identifier lists and parameter type lists. K&R-style identifier
1208  /// lists will have information about the identifier, but no type information.
1209  /// Parameter type lists will have type info (if the actions module provides
1210  /// it), but may have null identifier info: e.g. for 'void foo(int X, int)'.
1211  struct ParamInfo {
1215 
1216  /// DefaultArgTokens - When the parameter's default argument
1217  /// cannot be parsed immediately (because it occurs within the
1218  /// declaration of a member function), it will be stored here as a
1219  /// sequence of tokens to be parsed once the class definition is
1220  /// complete. Non-NULL indicates that there is a default argument.
1221  std::unique_ptr<CachedTokens> DefaultArgTokens;
1222 
1223  ParamInfo() = default;
1225  Decl *param,
1226  std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
1227  : Ident(ident), IdentLoc(iloc), Param(param),
1228  DefaultArgTokens(std::move(DefArgTokens)) {}
1229  };
1230 
1231  struct TypeAndRange {
1234  };
1235 
1237  /// hasPrototype - This is true if the function had at least one typed
1238  /// parameter. If the function is () or (a,b,c), then it has no prototype,
1239  /// and is treated as a K&R-style function.
1240  unsigned hasPrototype : 1;
1241 
1242  /// isVariadic - If this function has a prototype, and if that
1243  /// proto ends with ',...)', this is true. When true, EllipsisLoc
1244  /// contains the location of the ellipsis.
1245  unsigned isVariadic : 1;
1246 
1247  /// Can this declaration be a constructor-style initializer?
1248  unsigned isAmbiguous : 1;
1249 
1250  /// \brief Whether the ref-qualifier (if any) is an lvalue reference.
1251  /// Otherwise, it's an rvalue reference.
1253 
1254  /// The type qualifiers: const/volatile/restrict/__unaligned
1255  /// The qualifier bitmask values are the same as in QualType.
1256  unsigned TypeQuals : 4;
1257 
1258  /// ExceptionSpecType - An ExceptionSpecificationType value.
1259  unsigned ExceptionSpecType : 4;
1260 
1261  /// DeleteParams - If this is true, we need to delete[] Params.
1262  unsigned DeleteParams : 1;
1263 
1264  /// HasTrailingReturnType - If this is true, a trailing return type was
1265  /// specified.
1267 
1268  /// The location of the left parenthesis in the source.
1269  unsigned LParenLoc;
1270 
1271  /// When isVariadic is true, the location of the ellipsis in the source.
1272  unsigned EllipsisLoc;
1273 
1274  /// The location of the right parenthesis in the source.
1275  unsigned RParenLoc;
1276 
1277  /// NumParams - This is the number of formal parameters specified by the
1278  /// declarator.
1279  unsigned NumParams;
1280 
1281  /// NumExceptionsOrDecls - This is the number of types in the
1282  /// dynamic-exception-decl, if the function has one. In C, this is the
1283  /// number of declarations in the function prototype.
1285 
1286  /// \brief The location of the ref-qualifier, if any.
1287  ///
1288  /// If this is an invalid location, there is no ref-qualifier.
1290 
1291  /// \brief The location of the const-qualifier, if any.
1292  ///
1293  /// If this is an invalid location, there is no const-qualifier.
1295 
1296  /// \brief The location of the volatile-qualifier, if any.
1297  ///
1298  /// If this is an invalid location, there is no volatile-qualifier.
1300 
1301  /// \brief The location of the restrict-qualifier, if any.
1302  ///
1303  /// If this is an invalid location, there is no restrict-qualifier.
1305 
1306  /// \brief The location of the 'mutable' qualifer in a lambda-declarator, if
1307  /// any.
1308  unsigned MutableLoc;
1309 
1310  /// \brief The beginning location of the exception specification, if any.
1312 
1313  /// \brief The end location of the exception specification, if any.
1315 
1316  /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
1317  /// describe the parameters specified by this function declarator. null if
1318  /// there are no parameters specified.
1320 
1321  union {
1322  /// \brief Pointer to a new[]'d array of TypeAndRange objects that
1323  /// contain the types in the function's dynamic exception specification
1324  /// and their locations, if there is one.
1326 
1327  /// \brief Pointer to the expression in the noexcept-specifier of this
1328  /// function, if it has one.
1330 
1331  /// \brief Pointer to the cached tokens for an exception-specification
1332  /// that has not yet been parsed.
1334 
1335  /// Pointer to a new[]'d array of declarations that need to be available
1336  /// for lookup inside the function body, if one exists. Does not exist in
1337  /// C++.
1339  };
1340 
1341  /// \brief If HasTrailingReturnType is true, this is the trailing return
1342  /// type specified.
1344 
1345  /// \brief Reset the parameter list to having zero parameters.
1346  ///
1347  /// This is used in various places for error recovery.
1348  void freeParams() {
1349  for (unsigned I = 0; I < NumParams; ++I)
1350  Params[I].DefaultArgTokens.reset();
1351  if (DeleteParams) {
1352  delete[] Params;
1353  DeleteParams = false;
1354  }
1355  NumParams = 0;
1356  }
1357 
1358  void destroy() {
1359  if (DeleteParams)
1360  delete[] Params;
1361  switch (getExceptionSpecType()) {
1362  default:
1363  break;
1364  case EST_Dynamic:
1365  delete[] Exceptions;
1366  break;
1367  case EST_Unparsed:
1368  delete ExceptionSpecTokens;
1369  break;
1370  case EST_None:
1371  if (NumExceptionsOrDecls != 0)
1372  delete[] DeclsInPrototype;
1373  break;
1374  }
1375  }
1376 
1377  /// isKNRPrototype - Return true if this is a K&R style identifier list,
1378  /// like "void foo(a,b,c)". In a function definition, this will be followed
1379  /// by the parameter type definitions.
1380  bool isKNRPrototype() const { return !hasPrototype && NumParams != 0; }
1381 
1384  }
1385 
1388  }
1389 
1392  }
1393 
1396  }
1397 
1400  }
1401 
1404  }
1405 
1406  /// \brief Retrieve the location of the ref-qualifier, if any.
1409  }
1410 
1411  /// \brief Retrieve the location of the 'const' qualifier, if any.
1414  }
1415 
1416  /// \brief Retrieve the location of the 'volatile' qualifier, if any.
1419  }
1420 
1421  /// \brief Retrieve the location of the 'restrict' qualifier, if any.
1424  }
1425 
1426  /// \brief Retrieve the location of the 'mutable' qualifier, if any.
1429  }
1430 
1431  /// \brief Determine whether this function declaration contains a
1432  /// ref-qualifier.
1433  bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); }
1434 
1435  /// \brief Determine whether this lambda-declarator contains a 'mutable'
1436  /// qualifier.
1437  bool hasMutableQualifier() const { return getMutableLoc().isValid(); }
1438 
1439  /// \brief Get the type of exception specification this function has.
1441  return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
1442  }
1443 
1444  /// \brief Get the number of dynamic exception specifications.
1445  unsigned getNumExceptions() const {
1446  assert(ExceptionSpecType != EST_None);
1447  return NumExceptionsOrDecls;
1448  }
1449 
1450  /// \brief Get the non-parameter decls defined within this function
1451  /// prototype. Typically these are tag declarations.
1453  assert(ExceptionSpecType == EST_None);
1454  return llvm::makeArrayRef(DeclsInPrototype, NumExceptionsOrDecls);
1455  }
1456 
1457  /// \brief Determine whether this function declarator had a
1458  /// trailing-return-type.
1460 
1461  /// \brief Get the trailing-return-type for this function declarator.
1463  };
1464 
1466  /// For now, sema will catch these as invalid.
1467  /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
1468  unsigned TypeQuals : 5;
1469 
1470  void destroy() {
1471  }
1472  };
1473 
1475  /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
1476  unsigned TypeQuals : 5;
1477  // CXXScopeSpec has a constructor, so it can't be a direct member.
1478  // So we need some pointer-aligned storage and a bit of trickery.
1479  alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
1481  return *reinterpret_cast<CXXScopeSpec *>(ScopeMem);
1482  }
1483  const CXXScopeSpec &Scope() const {
1484  return *reinterpret_cast<const CXXScopeSpec *>(ScopeMem);
1485  }
1486  void destroy() {
1487  Scope().~CXXScopeSpec();
1488  }
1489  };
1490 
1492  /// The access writes.
1493  unsigned AccessWrites : 3;
1494 
1495  void destroy() {}
1496  };
1497 
1498  union {
1507  };
1508 
1509  void destroy() {
1510  switch (Kind) {
1511  case DeclaratorChunk::Function: return Fun.destroy();
1512  case DeclaratorChunk::Pointer: return Ptr.destroy();
1513  case DeclaratorChunk::BlockPointer: return Cls.destroy();
1514  case DeclaratorChunk::Reference: return Ref.destroy();
1515  case DeclaratorChunk::Array: return Arr.destroy();
1517  case DeclaratorChunk::Paren: return;
1518  case DeclaratorChunk::Pipe: return PipeInfo.destroy();
1519  }
1520  }
1521 
1522  /// \brief If there are attributes applied to this declaratorchunk, return
1523  /// them.
1524  const AttributeList *getAttrs() const {
1525  return Common.AttrList;
1526  }
1527 
1529  return Common.AttrList;
1530  }
1531 
1532  /// \brief Return a DeclaratorChunk for a pointer.
1533  static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc,
1534  SourceLocation ConstQualLoc,
1535  SourceLocation VolatileQualLoc,
1536  SourceLocation RestrictQualLoc,
1537  SourceLocation AtomicQualLoc,
1538  SourceLocation UnalignedQualLoc) {
1540  I.Kind = Pointer;
1541  I.Loc = Loc;
1542  I.Ptr.TypeQuals = TypeQuals;
1543  I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding();
1544  I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding();
1545  I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding();
1546  I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding();
1547  I.Ptr.UnalignedQualLoc = UnalignedQualLoc.getRawEncoding();
1548  I.Ptr.AttrList = nullptr;
1549  return I;
1550  }
1551 
1552  /// \brief Return a DeclaratorChunk for a reference.
1553  static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc,
1554  bool lvalue) {
1556  I.Kind = Reference;
1557  I.Loc = Loc;
1558  I.Ref.HasRestrict = (TypeQuals & DeclSpec::TQ_restrict) != 0;
1559  I.Ref.LValueRef = lvalue;
1560  I.Ref.AttrList = nullptr;
1561  return I;
1562  }
1563 
1564  /// \brief Return a DeclaratorChunk for an array.
1565  static DeclaratorChunk getArray(unsigned TypeQuals,
1566  bool isStatic, bool isStar, Expr *NumElts,
1567  SourceLocation LBLoc, SourceLocation RBLoc) {
1569  I.Kind = Array;
1570  I.Loc = LBLoc;
1571  I.EndLoc = RBLoc;
1572  I.Arr.AttrList = nullptr;
1573  I.Arr.TypeQuals = TypeQuals;
1574  I.Arr.hasStatic = isStatic;
1575  I.Arr.isStar = isStar;
1576  I.Arr.NumElts = NumElts;
1577  return I;
1578  }
1579 
1580  /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
1581  /// "TheDeclarator" is the declarator that this will be added to.
1582  static DeclaratorChunk getFunction(bool HasProto,
1583  bool IsAmbiguous,
1584  SourceLocation LParenLoc,
1585  ParamInfo *Params, unsigned NumParams,
1586  SourceLocation EllipsisLoc,
1587  SourceLocation RParenLoc,
1588  unsigned TypeQuals,
1589  bool RefQualifierIsLvalueRef,
1590  SourceLocation RefQualifierLoc,
1591  SourceLocation ConstQualifierLoc,
1592  SourceLocation VolatileQualifierLoc,
1593  SourceLocation RestrictQualifierLoc,
1594  SourceLocation MutableLoc,
1595  ExceptionSpecificationType ESpecType,
1596  SourceRange ESpecRange,
1597  ParsedType *Exceptions,
1598  SourceRange *ExceptionRanges,
1599  unsigned NumExceptions,
1600  Expr *NoexceptExpr,
1601  CachedTokens *ExceptionSpecTokens,
1602  ArrayRef<NamedDecl *> DeclsInPrototype,
1603  SourceLocation LocalRangeBegin,
1604  SourceLocation LocalRangeEnd,
1605  Declarator &TheDeclarator,
1606  TypeResult TrailingReturnType =
1607  TypeResult());
1608 
1609  /// \brief Return a DeclaratorChunk for a block.
1610  static DeclaratorChunk getBlockPointer(unsigned TypeQuals,
1611  SourceLocation Loc) {
1613  I.Kind = BlockPointer;
1614  I.Loc = Loc;
1615  I.Cls.TypeQuals = TypeQuals;
1616  I.Cls.AttrList = nullptr;
1617  return I;
1618  }
1619 
1620  /// \brief Return a DeclaratorChunk for a block.
1621  static DeclaratorChunk getPipe(unsigned TypeQuals,
1622  SourceLocation Loc) {
1624  I.Kind = Pipe;
1625  I.Loc = Loc;
1626  I.Cls.TypeQuals = TypeQuals;
1627  I.Cls.AttrList = nullptr;
1628  return I;
1629  }
1630 
1632  unsigned TypeQuals,
1633  SourceLocation Loc) {
1635  I.Kind = MemberPointer;
1636  I.Loc = SS.getBeginLoc();
1637  I.EndLoc = Loc;
1638  I.Mem.TypeQuals = TypeQuals;
1639  I.Mem.AttrList = nullptr;
1640  new (I.Mem.ScopeMem) CXXScopeSpec(SS);
1641  return I;
1642  }
1643 
1644  /// \brief Return a DeclaratorChunk for a paren.
1646  SourceLocation RParenLoc) {
1648  I.Kind = Paren;
1649  I.Loc = LParenLoc;
1650  I.EndLoc = RParenLoc;
1651  I.Common.AttrList = nullptr;
1652  return I;
1653  }
1654 
1655  bool isParen() const {
1656  return Kind == Paren;
1657  }
1658 };
1659 
1660 /// A parsed C++17 decomposition declarator of the form
1661 /// '[' identifier-list ']'
1663 public:
1664  struct Binding {
1667  };
1668 
1669 private:
1670  /// The locations of the '[' and ']' tokens.
1671  SourceLocation LSquareLoc, RSquareLoc;
1672 
1673  /// The bindings.
1674  Binding *Bindings;
1675  unsigned NumBindings : 31;
1676  unsigned DeleteBindings : 1;
1677 
1678  friend class Declarator;
1679 
1680 public:
1682  : Bindings(nullptr), NumBindings(0), DeleteBindings(false) {}
1686  if (DeleteBindings)
1687  delete[] Bindings;
1688  }
1689 
1690  void clear() {
1691  LSquareLoc = RSquareLoc = SourceLocation();
1692  if (DeleteBindings)
1693  delete[] Bindings;
1694  Bindings = nullptr;
1695  NumBindings = 0;
1696  DeleteBindings = false;
1697  }
1698 
1700  return llvm::makeArrayRef(Bindings, NumBindings);
1701  }
1702 
1703  bool isSet() const { return LSquareLoc.isValid(); }
1704 
1705  SourceLocation getLSquareLoc() const { return LSquareLoc; }
1706  SourceLocation getRSquareLoc() const { return RSquareLoc; }
1708  return SourceRange(LSquareLoc, RSquareLoc);
1709  }
1710 };
1711 
1712 /// \brief Described the kind of function definition (if any) provided for
1713 /// a function.
1719 };
1720 
1721 /// \brief Information about one declarator, including the parsed type
1722 /// information and the identifier.
1723 ///
1724 /// When the declarator is fully formed, this is turned into the appropriate
1725 /// Decl object.
1726 ///
1727 /// Declarators come in two types: normal declarators and abstract declarators.
1728 /// Abstract declarators are used when parsing types, and don't have an
1729 /// identifier. Normal declarators do have ID's.
1730 ///
1731 /// Instances of this class should be a transient object that lives on the
1732 /// stack, not objects that are allocated in large quantities on the heap.
1733 class Declarator {
1734 public:
1735  enum TheContext {
1736  FileContext, // File scope declaration.
1737  PrototypeContext, // Within a function prototype.
1738  ObjCResultContext, // An ObjC method result type.
1739  ObjCParameterContext,// An ObjC method parameter type.
1740  KNRTypeListContext, // K&R type definition list for formals.
1741  TypeNameContext, // Abstract declarator for types.
1742  FunctionalCastContext, // Type in a C++ functional cast expression.
1743  MemberContext, // Struct/Union field.
1744  BlockContext, // Declaration within a block in a function.
1745  ForContext, // Declaration within first part of a for loop.
1746  InitStmtContext, // Declaration within optional init stmt of if/switch.
1747  ConditionContext, // Condition declaration in a C++ if/switch/while/for.
1748  TemplateParamContext,// Within a template parameter list.
1749  CXXNewContext, // C++ new-expression.
1750  CXXCatchContext, // C++ catch exception-declaration
1751  ObjCCatchContext, // Objective-C catch exception-declaration
1752  BlockLiteralContext, // Block literal declarator.
1753  LambdaExprContext, // Lambda-expression declarator.
1754  LambdaExprParameterContext, // Lambda-expression parameter declarator.
1755  ConversionIdContext, // C++ conversion-type-id.
1756  TrailingReturnContext, // C++11 trailing-type-specifier.
1757  TemplateTypeArgContext, // Template type argument.
1758  AliasDeclContext, // C++11 alias-declaration.
1759  AliasTemplateContext // C++11 alias-declaration template.
1760  };
1761 
1762 private:
1763  const DeclSpec &DS;
1764  CXXScopeSpec SS;
1765  UnqualifiedId Name;
1766  SourceRange Range;
1767 
1768  /// \brief Where we are parsing this declarator.
1769  TheContext Context;
1770 
1771  /// The C++17 structured binding, if any. This is an alternative to a Name.
1772  DecompositionDeclarator BindingGroup;
1773 
1774  /// DeclTypeInfo - This holds each type that the declarator includes as it is
1775  /// parsed. This is pushed from the identifier out, which means that element
1776  /// #0 will be the most closely bound to the identifier, and
1777  /// DeclTypeInfo.back() will be the least closely bound.
1778  SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
1779 
1780  /// InvalidType - Set by Sema::GetTypeForDeclarator().
1781  unsigned InvalidType : 1;
1782 
1783  /// GroupingParens - Set by Parser::ParseParenDeclarator().
1784  unsigned GroupingParens : 1;
1785 
1786  /// FunctionDefinition - Is this Declarator for a function or member
1787  /// definition and, if so, what kind?
1788  ///
1789  /// Actually a FunctionDefinitionKind.
1790  unsigned FunctionDefinition : 2;
1791 
1792  /// \brief Is this Declarator a redeclaration?
1793  unsigned Redeclaration : 1;
1794 
1795  /// \brief true if the declaration is preceded by \c __extension__.
1796  unsigned Extension : 1;
1797 
1798  /// Indicates whether this is an Objective-C instance variable.
1799  unsigned ObjCIvar : 1;
1800 
1801  /// Indicates whether this is an Objective-C 'weak' property.
1802  unsigned ObjCWeakProperty : 1;
1803 
1804  /// Indicates whether the InlineParams / InlineBindings storage has been used.
1805  unsigned InlineStorageUsed : 1;
1806 
1807  /// Attrs - Attributes.
1808  ParsedAttributes Attrs;
1809 
1810  /// \brief The asm label, if specified.
1811  Expr *AsmLabel;
1812 
1813 #ifndef _MSC_VER
1814  union {
1815 #endif
1816  /// InlineParams - This is a local array used for the first function decl
1817  /// chunk to avoid going to the heap for the common case when we have one
1818  /// function chunk in the declarator.
1821 #ifndef _MSC_VER
1822  };
1823 #endif
1824 
1825  /// \brief If this is the second or subsequent declarator in this declaration,
1826  /// the location of the comma before this declarator.
1827  SourceLocation CommaLoc;
1828 
1829  /// \brief If provided, the source location of the ellipsis used to describe
1830  /// this declarator as a parameter pack.
1831  SourceLocation EllipsisLoc;
1832 
1833  friend struct DeclaratorChunk;
1834 
1835 public:
1837  : DS(ds), Range(ds.getSourceRange()), Context(C),
1838  InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error),
1839  GroupingParens(false), FunctionDefinition(FDK_Declaration),
1840  Redeclaration(false), Extension(false), ObjCIvar(false),
1841  ObjCWeakProperty(false), InlineStorageUsed(false),
1842  Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr) {}
1843 
1845  clear();
1846  }
1847  /// getDeclSpec - Return the declaration-specifier that this declarator was
1848  /// declared with.
1849  const DeclSpec &getDeclSpec() const { return DS; }
1850 
1851  /// getMutableDeclSpec - Return a non-const version of the DeclSpec. This
1852  /// should be used with extreme care: declspecs can often be shared between
1853  /// multiple declarators, so mutating the DeclSpec affects all of the
1854  /// Declarators. This should only be done when the declspec is known to not
1855  /// be shared or when in error recovery etc.
1856  DeclSpec &getMutableDeclSpec() { return const_cast<DeclSpec &>(DS); }
1857 
1859  return Attrs.getPool();
1860  }
1861 
1862  /// getCXXScopeSpec - Return the C++ scope specifier (global scope or
1863  /// nested-name-specifier) that is part of the declarator-id.
1864  const CXXScopeSpec &getCXXScopeSpec() const { return SS; }
1865  CXXScopeSpec &getCXXScopeSpec() { return SS; }
1866 
1867  /// \brief Retrieve the name specified by this declarator.
1868  UnqualifiedId &getName() { return Name; }
1869 
1871  return BindingGroup;
1872  }
1873 
1874  TheContext getContext() const { return Context; }
1875 
1876  bool isPrototypeContext() const {
1877  return (Context == PrototypeContext ||
1881  }
1882 
1883  /// \brief Get the source range that spans this declarator.
1884  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1885  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
1886  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
1887 
1888  void SetSourceRange(SourceRange R) { Range = R; }
1889  /// SetRangeBegin - Set the start of the source range to Loc, unless it's
1890  /// invalid.
1892  if (!Loc.isInvalid())
1893  Range.setBegin(Loc);
1894  }
1895  /// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
1897  if (!Loc.isInvalid())
1898  Range.setEnd(Loc);
1899  }
1900  /// ExtendWithDeclSpec - Extend the declarator source range to include the
1901  /// given declspec, unless its location is invalid. Adopts the range start if
1902  /// the current range start is invalid.
1903  void ExtendWithDeclSpec(const DeclSpec &DS) {
1904  SourceRange SR = DS.getSourceRange();
1905  if (Range.getBegin().isInvalid())
1906  Range.setBegin(SR.getBegin());
1907  if (!SR.getEnd().isInvalid())
1908  Range.setEnd(SR.getEnd());
1909  }
1910 
1911  /// \brief Reset the contents of this Declarator.
1912  void clear() {
1913  SS.clear();
1914  Name.clear();
1915  Range = DS.getSourceRange();
1916  BindingGroup.clear();
1917 
1918  for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
1919  DeclTypeInfo[i].destroy();
1920  DeclTypeInfo.clear();
1921  Attrs.clear();
1922  AsmLabel = nullptr;
1923  InlineStorageUsed = false;
1924  ObjCIvar = false;
1925  ObjCWeakProperty = false;
1926  CommaLoc = SourceLocation();
1927  EllipsisLoc = SourceLocation();
1928  }
1929 
1930  /// mayOmitIdentifier - Return true if the identifier is either optional or
1931  /// not allowed. This is true for typenames, prototypes, and template
1932  /// parameter lists.
1933  bool mayOmitIdentifier() const {
1934  switch (Context) {
1935  case FileContext:
1936  case KNRTypeListContext:
1937  case MemberContext:
1938  case BlockContext:
1939  case ForContext:
1940  case InitStmtContext:
1941  case ConditionContext:
1942  return false;
1943 
1944  case TypeNameContext:
1945  case FunctionalCastContext:
1946  case AliasDeclContext:
1947  case AliasTemplateContext:
1948  case PrototypeContext:
1950  case ObjCParameterContext:
1951  case ObjCResultContext:
1952  case TemplateParamContext:
1953  case CXXNewContext:
1954  case CXXCatchContext:
1955  case ObjCCatchContext:
1956  case BlockLiteralContext:
1957  case LambdaExprContext:
1958  case ConversionIdContext:
1960  case TrailingReturnContext:
1961  return true;
1962  }
1963  llvm_unreachable("unknown context kind!");
1964  }
1965 
1966  /// mayHaveIdentifier - Return true if the identifier is either optional or
1967  /// required. This is true for normal declarators and prototypes, but not
1968  /// typenames.
1969  bool mayHaveIdentifier() const {
1970  switch (Context) {
1971  case FileContext:
1972  case KNRTypeListContext:
1973  case MemberContext:
1974  case BlockContext:
1975  case ForContext:
1976  case InitStmtContext:
1977  case ConditionContext:
1978  case PrototypeContext:
1980  case TemplateParamContext:
1981  case CXXCatchContext:
1982  case ObjCCatchContext:
1983  return true;
1984 
1985  case TypeNameContext:
1986  case FunctionalCastContext:
1987  case CXXNewContext:
1988  case AliasDeclContext:
1989  case AliasTemplateContext:
1990  case ObjCParameterContext:
1991  case ObjCResultContext:
1992  case BlockLiteralContext:
1993  case LambdaExprContext:
1994  case ConversionIdContext:
1996  case TrailingReturnContext:
1997  return false;
1998  }
1999  llvm_unreachable("unknown context kind!");
2000  }
2001 
2002  /// Return true if the context permits a C++17 decomposition declarator.
2004  switch (Context) {
2005  case FileContext:
2006  // FIXME: It's not clear that the proposal meant to allow file-scope
2007  // structured bindings, but it does.
2008  case BlockContext:
2009  case ForContext:
2010  case InitStmtContext:
2011  return true;
2012 
2013  case ConditionContext:
2014  case MemberContext:
2015  case PrototypeContext:
2016  case TemplateParamContext:
2017  // Maybe one day...
2018  return false;
2019 
2020  // These contexts don't allow any kind of non-abstract declarator.
2021  case KNRTypeListContext:
2022  case TypeNameContext:
2023  case FunctionalCastContext:
2024  case AliasDeclContext:
2025  case AliasTemplateContext:
2027  case ObjCParameterContext:
2028  case ObjCResultContext:
2029  case CXXNewContext:
2030  case CXXCatchContext:
2031  case ObjCCatchContext:
2032  case BlockLiteralContext:
2033  case LambdaExprContext:
2034  case ConversionIdContext:
2036  case TrailingReturnContext:
2037  return false;
2038  }
2039  llvm_unreachable("unknown context kind!");
2040  }
2041 
2042  /// mayBeFollowedByCXXDirectInit - Return true if the declarator can be
2043  /// followed by a C++ direct initializer, e.g. "int x(1);".
2045  if (hasGroupingParens()) return false;
2046 
2047  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2048  return false;
2049 
2050  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern &&
2051  Context != FileContext)
2052  return false;
2053 
2054  // Special names can't have direct initializers.
2055  if (Name.getKind() != UnqualifiedId::IK_Identifier)
2056  return false;
2057 
2058  switch (Context) {
2059  case FileContext:
2060  case BlockContext:
2061  case ForContext:
2062  case InitStmtContext:
2063  return true;
2064 
2065  case ConditionContext:
2066  // This may not be followed by a direct initializer, but it can't be a
2067  // function declaration either, and we'd prefer to perform a tentative
2068  // parse in order to produce the right diagnostic.
2069  return true;
2070 
2071  case KNRTypeListContext:
2072  case MemberContext:
2073  case PrototypeContext:
2075  case ObjCParameterContext:
2076  case ObjCResultContext:
2077  case TemplateParamContext:
2078  case CXXCatchContext:
2079  case ObjCCatchContext:
2080  case TypeNameContext:
2081  case FunctionalCastContext: // FIXME
2082  case CXXNewContext:
2083  case AliasDeclContext:
2084  case AliasTemplateContext:
2085  case BlockLiteralContext:
2086  case LambdaExprContext:
2087  case ConversionIdContext:
2089  case TrailingReturnContext:
2090  return false;
2091  }
2092  llvm_unreachable("unknown context kind!");
2093  }
2094 
2095  /// isPastIdentifier - Return true if we have parsed beyond the point where
2096  /// the name would appear. (This may happen even if we haven't actually parsed
2097  /// a name, perhaps because this context doesn't require one.)
2098  bool isPastIdentifier() const { return Name.isValid(); }
2099 
2100  /// hasName - Whether this declarator has a name, which might be an
2101  /// identifier (accessible via getIdentifier()) or some kind of
2102  /// special C++ name (constructor, destructor, etc.), or a structured
2103  /// binding (which is not exactly a name, but occupies the same position).
2104  bool hasName() const {
2105  return Name.getKind() != UnqualifiedId::IK_Identifier || Name.Identifier ||
2107  }
2108 
2109  /// Return whether this declarator is a decomposition declarator.
2111  return BindingGroup.isSet();
2112  }
2113 
2115  if (Name.getKind() == UnqualifiedId::IK_Identifier)
2116  return Name.Identifier;
2117 
2118  return nullptr;
2119  }
2120  SourceLocation getIdentifierLoc() const { return Name.StartLocation; }
2121 
2122  /// \brief Set the name of this declarator to be the given identifier.
2124  Name.setIdentifier(Id, IdLoc);
2125  }
2126 
2127  /// Set the decomposition bindings for this declarator.
2128  void
2131  SourceLocation RSquareLoc);
2132 
2133  /// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
2134  /// EndLoc, which should be the last token of the chunk.
2136  ParsedAttributes &attrs,
2137  SourceLocation EndLoc) {
2138  DeclTypeInfo.push_back(TI);
2139  DeclTypeInfo.back().getAttrListRef() = attrs.getList();
2141 
2142  if (!EndLoc.isInvalid())
2143  SetRangeEnd(EndLoc);
2144  }
2145 
2146  /// \brief Add a new innermost chunk to this declarator.
2148  DeclTypeInfo.insert(DeclTypeInfo.begin(), TI);
2149  }
2150 
2151  /// \brief Return the number of types applied to this declarator.
2152  unsigned getNumTypeObjects() const { return DeclTypeInfo.size(); }
2153 
2154  /// Return the specified TypeInfo from this declarator. TypeInfo #0 is
2155  /// closest to the identifier.
2156  const DeclaratorChunk &getTypeObject(unsigned i) const {
2157  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2158  return DeclTypeInfo[i];
2159  }
2161  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2162  return DeclTypeInfo[i];
2163  }
2164 
2166  typedef llvm::iterator_range<type_object_iterator> type_object_range;
2167 
2168  /// Returns the range of type objects, from the identifier outwards.
2170  return type_object_range(DeclTypeInfo.begin(), DeclTypeInfo.end());
2171  }
2172 
2174  assert(!DeclTypeInfo.empty() && "No type chunks to drop.");
2175  DeclTypeInfo.front().destroy();
2176  DeclTypeInfo.erase(DeclTypeInfo.begin());
2177  }
2178 
2179  /// Return the innermost (closest to the declarator) chunk of this
2180  /// declarator that is not a parens chunk, or null if there are no
2181  /// non-parens chunks.
2183  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2184  if (!DeclTypeInfo[i].isParen())
2185  return &DeclTypeInfo[i];
2186  }
2187  return nullptr;
2188  }
2189 
2190  /// Return the outermost (furthest from the declarator) chunk of
2191  /// this declarator that is not a parens chunk, or null if there are
2192  /// no non-parens chunks.
2194  for (unsigned i = DeclTypeInfo.size(), i_end = 0; i != i_end; --i) {
2195  if (!DeclTypeInfo[i-1].isParen())
2196  return &DeclTypeInfo[i-1];
2197  }
2198  return nullptr;
2199  }
2200 
2201  /// isArrayOfUnknownBound - This method returns true if the declarator
2202  /// is a declarator for an array of unknown bound (looking through
2203  /// parentheses).
2204  bool isArrayOfUnknownBound() const {
2205  const DeclaratorChunk *chunk = getInnermostNonParenChunk();
2206  return (chunk && chunk->Kind == DeclaratorChunk::Array &&
2207  !chunk->Arr.NumElts);
2208  }
2209 
2210  /// isFunctionDeclarator - This method returns true if the declarator
2211  /// is a function declarator (looking through parentheses).
2212  /// If true is returned, then the reference type parameter idx is
2213  /// assigned with the index of the declaration chunk.
2214  bool isFunctionDeclarator(unsigned& idx) const {
2215  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2216  switch (DeclTypeInfo[i].Kind) {
2218  idx = i;
2219  return true;
2221  continue;
2227  case DeclaratorChunk::Pipe:
2228  return false;
2229  }
2230  llvm_unreachable("Invalid type chunk");
2231  }
2232  return false;
2233  }
2234 
2235  /// isFunctionDeclarator - Once this declarator is fully parsed and formed,
2236  /// this method returns true if the identifier is a function declarator
2237  /// (looking through parentheses).
2238  bool isFunctionDeclarator() const {
2239  unsigned index;
2240  return isFunctionDeclarator(index);
2241  }
2242 
2243  /// getFunctionTypeInfo - Retrieves the function type info object
2244  /// (looking through parentheses).
2246  assert(isFunctionDeclarator() && "Not a function declarator!");
2247  unsigned index = 0;
2248  isFunctionDeclarator(index);
2249  return DeclTypeInfo[index].Fun;
2250  }
2251 
2252  /// getFunctionTypeInfo - Retrieves the function type info object
2253  /// (looking through parentheses).
2255  return const_cast<Declarator*>(this)->getFunctionTypeInfo();
2256  }
2257 
2258  /// \brief Determine whether the declaration that will be produced from
2259  /// this declaration will be a function.
2260  ///
2261  /// A declaration can declare a function even if the declarator itself
2262  /// isn't a function declarator, if the type specifier refers to a function
2263  /// type. This routine checks for both cases.
2264  bool isDeclarationOfFunction() const;
2265 
2266  /// \brief Return true if this declaration appears in a context where a
2267  /// function declarator would be a function declaration.
2269  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2270  return false;
2271 
2272  switch (Context) {
2273  case FileContext:
2274  case MemberContext:
2275  case BlockContext:
2276  case ForContext:
2277  case InitStmtContext:
2278  return true;
2279 
2280  case ConditionContext:
2281  case KNRTypeListContext:
2282  case TypeNameContext:
2283  case FunctionalCastContext:
2284  case AliasDeclContext:
2285  case AliasTemplateContext:
2286  case PrototypeContext:
2288  case ObjCParameterContext:
2289  case ObjCResultContext:
2290  case TemplateParamContext:
2291  case CXXNewContext:
2292  case CXXCatchContext:
2293  case ObjCCatchContext:
2294  case BlockLiteralContext:
2295  case LambdaExprContext:
2296  case ConversionIdContext:
2298  case TrailingReturnContext:
2299  return false;
2300  }
2301  llvm_unreachable("unknown context kind!");
2302  }
2303 
2304  /// \brief Return true if a function declarator at this position would be a
2305  /// function declaration.
2308  return false;
2309 
2310  for (unsigned I = 0, N = getNumTypeObjects(); I != N; ++I)
2312  return false;
2313 
2314  return true;
2315  }
2316 
2317  /// \brief Determine whether a trailing return type was written (at any
2318  /// level) within this declarator.
2319  bool hasTrailingReturnType() const {
2320  for (const auto &Chunk : type_objects())
2321  if (Chunk.Kind == DeclaratorChunk::Function &&
2322  Chunk.Fun.hasTrailingReturnType())
2323  return true;
2324  return false;
2325  }
2326 
2327  /// takeAttributes - Takes attributes from the given parsed-attributes
2328  /// set and add them to this declarator.
2329  ///
2330  /// These examples both add 3 attributes to "var":
2331  /// short int var __attribute__((aligned(16),common,deprecated));
2332  /// short int x, __attribute__((aligned(16)) var
2333  /// __attribute__((common,deprecated));
2334  ///
2335  /// Also extends the range of the declarator.
2337  Attrs.takeAllFrom(attrs);
2338 
2339  if (!lastLoc.isInvalid())
2340  SetRangeEnd(lastLoc);
2341  }
2342 
2343  const AttributeList *getAttributes() const { return Attrs.getList(); }
2344  AttributeList *getAttributes() { return Attrs.getList(); }
2345 
2346  AttributeList *&getAttrListRef() { return Attrs.getListRef(); }
2347 
2348  /// hasAttributes - do we contain any attributes?
2349  bool hasAttributes() const {
2350  if (getAttributes() || getDeclSpec().hasAttributes()) return true;
2351  for (unsigned i = 0, e = getNumTypeObjects(); i != e; ++i)
2352  if (getTypeObject(i).getAttrs())
2353  return true;
2354  return false;
2355  }
2356 
2357  /// \brief Return a source range list of C++11 attributes associated
2358  /// with the declarator.
2360  AttributeList *AttrList = Attrs.getList();
2361  while (AttrList) {
2362  if (AttrList->isCXX11Attribute())
2363  Ranges.push_back(AttrList->getRange());
2364  AttrList = AttrList->getNext();
2365  }
2366  }
2367 
2368  void setAsmLabel(Expr *E) { AsmLabel = E; }
2369  Expr *getAsmLabel() const { return AsmLabel; }
2370 
2371  void setExtension(bool Val = true) { Extension = Val; }
2372  bool getExtension() const { return Extension; }
2373 
2374  void setObjCIvar(bool Val = true) { ObjCIvar = Val; }
2375  bool isObjCIvar() const { return ObjCIvar; }
2376 
2377  void setObjCWeakProperty(bool Val = true) { ObjCWeakProperty = Val; }
2378  bool isObjCWeakProperty() const { return ObjCWeakProperty; }
2379 
2380  void setInvalidType(bool Val = true) { InvalidType = Val; }
2381  bool isInvalidType() const {
2382  return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
2383  }
2384 
2385  void setGroupingParens(bool flag) { GroupingParens = flag; }
2386  bool hasGroupingParens() const { return GroupingParens; }
2387 
2388  bool isFirstDeclarator() const { return !CommaLoc.isValid(); }
2389  SourceLocation getCommaLoc() const { return CommaLoc; }
2390  void setCommaLoc(SourceLocation CL) { CommaLoc = CL; }
2391 
2392  bool hasEllipsis() const { return EllipsisLoc.isValid(); }
2393  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
2394  void setEllipsisLoc(SourceLocation EL) { EllipsisLoc = EL; }
2395 
2397  FunctionDefinition = Val;
2398  }
2399 
2400  bool isFunctionDefinition() const {
2402  }
2403 
2405  return (FunctionDefinitionKind)FunctionDefinition;
2406  }
2407 
2408  /// Returns true if this declares a real member and not a friend.
2411  }
2412 
2413  /// Returns true if this declares a static member. This cannot be called on a
2414  /// declarator outside of a MemberContext because we won't know until
2415  /// redeclaration time if the decl is static.
2416  bool isStaticMember();
2417 
2418  /// Returns true if this declares a constructor or a destructor.
2419  bool isCtorOrDtor();
2420 
2421  void setRedeclaration(bool Val) { Redeclaration = Val; }
2422  bool isRedeclaration() const { return Redeclaration; }
2423 };
2424 
2425 /// \brief This little struct is used to capture information about
2426 /// structure field declarators, which is basically just a bitfield size.
2430  explicit FieldDeclarator(const DeclSpec &DS)
2431  : D(DS, Declarator::MemberContext), BitfieldSize(nullptr) { }
2432 };
2433 
2434 /// \brief Represents a C++11 virt-specifier-seq.
2436 public:
2437  enum Specifier {
2438  VS_None = 0,
2442  // Represents the __final keyword, which is legal for gcc in pre-C++11 mode.
2444  };
2445 
2446  VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
2447 
2448  bool SetSpecifier(Specifier VS, SourceLocation Loc,
2449  const char *&PrevSpec);
2450 
2451  bool isUnset() const { return Specifiers == 0; }
2452 
2453  bool isOverrideSpecified() const { return Specifiers & VS_Override; }
2454  SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
2455 
2456  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed | VS_GNU_Final); }
2457  bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; }
2458  SourceLocation getFinalLoc() const { return VS_finalLoc; }
2459 
2460  void clear() { Specifiers = 0; }
2461 
2462  static const char *getSpecifierName(Specifier VS);
2463 
2464  SourceLocation getFirstLocation() const { return FirstLocation; }
2465  SourceLocation getLastLocation() const { return LastLocation; }
2466  Specifier getLastSpecifier() const { return LastSpecifier; }
2467 
2468 private:
2469  unsigned Specifiers;
2470  Specifier LastSpecifier;
2471 
2472  SourceLocation VS_overrideLoc, VS_finalLoc;
2473  SourceLocation FirstLocation;
2474  SourceLocation LastLocation;
2475 };
2476 
2478  NoInit, //!< [a]
2479  CopyInit, //!< [a = b], [a = {b}]
2480  DirectInit, //!< [a(b)]
2481  ListInit //!< [a{b}]
2482 };
2483 
2484 /// \brief Represents a complete lambda introducer.
2486  /// \brief An individual capture in a lambda introducer.
2487  struct LambdaCapture {
2499  : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc),
2500  InitKind(InitKind), Init(Init), InitCaptureType(InitCaptureType) {}
2501  };
2502 
2507 
2509  : Default(LCD_None) {}
2510 
2511  /// \brief Append a capture in a lambda introducer.
2513  SourceLocation Loc,
2514  IdentifierInfo* Id,
2515  SourceLocation EllipsisLoc,
2516  LambdaCaptureInitKind InitKind,
2517  ExprResult Init,
2518  ParsedType InitCaptureType) {
2519  Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
2520  InitCaptureType));
2521  }
2522 };
2523 
2524 } // end namespace clang
2525 
2526 #endif // LLVM_CLANG_SEMA_DECLSPEC_H
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1123
void ClearFunctionSpecs()
Definition: DeclSpec.h:578
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:458
SourceLocation getEnd() const
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
Definition: DeclSpec.h:1067
unsigned UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
Definition: DeclSpec.h:1170
IdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:1001
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2245
unsigned MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1308
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1252
no exception specification
SourceLocation getRestrictSpecLoc() const
Definition: DeclSpec.h:544
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:107
bool hasAttributes() const
hasAttributes - do we contain any attributes?
Definition: DeclSpec.h:2349
void clear()
Reset the contents of this Declarator.
Definition: DeclSpec.h:1912
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Definition: DeclSpec.h:1524
SourceLocation getConstSpecLoc() const
Definition: DeclSpec.h:543
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:573
TSW getTypeSpecWidth() const
Definition: DeclSpec.h:477
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
Definition: DeclSpec.h:1119
static const TSS TSS_unsigned
Definition: DeclSpec.h:268
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1304
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:978
const DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo() const
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2254
TheContext getContext() const
Definition: DeclSpec.h:1874
static const TST TST_wchar
Definition: DeclSpec.h:275
Decl * getRepAsDecl() const
Definition: DeclSpec.h:492
ThreadStorageClassSpecifier TSCS
Definition: DeclSpec.h:245
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
Definition: DeclSpec.h:2204
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:752
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Definition: DeclSpec.h:948
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:281
UnionParsedType TypeRep
Definition: DeclSpec.h:367
A conversion function name, e.g., operator int.
Definition: DeclSpec.h:912
void setEndLoc(SourceLocation Loc)
Definition: DeclSpec.h:71
static const TST TST_typeofExpr
Definition: DeclSpec.h:295
static const TST TST_char16
Definition: DeclSpec.h:276
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal)
Definition: DeclSpec.h:835
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:81
SourceRange getRange() const
unsigned ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1311
bool isTypeAltiVecBool() const
Definition: DeclSpec.h:483
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:956
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:778
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
AttributePool & getAttributePool() const
Definition: DeclSpec.h:1858
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1272
SourceRange getSourceRange() const
Definition: DeclSpec.h:1707
bool hasAutoTypeSpec() const
Definition: DeclSpec.h:522
SCS getStorageClassSpec() const
Definition: DeclSpec.h:448
FunctionDefinitionKind getFunctionDefinitionKind() const
Definition: DeclSpec.h:2404
const DecompositionDeclarator & getDecompositionDeclarator() const
Definition: DeclSpec.h:1870
TypeSpecifierType TST
Definition: DeclSpec.h:271
One instance of this struct is used for each type in a declarator that is parsed. ...
Definition: DeclSpec.h:1133
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:461
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1141
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
Definition: DeclSpec.h:1284
NamedDecl ** DeclsInPrototype
Pointer to a new[]'d array of declarations that need to be available for lookup inside the function b...
Definition: DeclSpec.h:1338
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Definition: DeclSpec.cpp:494
LambdaCaptureInitKind InitKind
Definition: DeclSpec.h:2492
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
Definition: DeclSpec.h:1221
SourceLocation getInlineSpecLoc() const
Definition: DeclSpec.h:565
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1331
SourceLocation getSetterNameLoc() const
Definition: DeclSpec.h:872
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:806
AttributeList *& getAttrListRef()
Definition: DeclSpec.h:2346
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
Definition: DeclSpec.h:2123
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
bool isConceptSpecified() const
Definition: DeclSpec.h:711
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1289
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1164
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1462
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:125
static const TSCS TSCS_unspecified
Definition: DeclSpec.h:246
SourceLocation getCommaLoc() const
Definition: DeclSpec.h:2389
void setObjCQualifiers(ObjCDeclSpec *quals)
Definition: DeclSpec.h:768
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
Definition: DeclSpec.h:1194
static const TST TST_underlyingType
Definition: DeclSpec.h:298
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1733
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:896
SourceLocation getLSquareLoc() const
Definition: DeclSpec.h:1705
void setTypeofParensRange(SourceRange range)
Definition: DeclSpec.h:520
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:1386
bool isObjCWeakProperty() const
Definition: DeclSpec.h:2378
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
static const TST TST_interface
Definition: DeclSpec.h:291
static const TST TST_char
Definition: DeclSpec.h:274
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:38
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
Definition: DeclSpec.h:2169
const DeclaratorChunk * getOutermostNonParenChunk() const
Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chu...
Definition: DeclSpec.h:2193
void addAll(AttributeList *newList)
bool isEmpty() const
No scope specifier.
Definition: DeclSpec.h:189
bool isParen() const
Definition: DeclSpec.h:1655
Information about a template-id annotation token.
IdentifierInfo * getGetterName()
Definition: DeclSpec.h:863
static const TST TST_unknown_anytype
Definition: DeclSpec.h:301
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:40
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
Definition: DeclSpec.h:972
C11 _Thread_local.
Definition: Specifiers.h:198
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1329
One of these records is kept for each identifier that is lexed.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
Definition: DeclSpec.cpp:39
SmallVectorImpl< DeclaratorChunk >::const_iterator type_object_iterator
Definition: DeclSpec.h:2165
bool getExtension() const
Definition: DeclSpec.h:2372
static const TST TST_decimal32
Definition: DeclSpec.h:285
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Definition: DeclSpec.h:956
AttributeList * getList() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
void DropFirstTypeObject()
Definition: DeclSpec.h:2173
A C++ nested-name-specifier augmented with source location information.
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the 'restrict' qualifier, if any.
Definition: DeclSpec.h:1422
bool isTypeSpecPipe() const
Definition: DeclSpec.h:486
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:2135
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
Definition: DeclSpec.h:1035
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
Definition: DeclSpec.h:1864
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:33
SourceLocation getTypeSpecSignLoc() const
Definition: DeclSpec.h:510
unsigned VolatileQualifierLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1299
TSS getTypeSpecSign() const
Definition: DeclSpec.h:479
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
DeclSpec(AttributeFactory &attrFactory)
Definition: DeclSpec.h:420
static const TST TST_class
Definition: DeclSpec.h:292
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:34
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
Definition: DeclSpec.h:967
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:931
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
Definition: DeclSpec.h:1256
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
Definition: DeclSpec.h:605
static const TST TST_double
Definition: DeclSpec.h:282
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
Definition: DeclSpec.h:952
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:881
bool isNoreturnSpecified() const
Definition: DeclSpec.h:575
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:828
static const TST TST_error
Definition: DeclSpec.h:306
static const TST TST_enum
Definition: DeclSpec.h:288
SourceLocation getFirstLocation() const
Definition: DeclSpec.h:2464
SourceLocation getTypeSpecTypeLoc() const
Definition: DeclSpec.h:511
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:1885
static const TSW TSW_unspecified
Definition: DeclSpec.h:253
void ClearStorageClassSpecs()
Definition: DeclSpec.h:462
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
Definition: DeclSpec.h:1533
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
Definition: DeclSpec.h:2044
void SetSourceRange(SourceRange R)
Definition: DeclSpec.h:1888
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2427
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:791
PointerTypeInfo Ptr
Definition: DeclSpec.h:1500
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Definition: DeclSpec.h:964
void setExternInLinkageSpec(bool Value)
Definition: DeclSpec.h:453
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:899
void setObjCWeakProperty(bool Val=true)
Definition: DeclSpec.h:2377
ObjCPropertyAttributeKind
PropertyAttributeKind - list of property attributes.
Definition: DeclSpec.h:799
void addAttributes(AttributeList *AL)
Concatenates two attribute lists.
Definition: DeclSpec.h:745
bool hasGroupingParens() const
Definition: DeclSpec.h:2386
unsigned ConstQualLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1158
void setExtension(bool Val=true)
Definition: DeclSpec.h:2371
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2152
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, std::unique_ptr< CachedTokens > DefArgTokens=nullptr)
Definition: DeclSpec.h:1224
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
Definition: DeclSpec.h:2268
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:221
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.
Definition: DeclSpec.h:1891
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
Definition: DeclSpec.h:2319
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:869
SCS
storage-class-specifier
Definition: DeclSpec.h:232
ArrayTypeInfo Arr
Definition: DeclSpec.h:1502
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:217
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:1122
void setRedeclaration(bool Val)
Definition: DeclSpec.h:2421
An implicit 'self' parameter.
Definition: DeclSpec.h:924
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
Definition: DeclSpec.h:1437
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Definition: DeclSpec.h:2147
void takeAllFrom(ParsedAttributes &attrs)
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1266
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:926
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1275
bool isObjCIvar() const
Definition: DeclSpec.h:2375
SourceLocation getEndLoc() const
Definition: DeclSpec.h:73
const IdentifierInfo * getSetterName() const
Definition: DeclSpec.h:870
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
Definition: DeclSpec.h:199
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:63
enum clang::DeclaratorChunk::@196 Kind
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:775
SourceLocation getConceptSpecLoc() const
Definition: DeclSpec.h:712
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:911
void UpdateExprRep(Expr *Rep)
Definition: DeclSpec.h:674
bool isExternInLinkageSpec() const
Definition: DeclSpec.h:452
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
Definition: DeclSpec.cpp:31
LambdaCaptureInitKind
Definition: DeclSpec.h:2477
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
Definition: DeclSpec.h:2306
SourceLocation getAltiVecLoc() const
Definition: DeclSpec.h:512
SourceRange getTypeSpecWidthRange() const
Definition: DeclSpec.h:508
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:504
SourceRange getSourceRange() const LLVM_READONLY
Definition: DeclSpec.h:503
detail::InMemoryDirectory::const_iterator I
bool isInvalid() const
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
Definition: DeclSpec.h:960
SourceRange getRange() const
Definition: DeclSpec.h:68
static const TST TST_float
Definition: DeclSpec.h:281
DecompositionDeclarator::Binding InlineBindings[16]
Definition: DeclSpec.h:1820
Class that aids in the construction of nested-name-specifiers along with source-location information ...
Declarator(const DeclSpec &ds, TheContext C)
Definition: DeclSpec.h:1836
unsigned AccessWrites
The access writes.
Definition: DeclSpec.h:1493
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Definition: DeclSpec.h:1856
SourceRange getTypeofParensRange() const
Definition: DeclSpec.h:519
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:269
static const TSW TSW_long
Definition: DeclSpec.h:255
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Definition: DeclSpec.h:2214
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType)
Definition: DeclSpec.h:2495
TST getTypeSpecType() const
Definition: DeclSpec.h:480
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:119
void setSetterName(IdentifierInfo *name, SourceLocation loc)
Definition: DeclSpec.h:873
void ClearConstexprSpec()
Definition: DeclSpec.h:714
SourceLocation getModulePrivateSpecLoc() const
Definition: DeclSpec.h:706
bool isTypeRep() const
Definition: DeclSpec.h:485
ObjCPropertyAttributeKind getPropertyAttributes() const
Definition: DeclSpec.h:832
IdentifierInfo * getSetterName()
Definition: DeclSpec.h:871
void SetRangeStart(SourceLocation Loc)
Definition: DeclSpec.h:609
SourceLocation getFriendSpecLoc() const
Definition: DeclSpec.h:703
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1279
ASTContext * Context
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
Definition: DeclSpec.h:1155
SmallVector< LambdaCapture, 4 > Captures
Definition: DeclSpec.h:2506
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
Definition: DeclSpec.h:1933
AttributeList * getAttributes()
Definition: DeclSpec.h:2344
static bool isDeclRep(TST T)
Definition: DeclSpec.h:414
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Definition: DeclSpec.h:542
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: DeclSpec.h:763
SourceLocation getLParenLoc() const
Definition: DeclSpec.h:1382
llvm::iterator_range< type_object_iterator > type_object_range
Definition: DeclSpec.h:2166
unsigned hasStatic
True if this dimension included the 'static' keyword.
Definition: DeclSpec.h:1191
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier, if any.
Definition: DeclSpec.h:1417
Expr - This represents one expression.
Definition: Expr.h:105
void setDecompositionBindings(SourceLocation LSquareLoc, ArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
Definition: DeclSpec.cpp:276
void setDeductionGuideName(ParsedTemplateTy Template, SourceLocation TemplateLoc)
Specify that this unqualified-id was parsed as a template-name for a deduction-guide.
Definition: DeclSpec.h:1111
SourceLocation getAtomicSpecLoc() const
Definition: DeclSpec.h:546
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
Definition: DeclSpec.cpp:308
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:509
An individual capture in a lambda introducer.
Definition: DeclSpec.h:2487
bool isFunctionDefinition() const
Definition: DeclSpec.h:2400
DeclaratorChunk & getTypeObject(unsigned i)
Definition: DeclSpec.h:2160
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1161
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
Definition: DeclSpec.h:940
TypeSpecifierWidth TSW
Definition: DeclSpec.h:252
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1621
void freeParams()
Reset the parameter list to having zero parameters.
Definition: DeclSpec.h:1348
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
Definition: DeclSpec.h:551
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
Definition: DeclSpec.h:987
Defines an enumeration for C++ overloaded operators.
void setAsmLabel(Expr *E)
Definition: DeclSpec.h:2368
void setRange(SourceRange R)
Definition: DeclSpec.h:69
SourceLocation getVolatileSpecLoc() const
Definition: DeclSpec.h:545
DeclaratorChunk::ParamInfo InlineParams[16]
InlineParams - This is a local array used for the first function decl chunk to avoid going to the hea...
Definition: DeclSpec.h:1819
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
Definition: DeclSpec.h:1662
TypeInfoCommon Common
Definition: DeclSpec.h:1499
Represents a C++ template name within the type system.
Definition: TemplateName.h:176
static const TST TST_decimal64
Definition: DeclSpec.h:286
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
Definition: DeclSpec.h:2098
SourceLocation getLastLocation() const
Definition: DeclSpec.h:2465
void UpdateTypeRep(ParsedType Rep)
Definition: DeclSpec.h:670
bool isConstexprSpecified() const
Definition: DeclSpec.h:708
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
Definition: DeclSpec.h:1333
Expr * getAsmLabel() const
Definition: DeclSpec.h:2369
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
Definition: DeclSpec.h:2110
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
Definition: DeclSpec.h:1180
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:592
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1139
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
Definition: DeclSpec.h:1052
SourceLocation getGetterNameLoc() const
Definition: DeclSpec.h:864
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
Definition: DeclSpec.h:2003
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier, if any.
Definition: DeclSpec.h:1412
static const TST TST_int
Definition: DeclSpec.h:278
void setEllipsisLoc(SourceLocation EL)
Definition: DeclSpec.h:2394
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:651
static const TST TST_half
Definition: DeclSpec.h:280
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1440
ObjCDeclSpec * getObjCQualifiers() const
Definition: DeclSpec.h:767
void ClearConceptSpec()
Definition: DeclSpec.h:719
Wraps an identifier and optional source location for the identifier.
Definition: AttributeList.h:73
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1459
SourceLocation getStorageClassSpecLoc() const
Definition: DeclSpec.h:457
static const TSW TSW_short
Definition: DeclSpec.h:254
bool isVirtualSpecified() const
Definition: DeclSpec.h:569
SourceLocation getNullabilityLoc() const
Definition: DeclSpec.h:847
IdKind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:906
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1343
bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
Definition: DeclSpec.cpp:624
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:995
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1325
AttributePool & getAttributePool() const
Definition: DeclSpec.h:724
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
static const TST TST_char32
Definition: DeclSpec.h:277
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
Definition: DeclSpec.h:1645
bool isPrototypeContext() const
Definition: DeclSpec.h:1876
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Definition: DeclSpec.cpp:396
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
Definition: DeclSpec.h:786
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,b,c)".
Definition: DeclSpec.h:1380
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
Definition: DeclSpec.h:998
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:136
bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:970
#define false
Definition: stdbool.h:33
SourceLocation DefaultLoc
Definition: DeclSpec.h:2504
Kind
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:145
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
Definition: DeclSpec.h:1553
Encodes a location in the source.
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType)
Append a capture in a lambda introducer.
Definition: DeclSpec.h:2512
static const TST TST_auto_type
Definition: DeclSpec.h:300
ReferenceTypeInfo Ref
Definition: DeclSpec.h:1501
ParsedSpecifiers
ParsedSpecifiers - Flags to query which specifiers were applied.
Definition: DeclSpec.h:322
Specifier getLastSpecifier() const
Definition: DeclSpec.h:2466
An overloaded operator name, e.g., operator+.
Definition: DeclSpec.h:910
Expr * getRepAsExpr() const
Definition: DeclSpec.h:496
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1868
A deduction-guide name (a template-name)
Definition: DeclSpec.h:926
bool isValid() const
Return true if this is a valid SourceLocation object.
std::pair< char *, unsigned > getBuffer() const
Retrieve the underlying buffer.
SourceLocation getPipeLoc() const
Definition: DeclSpec.h:548
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:143
FunctionTypeInfo Fun
Definition: DeclSpec.h:1503
bool isValid() const
static const TST TST_union
Definition: DeclSpec.h:289
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
Definition: DeclSpec.cpp:152
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
Definition: DeclSpec.cpp:549
SourceLocation getExceptionSpecLocEnd() const
Definition: DeclSpec.h:1398
ParsedType getRepAsType() const
Definition: DeclSpec.h:488
char ScopeMem[sizeof(CXXScopeSpec)]
Definition: DeclSpec.h:1479
TSC getTypeSpecComplex() const
Definition: DeclSpec.h:478
static const TSS TSS_signed
Definition: DeclSpec.h:267
void setGroupingParens(bool flag)
Definition: DeclSpec.h:2385
GNU __thread.
Definition: Specifiers.h:192
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SourceRange getExceptionSpecRange() const
Definition: DeclSpec.h:1402
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Definition: DeclSpec.h:194
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1505
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
Definition: DeclSpec.h:2238
SourceLocation getConstexprSpecLoc() const
Definition: DeclSpec.h:709
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
Definition: DeclSpec.h:2182
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2435
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:570
bool isFinalSpelledSealed() const
Definition: DeclSpec.h:2457
SourceLocation getUnalignedSpecLoc() const
Definition: DeclSpec.h:547
static const TST TST_typeofType
Definition: DeclSpec.h:294
SourceLocation getBegin() const
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:72
void setKind(IdKind kind)
Definition: DeclSpec.h:1002
AttributeList *& getAttrListRef()
Definition: DeclSpec.h:1528
bool hasAttributes() const
Definition: DeclSpec.h:749
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
Definition: DeclSpec.h:1714
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
Definition: DeclSpec.cpp:829
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
Definition: DeclSpec.h:1178
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
Definition: DeclSpec.h:1476
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:388
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:762
PipeTypeInfo PipeInfo
Definition: DeclSpec.h:1506
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
Definition: DeclSpec.h:1565
Decl * DeclRep
Definition: DeclSpec.h:368
SourceLocation getExceptionSpecLocBeg() const
Definition: DeclSpec.h:1394
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Definition: DeclSpec.h:2396
DecompositionDeclarator & operator=(const DecompositionDeclarator &G)=delete
A constructor named via a template-id.
Definition: DeclSpec.h:918
C++11 thread_local.
Definition: Specifiers.h:195
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
Definition: DeclSpec.h:1452
Defines various enumerations that describe declaration and type specifiers.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
Definition: DeclSpec.h:1884
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
Definition: DeclSpec.h:2336
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclSpec.h:822
static const TST TST_decltype_auto
Definition: DeclSpec.h:297
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:944
TSCS getThreadStorageClassSpec() const
Definition: DeclSpec.h:449
bool isUnset() const
Definition: DeclSpec.h:2451
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
Definition: DeclSpec.h:1188
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
Definition: DeclSpec.h:1127
FieldDeclarator(const DeclSpec &DS)
Definition: DeclSpec.h:2430
static const TSS TSS_unspecified
Definition: DeclSpec.h:266
LambdaCaptureDefault Default
Definition: DeclSpec.h:2505
void setObjCIvar(bool Val=true)
Definition: DeclSpec.h:2374
StringRef Name
Definition: USRFinder.cpp:123
static const TST TST_decltype
Definition: DeclSpec.h:296
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
static const TST TST_auto
Definition: DeclSpec.h:299
bool isFriendSpecified() const
Definition: DeclSpec.h:702
static const TST TST_void
Definition: DeclSpec.h:273
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
Definition: DeclSpec.h:1245
SourceLocation getTypeSpecTypeNameLoc() const
Definition: DeclSpec.h:514
static const TST TST_int128
Definition: DeclSpec.h:279
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
Definition: DeclSpec.h:1262
SourceLocation getFinalLoc() const
Definition: DeclSpec.h:2458
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1285
bool isFinalSpecified() const
Definition: DeclSpec.h:2456
bool hasTagDefinition() const
Definition: DeclSpec.cpp:401
unsigned ConstQualifierLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1294
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:505
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:825
detail::InMemoryDirectory::const_iterator E
SourceLocation getNoreturnSpecLoc() const
Definition: DeclSpec.h:576
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:2104
ArrayRef< Binding > bindings() const
Definition: DeclSpec.h:1699
static const TST TST_unspecified
Definition: DeclSpec.h:272
bool isFirstDeclarator() const
Definition: DeclSpec.h:2388
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
Definition: DeclSpec.h:191
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Definition: DeclSpec.cpp:1306
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1445
static const TST TST_decimal128
Definition: DeclSpec.h:287
void takeAttributesFrom(ParsedAttributes &attrs)
Definition: DeclSpec.h:754
static const TSCS TSCS___thread
Definition: DeclSpec.h:247
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
Definition: DeclSpec.h:1240
bool isRedeclaration() const
Definition: DeclSpec.h:2422
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
Definition: DeclSpec.h:1969
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1269
void setNullability(SourceLocation loc, NullabilityKind kind)
Definition: DeclSpec.h:854
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:610
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1291
static const TST TST_typename
Definition: DeclSpec.h:293
CXXScopeSpec & getCXXScopeSpec()
Definition: DeclSpec.h:1865
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
Definition: DeclSpec.h:1896
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< ParsedType > TypeResult
Definition: Ownership.h:254
unsigned AtomicQualLoc
The location of the _Atomic-qualifier, if any.
Definition: DeclSpec.h:1167
bool isInlineSpecified() const
Definition: DeclSpec.h:562
A template-id, e.g., f<int>.
Definition: DeclSpec.h:922
CXXScopeSpec & getTypeSpecScope()
Definition: DeclSpec.h:500
BlockPointerTypeInfo Cls
Definition: DeclSpec.h:1504
IdentifierInfo * getIdentifier() const
Definition: DeclSpec.h:2114
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:740
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:84
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
Definition: DeclSpec.h:2359
bool isCXX11Attribute() const
SourceLocation getRSquareLoc() const
Definition: DeclSpec.h:1706
void setInvalidType(bool Val=true)
Definition: DeclSpec.h:2380
unsigned TypeQuals
For now, sema will catch these as invalid.
Definition: DeclSpec.h:1468
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1610
AttributePool & getPool() const
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: DeclSpec.cpp:47
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
Definition: DeclSpec.h:1259
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:189
Captures information about "declaration specifiers".
Definition: DeclSpec.h:228
bool isExplicitSpecified() const
Definition: DeclSpec.h:572
SourceLocation getIdentifierLoc() const
Definition: DeclSpec.h:2120
void setEnd(SourceLocation e)
void UpdateDeclRep(Decl *Rep)
Definition: DeclSpec.h:666
Represents a C++ struct/union/class.
Definition: DeclCXX.h:267
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
static const TSCS TSCS_thread_local
Definition: DeclSpec.h:248
A user-defined literal name, e.g., operator "" _i.
Definition: DeclSpec.h:914
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:25
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Definition: DeclSpec.h:1199
void ClearTypeSpecType()
Definition: DeclSpec.h:470
static const TST TST_float128
Definition: DeclSpec.h:283
static const TST TST_bool
Definition: DeclSpec.h:284
SourceLocation getOverrideLoc() const
Definition: DeclSpec.h:2454
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:44
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:97
bool isOverrideSpecified() const
Definition: DeclSpec.h:2453
SourceLocation getRParenLoc() const
Definition: DeclSpec.h:1390
bool isTypeSpecOwned() const
Definition: DeclSpec.h:484
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Definition: DeclSpec.cpp:1002
SourceLocation getTypeSpecWidthLoc() const
Definition: DeclSpec.h:507
Represents a complete lambda introducer.
Definition: DeclSpec.h:2485
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
Definition: DeclSpec.h:1903
Expr * ExprRep
Definition: DeclSpec.h:369
static const TSW TSW_longlong
Definition: DeclSpec.h:256
void setBeginLoc(SourceLocation Loc)
Definition: DeclSpec.h:70
SourceLocation getMutableLoc() const
Retrieve the location of the 'mutable' qualifier, if any.
Definition: DeclSpec.h:1427
bool isTypeAltiVecVector() const
Definition: DeclSpec.h:481
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:410
TypeSpecifierSign TSS
Definition: DeclSpec.h:265
bool hasEllipsis() const
Definition: DeclSpec.h:2392
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Definition: DeclSpec.h:196
bool isSet() const
Deprecated.
Definition: DeclSpec.h:209
static const TST TST_atomic
Definition: DeclSpec.h:302
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
Definition: DeclSpec.h:1433
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
Definition: DeclSpec.h:1407
static const TST TST_struct
Definition: DeclSpec.h:290
const CXXScopeSpec & getTypeSpecScope() const
Definition: DeclSpec.h:501
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1211
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2156
AttributeList * getNext() const
A trivial tuple used to represent a source range.
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:641
NamedDecl - This represents a decl with a name.
Definition: Decl.h:213
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:1008
bool isInvalidType() const
Definition: DeclSpec.h:2381
bool SetTypeSpecError()
Definition: DeclSpec.cpp:821
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1314
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:705
NullabilityKind getNullability() const
Definition: DeclSpec.h:840
Represents a C++ namespace alias.
Definition: DeclCXX.h:2861
void setGetterName(IdentifierInfo *name, SourceLocation loc)
Definition: DeclSpec.h:865
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:981
static const TSCS TSCS__Thread_local
Definition: DeclSpec.h:249
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
Definition: DeclSpec.h:1090
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
Definition: DeclSpec.h:2409
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1886
void SetRangeEnd(SourceLocation Loc)
Definition: DeclSpec.h:610
const IdentifierInfo * getGetterName() const
Definition: DeclSpec.h:862
ParsedAttributes - A collection of parsed attributes.
void setCommaLoc(SourceLocation CL)
Definition: DeclSpec.h:2390
bool isTypeAltiVecPixel() const
Definition: DeclSpec.h:482
const CXXScopeSpec & Scope() const
Definition: DeclSpec.h:1483
enum clang::UnqualifiedId::IdKind Kind
SourceRange getSourceRange() const
Definition: DeclSpec.h:1143
AttributeList *& getListRef()
Returns a reference to the attribute list.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1319
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:751
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1849
AttributeList - Represents a syntactic attribute.
Definition: AttributeList.h:95
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS, unsigned TypeQuals, SourceLocation Loc)
Definition: DeclSpec.h:1631
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:855
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:2393
const AttributeList * getAttributes() const
Definition: DeclSpec.h:2343
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1248