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