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