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