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