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