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