clang  9.0.0svn
DeclSpec.h
Go to the documentation of this file.
1 //===--- DeclSpec.h - Parsed declaration specifiers -------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// This file defines the classes used to store parsed information about
11 /// declaration-specifiers and declarators.
12 ///
13 /// \verbatim
14 /// static const int volatile x, *y, *(*(*z)[10])(const void *x);
15 /// ------------------------- - -- ---------------------------
16 /// declaration-specifiers \ | /
17 /// declarators
18 /// \endverbatim
19 ///
20 //===----------------------------------------------------------------------===//
21 
22 #ifndef LLVM_CLANG_SEMA_DECLSPEC_H
23 #define LLVM_CLANG_SEMA_DECLSPEC_H
24 
27 #include "clang/Basic/Lambda.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 
37 namespace 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().
62 class CXXScopeSpec {
63  SourceRange Range;
65 
66 public:
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.
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 &Context, SourceLocation TemplateKWLoc, TypeLoc 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 &Context, IdentifierInfo *Identifier,
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 &Context, NamespaceDecl *Namespace,
119  SourceLocation NamespaceLoc, SourceLocation 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 &Context, NamespaceAliasDecl *Alias,
134  SourceLocation AliasLoc, SourceLocation ColonColonLoc);
135 
136  /// Turn this (empty) nested-name-specifier into the global
137  /// nested-name-specifier '::'.
138  void MakeGlobal(ASTContext &Context, SourceLocation 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 &Context, CXXRecordDecl *RD,
154  SourceLocation SuperLoc, SourceLocation 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 &Context, NestedNameSpecifier *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.
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
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.
199  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.
227 class DeclSpec {
228 public:
229  /// storage-class-specifier
230  /// \note The order of these enumerators is important for diagnostics.
231  enum SCS {
232  SCS_unspecified = 0,
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.
246  static const TSCS TSCS___thread = clang::TSCS___thread;
249 
250  // Import type specifier width enumeration and constants.
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 {
260  TSC_complex
261  };
262 
263  // Import type specifier sign enumeration and constants.
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.
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;
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;
295  static const TST TST_class = clang::TST_class;
296  static const TST TST_typename = clang::TST_typename;
299  static const TST TST_decltype = clang::TST_decltype;
302  static const TST TST_auto = clang::TST_auto;
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.
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 
334 private:
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_specified: 1;
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 {
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 StorageClassSpecLoc, ThreadStorageClassSpecLoc;
385  SourceRange TSWRange;
386  SourceLocation TSCLoc, TSSLoc, TSTLoc, AltiVecLoc, TSSatLoc;
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_constLoc, TQ_restrictLoc, TQ_volatileLoc, TQ_atomicLoc,
394  TQ_unalignedLoc;
395  SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc, FS_noreturnLoc;
396  SourceLocation FS_forceinlineLoc;
397  SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc;
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;
415 public:
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 
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; }
452  return (TSCS)ThreadStorageClassSpec;
453  }
454  bool isExternInLinkageSpec() const { return SCS_extern_in_linkage_spec; }
456  SCS_extern_in_linkage_spec = Value;
457  }
458 
459  SourceLocation getStorageClassSpecLoc() const { return StorageClassSpecLoc; }
461  return ThreadStorageClassSpecLoc;
462  }
463 
465  StorageClassSpec = DeclSpec::SCS_unspecified;
466  ThreadStorageClassSpec = DeclSpec::TSCS_unspecified;
467  SCS_extern_in_linkage_spec = false;
468  StorageClassSpecLoc = SourceLocation();
469  ThreadStorageClassSpecLoc = SourceLocation();
470  }
471 
473  TypeSpecType = DeclSpec::TST_unspecified;
474  TypeSpecOwned = false;
475  TSTLoc = SourceLocation();
476  }
477 
478  // type-specifier
479  TSW getTypeSpecWidth() const { return (TSW)TypeSpecWidth; }
480  TSC getTypeSpecComplex() const { return (TSC)TypeSpecComplex; }
481  TSS getTypeSpecSign() const { return (TSS)TypeSpecSign; }
482  TST getTypeSpecType() const { return (TST)TypeSpecType; }
483  bool isTypeAltiVecVector() const { return TypeAltiVecVector; }
484  bool isTypeAltiVecPixel() const { return TypeAltiVecPixel; }
485  bool isTypeAltiVecBool() const { return TypeAltiVecBool; }
486  bool isTypeSpecOwned() const { return TypeSpecOwned; }
487  bool isTypeRep() const { return isTypeRep((TST) TypeSpecType); }
488  bool isTypeSpecPipe() const { return TypeSpecPipe; }
489  bool isTypeSpecSat() const { return TypeSpecSat; }
490 
492  assert(isTypeRep((TST) TypeSpecType) && "DeclSpec does not store a type");
493  return TypeRep;
494  }
495  Decl *getRepAsDecl() const {
496  assert(isDeclRep((TST) TypeSpecType) && "DeclSpec does not store a decl");
497  return DeclRep;
498  }
499  Expr *getRepAsExpr() const {
500  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 
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.
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  }
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 
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 &S, SCS SC, SourceLocation Loc,
639  const char *&PrevSpec, unsigned &DiagID,
640  const PrintingPolicy &Policy);
641  bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc,
642  const char *&PrevSpec, unsigned &DiagID);
643  bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec,
644  unsigned &DiagID, const PrintingPolicy &Policy);
645  bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec,
646  unsigned &DiagID);
647  bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec,
648  unsigned &DiagID);
649  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
650  unsigned &DiagID, const PrintingPolicy &Policy);
651  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
652  unsigned &DiagID, ParsedType Rep,
653  const PrintingPolicy &Policy);
654  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
655  unsigned &DiagID, Decl *Rep, bool Owned,
656  const PrintingPolicy &Policy);
657  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
658  SourceLocation TagNameLoc, const char *&PrevSpec,
659  unsigned &DiagID, ParsedType Rep,
660  const PrintingPolicy &Policy);
661  bool SetTypeSpecType(TST T, SourceLocation TagKwLoc,
662  SourceLocation TagNameLoc, const char *&PrevSpec,
663  unsigned &DiagID, Decl *Rep, bool Owned,
664  const PrintingPolicy &Policy);
665 
666  bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec,
667  unsigned &DiagID, Expr *Rep,
668  const PrintingPolicy &policy);
669  bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc,
670  const char *&PrevSpec, unsigned &DiagID,
671  const PrintingPolicy &Policy);
672  bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc,
673  const char *&PrevSpec, unsigned &DiagID,
674  const PrintingPolicy &Policy);
675  bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc,
676  const char *&PrevSpec, unsigned &DiagID,
677  const PrintingPolicy &Policy);
678  bool SetTypePipe(bool isPipe, SourceLocation Loc,
679  const char *&PrevSpec, unsigned &DiagID,
680  const PrintingPolicy &Policy);
681  bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec,
682  unsigned &DiagID);
683  bool SetTypeSpecError();
684  void UpdateDeclRep(Decl *Rep) {
685  assert(isDeclRep((TST) TypeSpecType));
686  DeclRep = Rep;
687  }
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 T, SourceLocation Loc);
698 
699  bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
700  unsigned &DiagID, const LangOptions &Lang);
701 
702  bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec,
703  unsigned &DiagID);
704  bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec,
705  unsigned &DiagID);
706  bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec,
707  unsigned &DiagID);
708  bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec,
709  unsigned &DiagID);
710  bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec,
711  unsigned &DiagID);
712 
713  bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec,
714  unsigned &DiagID);
715  bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec,
716  unsigned &DiagID);
717  bool SetConstexprSpec(SourceLocation Loc, const 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 
730  Constexpr_specified = false;
731  ConstexprLoc = SourceLocation();
732  }
733 
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  ///
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 
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 &S, const PrintingPolicy &Policy);
772 
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.
789 public:
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.
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.
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 
829  : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
830  Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
831 
833  return (ObjCDeclQualifier)objcDeclQualifier;
834  }
836  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal);
837  }
839  objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
840  }
841 
843  return ObjCPropertyAttributeKind(PropertyAttributes);
844  }
846  PropertyAttributes =
847  (ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
848  }
849 
851  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
852  (getPropertyAttributes() & DQ_PR_nullability)) &&
853  "Objective-C declspec doesn't have nullability");
854  return static_cast<NullabilityKind>(Nullability);
855  }
856 
858  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
859  (getPropertyAttributes() & DQ_PR_nullability)) &&
860  "Objective-C declspec doesn't have nullability");
861  return NullabilityLoc;
862  }
863 
865  assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
866  (getPropertyAttributes() & DQ_PR_nullability)) &&
867  "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; }
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; }
884  SetterName = name;
885  SetterNameLoc = loc;
886  }
887 
888 private:
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.
909 enum class UnqualifiedIdKind {
910  /// An identifier.
912  /// An overloaded operator name, e.g., operator+.
914  /// A conversion function name, e.g., operator int.
916  /// A user-defined literal name, e.g., operator "" _i.
918  /// A constructor name.
920  /// A constructor named via a template-id.
922  /// A destructor name.
924  /// A template-id, e.g., f<int>.
926  /// An implicit 'self' parameter
928  /// A deduction-guide name (a template-name)
930 };
931 
932 /// Represents a C++ unqualified-id that has been parsed.
934 private:
935  UnqualifiedId(const UnqualifiedId &Other) = delete;
936  const UnqualifiedId &operator=(const UnqualifiedId &) = delete;
937 
938 public:
939  /// Describes the kind of unqualified-id parsed.
941 
942  struct OFI {
943  /// The kind of overloaded 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.
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.
970 
971  /// When Kind == IK_ConstructorName, the class-name of the type
972  /// whose constructor is being referenced.
974 
975  /// When Kind == IK_DestructorName, the type referred to by the
976  /// class-name.
978 
979  /// When Kind == IK_DeductionGuideName, the parsed template-name.
981 
982  /// When Kind == IK_TemplateId or IK_ConstructorTemplateId,
983  /// the template-id annotation that contains the template name and
984  /// template arguments.
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.
992 
993  /// The location of the last token that describes this unqualified-id.
995 
997  : Kind(UnqualifiedIdKind::IK_Identifier), Identifier(nullptr) {}
998 
999  /// Clear out this unqualified-id, setting it to default (invalid)
1000  /// state.
1001  void clear() {
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; }
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.
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,
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.
1050  ParsedType Ty,
1051  SourceLocation EndLoc) {
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.
1067  SourceLocation IdLoc) {
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.
1082  SourceLocation ClassNameLoc,
1083  SourceLocation EndLoc) {
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.
1105  ParsedType ClassType,
1106  SourceLocation EndLoc) {
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.
1126  SourceLocation TemplateLoc) {
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.
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.
1148  enum {
1149  Pointer, Reference, Array, Function, BlockPointer, MemberPointer, Paren, Pipe
1150  } Kind;
1151 
1152  /// Loc - The place where this type was defined.
1154  /// EndLoc - If valid, the place where this chunck ends.
1156 
1158  if (EndLoc.isInvalid())
1159  return SourceRange(Loc, Loc);
1160  return SourceRange(Loc, EndLoc);
1161  }
1162 
1164 
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.
1174 
1175  /// The location of the restrict-qualifier, if any.
1177 
1178  /// The location of the _Atomic-qualifier, if any.
1179  unsigned AtomicQualLoc;
1180 
1181  /// The location of the __unaligned-qualifier, if any.
1183 
1184  void destroy() {
1185  }
1186  };
1187 
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.
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 {
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<CachedTokens> DefaultArgTokens;
1234 
1235  ParamInfo() = default;
1237  Decl *param,
1238  std::unique_ptr<CachedTokens> DefArgTokens = nullptr)
1239  : Ident(ident), IdentLoc(iloc), Param(param),
1240  DefaultArgTokens(std::move(DefArgTokens)) {}
1241  };
1242 
1243  struct TypeAndRange {
1246  };
1247 
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.
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.
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.
1293 
1294  /// The location of the ref-qualifier, if any.
1295  ///
1296  /// If this is an invalid location, there is no ref-qualifier.
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.
1305 
1306  /// The end location of the exception specification, if any.
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.
1313 
1314  /// DeclSpec for the function with the qualifier related info.
1316 
1317  /// AtttibuteFactory for the MethodQualifiers.
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.
1325 
1326  /// Pointer to the expression in the noexcept-specifier of this
1327  /// function, if it has one.
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++.
1338  };
1339 
1340  /// If HasTrailingReturnType is true, this is the trailing return
1341  /// type specified.
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 = 0; I < 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 
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 
1391  return SourceLocation::getFromRawEncoding(LParenLoc);
1392  }
1393 
1395  return SourceLocation::getFromRawEncoding(EllipsisLoc);
1396  }
1397 
1399  return SourceLocation::getFromRawEncoding(RParenLoc);
1400  }
1401 
1403  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
1404  }
1405 
1407  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
1408  }
1409 
1411  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
1412  }
1413 
1414  /// Retrieve the location of the ref-qualifier, if any.
1416  return SourceLocation::getFromRawEncoding(RefQualifierLoc);
1417  }
1418 
1419  /// Retrieve the location of the 'const' qualifier.
1421  assert(MethodQualifiers);
1422  return MethodQualifiers->getConstSpecLoc();
1423  }
1424 
1425  /// Retrieve the location of the 'volatile' qualifier.
1427  assert(MethodQualifiers);
1428  return MethodQualifiers->getVolatileSpecLoc();
1429  }
1430 
1431  /// Retrieve the location of the 'restrict' qualifier.
1433  assert(MethodQualifiers);
1434  return MethodQualifiers->getRestrictSpecLoc();
1435  }
1436 
1437  /// Retrieve the location of the 'mutable' qualifier, if any.
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.
1452  return MethodQualifiers && (MethodQualifiers->getTypeQualifiers() ||
1453  MethodQualifiers->getAttributes().size());
1454  }
1455 
1456  /// Get the type of exception specification this function has.
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.
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 
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 
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(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
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 {
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::MemberPointer: return 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 TypeQuals, SourceLocation 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 TypeQuals, SourceLocation 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 isStatic, bool isStar, Expr *NumElts,
1576  SourceLocation LBLoc, SourceLocation 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 *Params, unsigned 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 
1635  unsigned TypeQuals,
1636  SourceLocation Loc) {
1637  DeclaratorChunk I;
1638  I.Kind = MemberPointer;
1639  I.Loc = SS.getBeginLoc();
1640  I.EndLoc = Loc;
1641  I.Mem.TypeQuals = TypeQuals;
1642  new (I.Mem.ScopeMem) CXXScopeSpec(SS);
1643  return I;
1644  }
1645 
1646  /// Return a DeclaratorChunk for a paren.
1648  SourceLocation RParenLoc) {
1649  DeclaratorChunk I;
1650  I.Kind = Paren;
1651  I.Loc = LParenLoc;
1652  I.EndLoc = RParenLoc;
1653  return I;
1654  }
1655 
1656  bool isParen() const {
1657  return Kind == Paren;
1658  }
1659 };
1660 
1661 /// A parsed C++17 decomposition declarator of the form
1662 /// '[' identifier-list ']'
1664 public:
1665  struct Binding {
1668  };
1669 
1670 private:
1671  /// The locations of the '[' and ']' tokens.
1672  SourceLocation LSquareLoc, RSquareLoc;
1673 
1674  /// The bindings.
1675  Binding *Bindings;
1676  unsigned NumBindings : 31;
1677  unsigned DeleteBindings : 1;
1678 
1679  friend class Declarator;
1680 
1681 public:
1683  : Bindings(nullptr), NumBindings(0), DeleteBindings(false) {}
1685  DecompositionDeclarator &operator=(const DecompositionDeclarator &G) = delete;
1687  if (DeleteBindings)
1688  delete[] Bindings;
1689  }
1690 
1691  void clear() {
1692  LSquareLoc = RSquareLoc = SourceLocation();
1693  if (DeleteBindings)
1694  delete[] Bindings;
1695  Bindings = nullptr;
1696  NumBindings = 0;
1697  DeleteBindings = false;
1698  }
1699 
1701  return llvm::makeArrayRef(Bindings, NumBindings);
1702  }
1703 
1704  bool isSet() const { return LSquareLoc.isValid(); }
1705 
1706  SourceLocation getLSquareLoc() const { return LSquareLoc; }
1707  SourceLocation getRSquareLoc() const { return RSquareLoc; }
1709  return SourceRange(LSquareLoc, RSquareLoc);
1710  }
1711 };
1712 
1713 /// Described the kind of function definition (if any) provided for
1714 /// a function.
1720 };
1721 
1722 enum class DeclaratorContext {
1723  FileContext, // File scope declaration.
1724  PrototypeContext, // Within a function prototype.
1725  ObjCResultContext, // An ObjC method result type.
1726  ObjCParameterContext,// An ObjC method parameter type.
1727  KNRTypeListContext, // K&R type definition list for formals.
1728  TypeNameContext, // Abstract declarator for types.
1729  FunctionalCastContext, // Type in a C++ functional cast expression.
1730  MemberContext, // Struct/Union field.
1731  BlockContext, // Declaration within a block in a function.
1732  ForContext, // Declaration within first part of a for loop.
1733  InitStmtContext, // Declaration within optional init stmt of if/switch.
1734  ConditionContext, // Condition declaration in a C++ if/switch/while/for.
1735  TemplateParamContext,// Within a template parameter list.
1736  CXXNewContext, // C++ new-expression.
1737  CXXCatchContext, // C++ catch exception-declaration
1738  ObjCCatchContext, // Objective-C catch exception-declaration
1739  BlockLiteralContext, // Block literal declarator.
1740  LambdaExprContext, // Lambda-expression declarator.
1741  LambdaExprParameterContext, // Lambda-expression parameter declarator.
1742  ConversionIdContext, // C++ conversion-type-id.
1743  TrailingReturnContext, // C++11 trailing-type-specifier.
1744  TrailingReturnVarContext, // C++11 trailing-type-specifier for variable.
1745  TemplateArgContext, // Any template argument (in template argument list).
1746  TemplateTypeArgContext, // Template type argument (in default argument).
1747  AliasDeclContext, // C++11 alias-declaration.
1748  AliasTemplateContext // C++11 alias-declaration template.
1749 };
1750 
1751 
1752 /// Information about one declarator, including the parsed type
1753 /// information and the identifier.
1754 ///
1755 /// When the declarator is fully formed, this is turned into the appropriate
1756 /// Decl object.
1757 ///
1758 /// Declarators come in two types: normal declarators and abstract declarators.
1759 /// Abstract declarators are used when parsing types, and don't have an
1760 /// identifier. Normal declarators do have ID's.
1761 ///
1762 /// Instances of this class should be a transient object that lives on the
1763 /// stack, not objects that are allocated in large quantities on the heap.
1764 class Declarator {
1765 
1766 private:
1767  const DeclSpec &DS;
1768  CXXScopeSpec SS;
1769  UnqualifiedId Name;
1770  SourceRange Range;
1771 
1772  /// Where we are parsing this declarator.
1773  DeclaratorContext Context;
1774 
1775  /// The C++17 structured binding, if any. This is an alternative to a Name.
1776  DecompositionDeclarator BindingGroup;
1777 
1778  /// DeclTypeInfo - This holds each type that the declarator includes as it is
1779  /// parsed. This is pushed from the identifier out, which means that element
1780  /// #0 will be the most closely bound to the identifier, and
1781  /// DeclTypeInfo.back() will be the least closely bound.
1782  SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
1783 
1784  /// InvalidType - Set by Sema::GetTypeForDeclarator().
1785  unsigned InvalidType : 1;
1786 
1787  /// GroupingParens - Set by Parser::ParseParenDeclarator().
1788  unsigned GroupingParens : 1;
1789 
1790  /// FunctionDefinition - Is this Declarator for a function or member
1791  /// definition and, if so, what kind?
1792  ///
1793  /// Actually a FunctionDefinitionKind.
1794  unsigned FunctionDefinition : 2;
1795 
1796  /// Is this Declarator a redeclaration?
1797  unsigned Redeclaration : 1;
1798 
1799  /// true if the declaration is preceded by \c __extension__.
1800  unsigned Extension : 1;
1801 
1802  /// Indicates whether this is an Objective-C instance variable.
1803  unsigned ObjCIvar : 1;
1804 
1805  /// Indicates whether this is an Objective-C 'weak' property.
1806  unsigned ObjCWeakProperty : 1;
1807 
1808  /// Indicates whether the InlineParams / InlineBindings storage has been used.
1809  unsigned InlineStorageUsed : 1;
1810 
1811  /// Attrs - Attributes.
1812  ParsedAttributes Attrs;
1813 
1814  /// The asm label, if specified.
1815  Expr *AsmLabel;
1816 
1817 #ifndef _MSC_VER
1818  union {
1819 #endif
1820  /// InlineParams - This is a local array used for the first function decl
1821  /// chunk to avoid going to the heap for the common case when we have one
1822  /// function chunk in the declarator.
1823  DeclaratorChunk::ParamInfo InlineParams[16];
1825 #ifndef _MSC_VER
1826  };
1827 #endif
1828 
1829  /// If this is the second or subsequent declarator in this declaration,
1830  /// the location of the comma before this declarator.
1831  SourceLocation CommaLoc;
1832 
1833  /// If provided, the source location of the ellipsis used to describe
1834  /// this declarator as a parameter pack.
1835  SourceLocation EllipsisLoc;
1836 
1837  friend struct DeclaratorChunk;
1838 
1839 public:
1841  : DS(ds), Range(ds.getSourceRange()), Context(C),
1842  InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error),
1843  GroupingParens(false), FunctionDefinition(FDK_Declaration),
1844  Redeclaration(false), Extension(false), ObjCIvar(false),
1845  ObjCWeakProperty(false), InlineStorageUsed(false),
1846  Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr) {}
1847 
1849  clear();
1850  }
1851  /// getDeclSpec - Return the declaration-specifier that this declarator was
1852  /// declared with.
1853  const DeclSpec &getDeclSpec() const { return DS; }
1854 
1855  /// getMutableDeclSpec - Return a non-const version of the DeclSpec. This
1856  /// should be used with extreme care: declspecs can often be shared between
1857  /// multiple declarators, so mutating the DeclSpec affects all of the
1858  /// Declarators. This should only be done when the declspec is known to not
1859  /// be shared or when in error recovery etc.
1860  DeclSpec &getMutableDeclSpec() { return const_cast<DeclSpec &>(DS); }
1861 
1863  return Attrs.getPool();
1864  }
1865 
1866  /// getCXXScopeSpec - Return the C++ scope specifier (global scope or
1867  /// nested-name-specifier) that is part of the declarator-id.
1868  const CXXScopeSpec &getCXXScopeSpec() const { return SS; }
1869  CXXScopeSpec &getCXXScopeSpec() { return SS; }
1870 
1871  /// Retrieve the name specified by this declarator.
1872  UnqualifiedId &getName() { return Name; }
1873 
1875  return BindingGroup;
1876  }
1877 
1878  DeclaratorContext getContext() const { return Context; }
1879 
1880  bool isPrototypeContext() const {
1881  return (Context == DeclaratorContext::PrototypeContext ||
1885  }
1886 
1887  /// Get the source range that spans this declarator.
1888  SourceRange getSourceRange() const LLVM_READONLY { return Range; }
1889  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.
1896  if (!Loc.isInvalid())
1897  Range.setBegin(Loc);
1898  }
1899  /// SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
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) {
1946  return false;
1947 
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) {
1989  return true;
1990 
2005  return false;
2006  }
2007  llvm_unreachable("unknown context kind!");
2008  }
2009 
2010  /// Return true if the context permits a C++17 decomposition declarator.
2012  switch (Context) {
2014  // FIXME: It's not clear that the proposal meant to allow file-scope
2015  // structured bindings, but it does.
2020  return true;
2021 
2025  // Maybe one day...
2026  return false;
2027 
2028  // These contexts don't allow any kind of non-abstract declarator.
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);".
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.
2066  return false;
2067 
2068  switch (Context) {
2074  return true;
2075 
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 
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.
2123  return BindingGroup.isSet();
2124  }
2125 
2128  return Name.Identifier;
2129 
2130  return nullptr;
2131  }
2133 
2134  /// Set the name of this declarator to be the given identifier.
2136  Name.setIdentifier(Id, IdLoc);
2137  }
2138 
2139  /// Set the decomposition bindings for this declarator.
2140  void
2141  setDecompositionBindings(SourceLocation LSquareLoc,
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.
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 &TI, SourceLocation 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.
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 i) const {
2179  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2180  return DeclTypeInfo[i];
2181  }
2183  assert(i < DeclTypeInfo.size() && "Invalid type chunk");
2184  return DeclTypeInfo[i];
2185  }
2186 
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 
2196  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.
2205  for (unsigned i = 0, i_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.
2216  for (unsigned i = DeclTypeInfo.size(), i_end = 0; i != 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(unsigned& idx) const {
2237  for (unsigned i = 0, i_end = DeclTypeInfo.size(); i < i_end; ++i) {
2238  switch (DeclTypeInfo[i].Kind) {
2240  idx = i;
2241  return true;
2243  continue;
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).
2268  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).
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.
2291  if (getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef)
2292  return false;
2293 
2294  switch (Context) {
2300  return true;
2301 
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) {
2335 
2336  // FIXME: sizeof(...) permits an expression.
2338 
2356  return false;
2357 
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.
2372  if (!isFunctionDeclarationContext())
2373  return false;
2374 
2375  for (unsigned I = 0, N = 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.
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 = 0, e = 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.
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 
2458  FunctionDefinition = Val;
2459  }
2460 
2461  bool isFunctionDefinition() const {
2462  return getFunctionDefinitionKind() != FDK_Declaration;
2463  }
2464 
2466  return (FunctionDefinitionKind)FunctionDefinition;
2467  }
2468 
2469  /// Returns true if this declares a real member and not a friend.
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.
2492  explicit FieldDeclarator(const DeclSpec &DS)
2493  : D(DS, DeclaratorContext::MemberContext),
2494  BitfieldSize(nullptr) {}
2495 };
2496 
2497 /// Represents a C++11 virt-specifier-seq.
2499 public:
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 VS, SourceLocation 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 
2531 private:
2532  unsigned Specifiers;
2533  Specifier LastSpecifier;
2534 
2535  SourceLocation VS_overrideLoc, VS_finalLoc;
2536  SourceLocation FirstLocation;
2537  SourceLocation LastLocation;
2538 };
2539 
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.
2549  /// An individual capture in a lambda introducer.
2550  struct LambdaCapture {
2559 
2561  IdentifierInfo *Id, SourceLocation EllipsisLoc,
2562  LambdaCaptureInitKind InitKind, ExprResult 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 
2574 
2576  : Default(LCD_None) {}
2577 
2578  /// Append a capture in a lambda introducer.
2580  SourceLocation Loc,
2581  IdentifierInfo* Id,
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
ParsedType getTrailingReturnType() const
Get the trailing-return-type for this function declarator.
Definition: DeclSpec.h:1479
void ClearFunctionSpecs()
Definition: DeclSpec.h:582
AttributePool & getAttributePool() const
Definition: DeclSpec.h:1862
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
Definition: DeclSpec.h:1081
unsigned UnalignedQualLoc
The location of the __unaligned-qualifier, if any.
Definition: DeclSpec.h:1182
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2267
unsigned MutableLoc
The location of the &#39;mutable&#39; qualifer in a lambda-declarator, if any.
Definition: DeclSpec.h:1301
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
Definition: DeclSpec.h:1264
StringRef Identifier
Definition: Format.cpp:1635
no exception specification
void setKind(UnqualifiedIdKind kind)
Definition: DeclSpec.h:1016
SourceLocation getLastQualifierNameLoc() const
Retrieve the location of the name in the last qualifier in this nested name specifier.
Definition: DeclSpec.cpp:135
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into &#39;__super&#39; nested-name-specifier.
Definition: DeclSpec.cpp:106
void clear()
Reset the contents of this Declarator.
Definition: DeclSpec.h:1916
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
Definition: DeclSpec.h:1133
ObjCDeclQualifier getObjCDeclQualifier() const
Definition: DeclSpec.h:832
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Definition: DeclSpec.h:991
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Definition: DeclSpec.h:2178
SizeType size() const
Definition: ParsedAttr.h:784
ThreadStorageClassSpecifier TSCS
Definition: DeclSpec.h:244
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
Definition: DeclSpec.h:961
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:285
UnionParsedType TypeRep
Definition: DeclSpec.h:369
bool isEmpty() const
No scope specifier.
Definition: DeclSpec.h:188
void setEndLoc(SourceLocation Loc)
Definition: DeclSpec.h:70
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal)
Definition: DeclSpec.h:845
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
unsigned ExceptionSpecLocBeg
The beginning location of the exception specification, if any.
Definition: DeclSpec.h:1304
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:788
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
Definition: Lambda.h:22
unsigned EllipsisLoc
When isVariadic is true, the location of the ellipsis in the source.
Definition: DeclSpec.h:1280
bool isOverrideSpecified() const
Definition: DeclSpec.h:2516
SourceLocation getVolatileQualifierLoc() const
Retrieve the location of the &#39;volatile&#39; qualifier.
Definition: DeclSpec.h:1426
A constructor named via a template-id.
SourceLocation getLParenLoc() const
Definition: DeclSpec.h:1390
Declarator(const DeclSpec &ds, DeclaratorContext C)
Definition: DeclSpec.h:1840
bool hasTrailingReturnType() const
Determine whether a trailing return type was written (at any level) within this declarator.
Definition: DeclSpec.h:2384
TypeSpecifierType TST
Definition: DeclSpec.h:270
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:1889
One instance of this struct is used for each type in a declarator that is parsed. ...
Definition: DeclSpec.h:1147
Represent a C++ namespace.
Definition: Decl.h:514
SourceLocation EndLoc
EndLoc - If valid, the place where this chunck ends.
Definition: DeclSpec.h:1155
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
Definition: DeclSpec.h:2236
unsigned NumExceptionsOrDecls
NumExceptionsOrDecls - This is the number of types in the dynamic-exception-decl, if the function has...
Definition: DeclSpec.h:1292
NamedDecl ** DeclsInPrototype
Pointer to a new[]&#39;d array of declarations that need to be available for lookup inside the function b...
Definition: DeclSpec.h:1337
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:1890
LambdaCaptureInitKind InitKind
Definition: DeclSpec.h:2555
bool isTypeSpecSat() const
Definition: DeclSpec.h:489
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter&#39;s default argument cannot be parsed immediately (because it occ...
Definition: DeclSpec.h:1233
An overloaded operator name, e.g., operator+.
TSCS getThreadStorageClassSpec() const
Definition: DeclSpec.h:451
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:220
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
Definition: DeclSpec.h:2135
SourceLocation getEndLoc() const
Definition: DeclSpec.h:72
unsigned RefQualifierLoc
The location of the ref-qualifier, if any.
Definition: DeclSpec.h:1297
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:1394
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:2408
SourceLocation getOverrideLoc() const
Definition: DeclSpec.h:2517
unsigned RestrictQualLoc
The location of the restrict-qualifier, if any.
Definition: DeclSpec.h:1176
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,b,c)".
Definition: DeclSpec.h:1388
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:124
std::pair< char *, unsigned > getBuffer() const
Retrieve the underlying buffer.
static const TSCS TSCS_unspecified
Definition: DeclSpec.h:245
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
Definition: DeclSpec.h:2290
void setObjCQualifiers(ObjCDeclSpec *quals)
Definition: DeclSpec.h:778
unsigned isStar
True if this dimension was [*]. In this case, NumElts is null.
Definition: DeclSpec.h:1206
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1764
void setTypeofParensRange(SourceRange range)
Definition: DeclSpec.h:524
ObjCDeclSpec * getObjCQualifiers() const
Definition: DeclSpec.h:777
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:44
SourceLocation getFinalLoc() const
Definition: DeclSpec.h:2521
void setBegin(SourceLocation b)
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Definition: DeclSpec.h:608
Describes how types, statements, expressions, and declarations should be printed. ...
Definition: PrettyPrinter.h:37
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
Definition: DeclSpec.h:1451
unsigned getNumExceptions() const
Get the number of dynamic exception specifications.
Definition: DeclSpec.h:1462
const IdentifierInfo * getSetterName() const
Definition: DeclSpec.h:880
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
Definition: DeclSpec.h:1937
Information about a template-id annotation token.
IdentifierInfo * getGetterName()
Definition: DeclSpec.h:873
SourceRange getTypeSpecWidthRange() const
Definition: DeclSpec.h:511
bool isUnset() const
Definition: DeclSpec.h:2514
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:56
SourceLocation getFriendSpecLoc() const
Definition: DeclSpec.h:721
bool isRedeclaration() const
Definition: DeclSpec.h:2484
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
Definition: DeclSpec.h:985
C11 _Thread_local.
Definition: Specifiers.h:201
Expr * NoexceptExpr
Pointer to the expression in the noexcept-specifier of this function, if it has one.
Definition: DeclSpec.h:1328
One of these records is kept for each identifier that is lexed.
SmallVectorImpl< DeclaratorChunk >::const_iterator type_object_iterator
Definition: DeclSpec.h:2187
SourceLocation getSetterNameLoc() const
Definition: DeclSpec.h:882
SourceLocation getExceptionSpecLocBeg() const
Definition: DeclSpec.h:1402
const WrittenBuiltinSpecs & getWrittenBuiltinSpecs() const
Definition: DeclSpec.h:773
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
Definition: DeclSpec.h:969
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:1137
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:154
void DropFirstTypeObject()
Definition: DeclSpec.h:2195
A C++ nested-name-specifier augmented with source location information.
SourceLocation getTypeSpecTypeLoc() const
Definition: DeclSpec.h:514
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
Definition: DeclSpec.h:1049
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:32
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
DeclSpec(AttributeFactory &attrFactory)
Definition: DeclSpec.h:422
LambdaCaptureKind
The different capture forms in a lambda introducer.
Definition: Lambda.h:33
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
Definition: DeclSpec.h:980
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
OverloadedOperatorKind Operator
The kind of overloaded operator.
Definition: DeclSpec.h:944
Definition: Format.h:2071
bool isParen() const
Definition: DeclSpec.h:1656
bool isFunctionDefinition() const
Definition: DeclSpec.h:2461
bool hasAutoTypeSpec() const
Definition: DeclSpec.h:526
void clearObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:838
static const TST TST_error
Definition: DeclSpec.h:309
static const TSW TSW_unspecified
Definition: DeclSpec.h:252
void ClearStorageClassSpecs()
Definition: DeclSpec.h:464
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
Definition: DeclSpec.h:1544
TSC getTypeSpecComplex() const
Definition: DeclSpec.h:480
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
SourceLocation getRestrictQualifierLoc() const
Retrieve the location of the &#39;restrict&#39; qualifier.
Definition: DeclSpec.h:1432
A user-defined literal name, e.g., operator "" _i.
void SetSourceRange(SourceRange R)
Definition: DeclSpec.h:1892
This little struct is used to capture information about structure field declarators, which is basically just a bitfield size.
Definition: DeclSpec.h:2489
bool isInvalidType() const
Definition: DeclSpec.h:2442
bool isFinalSpelledSealed() const
Definition: DeclSpec.h:2520
PointerTypeInfo Ptr
Definition: DeclSpec.h:1516
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Definition: DeclSpec.h:977
void setExternInLinkageSpec(bool Value)
Definition: DeclSpec.h:455
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:933
void setObjCWeakProperty(bool Val=true)
Definition: DeclSpec.h:2438
ObjCPropertyAttributeKind
PropertyAttributeKind - list of property attributes.
Definition: DeclSpec.h:809
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
Definition: DeclSpec.h:2371
unsigned ConstQualLoc
The location of the const-qualifier, if any.
Definition: DeclSpec.h:1170
void setExtension(bool Val=true)
Definition: DeclSpec.h:2432
bool isFunctionDeclarator() const
isFunctionDeclarator - Once this declarator is fully parsed and formed, this method returns true if t...
Definition: DeclSpec.h:2260
ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, std::unique_ptr< CachedTokens > DefArgTokens=nullptr)
Definition: DeclSpec.h:1236
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it&#39;s invalid.
Definition: DeclSpec.h:1895
bool isTypeSpecPipe() const
Definition: DeclSpec.h:488
SCS
storage-class-specifier
Definition: DeclSpec.h:231
ArrayTypeInfo Arr
Definition: DeclSpec.h:1518
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Definition: DeclSpec.h:2174
void setRedeclaration(bool Val)
Definition: DeclSpec.h:2483
const ParsedAttributes & getAttributes() const
Definition: DeclSpec.h:762
void AddInnermostTypeInfo(const DeclaratorChunk &TI)
Add a new innermost chunk to this declarator.
Definition: DeclSpec.h:2169
void takeAllFrom(ParsedAttributes &attrs)
Definition: ParsedAttr.h:880
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
Definition: DeclSpec.h:1274
TSS getTypeSpecSign() const
Definition: DeclSpec.h:481
bool hasAttributes() const
Definition: DeclSpec.h:759
ActionResult< ParsedType > TypeResult
Definition: Ownership.h:265
unsigned RParenLoc
The location of the right parenthesis in the source.
Definition: DeclSpec.h:1283
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:40
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
Definition: DeclSpec.h:198
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:62
bool isNoreturnSpecified() const
Definition: DeclSpec.h:579
void UpdateExprRep(Expr *Rep)
Definition: DeclSpec.h:692
SourceLocation getConstSpecLoc() const
Definition: DeclSpec.h:547
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
Definition: DeclSpec.h:1868
SourceLocation getLSquareLoc() const
Definition: DeclSpec.h:1706
LambdaCaptureInitKind
Definition: DeclSpec.h:2540
bool isTypeRep() const
Definition: DeclSpec.h:487
SourceRange getSourceRange() const LLVM_READONLY
Definition: DeclSpec.h:506
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: DeclSpec.cpp:142
IdentifierInfo * getIdentifier() const
Definition: DeclSpec.h:2126
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
Definition: DeclSpec.h:973
Class that aids in the construction of nested-name-specifiers along with source-location information ...
bool isExpressionContext() const
Determine whether this declaration appears in a context where an expression could appear...
Definition: DeclSpec.h:2330
bool isExternInLinkageSpec() const
Definition: DeclSpec.h:454
bool isFinalSpecified() const
Definition: DeclSpec.h:2519
SourceLocation getTypeSpecComplexLoc() const
Definition: DeclSpec.h:512
unsigned AccessWrites
The access writes.
Definition: DeclSpec.h:1510
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
Definition: DeclSpec.h:1860
SourceLocation getAltiVecLoc() const
Definition: DeclSpec.h:515
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
enum clang::DeclaratorChunk::@215 Kind
SourceLocation getUnalignedSpecLoc() const
Definition: DeclSpec.h:551
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
Definition: DeclSpec.cpp:118
void setSetterName(IdentifierInfo *name, SourceLocation loc)
Definition: DeclSpec.h:883
void ClearConstexprSpec()
Definition: DeclSpec.h:729
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
Definition: DeclSpec.h:2054
bool isTypeAltiVecPixel() const
Definition: DeclSpec.h:484
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:1136
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
Definition: DeclSpec.h:2110
IdentifierInfo * getSetterName()
Definition: DeclSpec.h:881
void SetRangeStart(SourceLocation Loc)
Definition: DeclSpec.h:625
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
Append a capture in a lambda introducer.
Definition: DeclSpec.h:2579
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
Definition: DeclSpec.h:1315
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
Definition: DeclSpec.h:1287
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Definition: DeclSpec.h:1540
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/unaligned/atomic.
Definition: DeclSpec.h:1167
bool getExtension() const
Definition: DeclSpec.h:2433
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
Definition: DeclSpec.h:2011
A conversion function name, e.g., operator int.
SourceRange getRange() const
Definition: DeclSpec.h:67
SmallVector< LambdaCapture, 4 > Captures
Definition: DeclSpec.h:2573
TST getTypeSpecType() const
Definition: DeclSpec.h:482
static bool isDeclRep(TST T)
Definition: DeclSpec.h:416
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:2409
llvm::iterator_range< type_object_iterator > type_object_range
Definition: DeclSpec.h:2188
SourceRange getSourceRange() const
Definition: DeclSpec.h:1157
unsigned hasStatic
True if this dimension included the &#39;static&#39; keyword.
Definition: DeclSpec.h:1203
This represents one expression.
Definition: Expr.h:106
void setDeductionGuideName(ParsedTemplateTy Template, SourceLocation TemplateLoc)
Specify that this unqualified-id was parsed as a template-name for a deduction-guide.
Definition: DeclSpec.h:1125
bool isExplicitSpecified() const
Definition: DeclSpec.h:576
UnqualifiedIdKind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:909
int Id
Definition: ASTDiff.cpp:190
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
Definition: DeclSpec.h:2122
An individual capture in a lambda introducer.
Definition: DeclSpec.h:2550
DeclaratorChunk & getTypeObject(unsigned i)
Definition: DeclSpec.h:2182
unsigned VolatileQualLoc
The location of the volatile-qualifier, if any.
Definition: DeclSpec.h:1173
TypeSpecifierWidth TSW
Definition: DeclSpec.h:251
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1625
Specifier getLastSpecifier() const
Definition: DeclSpec.h:2529
bool isTypeAltiVecVector() const
Definition: DeclSpec.h:483
void freeParams()
Reset the parameter list to having zero parameters.
Definition: DeclSpec.h:1347
SourceLocation getVolatileSpecLoc() const
Definition: DeclSpec.h:549
SourceLocation getThreadStorageClassSpecLoc() const
Definition: DeclSpec.h:460
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
Definition: DeclSpec.h:555
void clear()
Clear out this unqualified-id, setting it to default (invalid) state.
Definition: DeclSpec.h:1001
Defines an enumeration for C++ overloaded operators.
void setAsmLabel(Expr *E)
Definition: DeclSpec.h:2429
void setRange(SourceRange R)
Definition: DeclSpec.h:68
const DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo() const
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
Definition: DeclSpec.h:2276
SourceLocation getBeginLoc() const
Definition: DeclSpec.h:71
bool hasEllipsis() const
Definition: DeclSpec.h:2453
bool isConstexprSpecified() const
Definition: DeclSpec.h:726
A parsed C++17 decomposition declarator of the form &#39;[&#39; identifier-list &#39;]&#39;.
Definition: DeclSpec.h:1663
void addAll(iterator B, iterator E)
Definition: ParsedAttr.h:820
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
SourceLocation getStorageClassSpecLoc() const
Definition: DeclSpec.h:459
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
Definition: DeclSpec.h:1015
void UpdateTypeRep(ParsedType Rep)
Definition: DeclSpec.h:688
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
Definition: DeclSpec.h:1332
bool hasAttributes() const
hasAttributes - do we contain any attributes?
Definition: DeclSpec.h:2412
bool LValueRef
True if this is an lvalue reference, false if it&#39;s an rvalue reference.
Definition: DeclSpec.h:1192
SourceLocation Loc
Loc - The place where this type was defined.
Definition: DeclSpec.h:1153
bool hasMutableQualifier() const
Determine whether this lambda-declarator contains a &#39;mutable&#39; qualifier.
Definition: DeclSpec.h:1448
DeclaratorContext
Definition: DeclSpec.h:1722
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
Definition: DeclSpec.h:1066
void setEllipsisLoc(SourceLocation EL)
Definition: DeclSpec.h:2455
SourceLocation getEnd() const
ParsedAttributesView AttrList
Definition: DeclSpec.h:1163
const DeclaratorChunk * getOutermostNonParenChunk() const
Return the outermost (furthest from the declarator) chunk of this declarator that is not a parens chu...
Definition: DeclSpec.h:2215
bool isFriendSpecified() const
Definition: DeclSpec.h:720
Wraps an identifier and optional source location for the identifier.
Definition: ParsedAttr.h:94
SourceLocation getCommaLoc() const
Definition: DeclSpec.h:2450
bool isObjCIvar() const
Definition: DeclSpec.h:2436
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
Definition: DeclSpec.h:1009
bool isFirstDeclarator() const
Definition: DeclSpec.h:2449
UnionParsedType TrailingReturnType
If HasTrailingReturnType is true, this is the trailing return type specified.
Definition: DeclSpec.h:1342
SourceLocation getRSquareLoc() const
Definition: DeclSpec.h:1707
TypeAndRange * Exceptions
Pointer to a new[]&#39;d array of TypeAndRange objects that contain the types in the function&#39;s dynamic e...
Definition: DeclSpec.h:1324
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
Definition: DeclSpec.h:1415
NullabilityKind getNullability() const
Definition: DeclSpec.h:850
bool hasGroupingParens() const
Definition: DeclSpec.h:2447
SourceLocation getNoreturnSpecLoc() const
Definition: DeclSpec.h:580
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:75
ParsedAttributesView & getAttrs()
Definition: DeclSpec.h:1541
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
Definition: DeclSpec.h:1647
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:216
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
Definition: DeclSpec.h:796
UnqualifiedIdKind Kind
Describes the kind of unqualified-id parsed.
Definition: DeclSpec.h:940
#define false
Definition: stdbool.h:33
SourceLocation DefaultLoc
Definition: DeclSpec.h:2571
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
Definition: DeclSpec.h:2226
Kind
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:153
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
Definition: DeclSpec.h:1563
SCS getStorageClassSpec() const
Definition: DeclSpec.h:450
SourceLocation getRParenLoc() const
Definition: DeclSpec.h:1398
Expr * getAsmLabel() const
Definition: DeclSpec.h:2430
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Definition: DeclSpec.h:2116
Encodes a location in the source.
bool isTypeSpecOwned() const
Definition: DeclSpec.h:486
ReferenceTypeInfo Ref
Definition: DeclSpec.h:1517
ParsedSpecifiers
ParsedSpecifiers - Flags to query which specifiers were applied.
Definition: DeclSpec.h:325
FunctionDefinitionKind getFunctionDefinitionKind() const
Definition: DeclSpec.h:2465
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
Definition: DeclSpec.h:1872
FunctionTypeInfo Fun
Definition: DeclSpec.h:1519
bool isModulePrivateSpecified() const
Definition: DeclSpec.h:723
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclSpec.h:508
Defines several types used to describe C++ lambda expressions that are shared between the parser and ...
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:116
NestedNameSpecifier * getRepresentation() const
Retrieve the representation of the nested-name-specifier.
char ScopeMem[sizeof(CXXScopeSpec)]
Definition: DeclSpec.h:1496
const DecompositionDeclarator & getDecompositionDeclarator() const
Definition: DeclSpec.h:1874
void setGroupingParens(bool flag)
Definition: DeclSpec.h:2446
GNU __thread.
Definition: Specifiers.h:195
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
AttributeFactory * QualAttrFactory
AtttibuteFactory for the MethodQualifiers.
Definition: DeclSpec.h:1318
LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
Definition: DeclSpec.h:2560
ObjCPropertyAttributeKind getPropertyAttributes() const
Definition: DeclSpec.h:842
MemberPointerTypeInfo Mem
Definition: DeclSpec.h:1521
bool hasTrailingReturnType() const
Determine whether this function declarator had a trailing-return-type.
Definition: DeclSpec.h:1476
Decl * getRepAsDecl() const
Definition: DeclSpec.h:495
Represents a C++11 virt-specifier-seq.
Definition: DeclSpec.h:2498
void AddTypeInfo(const DeclaratorChunk &TI, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:2161
bool isInvalid() const
Determine whether this unqualified-id refers to an invalid name.
Definition: DeclSpec.h:1012
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
Definition: DeclSpec.h:1715
bool HasRestrict
The type qualifier: restrict. [GNU] C++ extension.
Definition: DeclSpec.h:1190
unsigned TypeQuals
The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
Definition: DeclSpec.h:1493
SourceLocation getConstQualifierLoc() const
Retrieve the location of the &#39;const&#39; qualifier.
Definition: DeclSpec.h:1420
PipeTypeInfo PipeInfo
Definition: DeclSpec.h:1522
SourceLocation getInlineSpecLoc() const
Definition: DeclSpec.h:569
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
Definition: DeclSpec.h:1574
Decl * DeclRep
Definition: DeclSpec.h:370
bool isInvalid() const
An error occurred during parsing of the scope specifier.
Definition: DeclSpec.h:193
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Definition: DeclSpec.h:2457
SourceLocation getLastLocation() const
Definition: DeclSpec.h:2528
C++11 thread_local.
Definition: Specifiers.h:198
Defines various enumerations that describe declaration and type specifiers.
SourceLocation getModulePrivateSpecLoc() const
Definition: DeclSpec.h:724
bool isObjCWeakProperty() const
Definition: DeclSpec.h:2439
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
Definition: DeclSpec.h:1888
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
Definition: DeclSpec.h:2401
TSW getTypeSpecWidth() const
Definition: DeclSpec.h:479
Dataflow Directional Tag Classes.
unsigned TypeQuals
The type qualifiers for the array: const/volatile/restrict/__unaligned/_Atomic.
Definition: DeclSpec.h:1200
bool isValid() const
Return true if this is a valid SourceLocation object.
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
Definition: DeclSpec.h:1141
FieldDeclarator(const DeclSpec &DS)
Definition: DeclSpec.h:2492
static const TSS TSS_unspecified
Definition: DeclSpec.h:265
SourceLocation getTypeSpecWidthLoc() const
Definition: DeclSpec.h:510
LambdaCaptureDefault Default
Definition: DeclSpec.h:2572
void setObjCIvar(bool Val=true)
Definition: DeclSpec.h:2435
SourceLocation getTypeSpecSatLoc() const
Definition: DeclSpec.h:516
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with &#39;,...)&#39;, this is true.
Definition: DeclSpec.h:1257
const DeclaratorChunk * getInnermostNonParenChunk() const
Return the innermost (closest to the declarator) chunk of this declarator that is not a parens chunk...
Definition: DeclSpec.h:2204
SourceRange getSourceRange(const SourceRange &Range)
Returns the SourceRange of a SourceRange.
Definition: FixIt.h:33
unsigned DeleteParams
DeleteParams - If this is true, we need to delete[] Params.
Definition: DeclSpec.h:1270
SourceLocation getPipeLoc() const
Definition: DeclSpec.h:552
SourceLocation getTypeSpecSignLoc() const
Definition: DeclSpec.h:513
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
Definition: DeclSpec.h:835
bool isTypeAltiVecBool() const
Definition: DeclSpec.h:485
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclSpec.h:507
static const TST TST_unspecified
Definition: DeclSpec.h:271
bool isValid() const
A scope specifier is present, and it refers to a real scope.
Definition: DeclSpec.h:195
const CXXScopeSpec & getTypeSpecScope() const
Definition: DeclSpec.h:504
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Definition: DeclSpec.h:546
void takeAttributesFrom(ParsedAttributes &attrs)
Definition: DeclSpec.h:764
SourceLocation getNullabilityLoc() const
Definition: DeclSpec.h:857
SourceLocation getVirtualSpecLoc() const
Definition: DeclSpec.h:574
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
Definition: DeclSpec.h:1252
SourceLocation getGetterNameLoc() const
Definition: DeclSpec.h:874
unsigned LParenLoc
The location of the left parenthesis in the source.
Definition: DeclSpec.h:1277
void setNullability(SourceLocation loc, NullabilityKind kind)
Definition: DeclSpec.h:864
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
Definition: DeclSpec.h:2191
CXXScopeSpec & getCXXScopeSpec()
Definition: DeclSpec.h:1869
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it&#39;s invalid.
Definition: DeclSpec.h:1900
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
unsigned AtomicQualLoc
The location of the _Atomic-qualifier, if any.
Definition: DeclSpec.h:1179
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
Definition: DeclSpec.h:1457
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Definition: DeclSpec.h:2149
SourceLocation getTypeSpecTypeNameLoc() const
Definition: DeclSpec.h:518
CXXScopeSpec & getTypeSpecScope()
Definition: DeclSpec.h:503
BlockPointerTypeInfo Cls
Definition: DeclSpec.h:1520
SourceRange getExceptionSpecRange() const
Definition: DeclSpec.h:1410
SourceLocation getIdentifierLoc() const
Definition: DeclSpec.h:2132
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:87
bool isSet() const
Deprecated.
Definition: DeclSpec.h:208
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
Definition: DeclSpec.h:2423
SourceRange getSourceRange() const
Definition: DeclSpec.h:1708
void setInvalidType(bool Val=true)
Definition: DeclSpec.h:2441
unsigned TypeQuals
For now, sema will catch these as invalid.
Definition: DeclSpec.h:1485
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
Definition: DeclSpec.h:1615
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form &#39;type...
Definition: DeclSpec.cpp:46
unsigned ExceptionSpecType
ExceptionSpecType - An ExceptionSpecificationType value.
Definition: DeclSpec.h:1267
const CXXScopeSpec & Scope() const
Definition: DeclSpec.h:1500
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:192
Captures information about "declaration specifiers".
Definition: DeclSpec.h:227
SourceLocation getRestrictSpecLoc() const
Definition: DeclSpec.h:548
void setEnd(SourceLocation e)
void UpdateDeclRep(Decl *Rep)
Definition: DeclSpec.h:684
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
Definition: ParsedAttr.h:597
SourceLocation getEllipsisLoc() const
Definition: DeclSpec.h:2454
bool isValid() const
SourceLocation getMutableLoc() const
Retrieve the location of the &#39;mutable&#39; qualifier, if any.
Definition: DeclSpec.h:1438
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:24
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
Definition: DeclSpec.h:1211
void ClearTypeSpecType()
Definition: DeclSpec.h:472
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
Definition: DeclSpec.h:1975
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
Definition: DeclSpec.h:190
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Definition: DeclSpec.h:1853
bool isVirtualSpecified() const
Definition: DeclSpec.h:573
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:60
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
Definition: DeclSpec.cpp:96
A template-id, e.g., f<int>.
SourceLocation getFirstLocation() const
Definition: DeclSpec.h:2527
AttributePool & getPool() const
Definition: ParsedAttr.h:878
ParsedType getRepAsType() const
Definition: DeclSpec.h:491
bool isInlineSpecified() const
Definition: DeclSpec.h:566
Represents a complete lambda introducer.
Definition: DeclSpec.h:2548
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
Definition: DeclSpec.h:1907
SourceLocation getAtomicSpecLoc() const
Definition: DeclSpec.h:550
Expr * ExprRep
Definition: DeclSpec.h:371
void setBeginLoc(SourceLocation Loc)
Definition: DeclSpec.h:69
SourceLocation getExplicitSpecLoc() const
Definition: DeclSpec.h:577
SourceLocation getConstexprSpecLoc() const
Definition: DeclSpec.h:727
TypeSpecifierSign TSS
Definition: DeclSpec.h:264
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
Definition: DeclSpec.h:1444
ArrayRef< NamedDecl * > getDeclsInPrototype() const
Get the non-parameter decls defined within this function prototype.
Definition: DeclSpec.h:1469
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
Definition: DeclSpec.h:621
const IdentifierInfo * getGetterName() const
Definition: DeclSpec.h:872
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
Definition: DeclSpec.h:1223
ArrayRef< Binding > bindings() const
Definition: DeclSpec.h:1700
DeclaratorContext getContext() const
Definition: DeclSpec.h:1878
SourceLocation getExceptionSpecLocEnd() const
Definition: DeclSpec.h:1406
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Definition: Decl.h:248
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:1022
unsigned ExceptionSpecLocEnd
The end location of the exception specification, if any.
Definition: DeclSpec.h:1307
Expr * getRepAsExpr() const
Definition: DeclSpec.h:499
Represents a C++ namespace alias.
Definition: DeclCXX.h:3019
void setGetterName(IdentifierInfo *name, SourceLocation loc)
Definition: DeclSpec.h:875
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
Definition: DeclSpec.h:994
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
Definition: DeclSpec.h:1104
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
Definition: DeclSpec.h:2470
void SetRangeEnd(SourceLocation Loc)
Definition: DeclSpec.h:626
bool isPrototypeContext() const
Definition: DeclSpec.h:1880
void addAttributes(ParsedAttributesView &AL)
Concatenates two attribute lists.
Definition: DeclSpec.h:755
AttributePool & getAttributePool() const
Definition: DeclSpec.h:734
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
Definition: ParsedAttr.h:873
void setCommaLoc(SourceLocation CL)
Definition: DeclSpec.h:2451
An implicit &#39;self&#39; parameter.
A deduction-guide name (a template-name)
ParamInfo * Params
Params - This is a pointer to a new[]&#39;d array of ParamInfo objects that describe the parameters speci...
Definition: DeclSpec.h:1312
ParsedAttributes & getAttributes()
Definition: DeclSpec.h:761
SourceRange getTypeofParensRange() const
Definition: DeclSpec.h:523
void Clear()
Clear out this builder, and prepare it to build another nested-name-specifier with source-location in...
static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS, unsigned TypeQuals, SourceLocation Loc)
Definition: DeclSpec.h:1634
unsigned isAmbiguous
Can this declaration be a constructor-style initializer?
Definition: DeclSpec.h:1260