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