clang  7.0.0
DeclSpec.h
Go to the documentation of this file.
1 //===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// 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  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
509  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
510  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
511  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
512 
513  SourceLocation getTypeSpecWidthLoc() const { return TSWRange.getBegin(); }
514  SourceRange getTypeSpecWidthRange() const { return TSWRange; }
515  SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
516  SourceLocation getTypeSpecSignLoc() const { return TSSLoc; }
517  SourceLocation getTypeSpecTypeLoc() const { return TSTLoc; }
518  SourceLocation getAltiVecLoc() const { return AltiVecLoc; }
519  SourceLocation getTypeSpecSatLoc() const { return TSSatLoc; }
520 
522  assert(isDeclRep((TST) TypeSpecType) || TypeSpecType == TST_typename);
523  return TSTNameLoc;
524  }
525 
526  SourceRange getTypeofParensRange() const { return TypeofParensRange; }
527  void setTypeofParensRange(SourceRange range) { TypeofParensRange = range; }
528 
529  bool hasAutoTypeSpec() const {
530  return (TypeSpecType == TST_auto || TypeSpecType == TST_auto_type ||
531  TypeSpecType == TST_decltype_auto);
532  }
533 
534  bool hasTagDefinition() const;
535 
536  /// Turn a type-specifier-type into a string like "_Bool" or "union".
537  static const char *getSpecifierName(DeclSpec::TST T,
538  const PrintingPolicy &Policy);
539  static const char *getSpecifierName(DeclSpec::TQ Q);
540  static const char *getSpecifierName(DeclSpec::TSS S);
541  static const char *getSpecifierName(DeclSpec::TSC C);
542  static const char *getSpecifierName(DeclSpec::TSW W);
543  static const char *getSpecifierName(DeclSpec::SCS S);
544  static const char *getSpecifierName(DeclSpec::TSCS S);
545 
546  // type-qualifiers
547 
548  /// getTypeQualifiers - Return a set of TQs.
549  unsigned getTypeQualifiers() const { return TypeQualifiers; }
550  SourceLocation getConstSpecLoc() const { return TQ_constLoc; }
551  SourceLocation getRestrictSpecLoc() const { return TQ_restrictLoc; }
552  SourceLocation getVolatileSpecLoc() const { return TQ_volatileLoc; }
553  SourceLocation getAtomicSpecLoc() const { return TQ_atomicLoc; }
554  SourceLocation getUnalignedSpecLoc() const { return TQ_unalignedLoc; }
555  SourceLocation getPipeLoc() const { return TQ_pipeLoc; }
556 
557  /// Clear out all of the type qualifiers.
559  TypeQualifiers = 0;
560  TQ_constLoc = SourceLocation();
561  TQ_restrictLoc = SourceLocation();
562  TQ_volatileLoc = SourceLocation();
563  TQ_atomicLoc = SourceLocation();
564  TQ_unalignedLoc = SourceLocation();
565  TQ_pipeLoc = SourceLocation();
566  }
567 
568  // function-specifier
569  bool isInlineSpecified() const {
570  return FS_inline_specified | FS_forceinline_specified;
571  }
573  return FS_inline_specified ? FS_inlineLoc : FS_forceinlineLoc;
574  }
575 
576  bool isVirtualSpecified() const { return FS_virtual_specified; }
577  SourceLocation getVirtualSpecLoc() const { return FS_virtualLoc; }
578 
579  bool isExplicitSpecified() const { return FS_explicit_specified; }
580  SourceLocation getExplicitSpecLoc() const { return FS_explicitLoc; }
581 
582  bool isNoreturnSpecified() const { return FS_noreturn_specified; }
583  SourceLocation getNoreturnSpecLoc() const { return FS_noreturnLoc; }
584 
586  FS_inline_specified = false;
587  FS_inlineLoc = SourceLocation();
588  FS_forceinline_specified = false;
589  FS_forceinlineLoc = SourceLocation();
590  FS_virtual_specified = false;
591  FS_virtualLoc = SourceLocation();
592  FS_explicit_specified = false;
593  FS_explicitLoc = SourceLocation();
594  FS_noreturn_specified = false;
595  FS_noreturnLoc = SourceLocation();
596  }
597 
598  /// Return true if any type-specifier has been found.
599  bool hasTypeSpecifier() const {
600  return getTypeSpecType() != DeclSpec::TST_unspecified ||
601  getTypeSpecWidth() != DeclSpec::TSW_unspecified ||
602  getTypeSpecComplex() != DeclSpec::TSC_unspecified ||
603  getTypeSpecSign() != DeclSpec::TSS_unspecified;
604  }
605 
606  /// Return a bitmask of which flavors of specifiers this
607  /// DeclSpec includes.
608  unsigned getParsedSpecifiers() const;
609 
610  /// isEmpty - Return true if this declaration specifier is completely empty:
611  /// no tokens were parsed in the production of it.
612  bool isEmpty() const {
613  return getParsedSpecifiers() == DeclSpec::PQ_None;
614  }
615 
616  void SetRangeStart(SourceLocation Loc) { Range.setBegin(Loc); }
617  void SetRangeEnd(SourceLocation Loc) { Range.setEnd(Loc); }
618 
619  /// These methods set the specified attribute of the DeclSpec and
620  /// return false if there was no error. If an error occurs (for
621  /// example, if we tried to set "auto" on a spec with "extern"
622  /// already set), they return true and set PrevSpec and DiagID
623  /// such that
624  /// Diag(Loc, DiagID) << PrevSpec;
625  /// will yield a useful result.
626  ///
627  /// TODO: use a more general approach that still allows these
628  /// diagnostics to be ignored when desired.
629  bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc,
630  const char *&PrevSpec, unsigned &DiagID,
631  const PrintingPolicy &Policy);
632  bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc,
633  const char *&PrevSpec, unsigned &DiagID);
634  bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec,
635  unsigned &DiagID, const PrintingPolicy &Policy);
636  bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec,
637  unsigned &DiagID);
638  bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
639  unsigned &DiagID);
640  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
641  unsigned &DiagID, const PrintingPolicy &Policy);
642  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
643  unsigned &DiagID, ParsedType Rep,
644  const PrintingPolicy &Policy);
645  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
646  unsigned &DiagID, Decl *Rep, bool Owned,
647  const PrintingPolicy &Policy);
648  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
649  SourceLocation TagNameLoc, const char *&PrevSpec,
650  unsigned &DiagID, ParsedType Rep,
651  const PrintingPolicy &Policy);
652  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
653  SourceLocation TagNameLoc, const char *&PrevSpec,
654  unsigned &DiagID, Decl *Rep, bool Owned,
655  const PrintingPolicy &Policy);
656 
657  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
658  unsigned &DiagID, Expr *Rep,
659  const PrintingPolicy &policy);
660  bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
661  const char *&PrevSpec, unsigned &DiagID,
662  const PrintingPolicy &Policy);
663  bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
664  const char *&PrevSpec, unsigned &DiagID,
665  const PrintingPolicy &Policy);
666  bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
667  const char *&PrevSpec, unsigned &DiagID,
668  const PrintingPolicy &Policy);
669  bool SetTypePipe(bool isPipe, SourceLocation Loc,
670  const char *&PrevSpec, unsigned &DiagID,
671  const PrintingPolicy &Policy);
672  bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec,
673  unsigned &DiagID);
674  bool SetTypeSpecError();
675  void UpdateDeclRep(Decl *Rep) {
676  assert(isDeclRep((TST) TypeSpecType));
677  DeclRep = Rep;
678  }
680  assert(isTypeRep((TST) TypeSpecType));
681  TypeRep = Rep;
682  }
683  void UpdateExprRep(Expr *Rep) {
684  assert(isExprRep((TST) TypeSpecType));
685  ExprRep = Rep;
686  }
687 
688  bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
689  unsigned &DiagID, const LangOptions &Lang);
690 
691  bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
692  unsigned &DiagID);
693  bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
694  unsigned &DiagID);
695  bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec,
696  unsigned &DiagID);
697  bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec,
698  unsigned &DiagID);
699  bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec,
700  unsigned &DiagID);
701 
702  bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
703  unsigned &DiagID);
704  bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
705  unsigned &DiagID);
706  bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec,
707  unsigned &DiagID);
708 
709  bool isFriendSpecified() const { return Friend_specified; }
710  SourceLocation getFriendSpecLoc() const { return FriendLoc; }
711 
712  bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); }
713  SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; }
714 
715  bool isConstexprSpecified() const { return Constexpr_specified; }
716  SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; }
717 
719  Constexpr_specified = false;
720  ConstexprLoc = SourceLocation();
721  }
722 
724  return Attrs.getPool();
725  }
726 
727  /// Concatenates two attribute lists.
728  ///
729  /// The GCC attribute syntax allows for the following:
730  ///
731  /// \code
732  /// short __attribute__(( unused, deprecated ))
733  /// int __attribute__(( may_alias, aligned(16) )) var;
734  /// \endcode
735  ///
736  /// This declares 4 attributes using 2 lists. The following syntax is
737  /// also allowed and equivalent to the previous declaration.
738  ///
739  /// \code
740  /// short __attribute__((unused)) __attribute__((deprecated))
741  /// int __attribute__((may_alias)) __attribute__((aligned(16))) var;
742  /// \endcode
743  ///
745  Attrs.addAll(AL.begin(), AL.end());
746  }
747 
748  bool hasAttributes() const { return !Attrs.empty(); }
749 
750  ParsedAttributes &getAttributes() { return Attrs; }
751  const ParsedAttributes &getAttributes() const { return Attrs; }
752 
754  Attrs.takeAllFrom(attrs);
755  }
756 
757  /// Finish - This does final analysis of the declspec, issuing diagnostics for
758  /// things like "_Imaginary" (lacking an FP type). After calling this method,
759  /// DeclSpec is guaranteed self-consistent, even if an error occurred.
760  void Finish(Sema &S, const PrintingPolicy &Policy);
761 
763  return writtenBS;
764  }
765 
766  ObjCDeclSpec *getObjCQualifiers() const { return ObjCQualifiers; }
767  void setObjCQualifiers(ObjCDeclSpec *quals) { ObjCQualifiers = quals; }
768 
769  /// Checks if this DeclSpec can stand alone, without a Declarator.
770  ///
771  /// Only tag declspecs can stand alone.
772  bool isMissingDeclaratorOk();
773 };
774 
775 /// Captures information about "declaration specifiers" specific to
776 /// Objective-C.
778 public:
779  /// ObjCDeclQualifier - Qualifier used on types in method
780  /// declarations. Not all combinations are sensible. Parameters
781  /// can be one of { in, out, inout } with one of { bycopy, byref }.
782  /// Returns can either be { oneway } or not.
783  ///
784  /// This should be kept in sync with Decl::ObjCDeclQualifier.
786  DQ_None = 0x0,
787  DQ_In = 0x1,
788  DQ_Inout = 0x2,
789  DQ_Out = 0x4,
790  DQ_Bycopy = 0x8,
791  DQ_Byref = 0x10,
792  DQ_Oneway = 0x20,
793  DQ_CSNullability = 0x40
794  };
795 
796  /// PropertyAttributeKind - list of property attributes.
797  /// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.
799  DQ_PR_noattr = 0x0,
800  DQ_PR_readonly = 0x01,
801  DQ_PR_getter = 0x02,
802  DQ_PR_assign = 0x04,
803  DQ_PR_readwrite = 0x08,
804  DQ_PR_retain = 0x10,
805  DQ_PR_copy = 0x20,
806  DQ_PR_nonatomic = 0x40,
807  DQ_PR_setter = 0x80,
808  DQ_PR_atomic = 0x100,
809  DQ_PR_weak = 0x200,
810  DQ_PR_strong = 0x400,
811  DQ_PR_unsafe_unretained = 0x800,
812  DQ_PR_nullability = 0x1000,
813  DQ_PR_null_resettable = 0x2000,
814  DQ_PR_class = 0x4000
815  };
816 
818  : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
819  Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
820 
822  return (ObjCDeclQualifier)objcDeclQualifier;
823  }
825  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
826  }
828  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
829  }
830 
832  return ObjCPropertyAttributeKind(PropertyAttributes);
833  }
835  PropertyAttributes =
836  (ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
837  }
838 
840  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
841  (getPropertyAttributes() & DQ_PR_nullability)) &&
842  "Objective-C declspec doesn't have nullability");
843  return static_cast<NullabilityKind>(Nullability);
844  }
845 
847  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
848  (getPropertyAttributes() & DQ_PR_nullability)) &&
849  "Objective-C declspec doesn't have nullability");
850  return NullabilityLoc;
851  }
852 
854  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
855  (getPropertyAttributes() & DQ_PR_nullability)) &&
856  "Set the nullability declspec or property attribute first");
857  Nullability = static_cast<unsigned>(kind);
858  NullabilityLoc = loc;
859  }
860 
861  const IdentifierInfo *getGetterName() const { return GetterName; }
862  IdentifierInfo *getGetterName() { return GetterName; }
863  SourceLocation getGetterNameLoc() const { return GetterNameLoc; }
865  GetterName = name;
866  GetterNameLoc = loc;
867  }
868 
869  const IdentifierInfo *getSetterName() const { return SetterName; }
870  IdentifierInfo *getSetterName() { return SetterName; }
871  SourceLocation getSetterNameLoc() const { return SetterNameLoc; }
873  SetterName = name;
874  SetterNameLoc = loc;
875  }
876 
877 private:
878  // FIXME: These two are unrelated and mutually exclusive. So perhaps
879  // we can put them in a union to reflect their mutual exclusivity
880  // (space saving is negligible).
881  unsigned objcDeclQualifier : 7;
882 
883  // NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind
884  unsigned PropertyAttributes : 15;
885 
886  unsigned Nullability : 2;
887 
888  SourceLocation NullabilityLoc;
889 
890  IdentifierInfo *GetterName; // getter name or NULL if no getter
891  IdentifierInfo *SetterName; // setter name or NULL if no setter
892  SourceLocation GetterNameLoc; // location of the getter attribute's value
893  SourceLocation SetterNameLoc; // location of the setter attribute's value
894 
895 };
896 
897 /// Describes the kind of unqualified-id parsed.
898 enum class UnqualifiedIdKind {
899  /// An identifier.
901  /// An overloaded operator name, e.g., operator+.
903  /// A conversion function name, e.g., operator int.
905  /// A user-defined literal name, e.g., operator "" _i.
907  /// A constructor name.
909  /// A constructor named via a template-id.
911  /// A destructor name.
913  /// A template-id, e.g., f<int>.
915  /// An implicit 'self' parameter
917  /// A deduction-guide name (a template-name)
919 };
920 
921 /// Represents a C++ unqualified-id that has been parsed.
923 private:
924  UnqualifiedId(const UnqualifiedId &Other) = delete;
925  const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
926 
927 public:
928  /// Describes the kind of unqualified-id parsed.
930 
931  struct OFI {
932  /// The kind of overloaded operator.
934 
935  /// The source locations of the individual tokens that name
936  /// the operator, e.g., the "new", "[", and "]" tokens in
937  /// operator new [].
938  ///
939  /// Different operators have different numbers of tokens in their name,
940  /// up to three. Any remaining source locations in this array will be
941  /// set to an invalid value for operators with fewer than three tokens.
942  unsigned SymbolLocations[3];
943  };
944 
945  /// Anonymous union that holds extra data associated with the
946  /// parsed unqualified-id.
947  union {
948  /// When Kind == IK_Identifier, the parsed identifier, or when
949  /// Kind == IK_UserLiteralId, the identifier suffix.
951 
952  /// When Kind == IK_OperatorFunctionId, the overloaded operator
953  /// that we parsed.
954  struct OFI OperatorFunctionId;
955 
956  /// When Kind == IK_ConversionFunctionId, the type that the
957  /// conversion function names.
959 
960  /// When Kind == IK_ConstructorName, the class-name of the type
961  /// whose constructor is being referenced.
963 
964  /// When Kind == IK_DestructorName, the type referred to by the
965  /// class-name.
967 
968  /// When Kind == IK_DeductionGuideName, the parsed template-name.
970 
971  /// When Kind == IK_TemplateId or IK_ConstructorTemplateId,
972  /// the template-id annotation that contains the template name and
973  /// template arguments.
975  };
976 
977  /// The location of the first token that describes this unqualified-id,
978  /// which will be the location of the identifier, "operator" keyword,
979  /// tilde (for a destructor), or the template name of a template-id.
981 
982  /// The location of the last token that describes this unqualified-id.
984 
986  : Kind(UnqualifiedIdKind::IK_Identifier), Identifier(nullptr) {}
987 
988  /// Clear out this unqualified-id, setting it to default (invalid)
989  /// state.
990  void clear() {
992  Identifier = nullptr;
993  StartLocation = SourceLocation();
994  EndLocation = SourceLocation();
995  }
996 
997  /// Determine whether this unqualified-id refers to a valid name.
998  bool isValid() const { return StartLocation.isValid(); }
999 
1000  /// Determine whether this unqualified-id refers to an invalid name.
1001  bool isInvalid() const { return !isValid(); }
1002 
1003  /// Determine what kind of name we have.
1004  UnqualifiedIdKind getKind() const { return Kind; }
1006 
1007  /// Specify that this unqualified-id was parsed as an identifier.
1008  ///
1009  /// \param Id the parsed identifier.
1010  /// \param IdLoc the location of the parsed identifier.
1013  Identifier = const_cast<IdentifierInfo *>(Id);
1014  StartLocation = EndLocation = IdLoc;
1015  }
1016 
1017  /// Specify that this unqualified-id was parsed as an
1018  /// operator-function-id.
1019  ///
1020  /// \param OperatorLoc the location of the 'operator' keyword.
1021  ///
1022  /// \param Op the overloaded operator.
1023  ///
1024  /// \param SymbolLocations the locations of the individual operator symbols
1025  /// in the operator.
1026  void setOperatorFunctionId(SourceLocation OperatorLoc,
1028  SourceLocation SymbolLocations[3]);
1029 
1030  /// Specify that this unqualified-id was parsed as a
1031  /// conversion-function-id.
1032  ///
1033  /// \param OperatorLoc the location of the 'operator' keyword.
1034  ///
1035  /// \param Ty the type to which this conversion function is converting.
1036  ///
1037  /// \param EndLoc the location of the last token that makes up the type name.
1039  ParsedType Ty,
1040  SourceLocation EndLoc) {
1042  StartLocation = OperatorLoc;
1043  EndLocation = EndLoc;
1044  ConversionFunctionId = Ty;
1045  }
1046 
1047  /// Specific that this unqualified-id was parsed as a
1048  /// literal-operator-id.
1049  ///
1050  /// \param Id the parsed identifier.
1051  ///
1052  /// \param OpLoc the location of the 'operator' keyword.
1053  ///
1054  /// \param IdLoc the location of the identifier.
1056  SourceLocation IdLoc) {
1058  Identifier = const_cast<IdentifierInfo *>(Id);
1059  StartLocation = OpLoc;
1060  EndLocation = IdLoc;
1061  }
1062 
1063  /// Specify that this unqualified-id was parsed as a constructor name.
1064  ///
1065  /// \param ClassType the class type referred to by the constructor name.
1066  ///
1067  /// \param ClassNameLoc the location of the class name.
1068  ///
1069  /// \param EndLoc the location of the last token that makes up the type name.
1071  SourceLocation ClassNameLoc,
1072  SourceLocation EndLoc) {
1074  StartLocation = ClassNameLoc;
1075  EndLocation = EndLoc;
1076  ConstructorName = ClassType;
1077  }
1078 
1079  /// Specify that this unqualified-id was parsed as a
1080  /// template-id that names a constructor.
1081  ///
1082  /// \param TemplateId the template-id annotation that describes the parsed
1083  /// template-id. This UnqualifiedId instance will take ownership of the
1084  /// \p TemplateId and will free it on destruction.
1085  void setConstructorTemplateId(TemplateIdAnnotation *TemplateId);
1086 
1087  /// Specify that this unqualified-id was parsed as a destructor name.
1088  ///
1089  /// \param TildeLoc the location of the '~' that introduces the destructor
1090  /// name.
1091  ///
1092  /// \param ClassType the name of the class referred to by the destructor name.
1094  ParsedType ClassType,
1095  SourceLocation EndLoc) {
1097  StartLocation = TildeLoc;
1098  EndLocation = EndLoc;
1099  DestructorName = ClassType;
1100  }
1101 
1102  /// Specify that this unqualified-id was parsed as a template-id.
1103  ///
1104  /// \param TemplateId the template-id annotation that describes the parsed
1105  /// template-id. This UnqualifiedId instance will take ownership of the
1106  /// \p TemplateId and will free it on destruction.
1107  void setTemplateId(TemplateIdAnnotation *TemplateId);
1108 
1109  /// Specify that this unqualified-id was parsed as a template-name for
1110  /// a deduction-guide.
1111  ///
1112  /// \param Template The parsed template-name.
1113  /// \param TemplateLoc The location of the parsed template-name.
1115  SourceLocation TemplateLoc) {
1117  TemplateName = Template;
1118  StartLocation = EndLocation = TemplateLoc;
1119  }
1120 
1121  /// Return the source range that covers this unqualified-id.
1122  SourceRange getSourceRange() const LLVM_READONLY {
1123  return SourceRange(StartLocation, EndLocation);
1124  }
1125  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1126  SourceLocation getBeginLoc() const LLVM_READONLY { return StartLocation; }
1127  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1128  SourceLocation getEndLoc() const LLVM_READONLY { return EndLocation; }
1129 };
1130 
1131 /// A set of tokens that has been cached for later parsing.
1133 
1134 /// One instance of this struct is used for each type in a
1135 /// declarator that is parsed.
1136 ///
1137 /// This is intended to be a small value object.
1139  enum {
1140  Pointer, Reference, Array, Function, BlockPointer, MemberPointer, Paren, Pipe
1141  } Kind;
1142 
1143  /// Loc - The place where this type was defined.
1145  /// EndLoc - If valid, the place where this chunck ends.
1147 
1149  if (EndLoc.isInvalid())
1150  return SourceRange(Loc, Loc);
1151  return SourceRange(Loc, EndLoc);
1152  }
1153 
1155 
1157  /// The type qualifiers: const/volatile/restrict/unaligned/atomic.
1158  unsigned TypeQuals : 5;
1159 
1160  /// The location of the const-qualifier, if any.
1161  unsigned ConstQualLoc;
1162 
1163  /// The location of the volatile-qualifier, if any.
1165 
1166  /// The location of the restrict-qualifier, if any.
1168 
1169  /// The location of the _Atomic-qualifier, if any.
1170  unsigned AtomicQualLoc;
1171 
1172  /// The location of the __unaligned-qualifier, if any.
1174 
1175  void destroy() {
1176  }
1177  };
1178 
1180  /// The type qualifier: restrict. [GNU] C++ extension
1181  bool HasRestrict : 1;
1182  /// True if this is an lvalue reference, false if it's an rvalue reference.
1183  bool LValueRef : 1;
1184  void destroy() {
1185  }
1186  };
1187 
1188  struct ArrayTypeInfo {
1189  /// The type qualifiers for the array:
1190  /// const/volatile/restrict/__unaligned/_Atomic.
1191  unsigned TypeQuals : 5;
1192 
1193  /// True if this dimension included the 'static' keyword.
1194  unsigned hasStatic : 1;
1195 
1196  /// True if this dimension was [*]. In this case, NumElts is null.
1197  unsigned isStar : 1;
1198 
1199  /// This is the size of the array, or null if [] or [*] was specified.
1200  /// Since the parser is multi-purpose, and we don't want to impose a root
1201  /// expression class on all clients, NumElts is untyped.
1203 
1204  void destroy() {}
1205  };
1206 
1207  /// ParamInfo - An array of paraminfo objects is allocated whenever a function
1208  /// declarator is parsed. There are two interesting styles of parameters
1209  /// here:
1210  /// K&R-style identifier lists and parameter type lists. K&R-style identifier
1211  /// lists will have information about the identifier, but no type information.
1212  /// Parameter type lists will have type info (if the actions module provides
1213  /// it), but may have null identifier info: e.g. for 'void foo(int X, int)'.
1214  struct ParamInfo {
1218 
1219  /// DefaultArgTokens - When the parameter's default argument
1220  /// cannot be parsed immediately (because it occurs within the
1221  /// declaration of a member function), it will be stored here as a
1222  /// sequence of tokens to be parsed once the class definition is
1223  /// complete. Non-NULL indicates that there is a default argument.
1224  std::unique_ptr<CachedTokens> DefaultArgTokens;
1225 
1226  ParamInfo() = default;
1228  Decl *param,
1229  std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
1230  : Ident(ident), IdentLoc(iloc), Param(param),
1231  DefaultArgTokens(std::move(DefArgTokens)) {}
1232  };
1233 
1234  struct TypeAndRange {
1237  };
1238 
1240  /// hasPrototype - This is true if the function had at least one typed
1241  /// parameter. If the function is () or (a,b,c), then it has no prototype,
1242  /// and is treated as a K&R-style function.
1243  unsigned hasPrototype : 1;
1244 
1245  /// isVariadic - If this function has a prototype, and if that
1246  /// proto ends with ',...)', this is true. When true, EllipsisLoc
1247  /// contains the location of the ellipsis.
1248  unsigned isVariadic : 1;
1249 
1250  /// Can this declaration be a constructor-style initializer?
1251  unsigned isAmbiguous : 1;
1252 
1253  /// Whether the ref-qualifier (if any) is an lvalue reference.
1254  /// Otherwise, it's an rvalue reference.
1256 
1257  /// The type qualifiers: const/volatile/restrict/__unaligned
1258  /// The qualifier bitmask values are the same as in QualType.
1259  unsigned TypeQuals : 4;
1260 
1261  /// ExceptionSpecType - An ExceptionSpecificationType value.
1262  unsigned ExceptionSpecType : 4;
1263 
1264  /// DeleteParams - If this is true, we need to delete[] Params.
1265  unsigned DeleteParams : 1;
1266 
1267  /// HasTrailingReturnType - If this is true, a trailing return type was
1268  /// specified.
1270 
1271  /// The location of the left parenthesis in the source.
1272  unsigned LParenLoc;
1273 
1274  /// When isVariadic is true, the location of the ellipsis in the source.
1275  unsigned EllipsisLoc;
1276 
1277  /// The location of the right parenthesis in the source.
1278  unsigned RParenLoc;
1279 
1280  /// NumParams - This is the number of formal parameters specified by the
1281  /// declarator.
1282  unsigned NumParams;
1283 
1284  /// NumExceptionsOrDecls - This is the number of types in the
1285  /// dynamic-exception-decl, if the function has one. In C, this is the
1286  /// number of declarations in the function prototype.
1288 
1289  /// The location of the ref-qualifier, if any.
1290  ///
1291  /// If this is an invalid location, there is no ref-qualifier.
1293 
1294  /// The location of the const-qualifier, if any.
1295  ///
1296  /// If this is an invalid location, there is no const-qualifier.
1298 
1299  /// The location of the volatile-qualifier, if any.
1300  ///
1301  /// If this is an invalid location, there is no volatile-qualifier.
1303 
1304  /// The location of the restrict-qualifier, if any.
1305  ///
1306  /// If this is an invalid location, there is no restrict-qualifier.
1308 
1309  /// The location of the 'mutable' qualifer in a lambda-declarator, if
1310  /// any.
1311  unsigned MutableLoc;
1312 
1313  /// The beginning location of the exception specification, if any.
1315 
1316  /// The end location of the exception specification, if any.
1318 
1319  /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
1320  /// describe the parameters specified by this function declarator. null if
1321  /// there are no parameters specified.
1323 
1324  union {
1325  /// Pointer to a new[]'d array of TypeAndRange objects that
1326  /// contain the types in the function's dynamic exception specification
1327  /// and their locations, if there is one.
1329 
1330  /// Pointer to the expression in the noexcept-specifier of this
1331  /// function, if it has one.
1333 
1334  /// Pointer to the cached tokens for an exception-specification
1335  /// that has not yet been parsed.
1336  CachedTokens *ExceptionSpecTokens;
1337 
1338  /// Pointer to a new[]'d array of declarations that need to be available
1339  /// for lookup inside the function body, if one exists. Does not exist in
1340  /// C++.
1342  };
1343 
1344  /// If HasTrailingReturnType is true, this is the trailing return
1345  /// type specified.
1347 
1348  /// Reset the parameter list to having zero parameters.
1349  ///
1350  /// This is used in various places for error recovery.
1351  void freeParams() {
1352  for (unsigned I = 0; I < NumParams; ++I)
1353  Params[I].DefaultArgTokens.reset();
1354  if (DeleteParams) {
1355  delete[] Params;
1356  DeleteParams = false;
1357  }
1358  NumParams = 0;
1359  }
1360 
1361  void destroy() {
1362  freeParams();
1363  switch (getExceptionSpecType()) {
1364  default:
1365  break;
1366  case EST_Dynamic:
1367  delete[] Exceptions;
1368  break;
1369  case EST_Unparsed:
1370  delete ExceptionSpecTokens;
1371  break;
1372  case EST_None:
1373  if (NumExceptionsOrDecls != 0)
1374  delete[] DeclsInPrototype;
1375  break;
1376  }
1377  }
1378 
1379  /// isKNRPrototype - Return true if this is a K&R style identifier list,
1380  /// like "void foo(a,b,c)". In a function definition, this will be followed
1381  /// by the parameter type definitions.
1382  bool isKNRPrototype() const { return !hasPrototype && NumParams != 0; }
1383 
1385  return SourceLocation::getFromRawEncoding(LParenLoc);
1386  }
1387 
1389  return SourceLocation::getFromRawEncoding(EllipsisLoc);
1390  }
1391 
1393  return SourceLocation::getFromRawEncoding(RParenLoc);
1394  }
1395 
1397  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
1398  }
1399 
1401  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
1402  }
1403 
1405  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
1406  }
1407 
1408  /// Retrieve the location of the ref-qualifier, if any.
1410  return SourceLocation::getFromRawEncoding(RefQualifierLoc);
1411  }
1412 
1413  /// Retrieve the location of the 'const' qualifier, if any.
1415  return SourceLocation::getFromRawEncoding(ConstQualifierLoc);
1416  }
1417 
1418  /// Retrieve the location of the 'volatile' qualifier, if any.
1420  return SourceLocation::getFromRawEncoding(VolatileQualifierLoc);
1421  }
1422 
1423  /// Retrieve the location of the 'restrict' qualifier, if any.
1425  return SourceLocation::getFromRawEncoding(RestrictQualifierLoc);
1426  }
1427 
1428  /// Retrieve the location of the 'mutable' qualifier, if any.
1430  return SourceLocation::getFromRawEncoding(MutableLoc);
1431  }
1432 
1433  /// Determine whether this function declaration contains a
1434  /// ref-qualifier.
1435  bool hasRefQualifier() const { return getRefQualifierLoc().isValid(); }
1436 
1437  /// Determine whether this lambda-declarator contains a 'mutable'
1438  /// qualifier.
1439  bool hasMutableQualifier() const { return getMutableLoc().isValid(); }
1440 
1441  /// Get the type of exception specification this function has.
1443  return static_cast<ExceptionSpecificationType>(ExceptionSpecType);
1444  }
1445 
1446  /// Get the number of dynamic exception specifications.
1447  unsigned getNumExceptions() const {
1448  assert(ExceptionSpecType != EST_None);
1449  return NumExceptionsOrDecls;
1450  }
1451 
1452  /// Get the non-parameter decls defined within this function
1453  /// prototype. Typically these are tag declarations.
1455  assert(ExceptionSpecType == EST_None);
1456  return llvm::makeArrayRef(DeclsInPrototype, NumExceptionsOrDecls);
1457  }
1458 
1459  /// Determine whether this function declarator had a
1460  /// trailing-return-type.
1461  bool hasTrailingReturnType() const { return HasTrailingReturnType; }
1462 
1463  /// Get the trailing-return-type for this function declarator.
1464  ParsedType getTrailingReturnType() const { return TrailingReturnType; }
1465  };
1466 
1468  /// For now, sema will catch these as invalid.
1469  /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
1470  unsigned TypeQuals : 5;
1471 
1472  void destroy() {
1473  }
1474  };
1475 
1477  /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
1478  unsigned TypeQuals : 5;
1479  // CXXScopeSpec has a constructor, so it can't be a direct member.
1480  // So we need some pointer-aligned storage and a bit of trickery.
1481  alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
1483  return *reinterpret_cast<CXXScopeSpec *>(ScopeMem);
1484  }
1485  const CXXScopeSpec &Scope() const {
1486  return *reinterpret_cast<const CXXScopeSpec *>(ScopeMem);
1487  }
1488  void destroy() {
1489  Scope().~CXXScopeSpec();
1490  }
1491  };
1492 
1493  struct PipeTypeInfo {
1494  /// The access writes.
1495  unsigned AccessWrites : 3;
1496 
1497  void destroy() {}
1498  };
1499 
1500  union {
1508  };
1509 
1510  void destroy() {
1511  switch (Kind) {
1512  case DeclaratorChunk::Function: return Fun.destroy();
1513  case DeclaratorChunk::Pointer: return Ptr.destroy();
1514  case DeclaratorChunk::BlockPointer: return Cls.destroy();
1515  case DeclaratorChunk::Reference: return Ref.destroy();
1516  case DeclaratorChunk::Array: return Arr.destroy();
1517  case DeclaratorChunk::MemberPointer: return Mem.destroy();
1518  case DeclaratorChunk::Paren: return;
1519  case DeclaratorChunk::Pipe: return PipeInfo.destroy();
1520  }
1521  }
1522 
1523  /// If there are attributes applied to this declaratorchunk, return
1524  /// them.
1525  const ParsedAttributesView &getAttrs() const { return AttrList; }
1526  ParsedAttributesView &getAttrs() { return AttrList; }
1527 
1528  /// Return a DeclaratorChunk for a pointer.
1529  static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc,
1530  SourceLocation ConstQualLoc,
1531  SourceLocation VolatileQualLoc,
1532  SourceLocation RestrictQualLoc,
1533  SourceLocation AtomicQualLoc,
1534  SourceLocation UnalignedQualLoc) {
1535  DeclaratorChunk I;
1536  I.Kind = Pointer;
1537  I.Loc = Loc;
1538  I.Ptr.TypeQuals = TypeQuals;
1539  I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding();
1540  I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding();
1541  I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding();
1542  I.Ptr.AtomicQualLoc = AtomicQualLoc.getRawEncoding();
1543  I.Ptr.UnalignedQualLoc = UnalignedQualLoc.getRawEncoding();
1544  return I;
1545  }
1546 
1547  /// Return a DeclaratorChunk for a reference.
1548  static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc,
1549  bool lvalue) {
1550  DeclaratorChunk I;
1551  I.Kind = Reference;
1552  I.Loc = Loc;
1553  I.Ref.HasRestrict = (TypeQuals & DeclSpec::TQ_restrict) != 0;
1554  I.Ref.LValueRef = lvalue;
1555  return I;
1556  }
1557 
1558  /// Return a DeclaratorChunk for an array.
1559  static DeclaratorChunk getArray(unsigned TypeQuals,
1560  bool isStatic, bool isStar, Expr *NumElts,
1561  SourceLocation LBLoc, SourceLocation RBLoc) {
1562  DeclaratorChunk I;
1563  I.Kind = Array;
1564  I.Loc = LBLoc;
1565  I.EndLoc = RBLoc;
1566  I.Arr.TypeQuals = TypeQuals;
1567  I.Arr.hasStatic = isStatic;
1568  I.Arr.isStar = isStar;
1569  I.Arr.NumElts = NumElts;
1570  return I;
1571  }
1572 
1573  /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
1574  /// "TheDeclarator" is the declarator that this will be added to.
1575  static DeclaratorChunk getFunction(bool HasProto,
1576  bool IsAmbiguous,
1577  SourceLocation LParenLoc,
1578  ParamInfo *Params, unsigned NumParams,
1579  SourceLocation EllipsisLoc,
1580  SourceLocation RParenLoc,
1581  unsigned TypeQuals,
1582  bool RefQualifierIsLvalueRef,
1583  SourceLocation RefQualifierLoc,
1584  SourceLocation ConstQualifierLoc,
1585  SourceLocation VolatileQualifierLoc,
1586  SourceLocation RestrictQualifierLoc,
1587  SourceLocation MutableLoc,
1588  ExceptionSpecificationType ESpecType,
1589  SourceRange ESpecRange,
1590  ParsedType *Exceptions,
1591  SourceRange *ExceptionRanges,
1592  unsigned NumExceptions,
1593  Expr *NoexceptExpr,
1594  CachedTokens *ExceptionSpecTokens,
1595  ArrayRef<NamedDecl *> DeclsInPrototype,
1596  SourceLocation LocalRangeBegin,
1597  SourceLocation LocalRangeEnd,
1598  Declarator &TheDeclarator,
1599  TypeResult TrailingReturnType =
1600  TypeResult());
1601 
1602  /// Return a DeclaratorChunk for a block.
1603  static DeclaratorChunk getBlockPointer(unsigned TypeQuals,
1604  SourceLocation Loc) {
1605  DeclaratorChunk I;
1606  I.Kind = BlockPointer;
1607  I.Loc = Loc;
1608  I.Cls.TypeQuals = TypeQuals;
1609  return I;
1610  }
1611 
1612  /// Return a DeclaratorChunk for a block.
1613  static DeclaratorChunk getPipe(unsigned TypeQuals,
1614  SourceLocation Loc) {
1615  DeclaratorChunk I;
1616  I.Kind = Pipe;
1617  I.Loc = Loc;
1618  I.Cls.TypeQuals = TypeQuals;
1619  return I;
1620  }
1621 
1623  unsigned TypeQuals,
1624  SourceLocation Loc) {
1625  DeclaratorChunk I;
1626  I.Kind = MemberPointer;
1627  I.Loc = SS.getBeginLoc();
1628  I.EndLoc = Loc;
1629  I.Mem.TypeQuals = TypeQuals;
1630  new (I.Mem.ScopeMem) CXXScopeSpec(SS);
1631  return I;
1632  }
1633 
1634  /// Return a DeclaratorChunk for a paren.
1636  SourceLocation RParenLoc) {
1637  DeclaratorChunk I;
1638  I.Kind = Paren;
1639  I.Loc = LParenLoc;
1640  I.EndLoc = RParenLoc;
1641  return I;
1642  }
1643 
1644  bool isParen() const {
1645  return Kind == Paren;
1646  }
1647 };
1648 
1649 /// A parsed C++17 decomposition declarator of the form
1650 /// '[' identifier-list ']'
1652 public:
1653  struct Binding {
1656  };
1657 
1658 private:
1659  /// The locations of the '[' and ']' tokens.
1660  SourceLocation LSquareLoc, RSquareLoc;
1661 
1662  /// The bindings.
1663  Binding *Bindings;
1664  unsigned NumBindings : 31;
1665  unsigned DeleteBindings : 1;
1666 
1667  friend class Declarator;
1668 
1669 public:
1671  : Bindings(nullptr), NumBindings(0), DeleteBindings(false) {}
1673  DecompositionDeclarator &operator=(const DecompositionDeclarator &G) = delete;
1675  if (DeleteBindings)
1676  delete[] Bindings;
1677  }
1678 
1679  void clear() {
1680  LSquareLoc = RSquareLoc = SourceLocation();
1681  if (DeleteBindings)
1682  delete[] Bindings;
1683  Bindings = nullptr;
1684  NumBindings = 0;
1685  DeleteBindings = false;
1686  }
1687 
1689  return llvm::makeArrayRef(Bindings, NumBindings);
1690  }
1691 
1692  bool isSet() const { return LSquareLoc.isValid(); }
1693 
1694  SourceLocation getLSquareLoc() const { return LSquareLoc; }
1695  SourceLocation getRSquareLoc() const { return RSquareLoc; }
1697  return SourceRange(LSquareLoc, RSquareLoc);
1698  }
1699 };
1700 
1701 /// Described the kind of function definition (if any) provided for
1702 /// a function.
1708 };
1709 
1710 enum class DeclaratorContext {
1711  FileContext, // File scope declaration.
1712  PrototypeContext, // Within a function prototype.
1713  ObjCResultContext, // An ObjC method result type.
1714  ObjCParameterContext,// An ObjC method parameter type.
1715  KNRTypeListContext, // K&R type definition list for formals.
1716  TypeNameContext, // Abstract declarator for types.
1717  FunctionalCastContext, // Type in a C++ functional cast expression.
1718  MemberContext, // Struct/Union field.
1719  BlockContext, // Declaration within a block in a function.
1720  ForContext, // Declaration within first part of a for loop.
1721  InitStmtContext, // Declaration within optional init stmt of if/switch.
1722  ConditionContext, // Condition declaration in a C++ if/switch/while/for.
1723  TemplateParamContext,// Within a template parameter list.
1724  CXXNewContext, // C++ new-expression.
1725  CXXCatchContext, // C++ catch exception-declaration
1726  ObjCCatchContext, // Objective-C catch exception-declaration
1727  BlockLiteralContext, // Block literal declarator.
1728  LambdaExprContext, // Lambda-expression declarator.
1729  LambdaExprParameterContext, // Lambda-expression parameter declarator.
1730  ConversionIdContext, // C++ conversion-type-id.
1731  TrailingReturnContext, // C++11 trailing-type-specifier.
1732  TrailingReturnVarContext, // C++11 trailing-type-specifier for variable.
1733  TemplateArgContext, // Any template argument (in template argument list).
1734  TemplateTypeArgContext, // Template type argument (in default argument).
1735  AliasDeclContext, // C++11 alias-declaration.
1736  AliasTemplateContext // C++11 alias-declaration template.
1737 };
1738 
1739 
1740 /// Information about one declarator, including the parsed type
1741 /// information and the identifier.
1742 ///
1743 /// When the declarator is fully formed, this is turned into the appropriate
1744 /// Decl object.
1745 ///
1746 /// Declarators come in two types: normal declarators and abstract declarators.
1747 /// Abstract declarators are used when parsing types, and don't have an
1748 /// identifier. Normal declarators do have ID's.
1749 ///
1750 /// Instances of this class should be a transient object that lives on the
1751 /// stack, not objects that are allocated in large quantities on the heap.
1752 class Declarator {
1753 
1754 private:
1755  const DeclSpec &DS;
1756  CXXScopeSpec SS;
1757  UnqualifiedId Name;
1758  SourceRange Range;
1759 
1760  /// Where we are parsing this declarator.
1761  DeclaratorContext Context;
1762 
1763  /// The C++17 structured binding, if any. This is an alternative to a Name.
1764  DecompositionDeclarator BindingGroup;
1765 
1766  /// DeclTypeInfo - This holds each type that the declarator includes as it is
1767  /// parsed. This is pushed from the identifier out, which means that element
1768  /// #0 will be the most closely bound to the identifier, and
1769  /// DeclTypeInfo.back() will be the least closely bound.
1770  SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
1771 
1772  /// InvalidType - Set by Sema::GetTypeForDeclarator().
1773  unsigned InvalidType : 1;
1774 
1775  /// GroupingParens - Set by Parser::ParseParenDeclarator().
1776  unsigned GroupingParens : 1;
1777 
1778  /// FunctionDefinition - Is this Declarator for a function or member
1779  /// definition and, if so, what kind?
1780  ///
1781  /// Actually a FunctionDefinitionKind.
1782  unsigned FunctionDefinition : 2;
1783 
1784  /// Is this Declarator a redeclaration?
1785  unsigned Redeclaration : 1;
1786 
1787  /// true if the declaration is preceded by \c __extension__.
1788  unsigned Extension : 1;
1789 
1790  /// Indicates whether this is an Objective-C instance variable.
1791  unsigned ObjCIvar : 1;
1792 
1793  /// Indicates whether this is an Objective-C 'weak' property.
1794  unsigned ObjCWeakProperty : 1;
1795 
1796  /// Indicates whether the InlineParams / InlineBindings storage has been used.
1797  unsigned InlineStorageUsed : 1;
1798 
1799  /// Attrs - Attributes.
1800  ParsedAttributes Attrs;
1801 
1802  /// The asm label, if specified.
1803  Expr *AsmLabel;
1804 
1805 #ifndef _MSC_VER
1806  union {
1807 #endif
1808  /// InlineParams - This is a local array used for the first function decl
1809  /// chunk to avoid going to the heap for the common case when we have one
1810  /// function chunk in the declarator.
1811  DeclaratorChunk::ParamInfo InlineParams[16];
1813 #ifndef _MSC_VER
1814  };
1815 #endif
1816 
1817  /// If this is the second or subsequent declarator in this declaration,
1818  /// the location of the comma before this declarator.
1819  SourceLocation CommaLoc;
1820 
1821  /// If provided, the source location of the ellipsis used to describe
1822  /// this declarator as a parameter pack.
1823  SourceLocation EllipsisLoc;
1824 
1825  friend struct DeclaratorChunk;
1826 
1827 public:
1829  : DS(ds), Range(ds.getSourceRange()), Context(C),
1830  InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error),
1831  GroupingParens(false), FunctionDefinition(FDK_Declaration),
1832  Redeclaration(false), Extension(false), ObjCIvar(false),
1833  ObjCWeakProperty(false), InlineStorageUsed(false),
1834  Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr) {}
1835 
1837  clear();
1838  }
1839  /// getDeclSpec - Return the declaration-specifier that this declarator was
1840  /// declared with.
1841  const DeclSpec &getDeclSpec() const { return DS; }
1842 
1843  /// getMutableDeclSpec - Return a non-const version of the DeclSpec. This
1844  /// should be used with extreme care: declspecs can often be shared between
1845  /// multiple declarators, so mutating the DeclSpec affects all of the
1846  /// Declarators. This should only be done when the declspec is known to not
1847  /// be shared or when in error recovery etc.
1848  DeclSpec &getMutableDeclSpec() { return const_cast<DeclSpec &>(DS); }
1849 
1851  return Attrs.getPool();
1852  }
1853 
1854  /// getCXXScopeSpec - Return the C++ scope specifier (global scope or
1855  /// nested-name-specifier) that is part of the declarator-id.
1856  const CXXScopeSpec &getCXXScopeSpec() const { return SS; }
1857  CXXScopeSpec &getCXXScopeSpec() { return SS; }
1858 
1859  /// Retrieve the name specified by this declarator.
1860  UnqualifiedId &getName() { return Name; }
1861 
1863  return BindingGroup;
1864  }
1865 
1866  DeclaratorContext getContext() const { return Context; }
1867 
1868  bool isPrototypeContext() const {
1869  return (Context == DeclaratorContext::PrototypeContext ||
1873  }
1874 
1875  /// Get the source range that spans this declarator.
1876  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1877  SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
1878  SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); }
1879  SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
1880  SourceLocation getEndLoc() const LLVM_READONLY { return Range.getEnd(); }
1881 
1882  void SetSourceRange(SourceRange R) { Range = R; }
1883  /// SetRangeBegin - Set the start of the source range to Loc, unless it's
1884  /// invalid.
1886  if (!Loc.isInvalid())
1887  Range.setBegin(Loc);
1888  }
1889  /// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
1891  if (!Loc.isInvalid())
1892  Range.setEnd(Loc);
1893  }
1894  /// ExtendWithDeclSpec - Extend the declarator source range to include the
1895  /// given declspec, unless its location is invalid. Adopts the range start if
1896  /// the current range start is invalid.
1897  void ExtendWithDeclSpec(const DeclSpec &DS) {
1898  SourceRange SR = DS.getSourceRange();
1899  if (Range.getBegin().isInvalid())
1900  Range.setBegin(SR.getBegin());
1901  if (!SR.getEnd().isInvalid())
1902  Range.setEnd(SR.getEnd());
1903  }
1904 
1905  /// Reset the contents of this Declarator.
1906  void clear() {
1907  SS.clear();
1908  Name.clear();
1909  Range = DS.getSourceRange();
1910  BindingGroup.clear();
1911 
1912  for (unsigned i = 0, e = DeclTypeInfo.size(); i != e; ++i)
1913  DeclTypeInfo[i].destroy();
1914  DeclTypeInfo.clear();
1915  Attrs.clear();
1916  AsmLabel = nullptr;
1917  InlineStorageUsed = false;
1918  ObjCIvar = false;
1919  ObjCWeakProperty = false;
1920  CommaLoc = SourceLocation();
1921  EllipsisLoc = SourceLocation();
1922  }
1923 
1924  /// mayOmitIdentifier - Return true if the identifier is either optional or
1925  /// not allowed. This is true for typenames, prototypes, and template
1926  /// parameter lists.
1927  bool mayOmitIdentifier() const {
1928  switch (Context) {
1936  return false;
1937 
1957  return true;
1958  }
1959  llvm_unreachable("unknown context kind!");
1960  }
1961 
1962  /// mayHaveIdentifier - Return true if the identifier is either optional or
1963  /// required. This is true for normal declarators and prototypes, but not
1964  /// typenames.
1965  bool mayHaveIdentifier() const {
1966  switch (Context) {
1979  return true;
1980 
1995  return false;
1996  }
1997  llvm_unreachable("unknown context kind!");
1998  }
1999 
2000  /// Return true if the context permits a C++17 decomposition declarator.
2002  switch (Context) {
2004  // FIXME: It's not clear that the proposal meant to allow file-scope
2005  // structured bindings, but it does.
2010  return true;
2011 
2015  // Maybe one day...
2016  return false;
2017 
2018  // These contexts don't allow any kind of non-abstract declarator.
2037  return false;
2038  }
2039  llvm_unreachable("unknown context kind!");
2040  }
2041 
2042  /// mayBeFollowedByCXXDirectInit - Return true if the declarator can be
2043  /// followed by a C++ direct initializer, e.g. "int x(1);".
2045  if (hasGroupingParens()) return false;
2046 
2047  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2048  return false;
2049 
2050  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_extern &&
2051  Context != DeclaratorContext::FileContext)
2052  return false;
2053 
2054  // Special names can't have direct initializers.
2056  return false;
2057 
2058  switch (Context) {
2064  return true;
2065 
2067  // This may not be followed by a direct initializer, but it can't be a
2068  // function declaration either, and we'd prefer to perform a tentative
2069  // parse in order to produce the right diagnostic.
2070  return true;
2071 
2092  return false;
2093  }
2094  llvm_unreachable("unknown context kind!");
2095  }
2096 
2097  /// isPastIdentifier - Return true if we have parsed beyond the point where
2098  /// the name would appear. (This may happen even if we haven't actually parsed
2099  /// a name, perhaps because this context doesn't require one.)
2100  bool isPastIdentifier() const { return Name.isValid(); }
2101 
2102  /// hasName - Whether this declarator has a name, which might be an
2103  /// identifier (accessible via getIdentifier()) or some kind of
2104  /// special C++ name (constructor, destructor, etc.), or a structured
2105  /// binding (which is not exactly a name, but occupies the same position).
2106  bool hasName() const {
2107  return Name.getKind() != UnqualifiedIdKind::IK_Identifier ||
2108  Name.Identifier || isDecompositionDeclarator();
2109  }
2110 
2111  /// Return whether this declarator is a decomposition declarator.
2113  return BindingGroup.isSet();
2114  }
2115 
2118  return Name.Identifier;
2119 
2120  return nullptr;
2121  }
2123 
2124  /// Set the name of this declarator to be the given identifier.
2126  Name.setIdentifier(Id, IdLoc);
2127  }
2128 
2129  /// Set the decomposition bindings for this declarator.
2130  void
2131  setDecompositionBindings(SourceLocation LSquareLoc,
2133  SourceLocation RSquareLoc);
2134 
2135  /// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
2136  /// EndLoc, which should be the last token of the chunk.
2137  /// This function takes attrs by R-Value reference because it takes ownership
2138  /// of those attributes from the parameter.
2140  SourceLocation EndLoc) {
2141  DeclTypeInfo.push_back(TI);
2142  DeclTypeInfo.back().getAttrs().addAll(attrs.begin(), attrs.end());
2143  getAttributePool().takeAllFrom(attrs.getPool());
2144 
2145  if (!EndLoc.isInvalid())
2146  SetRangeEnd(EndLoc);
2147  }
2148 
2149  /// AddTypeInfo - Add a chunk to this declarator. Also extend the range to
2150  /// EndLoc, which should be the last token of the chunk.
2151  void AddTypeInfo(const DeclaratorChunk &TI, SourceLocation EndLoc) {
2152  DeclTypeInfo.push_back(TI);
2153 
2154  if (!EndLoc.isInvalid())
2155  SetRangeEnd(EndLoc);
2156  }
2157 
2158  /// Add a new innermost chunk to this declarator.
2160  DeclTypeInfo.insert(DeclTypeInfo.begin(), TI);
2161  }
2162 
2163  /// Return the number of types applied to this declarator.
2164  unsigned getNumTypeObjects() const { return DeclTypeInfo.size(); }
2165 
2166  /// Return the specified TypeInfo from this declarator. TypeInfo #0 is
2167  /// closest to the identifier.
2168  const DeclaratorChunk &getTypeObject(unsigned i) const {
2169  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2170  return DeclTypeInfo[i];
2171  }
2173  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2174  return DeclTypeInfo[i];
2175  }
2176 
2178  typedef llvm::iterator_range<type_object_iterator> type_object_range;
2179 
2180  /// Returns the range of type objects, from the identifier outwards.
2181  type_object_range type_objects() const {
2182  return type_object_range(DeclTypeInfo.begin(), DeclTypeInfo.end());
2183  }
2184 
2186  assert(!DeclTypeInfo.empty() && "No type chunks to drop.");
2187  DeclTypeInfo.front().destroy();
2188  DeclTypeInfo.erase(DeclTypeInfo.begin());
2189  }
2190 
2191  /// Return the innermost (closest to the declarator) chunk of this
2192  /// declarator that is not a parens chunk, or null if there are no
2193  /// non-parens chunks.
2195  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2196  if (!DeclTypeInfo[i].isParen())
2197  return &DeclTypeInfo[i];
2198  }
2199  return nullptr;
2200  }
2201 
2202  /// Return the outermost (furthest from the declarator) chunk of
2203  /// this declarator that is not a parens chunk, or null if there are
2204  /// no non-parens chunks.
2206  for (unsigned i = DeclTypeInfo.size(), i_end = 0; i != i_end; --i) {
2207  if (!DeclTypeInfo[i-1].isParen())
2208  return &DeclTypeInfo[i-1];
2209  }
2210  return nullptr;
2211  }
2212 
2213  /// isArrayOfUnknownBound - This method returns true if the declarator
2214  /// is a declarator for an array of unknown bound (looking through
2215  /// parentheses).
2216  bool isArrayOfUnknownBound() const {
2217  const DeclaratorChunk *chunk = getInnermostNonParenChunk();
2218  return (chunk && chunk->Kind == DeclaratorChunk::Array &&
2219  !chunk->Arr.NumElts);
2220  }
2221 
2222  /// isFunctionDeclarator - This method returns true if the declarator
2223  /// is a function declarator (looking through parentheses).
2224  /// If true is returned, then the reference type parameter idx is
2225  /// assigned with the index of the declaration chunk.
2226  bool isFunctionDeclarator(unsigned& idx) const {
2227  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2228  switch (DeclTypeInfo[i].Kind) {
2230  idx = i;
2231  return true;
2233  continue;
2239  case DeclaratorChunk::Pipe:
2240  return false;
2241  }
2242  llvm_unreachable("Invalid type chunk");
2243  }
2244  return false;
2245  }
2246 
2247  /// isFunctionDeclarator - Once this declarator is fully parsed and formed,
2248  /// this method returns true if the identifier is a function declarator
2249  /// (looking through parentheses).
2250  bool isFunctionDeclarator() const {
2251  unsigned index;
2252  return isFunctionDeclarator(index);
2253  }
2254 
2255  /// getFunctionTypeInfo - Retrieves the function type info object
2256  /// (looking through parentheses).
2258  assert(isFunctionDeclarator() && "Not a function declarator!");
2259  unsigned index = 0;
2260  isFunctionDeclarator(index);
2261  return DeclTypeInfo[index].Fun;
2262  }
2263 
2264  /// getFunctionTypeInfo - Retrieves the function type info object
2265  /// (looking through parentheses).
2267  return const_cast<Declarator*>(this)->getFunctionTypeInfo();
2268  }
2269 
2270  /// Determine whether the declaration that will be produced from
2271  /// this declaration will be a function.
2272  ///
2273  /// A declaration can declare a function even if the declarator itself
2274  /// isn't a function declarator, if the type specifier refers to a function
2275  /// type. This routine checks for both cases.
2276  bool isDeclarationOfFunction() const;
2277 
2278  /// Return true if this declaration appears in a context where a
2279  /// function declarator would be a function declaration.
2281  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2282  return false;
2283 
2284  switch (Context) {
2290  return true;
2291 
2313  return false;
2314  }
2315  llvm_unreachable("unknown context kind!");
2316  }
2317 
2318  /// Determine whether this declaration appears in a context where an
2319  /// expression could appear.
2320  bool isExpressionContext() const {
2321  switch (Context) {
2325 
2326  // FIXME: sizeof(...) permits an expression.
2328 
2346  return false;
2347 
2353  return true;
2354  }
2355 
2356  llvm_unreachable("unknown context kind!");
2357  }
2358 
2359  /// Return true if a function declarator at this position would be a
2360  /// function declaration.
2362  if (!isFunctionDeclarationContext())
2363  return false;
2364 
2365  for (unsigned I = 0, N = getNumTypeObjects(); I != N; ++I)
2366  if (getTypeObject(I).Kind != DeclaratorChunk::Paren)
2367  return false;
2368 
2369  return true;
2370  }
2371 
2372  /// Determine whether a trailing return type was written (at any
2373  /// level) within this declarator.
2374  bool hasTrailingReturnType() const {
2375  for (const auto &Chunk : type_objects())
2376  if (Chunk.Kind == DeclaratorChunk::Function &&
2377  Chunk.Fun.hasTrailingReturnType())
2378  return true;
2379  return false;
2380  }
2381 
2382  /// takeAttributes - Takes attributes from the given parsed-attributes
2383  /// set and add them to this declarator.
2384  ///
2385  /// These examples both add 3 attributes to "var":
2386  /// short int var __attribute__((aligned(16),common,deprecated));
2387  /// short int x, __attribute__((aligned(16)) var
2388  /// __attribute__((common,deprecated));
2389  ///
2390  /// Also extends the range of the declarator.
2392  Attrs.takeAllFrom(attrs);
2393 
2394  if (!lastLoc.isInvalid())
2395  SetRangeEnd(lastLoc);
2396  }
2397 
2398  const ParsedAttributes &getAttributes() const { return Attrs; }
2399  ParsedAttributes &getAttributes() { return Attrs; }
2400 
2401  /// hasAttributes - do we contain any attributes?
2402  bool hasAttributes() const {
2403  if (!getAttributes().empty() || getDeclSpec().hasAttributes())
2404  return true;
2405  for (unsigned i = 0, e = getNumTypeObjects(); i != e; ++i)
2406  if (!getTypeObject(i).getAttrs().empty())
2407  return true;
2408  return false;
2409  }
2410 
2411  /// Return a source range list of C++11 attributes associated
2412  /// with the declarator.
2414  for (const ParsedAttr &AL : Attrs)
2415  if (AL.isCXX11Attribute())
2416  Ranges.push_back(AL.getRange());
2417  }
2418 
2419  void setAsmLabel(Expr *E) { AsmLabel = E; }
2420  Expr *getAsmLabel() const { return AsmLabel; }
2421 
2422  void setExtension(bool Val = true) { Extension = Val; }
2423  bool getExtension() const { return Extension; }
2424 
2425  void setObjCIvar(bool Val = true) { ObjCIvar = Val; }
2426  bool isObjCIvar() const { return ObjCIvar; }
2427 
2428  void setObjCWeakProperty(bool Val = true) { ObjCWeakProperty = Val; }
2429  bool isObjCWeakProperty() const { return ObjCWeakProperty; }
2430 
2431  void setInvalidType(bool Val = true) { InvalidType = Val; }
2432  bool isInvalidType() const {
2433  return InvalidType || DS.getTypeSpecType() == DeclSpec::TST_error;
2434  }
2435 
2436  void setGroupingParens(bool flag) { GroupingParens = flag; }
2437  bool hasGroupingParens() const { return GroupingParens; }
2438 
2439  bool isFirstDeclarator() const { return !CommaLoc.isValid(); }
2440  SourceLocation getCommaLoc() const { return CommaLoc; }
2441  void setCommaLoc(SourceLocation CL) { CommaLoc = CL; }
2442 
2443  bool hasEllipsis() const { return EllipsisLoc.isValid(); }
2444  SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
2445  void setEllipsisLoc(SourceLocation EL) { EllipsisLoc = EL; }
2446 
2448  FunctionDefinition = Val;
2449  }
2450 
2451  bool isFunctionDefinition() const {
2452  return getFunctionDefinitionKind() != FDK_Declaration;
2453  }
2454 
2456  return (FunctionDefinitionKind)FunctionDefinition;
2457  }
2458 
2459  /// Returns true if this declares a real member and not a friend.
2461  return getContext() == DeclaratorContext::MemberContext &&
2462  !getDeclSpec().isFriendSpecified();
2463  }
2464 
2465  /// Returns true if this declares a static member. This cannot be called on a
2466  /// declarator outside of a MemberContext because we won't know until
2467  /// redeclaration time if the decl is static.
2468  bool isStaticMember();
2469 
2470  /// Returns true if this declares a constructor or a destructor.
2471  bool isCtorOrDtor();
2472 
2473  void setRedeclaration(bool Val) { Redeclaration = Val; }
2474  bool isRedeclaration() const { return Redeclaration; }
2475 };
2476 
2477 /// This little struct is used to capture information about
2478 /// structure field declarators, which is basically just a bitfield size.
2482  explicit FieldDeclarator(const DeclSpec &DS)
2483  : D(DS, DeclaratorContext::MemberContext),
2484  BitfieldSize(nullptr) {}
2485 };
2486 
2487 /// Represents a C++11 virt-specifier-seq.
2489 public:
2490  enum Specifier {
2491  VS_None = 0,
2492  VS_Override = 1,
2493  VS_Final = 2,
2494  VS_Sealed = 4,
2495  // Represents the __final keyword, which is legal for gcc in pre-C++11 mode.
2496  VS_GNU_Final = 8
2497  };
2498 
2499  VirtSpecifiers() : Specifiers(0), LastSpecifier(VS_None) { }
2500 
2501  bool SetSpecifier(Specifier VS, SourceLocation Loc,
2502  const char *&PrevSpec);
2503 
2504  bool isUnset() const { return Specifiers == 0; }
2505 
2506  bool isOverrideSpecified() const { return Specifiers & VS_Override; }
2507  SourceLocation getOverrideLoc() const { return VS_overrideLoc; }
2508 
2509  bool isFinalSpecified() const { return Specifiers & (VS_Final | VS_Sealed | VS_GNU_Final); }
2510  bool isFinalSpelledSealed() const { return Specifiers & VS_Sealed; }
2511  SourceLocation getFinalLoc() const { return VS_finalLoc; }
2512 
2513  void clear() { Specifiers = 0; }
2514 
2515  static const char *getSpecifierName(Specifier VS);
2516 
2517  SourceLocation getFirstLocation() const { return FirstLocation; }
2518  SourceLocation getLastLocation() const { return LastLocation; }
2519  Specifier getLastSpecifier() const { return LastSpecifier; }
2520 
2521 private:
2522  unsigned Specifiers;
2523  Specifier LastSpecifier;
2524 
2525  SourceLocation VS_overrideLoc, VS_finalLoc;
2526  SourceLocation FirstLocation;
2527  SourceLocation LastLocation;
2528 };
2529 
2531  NoInit, //!< [a]
2532  CopyInit, //!< [a = b], [a = {b}]
2533  DirectInit, //!< [a(b)]
2534  ListInit //!< [a{b}]
2535 };
2536 
2537 /// Represents a complete lambda introducer.
2539  /// An individual capture in a lambda introducer.
2540  struct LambdaCapture {
2549 
2551  IdentifierInfo *Id, SourceLocation EllipsisLoc,
2552  LambdaCaptureInitKind InitKind, ExprResult Init,
2553  ParsedType InitCaptureType,
2554  SourceRange ExplicitRange)
2555  : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc),
2556  InitKind(InitKind), Init(Init), InitCaptureType(InitCaptureType),
2557  ExplicitRange(ExplicitRange) {}
2558  };
2559 
2564 
2566  : Default(LCD_None) {}
2567 
2568  /// Append a capture in a lambda introducer.
2570  SourceLocation Loc,
2571  IdentifierInfo* Id,
2572  SourceLocation EllipsisLoc,
2573  LambdaCaptureInitKind InitKind,
2574  ExprResult Init,
2575  ParsedType InitCaptureType,
2576  SourceRange ExplicitRange) {
2577  Captures.push_back(LambdaCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
2578  InitCaptureType, ExplicitRange));
2579  }
2580 };
2581 
2582 } // end namespace clang
2583 
2584 #endif // LLVM_CLANG_SEMA_DECLSPEC_H
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1464
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1127
void ClearFunctionSpecs()
Definition: DeclSpec.h:585
AttributePool & getAttributePool() const
Definition: DeclSpec.h:1850
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
Definition: DeclSpec.h:1070
unsigned UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
Definition: DeclSpec.h:1173
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2257
unsigned MutableLoc
The location of the &#39;mutable&#39; qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1311
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1255
no exception specification
void setKind(UnqualifiedIdKind kind)
Definition: DeclSpec.h:1005
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:1906
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
Definition: DeclSpec.h:1122
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclSpec.h:821
unsigned RestrictQualifierLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1307
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:980
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2168
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:950
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:834
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:1314
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:777
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:23
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1275
bool isOverrideSpecified() const
Definition: DeclSpec.h:2506
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the &#39;volatile&#39; qualifier, if any.
Definition: DeclSpec.h:1419
A constructor named via a template-id.
SourceLocation getLParenLoc() const
Definition: DeclSpec.h:1384
Declarator(const DeclSpec &ds, DeclaratorContext C)
Definition: DeclSpec.h:1828
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
Definition: DeclSpec.h:2374
TypeSpecifierType TST
Definition: DeclSpec.h:271
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:1878
One instance of this struct is used for each type in a declarator that is parsed. ...
Definition: DeclSpec.h:1138
Represent a C++ namespace.
Definition: Decl.h:514
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1146
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Definition: DeclSpec.h:2226
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
Definition: DeclSpec.h:1287
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:1341
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:1880
LambdaCaptureInitKind InitKind
Definition: DeclSpec.h:2545
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:1224
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:2125
SourceLocation getEndLoc() const
Definition: DeclSpec.h:73
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1292
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:1388
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:2398
SourceLocation getOverrideLoc() const
Definition: DeclSpec.h:2507
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1167
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,b,c)".
Definition: DeclSpec.h:1382
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:2280
void setObjCQualifiers(ObjCDeclSpec *quals)
Definition: DeclSpec.h:767
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
Definition: DeclSpec.h:1197
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1752
void setTypeofParensRange(SourceRange range)
Definition: DeclSpec.h:527
ObjCDeclSpec * getObjCQualifiers() const
Definition: DeclSpec.h:766
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
SourceLocation getFinalLoc() const
Definition: DeclSpec.h:2511
void setBegin(SourceLocation b)
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:599
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:1447
const IdentifierInfo * getSetterName() const
Definition: DeclSpec.h:869
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
Definition: DeclSpec.h:1927
Information about a template-id annotation token.
IdentifierInfo * getGetterName()
Definition: DeclSpec.h:862
SourceRange getTypeSpecWidthRange() const
Definition: DeclSpec.h:514
bool isUnset() const
Definition: DeclSpec.h:2504
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
SourceLocation getFriendSpecLoc() const
Definition: DeclSpec.h:710
bool isRedeclaration() const
Definition: DeclSpec.h:2474
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
Definition: DeclSpec.h:974
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:1332
One of these records is kept for each identifier that is lexed.
SmallVectorImpl< DeclaratorChunk >::const_iterator type_object_iterator
Definition: DeclSpec.h:2177
SourceLocation getSetterNameLoc() const
Definition: DeclSpec.h:871
SourceLocation getExceptionSpecLocBeg() const
Definition: DeclSpec.h:1396
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: DeclSpec.h:762
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Definition: DeclSpec.h:958
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:1128
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:150
void DropFirstTypeObject()
Definition: DeclSpec.h:2185
A C++ nested-name-specifier augmented with source location information.
SourceLocation getTypeSpecTypeLoc() const
Definition: DeclSpec.h:517
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
Definition: DeclSpec.h:1038
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:1302
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:969
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:933
Definition: Format.h:2031
bool isParen() const
Definition: DeclSpec.h:1644
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned The qualifier bitmask values are the same as...
Definition: DeclSpec.h:1259
bool isFunctionDefinition() const
Definition: DeclSpec.h:2451
bool hasAutoTypeSpec() const
Definition: DeclSpec.h:529
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:827
static const TST TST_error
Definition: DeclSpec.h:310
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:1877
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:1529
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:1424
A user-defined literal name, e.g., operator "" _i.
void SetSourceRange(SourceRange R)
Definition: DeclSpec.h:1882
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2479
bool isInvalidType() const
Definition: DeclSpec.h:2432
bool isFinalSpelledSealed() const
Definition: DeclSpec.h:2510
PointerTypeInfo Ptr
Definition: DeclSpec.h:1501
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Definition: DeclSpec.h:966
void setExternInLinkageSpec(bool Value)
Definition: DeclSpec.h:456
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:922
void setObjCWeakProperty(bool Val=true)
Definition: DeclSpec.h:2428
ObjCPropertyAttributeKind
PropertyAttributeKind - list of property attributes.
Definition: DeclSpec.h:798
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
Definition: DeclSpec.h:2361
unsigned ConstQualLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1161
void setExtension(bool Val=true)
Definition: DeclSpec.h:2422
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
Definition: DeclSpec.h:2250
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, std::unique_ptr< CachedTokens > DefArgTokens=nullptr)
Definition: DeclSpec.h:1227
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it&#39;s invalid.
Definition: DeclSpec.h:1885
bool isTypeSpecPipe() const
Definition: DeclSpec.h:489
SCS
storage-class-specifier
Definition: DeclSpec.h:232
ArrayTypeInfo Arr
Definition: DeclSpec.h:1503
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2164
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:1125
void setRedeclaration(bool Val)
Definition: DeclSpec.h:2473
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:751
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Definition: DeclSpec.h:2159
void takeAllFrom(ParsedAttributes &attrs)
Definition: ParsedAttr.h:810
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1269
TSS getTypeSpecSign() const
Definition: DeclSpec.h:482
bool hasAttributes() const
Definition: DeclSpec.h:748
ActionResult< ParsedType > TypeResult
Definition: Ownership.h:269
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1278
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
enum clang::DeclaratorChunk::@196 Kind
bool isNoreturnSpecified() const
Definition: DeclSpec.h:582
void UpdateExprRep(Expr *Rep)
Definition: DeclSpec.h:683
SourceLocation getConstSpecLoc() const
Definition: DeclSpec.h:550
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
Definition: DeclSpec.h:1856
SourceLocation getLSquareLoc() const
Definition: DeclSpec.h:1694
LambdaCaptureInitKind
Definition: DeclSpec.h:2530
bool isTypeRep() const
Definition: DeclSpec.h:488
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclSpec.h:508
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:2116
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
Definition: DeclSpec.h:962
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:2320
bool isExternInLinkageSpec() const
Definition: DeclSpec.h:455
bool isFinalSpecified() const
Definition: DeclSpec.h:2509
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:515
unsigned AccessWrites
The access writes.
Definition: DeclSpec.h:1495
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Definition: DeclSpec.h:1848
SourceLocation getAltiVecLoc() const
Definition: DeclSpec.h:518
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
SourceLocation getUnalignedSpecLoc() const
Definition: DeclSpec.h:554
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:872
void ClearConstexprSpec()
Definition: DeclSpec.h:718
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
Definition: DeclSpec.h:2044
bool isTypeAltiVecPixel() const
Definition: DeclSpec.h:485
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:1126
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
Definition: DeclSpec.h:2100
IdentifierInfo * getSetterName()
Definition: DeclSpec.h:870
void SetRangeStart(SourceLocation Loc)
Definition: DeclSpec.h:616
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:2569
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1282
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Definition: DeclSpec.h:1525
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
Definition: DeclSpec.h:1158
bool getExtension() const
Definition: DeclSpec.h:2423
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
Definition: DeclSpec.h:2001
A conversion function name, e.g., operator int.
SourceRange getRange() const
Definition: DeclSpec.h:68
SmallVector< LambdaCapture, 4 > Captures
Definition: DeclSpec.h:2563
TST getTypeSpecType() const
Definition: DeclSpec.h:483
static bool isDeclRep(TST T)
Definition: DeclSpec.h:417
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:2399
llvm::iterator_range< type_object_iterator > type_object_range
Definition: DeclSpec.h:2178
SourceRange getSourceRange() const
Definition: DeclSpec.h:1148
unsigned hasStatic
True if this dimension included the &#39;static&#39; keyword.
Definition: DeclSpec.h:1194
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:1114
bool isExplicitSpecified() const
Definition: DeclSpec.h:579
UnqualifiedIdKind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:898
int Id
Definition: ASTDiff.cpp:191
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
Definition: DeclSpec.h:2112
An individual capture in a lambda introducer.
Definition: DeclSpec.h:2540
DeclaratorChunk & getTypeObject(unsigned i)
Definition: DeclSpec.h:2172
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1164
TypeSpecifierWidth TSW
Definition: DeclSpec.h:252
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1613
Specifier getLastSpecifier() const
Definition: DeclSpec.h:2519
bool isTypeAltiVecVector() const
Definition: DeclSpec.h:484
void freeParams()
Reset the parameter list to having zero parameters.
Definition: DeclSpec.h:1351
SourceLocation getVolatileSpecLoc() const
Definition: DeclSpec.h:552
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:461
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
Definition: DeclSpec.h:558
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
Definition: DeclSpec.h:990
Defines an enumeration for C++ overloaded operators.
void setAsmLabel(Expr *E)
Definition: DeclSpec.h:2419
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:2266
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:72
bool hasEllipsis() const
Definition: DeclSpec.h:2443
bool isConstexprSpecified() const
Definition: DeclSpec.h:715
A parsed C++17 decomposition declarator of the form &#39;[&#39; identifier-list &#39;]&#39;.
Definition: DeclSpec.h:1651
void addAll(iterator B, iterator E)
Definition: ParsedAttr.h:767
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:1004
void UpdateTypeRep(ParsedType Rep)
Definition: DeclSpec.h:679
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
Definition: DeclSpec.h:1336
bool hasAttributes() const
hasAttributes - do we contain any attributes?
Definition: DeclSpec.h:2402
bool LValueRef
True if this is an lvalue reference, false if it&#39;s an rvalue reference.
Definition: DeclSpec.h:1183
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1144
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a &#39;mutable&#39; qualifier.
Definition: DeclSpec.h:1439
DeclaratorContext
Definition: DeclSpec.h:1710
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
Definition: DeclSpec.h:1055
void setEllipsisLoc(SourceLocation EL)
Definition: DeclSpec.h:2445
SourceLocation getEnd() const
ParsedAttributesView AttrList
Definition: DeclSpec.h:1154
const DeclaratorChunk * getOutermostNonParenChunk() const
Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chu...
Definition: DeclSpec.h:2205
bool isFriendSpecified() const
Definition: DeclSpec.h:709
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:83
SourceLocation getCommaLoc() const
Definition: DeclSpec.h:2440
bool isObjCIvar() const
Definition: DeclSpec.h:2426
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:998
bool isFirstDeclarator() const
Definition: DeclSpec.h:2439
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1346
SourceLocation getRSquareLoc() const
Definition: DeclSpec.h:1695
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:1328
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
Definition: DeclSpec.h:1409
NullabilityKind getNullability() const
Definition: DeclSpec.h:839
bool hasGroupingParens() const
Definition: DeclSpec.h:2437
SourceLocation getNoreturnSpecLoc() const
Definition: DeclSpec.h:583
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
ParsedAttributesView & getAttrs()
Definition: DeclSpec.h:1526
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
Definition: DeclSpec.h:1635
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:785
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:929
#define false
Definition: stdbool.h:33
SourceLocation DefaultLoc
Definition: DeclSpec.h:2561
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
Definition: DeclSpec.h:2216
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:1548
SCS getStorageClassSpec() const
Definition: DeclSpec.h:451
SourceLocation getRParenLoc() const
Definition: DeclSpec.h:1392
Expr * getAsmLabel() const
Definition: DeclSpec.h:2420
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:2106
Encodes a location in the source.
bool isTypeSpecOwned() const
Definition: DeclSpec.h:487
ReferenceTypeInfo Ref
Definition: DeclSpec.h:1502
ParsedSpecifiers
ParsedSpecifiers - Flags to query which specifiers were applied.
Definition: DeclSpec.h:326
FunctionDefinitionKind getFunctionDefinitionKind() const
Definition: DeclSpec.h:2455
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1860
FunctionTypeInfo Fun
Definition: DeclSpec.h:1504
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:712
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:511
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:105
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
char ScopeMem[sizeof(CXXScopeSpec)]
Definition: DeclSpec.h:1481
const DecompositionDeclarator & getDecompositionDeclarator() const
Definition: DeclSpec.h:1862
void setGroupingParens(bool flag)
Definition: DeclSpec.h:2436
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:2550
ObjCPropertyAttributeKind getPropertyAttributes() const
Definition: DeclSpec.h:831
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1506
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1461
Decl * getRepAsDecl() const
Definition: DeclSpec.h:496
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2488
void AddTypeInfo(const DeclaratorChunk &TI, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:2151
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
Definition: DeclSpec.h:1001
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
Definition: DeclSpec.h:1703
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
Definition: DeclSpec.h:1181
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
Definition: DeclSpec.h:1478
SourceLocation getConstQualifierLoc() const
Retrieve the location of the &#39;const&#39; qualifier, if any.
Definition: DeclSpec.h:1414
PipeTypeInfo PipeInfo
Definition: DeclSpec.h:1507
SourceLocation getInlineSpecLoc() const
Definition: DeclSpec.h:572
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
Definition: DeclSpec.h:1559
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:2447
SourceLocation getLastLocation() const
Definition: DeclSpec.h:2518
C++11 thread_local.
Definition: Specifiers.h:199
Defines various enumerations that describe declaration and type specifiers.
SourceLocation getModulePrivateSpecLoc() const
Definition: DeclSpec.h:713
bool isObjCWeakProperty() const
Definition: DeclSpec.h:2429
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
Definition: DeclSpec.h:1876
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
Definition: DeclSpec.h:2391
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:1191
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:1132
FieldDeclarator(const DeclSpec &DS)
Definition: DeclSpec.h:2482
static const TSS TSS_unspecified
Definition: DeclSpec.h:266
SourceLocation getTypeSpecWidthLoc() const
Definition: DeclSpec.h:513
LambdaCaptureDefault Default
Definition: DeclSpec.h:2562
void setObjCIvar(bool Val=true)
Definition: DeclSpec.h:2425
SourceLocation getTypeSpecSatLoc() const
Definition: DeclSpec.h:519
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:1248
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
Definition: DeclSpec.h:2194
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:1265
SourceLocation getPipeLoc() const
Definition: DeclSpec.h:555
unsigned ConstQualifierLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1297
SourceLocation getTypeSpecSignLoc() const
Definition: DeclSpec.h:516
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:510
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:824
bool isTypeAltiVecBool() const
Definition: DeclSpec.h:486
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:509
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
const CXXScopeSpec & getTypeSpecScope() const
Definition: DeclSpec.h:505
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Definition: DeclSpec.h:549
void takeAttributesFrom(ParsedAttributes &attrs)
Definition: DeclSpec.h:753
SourceLocation getNullabilityLoc() const
Definition: DeclSpec.h:846
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:577
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
Definition: DeclSpec.h:1243
SourceLocation getGetterNameLoc() const
Definition: DeclSpec.h:863
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1272
void setNullability(SourceLocation loc, NullabilityKind kind)
Definition: DeclSpec.h:853
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
Definition: DeclSpec.h:2181
CXXScopeSpec & getCXXScopeSpec()
Definition: DeclSpec.h:1857
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it&#39;s invalid.
Definition: DeclSpec.h:1890
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:1170
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1442
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:2139
SourceLocation getTypeSpecTypeNameLoc() const
Definition: DeclSpec.h:521
CXXScopeSpec & getTypeSpecScope()
Definition: DeclSpec.h:504
BlockPointerTypeInfo Cls
Definition: DeclSpec.h:1505
SourceRange getExceptionSpecRange() const
Definition: DeclSpec.h:1404
SourceLocation getIdentifierLoc() const
Definition: DeclSpec.h:2122
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:2413
SourceRange getSourceRange() const
Definition: DeclSpec.h:1696
void setInvalidType(bool Val=true)
Definition: DeclSpec.h:2431
unsigned TypeQuals
For now, sema will catch these as invalid.
Definition: DeclSpec.h:1470
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1603
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:1262
const CXXScopeSpec & Scope() const
Definition: DeclSpec.h:1485
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:193
Captures information about "declaration specifiers".
Definition: DeclSpec.h:228
SourceLocation getRestrictSpecLoc() const
Definition: DeclSpec.h:551
void setEnd(SourceLocation e)
void UpdateDeclRep(Decl *Rep)
Definition: DeclSpec.h:675
Represents a C++ struct/union/class.
Definition: DeclCXX.h:302
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
Definition: ParsedAttr.h:552
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:2444
bool isValid() const
SourceLocation getMutableLoc() const
Retrieve the location of the &#39;mutable&#39; qualifier, if any.
Definition: DeclSpec.h:1429
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:1202
void ClearTypeSpecType()
Definition: DeclSpec.h:473
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
Definition: DeclSpec.h:1965
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:1841
bool isVirtualSpecified() const
Definition: DeclSpec.h:576
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:2517
AttributePool & getPool() const
Definition: ParsedAttr.h:808
ParsedType getRepAsType() const
Definition: DeclSpec.h:492
bool isInlineSpecified() const
Definition: DeclSpec.h:569
Represents a complete lambda introducer.
Definition: DeclSpec.h:2538
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
Definition: DeclSpec.h:1897
SourceLocation getAtomicSpecLoc() const
Definition: DeclSpec.h:553
Expr * ExprRep
Definition: DeclSpec.h:372
void setBeginLoc(SourceLocation Loc)
Definition: DeclSpec.h:70
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:580
SourceLocation getConstexprSpecLoc() const
Definition: DeclSpec.h:716
TypeSpecifierSign TSS
Definition: DeclSpec.h:265
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
Definition: DeclSpec.h:1435
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
Definition: DeclSpec.h:1454
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
Definition: DeclSpec.h:612
const IdentifierInfo * getGetterName() const
Definition: DeclSpec.h:861
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1214
ArrayRef< Binding > bindings() const
Definition: DeclSpec.h:1688
DeclaratorContext getContext() const
Definition: DeclSpec.h:1866
SourceLocation getExceptionSpecLocEnd() const
Definition: DeclSpec.h:1400
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:1011
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1317
Expr * getRepAsExpr() const
Definition: DeclSpec.h:500
Represents a C++ namespace alias.
Definition: DeclCXX.h:3028
void setGetterName(IdentifierInfo *name, SourceLocation loc)
Definition: DeclSpec.h:864
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:983
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
Definition: DeclSpec.h:1093
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
Definition: DeclSpec.h:2460
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclSpec.h:1879
void SetRangeEnd(SourceLocation Loc)
Definition: DeclSpec.h:617
bool isPrototypeContext() const
Definition: DeclSpec.h:1868
void addAttributes(ParsedAttributesView &AL)
Concatenates two attribute lists.
Definition: DeclSpec.h:744
AttributePool & getAttributePool() const
Definition: DeclSpec.h:723
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:803
void setCommaLoc(SourceLocation CL)
Definition: DeclSpec.h:2441
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:1322
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:750
SourceRange getTypeofParensRange() const
Definition: DeclSpec.h:526
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:1622
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1251