Clang Project

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