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