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