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