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