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