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