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