clang  3.8.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;
283  static const TST TST_bool = clang::TST_bool;
287  static const TST TST_enum = clang::TST_enum;
298  static const TST TST_auto = clang::TST_auto;
303 
304  // type-qualifiers
305  enum TQ { // NOTE: These flags must be kept in sync with Qualifiers::TQ.
307  TQ_const = 1,
310  // This has no corresponding Qualifiers::TQ value, because it's not treated
311  // as a qualifier in our type system.
313  };
314 
315  /// ParsedSpecifiers - Flags to query which specifiers were applied. This is
316  /// returned by getParsedSpecifiers.
318  PQ_None = 0,
323  };
324 
325 private:
326  // storage-class-specifier
327  /*SCS*/unsigned StorageClassSpec : 3;
328  /*TSCS*/unsigned ThreadStorageClassSpec : 2;
329  unsigned SCS_extern_in_linkage_spec : 1;
330 
331  // type-specifier
332  /*TSW*/unsigned TypeSpecWidth : 2;
333  /*TSC*/unsigned TypeSpecComplex : 2;
334  /*TSS*/unsigned TypeSpecSign : 2;
335  /*TST*/unsigned TypeSpecType : 6;
336  unsigned TypeAltiVecVector : 1;
337  unsigned TypeAltiVecPixel : 1;
338  unsigned TypeAltiVecBool : 1;
339  unsigned TypeSpecOwned : 1;
340  unsigned TypeSpecPipe : 1;
341 
342  // type-qualifiers
343  unsigned TypeQualifiers : 4; // Bitwise OR of TQ.
344 
345  // function-specifier
346  unsigned FS_inline_specified : 1;
347  unsigned FS_forceinline_specified: 1;
348  unsigned FS_virtual_specified : 1;
349  unsigned FS_explicit_specified : 1;
350  unsigned FS_noreturn_specified : 1;
351 
352  // friend-specifier
353  unsigned Friend_specified : 1;
354 
355  // constexpr-specifier
356  unsigned Constexpr_specified : 1;
357 
358  // concept-specifier
359  unsigned Concept_specified : 1;
360 
361  union {
365  };
366 
367  // attributes.
368  ParsedAttributes Attrs;
369 
370  // Scope specifier for the type spec, if applicable.
371  CXXScopeSpec TypeScope;
372 
373  // SourceLocation info. These are null if the item wasn't specified or if
374  // the setting was synthesized.
375  SourceRange Range;
376 
377  SourceLocation StorageClassSpecLoc, ThreadStorageClassSpecLoc;
378  SourceLocation TSWLoc, TSCLoc, TSSLoc, TSTLoc, AltiVecLoc;
379  /// TSTNameLoc - If TypeSpecType is any of class, enum, struct, union,
380  /// typename, then this is the location of the named type (if present);
381  /// otherwise, it is the same as TSTLoc. Hence, the pair TSTLoc and
382  /// TSTNameLoc provides source range info for tag types.
383  SourceLocation TSTNameLoc;
384  SourceRange TypeofParensRange;
385  SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc;
386  SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc;
387  SourceLocation FS_forceinlineLoc;
388  SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc, ConceptLoc;
389  SourceLocation TQ_pipeLoc;
390 
391  WrittenBuiltinSpecs writtenBS;
392  void SaveWrittenBuiltinSpecs();
393 
394  ObjCDeclSpec *ObjCQualifiers;
395 
396  static bool isTypeRep(TST T) {
397  return (T == TST_typename || T == TST_typeofType ||
398  T == TST_underlyingType || T == TST_atomic);
399  }
400  static bool isExprRep(TST T) {
401  return (T == TST_typeofExpr || T == TST_decltype);
402  }
403 
404  DeclSpec(const DeclSpec &) = delete;
405  void operator=(const DeclSpec &) = delete;
406 public:
407  static bool isDeclRep(TST T) {
408  return (T == TST_enum || T == TST_struct ||
409  T == TST_interface || T == TST_union ||
410  T == TST_class);
411  }
412 
414  : StorageClassSpec(SCS_unspecified),
415  ThreadStorageClassSpec(TSCS_unspecified),
416  SCS_extern_in_linkage_spec(false),
417  TypeSpecWidth(TSW_unspecified),
418  TypeSpecComplex(TSC_unspecified),
419  TypeSpecSign(TSS_unspecified),
420  TypeSpecType(TST_unspecified),
421  TypeAltiVecVector(false),
422  TypeAltiVecPixel(false),
423  TypeAltiVecBool(false),
424  TypeSpecOwned(false),
425  TypeSpecPipe(false),
426  TypeQualifiers(TQ_unspecified),
427  FS_inline_specified(false),
428  FS_forceinline_specified(false),
429  FS_virtual_specified(false),
430  FS_explicit_specified(false),
431  FS_noreturn_specified(false),
432  Friend_specified(false),
433  Constexpr_specified(false),
434  Concept_specified(false),
435  Attrs(attrFactory),
436  writtenBS(),
437  ObjCQualifiers(nullptr) {
438  }
439 
440  // storage-class-specifier
441  SCS getStorageClassSpec() const { return (SCS)StorageClassSpec; }
443  return (TSCS)ThreadStorageClassSpec;
444  }
445  bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
447  SCS_extern_in_linkage_spec = Value;
448  }
449 
450  SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
452  return ThreadStorageClassSpecLoc;
453  }
454 
456  StorageClassSpec = DeclSpec::SCS_unspecified;
457  ThreadStorageClassSpec = DeclSpec::TSCS_unspecified;
458  SCS_extern_in_linkage_spec = false;
459  StorageClassSpecLoc = SourceLocation();
460  ThreadStorageClassSpecLoc = SourceLocation();
461  }
462 
464  TypeSpecType = DeclSpec::TST_unspecified;
465  TypeSpecOwned = false;
466  TSTLoc = SourceLocation();
467  }
468 
469  // type-specifier
470  TSW getTypeSpecWidth() const { return (TSW)TypeSpecWidth; }
471  TSC getTypeSpecComplex() const { return (TSC)TypeSpecComplex; }
472  TSS getTypeSpecSign() const { return (TSS)TypeSpecSign; }
473  TST getTypeSpecType() const { return (TST)TypeSpecType; }
474  bool isTypeAltiVecVector() const { return TypeAltiVecVector; }
475  bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; }
476  bool isTypeAltiVecBool() const { return TypeAltiVecBool; }
477  bool isTypeSpecOwned() const { return TypeSpecOwned; }
478  bool isTypeRep() const { return isTypeRep((TST) TypeSpecType); }
479  bool isTypeSpecPipe() const { return TypeSpecPipe; }
480 
482  assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
483  return TypeRep;
484  }
485  Decl *getRepAsDecl() const {
486  assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
487  return DeclRep;
488  }
489  Expr *getRepAsExpr() const {
490  assert(isExprRep((TST) TypeSpecType) && "DeclSpec does not store an expr");
491  return ExprRep;
492  }
493  CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
494  const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
495 
496  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
497  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
498  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
499 
500  SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; }
501  SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
502  SourceLocation getTypeSpecSignLoc() const { return TSSLoc; }
503  SourceLocation getTypeSpecTypeLoc() const { return TSTLoc; }
504  SourceLocation getAltiVecLoc() const { return AltiVecLoc; }
505 
507  assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
508  return TSTNameLoc;
509  }
510 
511  SourceRange getTypeofParensRange() const { return TypeofParensRange; }
512  void setTypeofParensRange(SourceRange range) { TypeofParensRange = range; }
513 
514  bool containsPlaceholderType() const {
515  return (TypeSpecType == TST_auto || TypeSpecType == TST_auto_type ||
516  TypeSpecType == TST_decltype_auto);
517  }
518 
519  bool hasTagDefinition() const;
520 
521  /// \brief Turn a type-specifier-type into a string like "_Bool" or "union".
522  static const char *getSpecifierName(DeclSpec::TST T,
523  const PrintingPolicy &Policy);
524  static const char *getSpecifierName(DeclSpec::TQ Q);
525  static const char *getSpecifierName(DeclSpec::TSS S);
526  static const char *getSpecifierName(DeclSpec::TSC C);
527  static const char *getSpecifierName(DeclSpec::TSW W);
528  static const char *getSpecifierName(DeclSpec::SCS S);
529  static const char *getSpecifierName(DeclSpec::TSCS S);
530 
531  // type-qualifiers
532 
533  /// getTypeQualifiers - Return a set of TQs.
534  unsigned getTypeQualifiers() const { return TypeQualifiers; }
535  SourceLocation getConstSpecLoc() const { return TQ_constLoc; }
536  SourceLocation getRestrictSpecLoc() const { return TQ_restrictLoc; }
537  SourceLocation getVolatileSpecLoc() const { return TQ_volatileLoc; }
538  SourceLocation getAtomicSpecLoc() const { return TQ_atomicLoc; }
539  SourceLocation getPipeLoc() const { return TQ_pipeLoc; }
540 
541  /// \brief Clear out all of the type qualifiers.
543  TypeQualifiers = 0;
544  TQ_constLoc = SourceLocation();
545  TQ_restrictLoc = SourceLocation();
546  TQ_volatileLoc = SourceLocation();
547  TQ_atomicLoc = SourceLocation();
548  TQ_pipeLoc = SourceLocation();
549  }
550 
551  // function-specifier
552  bool isInlineSpecified() const {
553  return FS_inline_specified | FS_forceinline_specified;
554  }
556  return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
557  }
558 
559  bool isVirtualSpecified() const { return FS_virtual_specified; }
560  SourceLocation getVirtualSpecLoc() const { return FS_virtualLoc; }
561 
562  bool isExplicitSpecified() const { return FS_explicit_specified; }
563  SourceLocation getExplicitSpecLoc() const { return FS_explicitLoc; }
564 
565  bool isNoreturnSpecified() const { return FS_noreturn_specified; }
566  SourceLocation getNoreturnSpecLoc() const { return FS_noreturnLoc; }
567 
569  FS_inline_specified = false;
570  FS_inlineLoc = SourceLocation();
571  FS_forceinline_specified = false;
572  FS_forceinlineLoc = SourceLocation();
573  FS_virtual_specified = false;
574  FS_virtualLoc = SourceLocation();
575  FS_explicit_specified = false;
576  FS_explicitLoc = SourceLocation();
577  FS_noreturn_specified = false;
578  FS_noreturnLoc = SourceLocation();
579  }
580 
581  /// \brief Return true if any type-specifier has been found.
582  bool hasTypeSpecifier() const {
587  }
588 
589  /// \brief Return a bitmask of which flavors of specifiers this
590  /// DeclSpec includes.
591  unsigned getParsedSpecifiers() const;
592 
593  /// isEmpty - Return true if this declaration specifier is completely empty:
594  /// no tokens were parsed in the production of it.
595  bool isEmpty() const {
597  }
598 
599  void SetRangeStart(SourceLocation Loc) { Range.setBegin(Loc); }
600  void SetRangeEnd(SourceLocation Loc) { Range.setEnd(Loc); }
601 
602  /// These methods set the specified attribute of the DeclSpec and
603  /// return false if there was no error. If an error occurs (for
604  /// example, if we tried to set "auto" on a spec with "extern"
605  /// already set), they return true and set PrevSpec and DiagID
606  /// such that
607  /// Diag(Loc, DiagID) << PrevSpec;
608  /// will yield a useful result.
609  ///
610  /// TODO: use a more general approach that still allows these
611  /// diagnostics to be ignored when desired.
613  const char *&PrevSpec, unsigned &DiagID,
614  const PrintingPolicy &Policy);
616  const char *&PrevSpec, unsigned &DiagID);
617  bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec,
618  unsigned &DiagID, const PrintingPolicy &Policy);
619  bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec,
620  unsigned &DiagID);
621  bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
622  unsigned &DiagID);
623  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
624  unsigned &DiagID, const PrintingPolicy &Policy);
625  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
626  unsigned &DiagID, ParsedType Rep,
627  const PrintingPolicy &Policy);
628  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
629  unsigned &DiagID, Decl *Rep, bool Owned,
630  const PrintingPolicy &Policy);
631  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
632  SourceLocation TagNameLoc, const char *&PrevSpec,
633  unsigned &DiagID, ParsedType Rep,
634  const PrintingPolicy &Policy);
635  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
636  SourceLocation TagNameLoc, const char *&PrevSpec,
637  unsigned &DiagID, Decl *Rep, bool Owned,
638  const PrintingPolicy &Policy);
639 
640  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
641  unsigned &DiagID, Expr *Rep,
642  const PrintingPolicy &policy);
643  bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
644  const char *&PrevSpec, unsigned &DiagID,
645  const PrintingPolicy &Policy);
646  bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
647  const char *&PrevSpec, unsigned &DiagID,
648  const PrintingPolicy &Policy);
649  bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
650  const char *&PrevSpec, unsigned &DiagID,
651  const PrintingPolicy &Policy);
652  bool SetTypePipe(bool isPipe, SourceLocation Loc,
653  const char *&PrevSpec, unsigned &DiagID,
654  const PrintingPolicy &Policy);
655  bool SetTypeSpecError();
656  void UpdateDeclRep(Decl *Rep) {
657  assert(isDeclRep((TST) TypeSpecType));
658  DeclRep = Rep;
659  }
661  assert(isTypeRep((TST) TypeSpecType));
662  TypeRep = Rep;
663  }
664  void UpdateExprRep(Expr *Rep) {
665  assert(isExprRep((TST) TypeSpecType));
666  ExprRep = Rep;
667  }
668 
669  bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
670  unsigned &DiagID, const LangOptions &Lang);
671 
672  bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
673  unsigned &DiagID);
674  bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
675  unsigned &DiagID);
676  bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec,
677  unsigned &DiagID);
678  bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec,
679  unsigned &DiagID);
680  bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec,
681  unsigned &DiagID);
682 
683  bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
684  unsigned &DiagID);
685  bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
686  unsigned &DiagID);
687  bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
688  unsigned &DiagID);
689  bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec,
690  unsigned &DiagID);
691 
692  bool isFriendSpecified() const { return Friend_specified; }
693  SourceLocation getFriendSpecLoc() const { return FriendLoc; }
694 
695  bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); }
696  SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; }
697 
698  bool isConstexprSpecified() const { return Constexpr_specified; }
699  SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; }
700 
701  bool isConceptSpecified() const { return Concept_specified; }
702  SourceLocation getConceptSpecLoc() const { return ConceptLoc; }
703 
705  Constexpr_specified = false;
706  ConstexprLoc = SourceLocation();
707  }
708 
710  Concept_specified = false;
711  ConceptLoc = SourceLocation();
712  }
713 
715  return Attrs.getPool();
716  }
717 
718  /// \brief Concatenates two attribute lists.
719  ///
720  /// The GCC attribute syntax allows for the following:
721  ///
722  /// \code
723  /// short __attribute__(( unused, deprecated ))
724  /// int __attribute__(( may_alias, aligned(16) )) var;
725  /// \endcode
726  ///
727  /// This declares 4 attributes using 2 lists. The following syntax is
728  /// also allowed and equivalent to the previous declaration.
729  ///
730  /// \code
731  /// short __attribute__((unused)) __attribute__((deprecated))
732  /// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
733  /// \endcode
734  ///
736  Attrs.addAll(AL);
737  }
738 
739  bool hasAttributes() const { return !Attrs.empty(); }
740 
741  ParsedAttributes &getAttributes() { return Attrs; }
742  const ParsedAttributes &getAttributes() const { return Attrs; }
743 
745  Attrs.takeAllFrom(attrs);
746  }
747 
748  /// Finish - This does final analysis of the declspec, issuing diagnostics for
749  /// things like "_Imaginary" (lacking an FP type). After calling this method,
750  /// DeclSpec is guaranteed self-consistent, even if an error occurred.
751  void Finish(Sema &S, const PrintingPolicy &Policy);
752 
754  return writtenBS;
755  }
756 
757  ObjCDeclSpec *getObjCQualifiers() const { return ObjCQualifiers; }
758  void setObjCQualifiers(ObjCDeclSpec *quals) { ObjCQualifiers = quals; }
759 
760  /// \brief Checks if this DeclSpec can stand alone, without a Declarator.
761  ///
762  /// Only tag declspecs can stand alone.
763  bool isMissingDeclaratorOk();
764 };
765 
766 /// \brief Captures information about "declaration specifiers" specific to
767 /// Objective-C.
769 public:
770  /// ObjCDeclQualifier - Qualifier used on types in method
771  /// declarations. Not all combinations are sensible. Parameters
772  /// can be one of { in, out, inout } with one of { bycopy, byref }.
773  /// Returns can either be { oneway } or not.
774  ///
775  /// This should be kept in sync with Decl::ObjCDeclQualifier.
777  DQ_None = 0x0,
778  DQ_In = 0x1,
779  DQ_Inout = 0x2,
780  DQ_Out = 0x4,
781  DQ_Bycopy = 0x8,
782  DQ_Byref = 0x10,
783  DQ_Oneway = 0x20,
785  };
786 
787  /// PropertyAttributeKind - list of property attributes.
791  DQ_PR_getter = 0x02,
792  DQ_PR_assign = 0x04,
794  DQ_PR_retain = 0x10,
795  DQ_PR_copy = 0x20,
797  DQ_PR_setter = 0x80,
798  DQ_PR_atomic = 0x100,
799  DQ_PR_weak = 0x200,
800  DQ_PR_strong = 0x400,
804  };
805 
807  : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
808  Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
809 
810  ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }
812  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
813  }
815  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
816  }
817 
819  return ObjCPropertyAttributeKind(PropertyAttributes);
820  }
822  PropertyAttributes =
823  (ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
824  }
825 
827  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
829  "Objective-C declspec doesn't have nullability");
830  return static_cast<NullabilityKind>(Nullability);
831  }
832 
834  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
836  "Objective-C declspec doesn't have nullability");
837  return NullabilityLoc;
838  }
839 
841  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
843  "Set the nullability declspec or property attribute first");
844  Nullability = static_cast<unsigned>(kind);
845  NullabilityLoc = loc;
846  }
847 
848  const IdentifierInfo *getGetterName() const { return GetterName; }
849  IdentifierInfo *getGetterName() { return GetterName; }
850  void setGetterName(IdentifierInfo *name) { GetterName = name; }
851 
852  const IdentifierInfo *getSetterName() const { return SetterName; }
853  IdentifierInfo *getSetterName() { return SetterName; }
854  void setSetterName(IdentifierInfo *name) { SetterName = name; }
855 
856 private:
857  // FIXME: These two are unrelated and mutually exclusive. So perhaps
858  // we can put them in a union to reflect their mutual exclusivity
859  // (space saving is negligible).
860  ObjCDeclQualifier objcDeclQualifier : 7;
861 
862  // NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind
863  unsigned PropertyAttributes : 14;
864 
865  unsigned Nullability : 2;
866 
867  SourceLocation NullabilityLoc;
868 
869  IdentifierInfo *GetterName; // getter name or NULL if no getter
870  IdentifierInfo *SetterName; // setter name or NULL if no setter
871 };
872 
873 /// \brief Represents a C++ unqualified-id that has been parsed.
875 private:
876  UnqualifiedId(const UnqualifiedId &Other) = delete;
877  const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
878 
879 public:
880  /// \brief Describes the kind of unqualified-id parsed.
881  enum IdKind {
882  /// \brief An identifier.
884  /// \brief An overloaded operator name, e.g., operator+.
886  /// \brief A conversion function name, e.g., operator int.
888  /// \brief A user-defined literal name, e.g., operator "" _i.
890  /// \brief A constructor name.
892  /// \brief A constructor named via a template-id.
894  /// \brief A destructor name.
896  /// \brief A template-id, e.g., f<int>.
898  /// \brief An implicit 'self' parameter
900  } Kind;
901 
902  struct OFI {
903  /// \brief The kind of overloaded operator.
905 
906  /// \brief The source locations of the individual tokens that name
907  /// the operator, e.g., the "new", "[", and "]" tokens in
908  /// operator new [].
909  ///
910  /// Different operators have different numbers of tokens in their name,
911  /// up to three. Any remaining source locations in this array will be
912  /// set to an invalid value for operators with fewer than three tokens.
913  unsigned SymbolLocations[3];
914  };
915 
916  /// \brief Anonymous union that holds extra data associated with the
917  /// parsed unqualified-id.
918  union {
919  /// \brief When Kind == IK_Identifier, the parsed identifier, or when Kind
920  /// == IK_UserLiteralId, the identifier suffix.
922 
923  /// \brief When Kind == IK_OperatorFunctionId, the overloaded operator
924  /// that we parsed.
926 
927  /// \brief When Kind == IK_ConversionFunctionId, the type that the
928  /// conversion function names.
930 
931  /// \brief When Kind == IK_ConstructorName, the class-name of the type
932  /// whose constructor is being referenced.
934 
935  /// \brief When Kind == IK_DestructorName, the type referred to by the
936  /// class-name.
938 
939  /// \brief When Kind == IK_TemplateId or IK_ConstructorTemplateId,
940  /// the template-id annotation that contains the template name and
941  /// template arguments.
943  };
944 
945  /// \brief The location of the first token that describes this unqualified-id,
946  /// which will be the location of the identifier, "operator" keyword,
947  /// tilde (for a destructor), or the template name of a template-id.
949 
950  /// \brief The location of the last token that describes this unqualified-id.
952 
954 
955  /// \brief Clear out this unqualified-id, setting it to default (invalid)
956  /// state.
957  void clear() {
959  Identifier = nullptr;
962  }
963 
964  /// \brief Determine whether this unqualified-id refers to a valid name.
965  bool isValid() const { return StartLocation.isValid(); }
966 
967  /// \brief Determine whether this unqualified-id refers to an invalid name.
968  bool isInvalid() const { return !isValid(); }
969 
970  /// \brief Determine what kind of name we have.
971  IdKind getKind() const { return Kind; }
972  void setKind(IdKind kind) { Kind = kind; }
973 
974  /// \brief Specify that this unqualified-id was parsed as an identifier.
975  ///
976  /// \param Id the parsed identifier.
977  /// \param IdLoc the location of the parsed identifier.
978  void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc) {
980  Identifier = const_cast<IdentifierInfo *>(Id);
981  StartLocation = EndLocation = IdLoc;
982  }
983 
984  /// \brief Specify that this unqualified-id was parsed as an
985  /// operator-function-id.
986  ///
987  /// \param OperatorLoc the location of the 'operator' keyword.
988  ///
989  /// \param Op the overloaded operator.
990  ///
991  /// \param SymbolLocations the locations of the individual operator symbols
992  /// in the operator.
993  void setOperatorFunctionId(SourceLocation OperatorLoc,
995  SourceLocation SymbolLocations[3]);
996 
997  /// \brief Specify that this unqualified-id was parsed as a
998  /// conversion-function-id.
999  ///
1000  /// \param OperatorLoc the location of the 'operator' keyword.
1001  ///
1002  /// \param Ty the type to which this conversion function is converting.
1003  ///
1004  /// \param EndLoc the location of the last token that makes up the type name.
1006  ParsedType Ty,
1007  SourceLocation EndLoc) {
1009  StartLocation = OperatorLoc;
1010  EndLocation = EndLoc;
1011  ConversionFunctionId = Ty;
1012  }
1013 
1014  /// \brief Specific that this unqualified-id was parsed as a
1015  /// literal-operator-id.
1016  ///
1017  /// \param Id the parsed identifier.
1018  ///
1019  /// \param OpLoc the location of the 'operator' keyword.
1020  ///
1021  /// \param IdLoc the location of the identifier.
1023  SourceLocation IdLoc) {
1025  Identifier = const_cast<IdentifierInfo *>(Id);
1026  StartLocation = OpLoc;
1027  EndLocation = IdLoc;
1028  }
1029 
1030  /// \brief Specify that this unqualified-id was parsed as a constructor name.
1031  ///
1032  /// \param ClassType the class type referred to by the constructor name.
1033  ///
1034  /// \param ClassNameLoc the location of the class name.
1035  ///
1036  /// \param EndLoc the location of the last token that makes up the type name.
1038  SourceLocation ClassNameLoc,
1039  SourceLocation EndLoc) {
1041  StartLocation = ClassNameLoc;
1042  EndLocation = EndLoc;
1043  ConstructorName = ClassType;
1044  }
1045 
1046  /// \brief Specify that this unqualified-id was parsed as a
1047  /// template-id that names a constructor.
1048  ///
1049  /// \param TemplateId the template-id annotation that describes the parsed
1050  /// template-id. This UnqualifiedId instance will take ownership of the
1051  /// \p TemplateId and will free it on destruction.
1053 
1054  /// \brief Specify that this unqualified-id was parsed as a destructor name.
1055  ///
1056  /// \param TildeLoc the location of the '~' that introduces the destructor
1057  /// name.
1058  ///
1059  /// \param ClassType the name of the class referred to by the destructor name.
1061  ParsedType ClassType,
1062  SourceLocation EndLoc) {
1064  StartLocation = TildeLoc;
1065  EndLocation = EndLoc;
1066  DestructorName = ClassType;
1067  }
1068 
1069  /// \brief Specify that this unqualified-id was parsed as a template-id.
1070  ///
1071  /// \param TemplateId the template-id annotation that describes the parsed
1072  /// template-id. This UnqualifiedId instance will take ownership of the
1073  /// \p TemplateId and will free it on destruction.
1075 
1076  /// \brief Return the source range that covers this unqualified-id.
1077  SourceRange getSourceRange() const LLVM_READONLY {
1079  }
1080  SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
1081  SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
1082 };
1083 
1084 /// \brief A set of tokens that has been cached for later parsing.
1086 
1087 /// \brief One instance of this struct is used for each type in a
1088 /// declarator that is parsed.
1089 ///
1090 /// This is intended to be a small value object.
1092  enum {
1094  } Kind;
1095 
1096  /// Loc - The place where this type was defined.
1098  /// EndLoc - If valid, the place where this chunck ends.
1100 
1102  if (EndLoc.isInvalid())
1103  return SourceRange(Loc, Loc);
1104  return SourceRange(Loc, EndLoc);
1105  }
1106 
1109  };
1110 
1112  /// The type qualifiers: const/volatile/restrict/atomic.
1113  unsigned TypeQuals : 4;
1114 
1115  /// The location of the const-qualifier, if any.
1116  unsigned ConstQualLoc;
1117 
1118  /// The location of the volatile-qualifier, if any.
1120 
1121  /// The location of the restrict-qualifier, if any.
1123 
1124  /// The location of the _Atomic-qualifier, if any.
1125  unsigned AtomicQualLoc;
1126 
1127  void destroy() {
1128  }
1129  };
1130 
1132  /// The type qualifier: restrict. [GNU] C++ extension
1133  bool HasRestrict : 1;
1134  /// True if this is an lvalue reference, false if it's an rvalue reference.
1135  bool LValueRef : 1;
1136  void destroy() {
1137  }
1138  };
1139 
1141  /// The type qualifiers for the array: const/volatile/restrict/_Atomic.
1142  unsigned TypeQuals : 4;
1143 
1144  /// True if this dimension included the 'static' keyword.
1145  bool hasStatic : 1;
1146 
1147  /// True if this dimension was [*]. In this case, NumElts is null.
1148  bool isStar : 1;
1149 
1150  /// This is the size of the array, or null if [] or [*] was specified.
1151  /// Since the parser is multi-purpose, and we don't want to impose a root
1152  /// expression class on all clients, NumElts is untyped.
1154 
1155  void destroy() {}
1156  };
1157 
1158  /// ParamInfo - An array of paraminfo objects is allocated whenever a function
1159  /// declarator is parsed. There are two interesting styles of parameters
1160  /// here:
1161  /// K&R-style identifier lists and parameter type lists. K&R-style identifier
1162  /// lists will have information about the identifier, but no type information.
1163  /// Parameter type lists will have type info (if the actions module provides
1164  /// it), but may have null identifier info: e.g. for 'void foo(int X, int)'.
1165  struct ParamInfo {
1169 
1170  /// DefaultArgTokens - When the parameter's default argument
1171  /// cannot be parsed immediately (because it occurs within the
1172  /// declaration of a member function), it will be stored here as a
1173  /// sequence of tokens to be parsed once the class definition is
1174  /// complete. Non-NULL indicates that there is a default argument.
1176 
1179  Decl *param,
1180  CachedTokens *DefArgTokens = nullptr)
1181  : Ident(ident), IdentLoc(iloc), Param(param),
1182  DefaultArgTokens(DefArgTokens) {}
1183  };
1184 
1185  struct TypeAndRange {
1188  };
1189 
1191  /// hasPrototype - This is true if the function had at least one typed
1192  /// parameter. If the function is () or (a,b,c), then it has no prototype,
1193  /// and is treated as a K&R-style function.
1194  unsigned hasPrototype : 1;
1195 
1196  /// isVariadic - If this function has a prototype, and if that
1197  /// proto ends with ',...)', this is true. When true, EllipsisLoc
1198  /// contains the location of the ellipsis.
1199  unsigned isVariadic : 1;
1200 
1201  /// Can this declaration be a constructor-style initializer?
1202  unsigned isAmbiguous : 1;
1203 
1204  /// \brief Whether the ref-qualifier (if any) is an lvalue reference.
1205  /// Otherwise, it's an rvalue reference.
1207 
1208  /// The type qualifiers: const/volatile/restrict.
1209  /// The qualifier bitmask values are the same as in QualType.
1210  unsigned TypeQuals : 3;
1211 
1212  /// ExceptionSpecType - An ExceptionSpecificationType value.
1213  unsigned ExceptionSpecType : 4;
1214 
1215  /// DeleteParams - If this is true, we need to delete[] Params.
1216  unsigned DeleteParams : 1;
1217 
1218  /// HasTrailingReturnType - If this is true, a trailing return type was
1219  /// specified.
1221 
1222  /// The location of the left parenthesis in the source.
1223  unsigned LParenLoc;
1224 
1225  /// When isVariadic is true, the location of the ellipsis in the source.
1226  unsigned EllipsisLoc;
1227 
1228  /// The location of the right parenthesis in the source.
1229  unsigned RParenLoc;
1230 
1231  /// NumParams - This is the number of formal parameters specified by the
1232  /// declarator.
1233  unsigned NumParams;
1234 
1235  /// NumExceptions - This is the number of types in the dynamic-exception-
1236  /// decl, if the function has one.
1237  unsigned NumExceptions;
1238 
1239  /// \brief The location of the ref-qualifier, if any.
1240  ///
1241  /// If this is an invalid location, there is no ref-qualifier.
1243 
1244  /// \brief The location of the const-qualifier, if any.
1245  ///
1246  /// If this is an invalid location, there is no const-qualifier.
1248 
1249  /// \brief The location of the volatile-qualifier, if any.
1250  ///
1251  /// If this is an invalid location, there is no volatile-qualifier.
1253 
1254  /// \brief The location of the restrict-qualifier, if any.
1255  ///
1256  /// If this is an invalid location, there is no restrict-qualifier.
1258 
1259  /// \brief The location of the 'mutable' qualifer in a lambda-declarator, if
1260  /// any.
1261  unsigned MutableLoc;
1262 
1263  /// \brief The beginning location of the exception specification, if any.
1265 
1266  /// \brief The end location of the exception specification, if any.
1268 
1269  /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
1270  /// describe the parameters specified by this function declarator. null if
1271  /// there are no parameters specified.
1273 
1274  union {
1275  /// \brief Pointer to a new[]'d array of TypeAndRange objects that
1276  /// contain the types in the function's dynamic exception specification
1277  /// and their locations, if there is one.
1279 
1280  /// \brief Pointer to the expression in the noexcept-specifier of this
1281  /// function, if it has one.
1283 
1284  /// \brief Pointer to the cached tokens for an exception-specification
1285  /// that has not yet been parsed.
1287  };
1288 
1289  /// \brief If HasTrailingReturnType is true, this is the trailing return
1290  /// type specified.
1292 
1293  /// \brief Reset the parameter list to having zero parameters.
1294  ///
1295  /// This is used in various places for error recovery.
1296  void freeParams() {
1297  for (unsigned I = 0; I < NumParams; ++I) {
1298  delete Params[I].DefaultArgTokens;
1299  Params[I].DefaultArgTokens = nullptr;
1300  }
1301  if (DeleteParams) {
1302  delete[] Params;
1303  DeleteParams = false;
1304  }
1305  NumParams = 0;
1306  }
1307 
1308  void destroy() {
1309  if (DeleteParams)
1310  delete[] Params;
1312  delete[] Exceptions;
1313  else if (getExceptionSpecType() == EST_Unparsed)
1314  delete ExceptionSpecTokens;
1315  }
1316 
1317  /// isKNRPrototype - Return true if this is a K&R style identifier list,
1318  /// like "void foo(a,b,c)". In a function definition, this will be followed
1319  /// by the parameter type definitions.
1320  bool isKNRPrototype() const { return !hasPrototype && NumParams != 0; }
1321 
1324  }
1325 
1328  }
1329 
1332  }
1333 
1336  }
1337 
1340  }
1341 
1344  }
1345 
1346  /// \brief Retrieve the location of the ref-qualifier, if any.
1349  }
1350 
1351  /// \brief Retrieve the location of the 'const' qualifier, if any.
1354  }
1355 
1356  /// \brief Retrieve the location of the 'volatile' qualifier, if any.
1359  }
1360 
1361  /// \brief Retrieve the location of the 'restrict' qualifier, if any.
1364  }
1365 
1366  /// \brief Retrieve the location of the 'mutable' qualifier, if any.
1369  }
1370 
1371  /// \brief Determine whether this function declaration contains a
1372  /// ref-qualifier.
1373  bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); }
1374 
1375  /// \brief Determine whether this lambda-declarator contains a 'mutable'
1376  /// qualifier.
1377  bool hasMutableQualifier() const { return getMutableLoc().isValid(); }
1378 
1379  /// \brief Get the type of exception specification this function has.
1381  return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
1382  }
1383 
1384  /// \brief Determine whether this function declarator had a
1385  /// trailing-return-type.
1387 
1388  /// \brief Get the trailing-return-type for this function declarator.
1390  };
1391 
1393  /// For now, sema will catch these as invalid.
1394  /// The type qualifiers: const/volatile/restrict/_Atomic.
1395  unsigned TypeQuals : 4;
1396 
1397  void destroy() {
1398  }
1399  };
1400 
1402  /// The type qualifiers: const/volatile/restrict/_Atomic.
1403  unsigned TypeQuals : 4;
1404  // CXXScopeSpec has a constructor, so it can't be a direct member.
1405  // So we need some pointer-aligned storage and a bit of trickery.
1406  union {
1407  void *Aligner;
1408  char Mem[sizeof(CXXScopeSpec)];
1409  } ScopeMem;
1411  return *reinterpret_cast<CXXScopeSpec*>(ScopeMem.Mem);
1412  }
1413  const CXXScopeSpec &Scope() const {
1414  return *reinterpret_cast<const CXXScopeSpec*>(ScopeMem.Mem);
1415  }
1416  void destroy() {
1417  Scope().~CXXScopeSpec();
1418  }
1419  };
1420 
1422  /// The access writes.
1423  unsigned AccessWrites : 3;
1424 
1425  void destroy() {}
1426  };
1427 
1428  union {
1437  };
1438 
1439  void destroy() {
1440  switch (Kind) {
1441  case DeclaratorChunk::Function: return Fun.destroy();
1442  case DeclaratorChunk::Pointer: return Ptr.destroy();
1443  case DeclaratorChunk::BlockPointer: return Cls.destroy();
1444  case DeclaratorChunk::Reference: return Ref.destroy();
1445  case DeclaratorChunk::Array: return Arr.destroy();
1447  case DeclaratorChunk::Paren: return;
1448  case DeclaratorChunk::Pipe: return PipeInfo.destroy();
1449  }
1450  }
1451 
1452  /// \brief If there are attributes applied to this declaratorchunk, return
1453  /// them.
1454  const AttributeList *getAttrs() const {
1455  return Common.AttrList;
1456  }
1457 
1459  return Common.AttrList;
1460  }
1461 
1462  /// \brief Return a DeclaratorChunk for a pointer.
1463  static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc,
1464  SourceLocation ConstQualLoc,
1465  SourceLocation VolatileQualLoc,
1466  SourceLocation RestrictQualLoc,
1467  SourceLocation AtomicQualLoc) {
1469  I.Kind = Pointer;
1470  I.Loc = Loc;
1471  I.Ptr.TypeQuals = TypeQuals;
1472  I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding();
1473  I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding();
1474  I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding();
1475  I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding();
1476  I.Ptr.AttrList = nullptr;
1477  return I;
1478  }
1479 
1480  /// \brief Return a DeclaratorChunk for a reference.
1481  static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc,
1482  bool lvalue) {
1484  I.Kind = Reference;
1485  I.Loc = Loc;
1486  I.Ref.HasRestrict = (TypeQuals & DeclSpec::TQ_restrict) != 0;
1487  I.Ref.LValueRef = lvalue;
1488  I.Ref.AttrList = nullptr;
1489  return I;
1490  }
1491 
1492  /// \brief Return a DeclaratorChunk for an array.
1493  static DeclaratorChunk getArray(unsigned TypeQuals,
1494  bool isStatic, bool isStar, Expr *NumElts,
1495  SourceLocation LBLoc, SourceLocation RBLoc) {
1497  I.Kind = Array;
1498  I.Loc = LBLoc;
1499  I.EndLoc = RBLoc;
1500  I.Arr.AttrList = nullptr;
1501  I.Arr.TypeQuals = TypeQuals;
1502  I.Arr.hasStatic = isStatic;
1503  I.Arr.isStar = isStar;
1504  I.Arr.NumElts = NumElts;
1505  return I;
1506  }
1507 
1508  /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
1509  /// "TheDeclarator" is the declarator that this will be added to.
1510  static DeclaratorChunk getFunction(bool HasProto,
1511  bool IsAmbiguous,
1512  SourceLocation LParenLoc,
1513  ParamInfo *Params, unsigned NumParams,
1514  SourceLocation EllipsisLoc,
1515  SourceLocation RParenLoc,
1516  unsigned TypeQuals,
1517  bool RefQualifierIsLvalueRef,
1518  SourceLocation RefQualifierLoc,
1519  SourceLocation ConstQualifierLoc,
1520  SourceLocation VolatileQualifierLoc,
1521  SourceLocation RestrictQualifierLoc,
1522  SourceLocation MutableLoc,
1523  ExceptionSpecificationType ESpecType,
1524  SourceRange ESpecRange,
1525  ParsedType *Exceptions,
1526  SourceRange *ExceptionRanges,
1527  unsigned NumExceptions,
1528  Expr *NoexceptExpr,
1529  CachedTokens *ExceptionSpecTokens,
1530  SourceLocation LocalRangeBegin,
1531  SourceLocation LocalRangeEnd,
1532  Declarator &TheDeclarator,
1533  TypeResult TrailingReturnType =
1534  TypeResult());
1535 
1536  /// \brief Return a DeclaratorChunk for a block.
1537  static DeclaratorChunk getBlockPointer(unsigned TypeQuals,
1538  SourceLocation Loc) {
1540  I.Kind = BlockPointer;
1541  I.Loc = Loc;
1542  I.Cls.TypeQuals = TypeQuals;
1543  I.Cls.AttrList = nullptr;
1544  return I;
1545  }
1546 
1547  /// \brief Return a DeclaratorChunk for a block.
1548  static DeclaratorChunk getPipe(unsigned TypeQuals,
1549  SourceLocation Loc) {
1551  I.Kind = Pipe;
1552  I.Loc = Loc;
1553  I.Cls.TypeQuals = TypeQuals;
1554  I.Cls.AttrList = 0;
1555  return I;
1556  }
1557 
1559  unsigned TypeQuals,
1560  SourceLocation Loc) {
1562  I.Kind = MemberPointer;
1563  I.Loc = SS.getBeginLoc();
1564  I.EndLoc = Loc;
1565  I.Mem.TypeQuals = TypeQuals;
1566  I.Mem.AttrList = nullptr;
1567  new (I.Mem.ScopeMem.Mem) CXXScopeSpec(SS);
1568  return I;
1569  }
1570 
1571  /// \brief Return a DeclaratorChunk for a paren.
1573  SourceLocation RParenLoc) {
1575  I.Kind = Paren;
1576  I.Loc = LParenLoc;
1577  I.EndLoc = RParenLoc;
1578  I.Common.AttrList = nullptr;
1579  return I;
1580  }
1581 
1582  bool isParen() const {
1583  return Kind == Paren;
1584  }
1585 };
1586 
1587 /// \brief Described the kind of function definition (if any) provided for
1588 /// a function.
1594 };
1595 
1596 /// \brief Information about one declarator, including the parsed type
1597 /// information and the identifier.
1598 ///
1599 /// When the declarator is fully formed, this is turned into the appropriate
1600 /// Decl object.
1601 ///
1602 /// Declarators come in two types: normal declarators and abstract declarators.
1603 /// Abstract declarators are used when parsing types, and don't have an
1604 /// identifier. Normal declarators do have ID's.
1605 ///
1606 /// Instances of this class should be a transient object that lives on the
1607 /// stack, not objects that are allocated in large quantities on the heap.
1608 class Declarator {
1609 public:
1610  enum TheContext {
1611  FileContext, // File scope declaration.
1612  PrototypeContext, // Within a function prototype.
1613  ObjCResultContext, // An ObjC method result type.
1614  ObjCParameterContext,// An ObjC method parameter type.
1615  KNRTypeListContext, // K&R type definition list for formals.
1616  TypeNameContext, // Abstract declarator for types.
1617  MemberContext, // Struct/Union field.
1618  BlockContext, // Declaration within a block in a function.
1619  ForContext, // Declaration within first part of a for loop.
1620  ConditionContext, // Condition declaration in a C++ if/switch/while/for.
1621  TemplateParamContext,// Within a template parameter list.
1622  CXXNewContext, // C++ new-expression.
1623  CXXCatchContext, // C++ catch exception-declaration
1624  ObjCCatchContext, // Objective-C catch exception-declaration
1625  BlockLiteralContext, // Block literal declarator.
1626  LambdaExprContext, // Lambda-expression declarator.
1627  LambdaExprParameterContext, // Lambda-expression parameter declarator.
1628  ConversionIdContext, // C++ conversion-type-id.
1629  TrailingReturnContext, // C++11 trailing-type-specifier.
1630  TemplateTypeArgContext, // Template type argument.
1631  AliasDeclContext, // C++11 alias-declaration.
1632  AliasTemplateContext // C++11 alias-declaration template.
1633  };
1634 
1635 private:
1636  const DeclSpec &DS;
1637  CXXScopeSpec SS;
1638  UnqualifiedId Name;
1639  SourceRange Range;
1640 
1641  /// \brief Where we are parsing this declarator.
1642  TheContext Context;
1643 
1644  /// DeclTypeInfo - This holds each type that the declarator includes as it is
1645  /// parsed. This is pushed from the identifier out, which means that element
1646  /// #0 will be the most closely bound to the identifier, and
1647  /// DeclTypeInfo.back() will be the least closely bound.
1648  SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
1649 
1650  /// InvalidType - Set by Sema::GetTypeForDeclarator().
1651  bool InvalidType : 1;
1652 
1653  /// GroupingParens - Set by Parser::ParseParenDeclarator().
1654  bool GroupingParens : 1;
1655 
1656  /// FunctionDefinition - Is this Declarator for a function or member
1657  /// definition and, if so, what kind?
1658  ///
1659  /// Actually a FunctionDefinitionKind.
1660  unsigned FunctionDefinition : 2;
1661 
1662  /// \brief Is this Declarator a redeclaration?
1663  bool Redeclaration : 1;
1664 
1665  /// Attrs - Attributes.
1666  ParsedAttributes Attrs;
1667 
1668  /// \brief The asm label, if specified.
1669  Expr *AsmLabel;
1670 
1671  /// InlineParams - This is a local array used for the first function decl
1672  /// chunk to avoid going to the heap for the common case when we have one
1673  /// function chunk in the declarator.
1674  DeclaratorChunk::ParamInfo InlineParams[16];
1675  bool InlineParamsUsed;
1676 
1677  /// \brief true if the declaration is preceded by \c __extension__.
1678  unsigned Extension : 1;
1679 
1680  /// Indicates whether this is an Objective-C instance variable.
1681  unsigned ObjCIvar : 1;
1682 
1683  /// Indicates whether this is an Objective-C 'weak' property.
1684  unsigned ObjCWeakProperty : 1;
1685 
1686  /// \brief If this is the second or subsequent declarator in this declaration,
1687  /// the location of the comma before this declarator.
1688  SourceLocation CommaLoc;
1689 
1690  /// \brief If provided, the source location of the ellipsis used to describe
1691  /// this declarator as a parameter pack.
1692  SourceLocation EllipsisLoc;
1693 
1694  friend struct DeclaratorChunk;
1695 
1696 public:
1698  : DS(ds), Range(ds.getSourceRange()), Context(C),
1699  InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error),
1700  GroupingParens(false), FunctionDefinition(FDK_Declaration),
1701  Redeclaration(false),
1702  Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr),
1703  InlineParamsUsed(false), Extension(false), ObjCIvar(false),
1704  ObjCWeakProperty(false) {
1705  }
1706 
1708  clear();
1709  }
1710  /// getDeclSpec - Return the declaration-specifier that this declarator was
1711  /// declared with.
1712  const DeclSpec &getDeclSpec() const { return DS; }
1713 
1714  /// getMutableDeclSpec - Return a non-const version of the DeclSpec. This
1715  /// should be used with extreme care: declspecs can often be shared between
1716  /// multiple declarators, so mutating the DeclSpec affects all of the
1717  /// Declarators. This should only be done when the declspec is known to not
1718  /// be shared or when in error recovery etc.
1719  DeclSpec &getMutableDeclSpec() { return const_cast<DeclSpec &>(DS); }
1720 
1722  return Attrs.getPool();
1723  }
1724 
1725  /// getCXXScopeSpec - Return the C++ scope specifier (global scope or
1726  /// nested-name-specifier) that is part of the declarator-id.
1727  const CXXScopeSpec &getCXXScopeSpec() const { return SS; }
1728  CXXScopeSpec &getCXXScopeSpec() { return SS; }
1729 
1730  /// \brief Retrieve the name specified by this declarator.
1731  UnqualifiedId &getName() { return Name; }
1732 
1733  TheContext getContext() const { return Context; }
1734 
1735  bool isPrototypeContext() const {
1736  return (Context == PrototypeContext ||
1740  }
1741 
1742  /// \brief Get the source range that spans this declarator.
1743  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1744  SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
1745  SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
1746 
1747  void SetSourceRange(SourceRange R) { Range = R; }
1748  /// SetRangeBegin - Set the start of the source range to Loc, unless it's
1749  /// invalid.
1751  if (!Loc.isInvalid())
1752  Range.setBegin(Loc);
1753  }
1754  /// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
1756  if (!Loc.isInvalid())
1757  Range.setEnd(Loc);
1758  }
1759  /// ExtendWithDeclSpec - Extend the declarator source range to include the
1760  /// given declspec, unless its location is invalid. Adopts the range start if
1761  /// the current range start is invalid.
1762  void ExtendWithDeclSpec(const DeclSpec &DS) {
1763  SourceRange SR = DS.getSourceRange();
1764  if (Range.getBegin().isInvalid())
1765  Range.setBegin(SR.getBegin());
1766  if (!SR.getEnd().isInvalid())
1767  Range.setEnd(SR.getEnd());
1768  }
1769 
1770  /// \brief Reset the contents of this Declarator.
1771  void clear() {
1772  SS.clear();
1773  Name.clear();
1774  Range = DS.getSourceRange();
1775 
1776  for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
1777  DeclTypeInfo[i].destroy();
1778  DeclTypeInfo.clear();
1779  Attrs.clear();
1780  AsmLabel = nullptr;
1781  InlineParamsUsed = false;
1782  ObjCIvar = false;
1783  ObjCWeakProperty = false;
1784  CommaLoc = SourceLocation();
1785  EllipsisLoc = SourceLocation();
1786  }
1787 
1788  /// mayOmitIdentifier - Return true if the identifier is either optional or
1789  /// not allowed. This is true for typenames, prototypes, and template
1790  /// parameter lists.
1791  bool mayOmitIdentifier() const {
1792  switch (Context) {
1793  case FileContext:
1794  case KNRTypeListContext:
1795  case MemberContext:
1796  case BlockContext:
1797  case ForContext:
1798  case ConditionContext:
1799  return false;
1800 
1801  case TypeNameContext:
1802  case AliasDeclContext:
1803  case AliasTemplateContext:
1804  case PrototypeContext:
1806  case ObjCParameterContext:
1807  case ObjCResultContext:
1808  case TemplateParamContext:
1809  case CXXNewContext:
1810  case CXXCatchContext:
1811  case ObjCCatchContext:
1812  case BlockLiteralContext:
1813  case LambdaExprContext:
1814  case ConversionIdContext:
1816  case TrailingReturnContext:
1817  return true;
1818  }
1819  llvm_unreachable("unknown context kind!");
1820  }
1821 
1822  /// mayHaveIdentifier - Return true if the identifier is either optional or
1823  /// required. This is true for normal declarators and prototypes, but not
1824  /// typenames.
1825  bool mayHaveIdentifier() const {
1826  switch (Context) {
1827  case FileContext:
1828  case KNRTypeListContext:
1829  case MemberContext:
1830  case BlockContext:
1831  case ForContext:
1832  case ConditionContext:
1833  case PrototypeContext:
1835  case TemplateParamContext:
1836  case CXXCatchContext:
1837  case ObjCCatchContext:
1838  return true;
1839 
1840  case TypeNameContext:
1841  case CXXNewContext:
1842  case AliasDeclContext:
1843  case AliasTemplateContext:
1844  case ObjCParameterContext:
1845  case ObjCResultContext:
1846  case BlockLiteralContext:
1847  case LambdaExprContext:
1848  case ConversionIdContext:
1850  case TrailingReturnContext:
1851  return false;
1852  }
1853  llvm_unreachable("unknown context kind!");
1854  }
1855 
1856  /// diagnoseIdentifier - Return true if the identifier is prohibited and
1857  /// should be diagnosed (because it cannot be anything else).
1858  bool diagnoseIdentifier() const {
1859  switch (Context) {
1860  case FileContext:
1861  case KNRTypeListContext:
1862  case MemberContext:
1863  case BlockContext:
1864  case ForContext:
1865  case ConditionContext:
1866  case PrototypeContext:
1868  case TemplateParamContext:
1869  case CXXCatchContext:
1870  case ObjCCatchContext:
1871  case TypeNameContext:
1872  case ConversionIdContext:
1873  case ObjCParameterContext:
1874  case ObjCResultContext:
1875  case BlockLiteralContext:
1876  case CXXNewContext:
1877  case LambdaExprContext:
1878  return false;
1879 
1880  case AliasDeclContext:
1881  case AliasTemplateContext:
1883  case TrailingReturnContext:
1884  return true;
1885  }
1886  llvm_unreachable("unknown context kind!");
1887  }
1888 
1889  /// mayBeFollowedByCXXDirectInit - Return true if the declarator can be
1890  /// followed by a C++ direct initializer, e.g. "int x(1);".
1892  if (hasGroupingParens()) return false;
1893 
1894  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
1895  return false;
1896 
1897  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern &&
1898  Context != FileContext)
1899  return false;
1900 
1901  // Special names can't have direct initializers.
1902  if (Name.getKind() != UnqualifiedId::IK_Identifier)
1903  return false;
1904 
1905  switch (Context) {
1906  case FileContext:
1907  case BlockContext:
1908  case ForContext:
1909  return true;
1910 
1911  case ConditionContext:
1912  // This may not be followed by a direct initializer, but it can't be a
1913  // function declaration either, and we'd prefer to perform a tentative
1914  // parse in order to produce the right diagnostic.
1915  return true;
1916 
1917  case KNRTypeListContext:
1918  case MemberContext:
1919  case PrototypeContext:
1921  case ObjCParameterContext:
1922  case ObjCResultContext:
1923  case TemplateParamContext:
1924  case CXXCatchContext:
1925  case ObjCCatchContext:
1926  case TypeNameContext:
1927  case CXXNewContext:
1928  case AliasDeclContext:
1929  case AliasTemplateContext:
1930  case BlockLiteralContext:
1931  case LambdaExprContext:
1932  case ConversionIdContext:
1934  case TrailingReturnContext:
1935  return false;
1936  }
1937  llvm_unreachable("unknown context kind!");
1938  }
1939 
1940  /// isPastIdentifier - Return true if we have parsed beyond the point where
1941  /// the
1942  bool isPastIdentifier() const { return Name.isValid(); }
1943 
1944  /// hasName - Whether this declarator has a name, which might be an
1945  /// identifier (accessible via getIdentifier()) or some kind of
1946  /// special C++ name (constructor, destructor, etc.).
1947  bool hasName() const {
1948  return Name.getKind() != UnqualifiedId::IK_Identifier || Name.Identifier;
1949  }
1950 
1952  if (Name.getKind() == UnqualifiedId::IK_Identifier)
1953  return Name.Identifier;
1954 
1955  return nullptr;
1956  }
1957  SourceLocation getIdentifierLoc() const { return Name.StartLocation; }
1958 
1959  /// \brief Set the name of this declarator to be the given identifier.
1961  Name.setIdentifier(Id, IdLoc);
1962  }
1963 
1964  /// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
1965  /// EndLoc, which should be the last token of the chunk.
1967  ParsedAttributes &attrs,
1968  SourceLocation EndLoc) {
1969  DeclTypeInfo.push_back(TI);
1970  DeclTypeInfo.back().getAttrListRef() = attrs.getList();
1972 
1973  if (!EndLoc.isInvalid())
1974  SetRangeEnd(EndLoc);
1975  }
1976 
1977  /// \brief Add a new innermost chunk to this declarator.
1979  DeclTypeInfo.insert(DeclTypeInfo.begin(), TI);
1980  }
1981 
1982  /// \brief Return the number of types applied to this declarator.
1983  unsigned getNumTypeObjects() const { return DeclTypeInfo.size(); }
1984 
1985  /// Return the specified TypeInfo from this declarator. TypeInfo #0 is
1986  /// closest to the identifier.
1987  const DeclaratorChunk &getTypeObject(unsigned i) const {
1988  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
1989  return DeclTypeInfo[i];
1990  }
1992  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
1993  return DeclTypeInfo[i];
1994  }
1995 
1997  typedef llvm::iterator_range<type_object_iterator> type_object_range;
1998 
1999  /// Returns the range of type objects, from the identifier outwards.
2001  return type_object_range(DeclTypeInfo.begin(), DeclTypeInfo.end());
2002  }
2003 
2005  assert(!DeclTypeInfo.empty() && "No type chunks to drop.");
2006  DeclTypeInfo.front().destroy();
2007  DeclTypeInfo.erase(DeclTypeInfo.begin());
2008  }
2009 
2010  /// Return the innermost (closest to the declarator) chunk of this
2011  /// declarator that is not a parens chunk, or null if there are no
2012  /// non-parens chunks.
2014  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2015  if (!DeclTypeInfo[i].isParen())
2016  return &DeclTypeInfo[i];
2017  }
2018  return nullptr;
2019  }
2020 
2021  /// Return the outermost (furthest from the declarator) chunk of
2022  /// this declarator that is not a parens chunk, or null if there are
2023  /// no non-parens chunks.
2025  for (unsigned i = DeclTypeInfo.size(), i_end = 0; i != i_end; --i) {
2026  if (!DeclTypeInfo[i-1].isParen())
2027  return &DeclTypeInfo[i-1];
2028  }
2029  return nullptr;
2030  }
2031 
2032  /// isArrayOfUnknownBound - This method returns true if the declarator
2033  /// is a declarator for an array of unknown bound (looking through
2034  /// parentheses).
2035  bool isArrayOfUnknownBound() const {
2036  const DeclaratorChunk *chunk = getInnermostNonParenChunk();
2037  return (chunk && chunk->Kind == DeclaratorChunk::Array &&
2038  !chunk->Arr.NumElts);
2039  }
2040 
2041  /// isFunctionDeclarator - This method returns true if the declarator
2042  /// is a function declarator (looking through parentheses).
2043  /// If true is returned, then the reference type parameter idx is
2044  /// assigned with the index of the declaration chunk.
2045  bool isFunctionDeclarator(unsigned& idx) const {
2046  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2047  switch (DeclTypeInfo[i].Kind) {
2049  idx = i;
2050  return true;
2052  continue;
2058  case DeclaratorChunk::Pipe:
2059  return false;
2060  }
2061  llvm_unreachable("Invalid type chunk");
2062  }
2063  return false;
2064  }
2065 
2066  /// isFunctionDeclarator - Once this declarator is fully parsed and formed,
2067  /// this method returns true if the identifier is a function declarator
2068  /// (looking through parentheses).
2069  bool isFunctionDeclarator() const {
2070  unsigned index;
2071  return isFunctionDeclarator(index);
2072  }
2073 
2074  /// getFunctionTypeInfo - Retrieves the function type info object
2075  /// (looking through parentheses).
2077  assert(isFunctionDeclarator() && "Not a function declarator!");
2078  unsigned index = 0;
2079  isFunctionDeclarator(index);
2080  return DeclTypeInfo[index].Fun;
2081  }
2082 
2083  /// getFunctionTypeInfo - Retrieves the function type info object
2084  /// (looking through parentheses).
2086  return const_cast<Declarator*>(this)->getFunctionTypeInfo();
2087  }
2088 
2089  /// \brief Determine whether the declaration that will be produced from
2090  /// this declaration will be a function.
2091  ///
2092  /// A declaration can declare a function even if the declarator itself
2093  /// isn't a function declarator, if the type specifier refers to a function
2094  /// type. This routine checks for both cases.
2095  bool isDeclarationOfFunction() const;
2096 
2097  /// \brief Return true if this declaration appears in a context where a
2098  /// function declarator would be a function declaration.
2100  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2101  return false;
2102 
2103  switch (Context) {
2104  case FileContext:
2105  case MemberContext:
2106  case BlockContext:
2107  return true;
2108 
2109  case ForContext:
2110  case ConditionContext:
2111  case KNRTypeListContext:
2112  case TypeNameContext:
2113  case AliasDeclContext:
2114  case AliasTemplateContext:
2115  case PrototypeContext:
2117  case ObjCParameterContext:
2118  case ObjCResultContext:
2119  case TemplateParamContext:
2120  case CXXNewContext:
2121  case CXXCatchContext:
2122  case ObjCCatchContext:
2123  case BlockLiteralContext:
2124  case LambdaExprContext:
2125  case ConversionIdContext:
2127  case TrailingReturnContext:
2128  return false;
2129  }
2130  llvm_unreachable("unknown context kind!");
2131  }
2132 
2133  /// \brief Return true if a function declarator at this position would be a
2134  /// function declaration.
2137  return false;
2138 
2139  for (unsigned I = 0, N = getNumTypeObjects(); I != N; ++I)
2141  return false;
2142 
2143  return true;
2144  }
2145 
2146  /// takeAttributes - Takes attributes from the given parsed-attributes
2147  /// set and add them to this declarator.
2148  ///
2149  /// These examples both add 3 attributes to "var":
2150  /// short int var __attribute__((aligned(16),common,deprecated));
2151  /// short int x, __attribute__((aligned(16)) var
2152  /// __attribute__((common,deprecated));
2153  ///
2154  /// Also extends the range of the declarator.
2156  Attrs.takeAllFrom(attrs);
2157 
2158  if (!lastLoc.isInvalid())
2159  SetRangeEnd(lastLoc);
2160  }
2161 
2162  const AttributeList *getAttributes() const { return Attrs.getList(); }
2163  AttributeList *getAttributes() { return Attrs.getList(); }
2164 
2165  AttributeList *&getAttrListRef() { return Attrs.getListRef(); }
2166 
2167  /// hasAttributes - do we contain any attributes?
2168  bool hasAttributes() const {
2169  if (getAttributes() || getDeclSpec().hasAttributes()) return true;
2170  for (unsigned i = 0, e = getNumTypeObjects(); i != e; ++i)
2171  if (getTypeObject(i).getAttrs())
2172  return true;
2173  return false;
2174  }
2175 
2176  /// \brief Return a source range list of C++11 attributes associated
2177  /// with the declarator.
2179  AttributeList *AttrList = Attrs.getList();
2180  while (AttrList) {
2181  if (AttrList->isCXX11Attribute())
2182  Ranges.push_back(AttrList->getRange());
2183  AttrList = AttrList->getNext();
2184  }
2185  }
2186 
2187  void setAsmLabel(Expr *E) { AsmLabel = E; }
2188  Expr *getAsmLabel() const { return AsmLabel; }
2189 
2190  void setExtension(bool Val = true) { Extension = Val; }
2191  bool getExtension() const { return Extension; }
2192 
2193  void setObjCIvar(bool Val = true) { ObjCIvar = Val; }
2194  bool isObjCIvar() const { return ObjCIvar; }
2195 
2196  void setObjCWeakProperty(bool Val = true) { ObjCWeakProperty = Val; }
2197  bool isObjCWeakProperty() const { return ObjCWeakProperty; }
2198 
2199  void setInvalidType(bool Val = true) { InvalidType = Val; }
2200  bool isInvalidType() const {
2201  return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
2202  }
2203 
2204  void setGroupingParens(bool flag) { GroupingParens = flag; }
2205  bool hasGroupingParens() const { return GroupingParens; }
2206 
2207  bool isFirstDeclarator() const { return !CommaLoc.isValid(); }
2208  SourceLocation getCommaLoc() const { return CommaLoc; }
2209  void setCommaLoc(SourceLocation CL) { CommaLoc = CL; }
2210 
2211  bool hasEllipsis() const { return EllipsisLoc.isValid(); }
2212  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
2213  void setEllipsisLoc(SourceLocation EL) { EllipsisLoc = EL; }
2214 
2216  FunctionDefinition = Val;
2217  }
2218 
2219  bool isFunctionDefinition() const {
2221  }
2222 
2224  return (FunctionDefinitionKind)FunctionDefinition;
2225  }
2226 
2227  /// Returns true if this declares a real member and not a friend.
2230  }
2231 
2232  /// Returns true if this declares a static member. This cannot be called on a
2233  /// declarator outside of a MemberContext because we won't know until
2234  /// redeclaration time if the decl is static.
2235  bool isStaticMember();
2236 
2237  /// Returns true if this declares a constructor or a destructor.
2238  bool isCtorOrDtor();
2239 
2240  void setRedeclaration(bool Val) { Redeclaration = Val; }
2241  bool isRedeclaration() const { return Redeclaration; }
2242 };
2243 
2244 /// \brief This little struct is used to capture information about
2245 /// structure field declarators, which is basically just a bitfield size.
2249  explicit FieldDeclarator(const DeclSpec &DS)
2250  : D(DS, Declarator::MemberContext), BitfieldSize(nullptr) { }
2251 };
2252 
2253 /// \brief Represents a C++11 virt-specifier-seq.
2255 public:
2256  enum Specifier {
2257  VS_None = 0,
2261  };
2262 
2263  VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
2264 
2265  bool SetSpecifier(Specifier VS, SourceLocation Loc,
2266  const char *&PrevSpec);
2267 
2268  bool isUnset() const { return Specifiers == 0; }
2269 
2270  bool isOverrideSpecified() const { return Specifiers & VS_Override; }
2271  SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
2272 
2273  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed); }
2274  bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; }
2275  SourceLocation getFinalLoc() const { return VS_finalLoc; }
2276 
2277  void clear() { Specifiers = 0; }
2278 
2279  static const char *getSpecifierName(Specifier VS);
2280 
2281  SourceLocation getFirstLocation() const { return FirstLocation; }
2282  SourceLocation getLastLocation() const { return LastLocation; }
2283  Specifier getLastSpecifier() const { return LastSpecifier; }
2284 
2285 private:
2286  unsigned Specifiers;
2287  Specifier LastSpecifier;
2288 
2289  SourceLocation VS_overrideLoc, VS_finalLoc;
2290  SourceLocation FirstLocation;
2291  SourceLocation LastLocation;
2292 };
2293 
2295  NoInit, //!< [a]
2296  CopyInit, //!< [a = b], [a = {b}]
2297  DirectInit, //!< [a(b)]
2298  ListInit //!< [a{b}]
2299 };
2300 
2301 /// \brief Represents a complete lambda introducer.
2303  /// \brief An individual capture in a lambda introducer.
2304  struct LambdaCapture {
2316  : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc),
2317  InitKind(InitKind), Init(Init), InitCaptureType(InitCaptureType) {}
2318  };
2319 
2324 
2326  : Default(LCD_None) {}
2327 
2328  /// \brief Append a capture in a lambda introducer.
2330  SourceLocation Loc,
2331  IdentifierInfo* Id,
2332  SourceLocation EllipsisLoc,
2333  LambdaCaptureInitKind InitKind,
2334  ExprResult Init,
2335  ParsedType InitCaptureType) {
2336  Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
2337  InitCaptureType));
2338  }
2339 };
2340 
2341 } // end namespace clang
2342 
2343 #endif
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1081
void ClearFunctionSpecs()
Definition: DeclSpec.h:568
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:451
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:1037
IdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:971
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2076
unsigned MutableLoc
The location of the 'mutable' qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1261
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:1206
SourceLocation getRestrictSpecLoc() const
Definition: DeclSpec.h:536
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:2168
void clear()
Reset the contents of this Declarator.
Definition: DeclSpec.h:1771
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Definition: DeclSpec.h:1454
SourceLocation getConstSpecLoc() const
Definition: DeclSpec.h:535
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:563
TSW getTypeSpecWidth() const
Definition: DeclSpec.h:470
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
Definition: DeclSpec.h:1077
static const TSS TSS_unsigned
Definition: DeclSpec.h:268
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1257
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:948
const DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo() const
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2085
TheContext getContext() const
Definition: DeclSpec.h:1733
static const TST TST_wchar
Definition: DeclSpec.h:275
Decl * getRepAsDecl() const
Definition: DeclSpec.h:485
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:2035
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:742
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Definition: DeclSpec.h:921
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:271
UnionParsedType TypeRep
Definition: DeclSpec.h:362
CachedTokens * DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
Definition: DeclSpec.h:1175
A conversion function name, e.g., operator int.
Definition: DeclSpec.h:887
void setEndLoc(SourceLocation Loc)
Definition: DeclSpec.h:71
static const TST TST_typeofExpr
Definition: DeclSpec.h:294
static const TST TST_char16
Definition: DeclSpec.h:276
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal)
Definition: DeclSpec.h:821
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:77
SourceRange getRange() const
unsigned ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1264
bool isTypeAltiVecBool() const
Definition: DeclSpec.h:476
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:897
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:768
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
AttributePool & getAttributePool() const
Definition: DeclSpec.h:1721
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1226
SCS getStorageClassSpec() const
Definition: DeclSpec.h:441
FunctionDefinitionKind getFunctionDefinitionKind() const
Definition: DeclSpec.h:2223
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, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
Definition: DeclSpec.cpp:152
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:1091
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:402
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1099
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:444
LambdaCaptureInitKind InitKind
Definition: DeclSpec.h:2309
SourceLocation getInlineSpecLoc() const
Definition: DeclSpec.h:555
static const char * getSpecifierName(Specifier VS)
Definition: DeclSpec.cpp:1267
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:748
AttributeList *& getAttrListRef()
Definition: DeclSpec.h:2165
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
Definition: DeclSpec.h:1960
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:701
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1242
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1122
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1389
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:2208
void setObjCQualifiers(ObjCDeclSpec *quals)
Definition: DeclSpec.h:758
static const TST TST_underlyingType
Definition: DeclSpec.h:297
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1608
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:837
void setTypeofParensRange(SourceRange range)
Definition: DeclSpec.h:512
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:1326
bool isObjCWeakProperty() const
Definition: DeclSpec.h:2197
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
static const TST TST_interface
Definition: DeclSpec.h:290
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:35
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
Definition: DeclSpec.h:2000
const DeclaratorChunk * getOutermostNonParenChunk() const
Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chu...
Definition: DeclSpec.h:2024
void addAll(AttributeList *newList)
bool isEmpty() const
No scope specifier.
Definition: DeclSpec.h:189
bool isParen() const
Definition: DeclSpec.h:1582
Information about a template-id annotation token.
IdentifierInfo * getGetterName()
Definition: DeclSpec.h:849
static const TST TST_unknown_anytype
Definition: DeclSpec.h:300
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:942
C11 _Thread_local.
Definition: Specifiers.h:194
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1282
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:1996
bool getExtension() const
Definition: DeclSpec.h:2191
static const TST TST_decimal32
Definition: DeclSpec.h:284
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4381
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Definition: DeclSpec.h:929
AttributeList * getList() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:91
void DropFirstTypeObject()
Definition: DeclSpec.h:2004
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:1362
bool isTypeSpecPipe() const
Definition: DeclSpec.h:479
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:1966
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
Definition: DeclSpec.h:1005
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
Definition: DeclSpec.h:1727
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:33
SourceLocation getTypeSpecSignLoc() const
Definition: DeclSpec.h:502
unsigned VolatileQualifierLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1252
TSS getTypeSpecSign() const
Definition: DeclSpec.h:472
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
DeclSpec(AttributeFactory &attrFactory)
Definition: DeclSpec.h:413
static const TST TST_class
Definition: DeclSpec.h:291
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:34
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:904
unsigned TypeQuals
The type qualifiers: const/volatile/restrict.
Definition: DeclSpec.h:1210
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
Definition: DeclSpec.h:595
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:925
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:822
bool isNoreturnSpecified() const
Definition: DeclSpec.h:565
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:814
union clang::DeclaratorChunk::MemberPointerTypeInfo::@188 ScopeMem
static const TST TST_error
Definition: DeclSpec.h:302
static const TST TST_enum
Definition: DeclSpec.h:287
SourceLocation getFirstLocation() const
Definition: DeclSpec.h:2281
SourceLocation getTypeSpecTypeLoc() const
Definition: DeclSpec.h:503
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:1744
static const TSW TSW_unspecified
Definition: DeclSpec.h:253
void ClearStorageClassSpecs()
Definition: DeclSpec.h:455
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:1891
void SetSourceRange(SourceRange R)
Definition: DeclSpec.h:1747
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2246
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:733
bool hasStatic
True if this dimension included the 'static' keyword.
Definition: DeclSpec.h:1145
PointerTypeInfo Ptr
Definition: DeclSpec.h:1430
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Definition: DeclSpec.h:937
void setExternInLinkageSpec(bool Value)
Definition: DeclSpec.h:446
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:874
void setObjCWeakProperty(bool Val=true)
Definition: DeclSpec.h:2196
ObjCPropertyAttributeKind
PropertyAttributeKind - list of property attributes.
Definition: DeclSpec.h:788
void addAttributes(AttributeList *AL)
Concatenates two attribute lists.
Definition: DeclSpec.h:735
bool hasGroupingParens() const
Definition: DeclSpec.h:2205
unsigned ConstQualLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1116
void setExtension(bool Val=true)
Definition: DeclSpec.h:2190
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:1983
SmallVector< CharSourceRange, 8 > Ranges
Definition: Format.cpp:1715
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
Definition: DeclSpec.h:2099
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:1750
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:810
SCS
storage-class-specifier
Definition: DeclSpec.h:232
ArrayTypeInfo Arr
Definition: DeclSpec.h:1432
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:1080
void setRedeclaration(bool Val)
Definition: DeclSpec.h:2240
An implicit 'self' parameter.
Definition: DeclSpec.h:899
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a 'mutable' qualifier.
Definition: DeclSpec.h:1377
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Definition: DeclSpec.h:1978
void takeAllFrom(ParsedAttributes &attrs)
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1220
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:867
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1229
bool isObjCIvar() const
Definition: DeclSpec.h:2194
SourceLocation getEndLoc() const
Definition: DeclSpec.h:73
const IdentifierInfo * getSetterName() const
Definition: DeclSpec.h:852
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
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:717
SourceLocation getConceptSpecLoc() const
Definition: DeclSpec.h:702
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:852
void UpdateExprRep(Expr *Rep)
Definition: DeclSpec.h:664
bool isExternInLinkageSpec() const
Definition: DeclSpec.h:445
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
Definition: DeclSpec.cpp:31
LambdaCaptureInitKind
Definition: DeclSpec.h:2294
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
Definition: DeclSpec.h:2135
SourceLocation getAltiVecLoc() const
Definition: DeclSpec.h:504
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:497
SourceRange getSourceRange() const LLVM_READONLY
Definition: DeclSpec.h:496
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:933
SourceRange getRange() const
Definition: DeclSpec.h:68
static const TST TST_float
Definition: DeclSpec.h:281
Class that aids in the construction of nested-name-specifiers along with source-location information ...
Declarator(const DeclSpec &ds, TheContext C)
Definition: DeclSpec.h:1697
unsigned AccessWrites
The access writes.
Definition: DeclSpec.h:1423
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Definition: DeclSpec.h:1719
SourceRange getTypeofParensRange() const
Definition: DeclSpec.h:511
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:259
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:2045
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType)
Definition: DeclSpec.h:2312
TST getTypeSpecType() const
Definition: DeclSpec.h:473
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:119
void ClearConstexprSpec()
Definition: DeclSpec.h:704
SourceLocation getModulePrivateSpecLoc() const
Definition: DeclSpec.h:696
bool isTypeRep() const
Definition: DeclSpec.h:478
ObjCPropertyAttributeKind getPropertyAttributes() const
Definition: DeclSpec.h:818
IdentifierInfo * getSetterName()
Definition: DeclSpec.h:853
void SetRangeStart(SourceLocation Loc)
Definition: DeclSpec.h:599
SourceLocation getFriendSpecLoc() const
Definition: DeclSpec.h:693
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1233
ASTContext * Context
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/atomic.
Definition: DeclSpec.h:1113
SmallVector< LambdaCapture, 4 > Captures
Definition: DeclSpec.h:2323
unsigned NumExceptions
NumExceptions - This is the number of types in the dynamic-exception- decl, if the function has one...
Definition: DeclSpec.h:1237
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
Definition: DeclSpec.h:1791
AttributeList * getAttributes()
Definition: DeclSpec.h:2163
static bool isDeclRep(TST T)
Definition: DeclSpec.h:407
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Definition: DeclSpec.h:534
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: DeclSpec.h:753
SourceLocation getLParenLoc() const
Definition: DeclSpec.h:1322
llvm::iterator_range< type_object_iterator > type_object_range
Definition: DeclSpec.h:1997
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the 'volatile' qualifier, if any.
Definition: DeclSpec.h:1357
friend class ASTContext
Definition: Type.h:4012
Expr - This represents one expression.
Definition: Expr.h:104
SourceLocation getAtomicSpecLoc() const
Definition: DeclSpec.h:538
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
Definition: DeclSpec.cpp:261
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:501
An individual capture in a lambda introducer.
Definition: DeclSpec.h:2304
bool isFunctionDefinition() const
Definition: DeclSpec.h:2219
DeclaratorChunk & getTypeObject(unsigned i)
Definition: DeclSpec.h:1991
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1119
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:913
TypeSpecifierWidth TSW
Definition: DeclSpec.h:252
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1548
void freeParams()
Reset the parameter list to having zero parameters.
Definition: DeclSpec.h:1296
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
Definition: DeclSpec.h:542
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
Definition: DeclSpec.h:957
Defines an enumeration for C++ overloaded operators.
void setAsmLabel(Expr *E)
Definition: DeclSpec.h:2187
void setRange(SourceRange R)
Definition: DeclSpec.h:69
SourceLocation getVolatileSpecLoc() const
Definition: DeclSpec.h:537
TypeInfoCommon Common
Definition: DeclSpec.h:1429
static const TST TST_decimal64
Definition: DeclSpec.h:285
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the
Definition: DeclSpec.h:1942
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, CachedTokens *DefArgTokens=nullptr)
Definition: DeclSpec.h:1178
SourceLocation getLastLocation() const
Definition: DeclSpec.h:2282
void UpdateTypeRep(ParsedType Rep)
Definition: DeclSpec.h:660
bool isConstexprSpecified() const
Definition: DeclSpec.h:698
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
Definition: DeclSpec.h:1286
Expr * getAsmLabel() const
Definition: DeclSpec.h:2188
bool LValueRef
True if this is an lvalue reference, false if it's an rvalue reference.
Definition: DeclSpec.h:1135
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:582
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1097
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
Definition: DeclSpec.h:1022
SourceLocation getConstQualifierLoc() const
Retrieve the location of the 'const' qualifier, if any.
Definition: DeclSpec.h:1352
static const TST TST_int
Definition: DeclSpec.h:278
void setEllipsisLoc(SourceLocation EL)
Definition: DeclSpec.h:2213
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:593
static const TST TST_half
Definition: DeclSpec.h:280
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1380
ObjCDeclSpec * getObjCQualifiers() const
Definition: DeclSpec.h:757
void ClearConceptSpec()
Definition: DeclSpec.h:709
Wraps an identifier and optional source location for the identifier.
Definition: AttributeList.h:50
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1386
SourceLocation getStorageClassSpecLoc() const
Definition: DeclSpec.h:450
static const TSW TSW_short
Definition: DeclSpec.h:254
bool isVirtualSpecified() const
Definition: DeclSpec.h:559
SourceLocation getNullabilityLoc() const
Definition: DeclSpec.h:833
IdKind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:881
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1291
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:568
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:965
TypeAndRange * Exceptions
Pointer to a new[]'d array of TypeAndRange objects that contain the types in the function's dynamic e...
Definition: DeclSpec.h:1278
AttributePool & getAttributePool() const
Definition: DeclSpec.h:714
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:1572
bool isPrototypeContext() const
Definition: DeclSpec.h:1735
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
Definition: DeclSpec.cpp:346
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
Definition: DeclSpec.h:776
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,b,c)".
Definition: DeclSpec.h:1320
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
Definition: DeclSpec.h:968
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:911
#define false
Definition: stdbool.h:33
SourceLocation DefaultLoc
Definition: DeclSpec.h:2321
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:1481
enum clang::DeclaratorChunk::@183 Kind
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:2329
static const TST TST_auto_type
Definition: DeclSpec.h:299
ReferenceTypeInfo Ref
Definition: DeclSpec.h:1431
ParsedSpecifiers
ParsedSpecifiers - Flags to query which specifiers were applied.
Definition: DeclSpec.h:317
Specifier getLastSpecifier() const
Definition: DeclSpec.h:2283
An overloaded operator name, e.g., operator+.
Definition: DeclSpec.h:885
Expr * getRepAsExpr() const
Definition: DeclSpec.h:489
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1731
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:539
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:1433
bool isValid() const
static const TST TST_union
Definition: DeclSpec.h:288
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:493
SourceLocation getExceptionSpecLocEnd() const
Definition: DeclSpec.h:1338
ParsedType getRepAsType() const
Definition: DeclSpec.h:481
TSC getTypeSpecComplex() const
Definition: DeclSpec.h:471
static const TSS TSS_signed
Definition: DeclSpec.h:267
void setGroupingParens(bool flag)
Definition: DeclSpec.h:2204
GNU __thread.
Definition: Specifiers.h:188
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SourceRange getExceptionSpecRange() const
Definition: DeclSpec.h:1342
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Definition: DeclSpec.h:194
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1435
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
Definition: DeclSpec.h:2069
SourceLocation getConstexprSpecLoc() const
Definition: DeclSpec.h:699
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
Definition: DeclSpec.h:2013
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2254
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:560
bool isFinalSpelledSealed() const
Definition: DeclSpec.h:2274
static const TST TST_typeofType
Definition: DeclSpec.h:293
SourceLocation getBegin() const
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:72
void setKind(IdKind kind)
Definition: DeclSpec.h:972
AttributeList *& getAttrListRef()
Definition: DeclSpec.h:1458
bool hasAttributes() const
Definition: DeclSpec.h:739
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
Definition: DeclSpec.h:1589
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
Definition: DeclSpec.cpp:771
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
Definition: DeclSpec.h:1133
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/_Atomic.
Definition: DeclSpec.h:1403
bool isStaticMember()
Returns true if this declares a static member.
Definition: DeclSpec.cpp:338
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:704
PipeTypeInfo PipeInfo
Definition: DeclSpec.h:1436
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
Definition: DeclSpec.h:1493
Decl * DeclRep
Definition: DeclSpec.h:363
SourceLocation getExceptionSpecLocBeg() const
Definition: DeclSpec.h:1334
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Definition: DeclSpec.h:2215
A constructor named via a template-id.
Definition: DeclSpec.h:893
C++11 thread_local.
Definition: Specifiers.h:191
bool containsPlaceholderType() const
Definition: DeclSpec.h:514
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:1743
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
Definition: DeclSpec.h:2155
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclSpec.h:810
static const TST TST_decltype_auto
Definition: DeclSpec.h:296
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:885
TSCS getThreadStorageClassSpec() const
Definition: DeclSpec.h:442
bool isUnset() const
Definition: DeclSpec.h:2268
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/_Atomic.
Definition: DeclSpec.h:1142
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
Definition: DeclSpec.h:1085
FieldDeclarator(const DeclSpec &DS)
Definition: DeclSpec.h:2249
static const TSS TSS_unspecified
Definition: DeclSpec.h:266
LambdaCaptureDefault Default
Definition: DeclSpec.h:2322
void setObjCIvar(bool Val=true)
Definition: DeclSpec.h:2193
static const TST TST_decltype
Definition: DeclSpec.h:295
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
static const TST TST_auto
Definition: DeclSpec.h:298
bool isFriendSpecified() const
Definition: DeclSpec.h:692
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:1199
SourceLocation getTypeSpecTypeNameLoc() const
Definition: DeclSpec.h:506
static const TST TST_int128
Definition: DeclSpec.h:279
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
Definition: DeclSpec.h:1216
SourceLocation getFinalLoc() const
Definition: DeclSpec.h:2275
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
Definition: DeclSpec.cpp:1222
bool isFinalSpecified() const
Definition: DeclSpec.h:2273
bool hasTagDefinition() const
Definition: DeclSpec.cpp:351
unsigned ConstQualifierLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1247
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:498
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:811
detail::InMemoryDirectory::const_iterator E
SourceLocation getNoreturnSpecLoc() const
Definition: DeclSpec.h:566
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:1947
static const TST TST_unspecified
Definition: DeclSpec.h:272
bool isFirstDeclarator() const
Definition: DeclSpec.h:2207
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:1243
static const TST TST_decimal128
Definition: DeclSpec.h:286
void takeAttributesFrom(ParsedAttributes &attrs)
Definition: DeclSpec.h:744
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:1194
bool isRedeclaration() const
Definition: DeclSpec.h:2241
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
Definition: DeclSpec.h:1825
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1223
void setNullability(SourceLocation loc, NullabilityKind kind)
Definition: DeclSpec.h:840
void setSetterName(IdentifierInfo *name)
Definition: DeclSpec.h:854
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:554
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
Definition: DeclSpec.cpp:1228
static const TST TST_typename
Definition: DeclSpec.h:292
CXXScopeSpec & getCXXScopeSpec()
Definition: DeclSpec.h:1728
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
Definition: DeclSpec.h:1755
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:1125
bool isInlineSpecified() const
Definition: DeclSpec.h:552
A template-id, e.g., f<int>.
Definition: DeclSpec.h:897
CXXScopeSpec & getTypeSpecScope()
Definition: DeclSpec.h:493
BlockPointerTypeInfo Cls
Definition: DeclSpec.h:1434
IdentifierInfo * getIdentifier() const
Definition: DeclSpec.h:1951
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Definition: DeclSpec.cpp:682
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:81
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
Definition: DeclSpec.h:2178
bool isCXX11Attribute() const
void setInvalidType(bool Val=true)
Definition: DeclSpec.h:2199
unsigned TypeQuals
For now, sema will catch these as invalid.
Definition: DeclSpec.h:1395
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1537
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:1213
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:185
Captures information about "declaration specifiers".
Definition: DeclSpec.h:228
bool isExplicitSpecified() const
Definition: DeclSpec.h:562
SourceLocation getIdentifierLoc() const
Definition: DeclSpec.h:1957
void setEnd(SourceLocation e)
void UpdateDeclRep(Decl *Rep)
Definition: DeclSpec.h:656
Represents a C++ struct/union/class.
Definition: DeclCXX.h:285
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:889
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:1153
void ClearTypeSpecType()
Definition: DeclSpec.h:463
static const TST TST_bool
Definition: DeclSpec.h:283
SourceLocation getOverrideLoc() const
Definition: DeclSpec.h:2271
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:43
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:97
bool diagnoseIdentifier() const
diagnoseIdentifier - Return true if the identifier is prohibited and should be diagnosed (because it ...
Definition: DeclSpec.h:1858
bool isOverrideSpecified() const
Definition: DeclSpec.h:2270
SourceLocation getRParenLoc() const
Definition: DeclSpec.h:1330
bool isTypeSpecOwned() const
Definition: DeclSpec.h:477
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc)
Return a DeclaratorChunk for a pointer.
Definition: DeclSpec.h:1463
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Definition: DeclSpec.cpp:943
SourceLocation getTypeSpecWidthLoc() const
Definition: DeclSpec.h:500
bool isStar
True if this dimension was [*]. In this case, NumElts is null.
Definition: DeclSpec.h:1148
Represents a complete lambda introducer.
Definition: DeclSpec.h:2302
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
Definition: DeclSpec.h:1762
void setGetterName(IdentifierInfo *name)
Definition: DeclSpec.h:850
Expr * ExprRep
Definition: DeclSpec.h:364
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:1367
bool isTypeAltiVecVector() const
Definition: DeclSpec.h:474
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
Definition: DeclSpec.cpp:360
TypeSpecifierSign TSS
Definition: DeclSpec.h:265
bool hasEllipsis() const
Definition: DeclSpec.h:2211
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:301
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
Definition: DeclSpec.h:1373
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
Definition: DeclSpec.h:1347
static const TST TST_struct
Definition: DeclSpec.h:289
const CXXScopeSpec & getTypeSpecScope() const
Definition: DeclSpec.h:494
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1165
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:1987
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:583
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:978
bool isInvalidType() const
Definition: DeclSpec.h:2200
bool SetTypeSpecError()
Definition: DeclSpec.cpp:763
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1267
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:695
NullabilityKind getNullability() const
Definition: DeclSpec.h:826
Represents a C++ namespace alias.
Definition: DeclCXX.h:2649
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:951
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:1060
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
Definition: DeclSpec.h:2228
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1745
void SetRangeEnd(SourceLocation Loc)
Definition: DeclSpec.h:600
const IdentifierInfo * getGetterName() const
Definition: DeclSpec.h:848
ParsedAttributes - A collection of parsed attributes.
void setCommaLoc(SourceLocation CL)
Definition: DeclSpec.h:2209
bool isTypeAltiVecPixel() const
Definition: DeclSpec.h:475
const CXXScopeSpec & Scope() const
Definition: DeclSpec.h:1413
enum clang::UnqualifiedId::IdKind Kind
SourceRange getSourceRange() const
Definition: DeclSpec.h:1101
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:1272
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:741
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1712
AttributeList - Represents a syntactic attribute.
Definition: AttributeList.h:72
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:1558
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Definition: DeclSpec.cpp:796
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:2212
const AttributeList * getAttributes() const
Definition: DeclSpec.h:2162
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1202