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