clang 24.0.0git
Decl.h
Go to the documentation of this file.
1//===- Decl.h - Classes for representing declarations -----------*- 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// This file defines the Decl subclasses.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_DECL_H
14#define LLVM_CLANG_AST_DECL_H
15
17#include "clang/AST/APValue.h"
20#include "clang/AST/DeclBase.h"
25#include "clang/AST/TypeBase.h"
29#include "clang/Basic/LLVM.h"
30#include "clang/Basic/Linkage.h"
38#include "llvm/ADT/APSInt.h"
39#include "llvm/ADT/ArrayRef.h"
40#include "llvm/ADT/FoldingSet.h"
41#include "llvm/ADT/PointerIntPair.h"
42#include "llvm/ADT/PointerUnion.h"
43#include "llvm/ADT/StringRef.h"
44#include "llvm/ADT/iterator_range.h"
45#include "llvm/BinaryFormat/DXContainer.h"
46#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/Compiler.h"
49#include "llvm/Support/TrailingObjects.h"
50#include <cassert>
51#include <cstddef>
52#include <cstdint>
53#include <optional>
54#include <string>
55#include <utility>
56
57namespace clang {
58
59class ASTContext;
61class CompoundStmt;
63class EnumDecl;
64class Expr;
67class FunctionTypeLoc;
68class LabelStmt;
70class Module;
71class NamespaceDecl;
72class ParmVarDecl;
73class RecordDecl;
74class SemaProxy;
75class Stmt;
76class StringLiteral;
77class TagDecl;
83class VarTemplateDecl;
84enum class ImplicitParamKind;
86
87// Holds a constraint expression along with a pack expansion index, if
88// expanded.
90 const Expr *ConstraintExpr = nullptr;
92
93 constexpr AssociatedConstraint() = default;
94
98
99 explicit operator bool() const { return ConstraintExpr != nullptr; }
100
101 bool isNull() const { return !operator bool(); }
102};
103
104/// The top declaration context.
105class TranslationUnitDecl : public Decl,
106 public DeclContext,
107 public Redeclarable<TranslationUnitDecl> {
108 using redeclarable_base = Redeclarable<TranslationUnitDecl>;
109
110 TranslationUnitDecl *getNextRedeclarationImpl() override {
111 return getNextRedeclaration();
112 }
113
114 TranslationUnitDecl *getPreviousDeclImpl() override {
115 return getPreviousDecl();
116 }
117
118 TranslationUnitDecl *getMostRecentDeclImpl() override {
119 return getMostRecentDecl();
120 }
121
122 ASTContext &Ctx;
123
124 /// The (most recently entered) anonymous namespace for this
125 /// translation unit, if one has been created.
126 NamespaceDecl *AnonymousNamespace = nullptr;
127
128 explicit TranslationUnitDecl(ASTContext &ctx);
129
130 virtual void anchor();
131
132public:
134 using redecl_iterator = redeclarable_base::redecl_iterator;
135
142
143 ASTContext &getASTContext() const { return Ctx; }
144
145 NamespaceDecl *getAnonymousNamespace() const { return AnonymousNamespace; }
147
149
150 // Implement isa/cast/dyncast/etc.
151 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
152 static bool classofKind(Kind K) { return K == TranslationUnit; }
153 static DeclContext *castToDeclContext(const TranslationUnitDecl *D) {
154 return static_cast<DeclContext *>(const_cast<TranslationUnitDecl*>(D));
155 }
156 static TranslationUnitDecl *castFromDeclContext(const DeclContext *DC) {
157 return static_cast<TranslationUnitDecl *>(const_cast<DeclContext*>(DC));
158 }
159
160 /// Retrieves the canonical declaration of this translation unit.
161 TranslationUnitDecl *getCanonicalDecl() override { return getFirstDecl(); }
162 const TranslationUnitDecl *getCanonicalDecl() const { return getFirstDecl(); }
163};
164
165/// Represents a `#pragma comment` line. Always a child of
166/// TranslationUnitDecl.
167class PragmaCommentDecl final
168 : public Decl,
169 private llvm::TrailingObjects<PragmaCommentDecl, char> {
170 friend class ASTDeclReader;
171 friend class ASTDeclWriter;
172 friend TrailingObjects;
173
174 PragmaMSCommentKind CommentKind;
175
176 PragmaCommentDecl(TranslationUnitDecl *TU, SourceLocation CommentLoc,
177 PragmaMSCommentKind CommentKind)
178 : Decl(PragmaComment, TU, CommentLoc), CommentKind(CommentKind) {}
179
180 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
181
182public:
184 SourceLocation CommentLoc,
185 PragmaMSCommentKind CommentKind,
186 StringRef Arg);
188 unsigned ArgSize);
189
190 PragmaMSCommentKind getCommentKind() const { return CommentKind; }
191
192 StringRef getArg() const { return getTrailingObjects(); }
193
194 // Implement isa/cast/dyncast/etc.
195 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
196 static bool classofKind(Kind K) { return K == PragmaComment; }
197};
198
199/// Represents a `#pragma detect_mismatch` line. Always a child of
200/// TranslationUnitDecl.
201class PragmaDetectMismatchDecl final
202 : public Decl,
203 private llvm::TrailingObjects<PragmaDetectMismatchDecl, char> {
204 friend class ASTDeclReader;
205 friend class ASTDeclWriter;
206 friend TrailingObjects;
207
208 size_t ValueStart;
209
210 PragmaDetectMismatchDecl(TranslationUnitDecl *TU, SourceLocation Loc,
211 size_t ValueStart)
212 : Decl(PragmaDetectMismatch, TU, Loc), ValueStart(ValueStart) {}
213
214 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
215
216public:
219 SourceLocation Loc, StringRef Name,
220 StringRef Value);
222 CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NameValueSize);
223
224 StringRef getName() const { return getTrailingObjects(); }
225 StringRef getValue() const { return getTrailingObjects() + ValueStart; }
226
227 // Implement isa/cast/dyncast/etc.
228 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
229 static bool classofKind(Kind K) { return K == PragmaDetectMismatch; }
230};
231
232/// Declaration context for names declared as extern "C" in C++. This
233/// is neither the semantic nor lexical context for such declarations, but is
234/// used to check for conflicts with other extern "C" declarations. Example:
235///
236/// \code
237/// namespace N { extern "C" void f(); } // #1
238/// void N::f() {} // #2
239/// namespace M { extern "C" void f(); } // #3
240/// \endcode
241///
242/// The semantic context of #1 is namespace N and its lexical context is the
243/// LinkageSpecDecl; the semantic context of #2 is namespace N and its lexical
244/// context is the TU. However, both declarations are also visible in the
245/// extern "C" context.
246///
247/// The declaration at #3 finds it is a redeclaration of \c N::f through
248/// lookup in the extern "C" context.
249class ExternCContextDecl : public Decl, public DeclContext {
250 explicit ExternCContextDecl(TranslationUnitDecl *TU)
251 : Decl(ExternCContext, TU, SourceLocation()),
252 DeclContext(ExternCContext) {}
253
254 virtual void anchor();
255
256public:
257 static ExternCContextDecl *Create(const ASTContext &C,
259
260 // Implement isa/cast/dyncast/etc.
261 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
262 static bool classofKind(Kind K) { return K == ExternCContext; }
263 static DeclContext *castToDeclContext(const ExternCContextDecl *D) {
264 return static_cast<DeclContext *>(const_cast<ExternCContextDecl*>(D));
265 }
266 static ExternCContextDecl *castFromDeclContext(const DeclContext *DC) {
267 return static_cast<ExternCContextDecl *>(const_cast<DeclContext*>(DC));
268 }
269};
270
271/// This represents a decl that may have a name. Many decls have names such
272/// as ObjCMethodDecl, but not \@class, etc.
273///
274/// Note that not every NamedDecl is actually named (e.g., a struct might
275/// be anonymous), and not every name is an identifier.
276class NamedDecl : public Decl {
277 /// The name of this declaration, which is typically a normal
278 /// identifier but may also be a special kind of name (C++
279 /// constructor, Objective-C selector, etc.)
280 DeclarationName Name;
281
282 virtual void anchor();
283
284private:
285 NamedDecl *getUnderlyingDeclImpl() LLVM_READONLY;
286
287protected:
289 : Decl(DK, DC, L), Name(N) {}
290
291public:
292 /// Get the identifier that names this declaration, if there is one.
293 ///
294 /// This will return NULL if this declaration has no name (e.g., for
295 /// an unnamed class) or if the name is a special name (C++ constructor,
296 /// Objective-C selector, etc.).
297 IdentifierInfo *getIdentifier() const { return Name.getAsIdentifierInfo(); }
298
299 /// Get the name of identifier for this declaration as a StringRef.
300 ///
301 /// This requires that the declaration have a name and that it be a simple
302 /// identifier.
303 StringRef getName() const {
304 assert(Name.isIdentifier() && "Name is not a simple identifier");
305 return getIdentifier() ? getIdentifier()->getName() : "";
306 }
307
308 /// Get a human-readable name for the declaration, even if it is one of the
309 /// special kinds of names (C++ constructor, Objective-C selector, etc).
310 ///
311 /// Creating this name requires expensive string manipulation, so it should
312 /// be called only when performance doesn't matter. For simple declarations,
313 /// getNameAsCString() should suffice.
314 //
315 // FIXME: This function should be renamed to indicate that it is not just an
316 // alternate form of getName(), and clients should move as appropriate.
317 //
318 // FIXME: Deprecated, move clients to getName().
319 std::string getNameAsString() const { return Name.getAsString(); }
320
321 /// Pretty-print the unqualified name of this declaration. Can be overloaded
322 /// by derived classes to provide a more user-friendly name when appropriate.
323 virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const;
324 /// Calls printName() with the ASTContext printing policy from the decl.
325 void printName(raw_ostream &OS) const;
326
327 /// Get the actual, stored name of the declaration, which may be a special
328 /// name.
329 ///
330 /// Note that generally in diagnostics, the non-null \p NamedDecl* itself
331 /// should be sent into the diagnostic instead of using the result of
332 /// \p getDeclName().
333 ///
334 /// A \p DeclarationName in a diagnostic will just be streamed to the output,
335 /// which will directly result in a call to \p DeclarationName::print.
336 ///
337 /// A \p NamedDecl* in a diagnostic will also ultimately result in a call to
338 /// \p DeclarationName::print, but with two customisation points along the
339 /// way (\p getNameForDiagnostic and \p printName). These are used to print
340 /// the template arguments if any, and to provide a user-friendly name for
341 /// some entities (such as unnamed variables and anonymous records).
342 DeclarationName getDeclName() const { return Name; }
343
344 /// Set the name of this declaration.
345 void setDeclName(DeclarationName N) { Name = N; }
346
347 /// Returns a human-readable qualified name for this declaration, like
348 /// A::B::i, for i being member of namespace A::B.
349 ///
350 /// If the declaration is not a member of context which can be named (record,
351 /// namespace), it will return the same result as printName().
352 ///
353 /// Creating this name is expensive, so it should be called only when
354 /// performance doesn't matter.
355 void printQualifiedName(raw_ostream &OS) const;
356 void printQualifiedName(raw_ostream &OS, const PrintingPolicy &Policy) const;
357
358 /// Print only the nested name specifier part of a fully-qualified name,
359 /// including the '::' at the end. E.g.
360 /// when `printQualifiedName(D)` prints "A::B::i",
361 /// this function prints "A::B::".
362 void printNestedNameSpecifier(raw_ostream &OS) const;
363 void printNestedNameSpecifier(raw_ostream &OS,
364 const PrintingPolicy &Policy) const;
365
366 // FIXME: Remove string version.
367 std::string getQualifiedNameAsString() const;
368
369 /// Appends a human-readable name for this declaration into the given stream.
370 ///
371 /// This is the method invoked by Sema when displaying a NamedDecl
372 /// in a diagnostic. It does not necessarily produce the same
373 /// result as printName(); for example, class template
374 /// specializations are printed with their template arguments.
375 virtual void getNameForDiagnostic(raw_ostream &OS,
376 const PrintingPolicy &Policy,
377 bool Qualified) const;
378
379 /// Determine whether this declaration, if known to be well-formed within
380 /// its context, will replace the declaration OldD if introduced into scope.
381 ///
382 /// A declaration will replace another declaration if, for example, it is
383 /// a redeclaration of the same variable or function, but not if it is a
384 /// declaration of a different kind (function vs. class) or an overloaded
385 /// function.
386 ///
387 /// \param IsKnownNewer \c true if this declaration is known to be newer
388 /// than \p OldD (for instance, if this declaration is newly-created).
389 bool declarationReplaces(const NamedDecl *OldD,
390 bool IsKnownNewer = true) const;
391
392 /// Determine whether this declaration has linkage.
393 bool hasLinkage() const;
394
397
398 /// Determine whether this declaration is a C++ class member.
399 bool isCXXClassMember() const {
400 const DeclContext *DC = getDeclContext();
401
402 // C++0x [class.mem]p1:
403 // The enumerators of an unscoped enumeration defined in
404 // the class are members of the class.
405 if (isa<EnumDecl>(DC))
406 DC = DC->getRedeclContext();
407
408 return DC->isRecord();
409 }
410
411 /// Determine whether the given declaration is an instance member of
412 /// a C++ class.
413 bool isCXXInstanceMember() const;
414
415 /// Determine if the declaration obeys the reserved identifier rules of the
416 /// given language.
417 ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const;
418
419 /// Determine what kind of linkage this entity has.
420 ///
421 /// This is not the linkage as defined by the standard or the codegen notion
422 /// of linkage. It is just an implementation detail that is used to compute
423 /// those.
425
426 /// Get the linkage from a semantic point of view. Entities in
427 /// anonymous namespaces are external (in c++98).
429
430 /// True if this decl has external linkage.
434
438
439 /// Determine whether this declaration can be redeclared in a
440 /// different translation unit.
444
445 /// Determines the visibility of this entity.
449
450 /// Determines the linkage and visibility of this entity.
452
453 /// Kinds of explicit visibility.
455 /// Do an LV computation for, ultimately, a type.
456 /// Visibility may be restricted by type visibility settings and
457 /// the visibility of template arguments.
459
460 /// Do an LV computation for, ultimately, a non-type declaration.
461 /// Visibility may be restricted by value visibility settings and
462 /// the visibility of template arguments.
464 };
465
466 /// If visibility was explicitly specified for this
467 /// declaration, return that visibility.
468 std::optional<Visibility>
470
471 /// True if the computed linkage is valid. Used for consistency
472 /// checking. Should always return true.
473 bool isLinkageValid() const;
474
475 /// True if something has required us to compute the linkage
476 /// of this declaration.
477 ///
478 /// Language features which can retroactively change linkage (like a
479 /// typedef name for linkage purposes) may need to consider this,
480 /// but hopefully only in transitory ways during parsing.
482 return hasCachedLinkage();
483 }
484
485 bool isPlaceholderVar(const LangOptions &LangOpts) const;
486
487 /// Looks through UsingDecls and ObjCCompatibleAliasDecls for
488 /// the underlying named decl.
490 // Fast-path the common case.
491 if (this->getKind() != UsingShadow &&
492 this->getKind() != ConstructorUsingShadow &&
493 this->getKind() != ObjCCompatibleAlias &&
494 this->getKind() != NamespaceAlias)
495 return this;
496
497 return getUnderlyingDeclImpl();
498 }
500 return const_cast<NamedDecl*>(this)->getUnderlyingDecl();
501 }
502
504 return cast<NamedDecl>(static_cast<Decl *>(this)->getMostRecentDecl());
505 }
507 return const_cast<NamedDecl*>(this)->getMostRecentDecl();
508 }
509
511
512 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
513 static bool classofKind(Kind K) { return K >= firstNamed && K <= lastNamed; }
514};
515
516inline raw_ostream &operator<<(raw_ostream &OS, const NamedDecl &ND) {
517 ND.printName(OS);
518 return OS;
519}
520
521/// Represents the declaration of a label. Labels also have a
522/// corresponding LabelStmt, which indicates the position that the label was
523/// defined at. For normal labels, the location of the decl is the same as the
524/// location of the statement. For GNU local labels (__label__), the decl
525/// location is where the __label__ is.
526class LabelDecl : public NamedDecl {
527 LabelStmt *TheStmt;
528 StringRef MSAsmName;
529 bool MSAsmNameResolved = false;
530
531 /// For normal labels, this is the same as the main declaration
532 /// label, i.e., the location of the identifier; for GNU local labels,
533 /// this is the location of the __label__ keyword.
534 SourceLocation LocStart;
535
536 LabelDecl(DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II,
537 LabelStmt *S, SourceLocation StartL)
538 : NamedDecl(Label, DC, IdentL, II), TheStmt(S), LocStart(StartL) {}
539
540 void anchor() override;
541
542public:
543 static LabelDecl *Create(ASTContext &C, DeclContext *DC,
544 SourceLocation IdentL, IdentifierInfo *II);
545 static LabelDecl *Create(ASTContext &C, DeclContext *DC,
546 SourceLocation IdentL, IdentifierInfo *II,
547 SourceLocation GnuLabelL);
548 static LabelDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
549
550 LabelStmt *getStmt() const { return TheStmt; }
551 void setStmt(LabelStmt *T) { TheStmt = T; }
552
553 bool isGnuLocal() const { return LocStart != getLocation(); }
554 void setLocStart(SourceLocation L) { LocStart = L; }
555
556 SourceRange getSourceRange() const override LLVM_READONLY {
557 return SourceRange(LocStart, getLocation());
558 }
559
560 bool isMSAsmLabel() const { return !MSAsmName.empty(); }
561 bool isResolvedMSAsmLabel() const { return isMSAsmLabel() && MSAsmNameResolved; }
562 void setMSAsmLabel(StringRef Name);
563 StringRef getMSAsmLabel() const { return MSAsmName; }
564 void setMSAsmLabelResolved() { MSAsmNameResolved = true; }
565
566 // Implement isa/cast/dyncast/etc.
567 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
568 static bool classofKind(Kind K) { return K == Label; }
569};
570
571/// Represents C++ namespaces and their aliases.
572///
573/// FIXME: Move `NamespaceBaseDecl` and `NamespaceDecl` to "DeclCXX.h" or
574/// explain why not moving.
576protected:
578
579public:
582 return const_cast<NamespaceBaseDecl *>(this)->getNamespace();
583 }
584
585 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
586 static bool classofKind(Kind K) {
587 return K >= firstNamespaceBase && K <= lastNamespaceBase;
588 }
589};
590
591/// Represent a C++ namespace.
592class NamespaceDecl : public NamespaceBaseDecl,
593 public DeclContext,
594 public Redeclarable<NamespaceDecl> {
595 /// The starting location of the source range, pointing
596 /// to either the namespace or the inline keyword.
597 SourceLocation LocStart;
598
599 /// The ending location of the source range.
600 SourceLocation RBraceLoc;
601
602 /// The unnamed namespace that inhabits this namespace, if any.
603 NamespaceDecl *AnonymousNamespace = nullptr;
604
605 NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
606 SourceLocation StartLoc, SourceLocation IdLoc,
607 IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested);
608
609 using redeclarable_base = Redeclarable<NamespaceDecl>;
610
611 NamespaceDecl *getNextRedeclarationImpl() override;
612 NamespaceDecl *getPreviousDeclImpl() override;
613 NamespaceDecl *getMostRecentDeclImpl() override;
614
615public:
616 friend class ASTDeclReader;
617 friend class ASTDeclWriter;
618
619 static NamespaceDecl *Create(ASTContext &C, DeclContext *DC, bool Inline,
620 SourceLocation StartLoc, SourceLocation IdLoc,
621 IdentifierInfo *Id, NamespaceDecl *PrevDecl,
622 bool Nested);
623
624 static NamespaceDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
625
627 using redecl_iterator = redeclarable_base::redecl_iterator;
628
635
636 /// Returns true if this is an anonymous namespace declaration.
637 ///
638 /// For example:
639 /// \code
640 /// namespace {
641 /// ...
642 /// };
643 /// \endcode
644 /// q.v. C++ [namespace.unnamed]
645 bool isAnonymousNamespace() const {
646 return !getIdentifier();
647 }
648
649 /// Returns true if this is an inline namespace declaration.
650 bool isInline() const { return NamespaceDeclBits.IsInline; }
651
652 /// Set whether this is an inline namespace declaration.
653 void setInline(bool Inline) { NamespaceDeclBits.IsInline = Inline; }
654
655 /// Returns true if this is a nested namespace declaration.
656 /// \code
657 /// namespace outer::nested { }
658 /// \endcode
659 bool isNested() const { return NamespaceDeclBits.IsNested; }
660
661 /// Set whether this is a nested namespace declaration.
662 void setNested(bool Nested) { NamespaceDeclBits.IsNested = Nested; }
663
664 /// Returns true if the inline qualifier for \c Name is redundant.
666 if (!isInline())
667 return false;
668 auto X = lookup(Name);
669 // We should not perform a lookup within a transparent context, so find a
670 // non-transparent parent context.
671 auto Y = getParent()->getNonTransparentContext()->lookup(Name);
672 return std::distance(X.begin(), X.end()) ==
673 std::distance(Y.begin(), Y.end());
674 }
675
676 /// Retrieve the anonymous namespace that inhabits this namespace, if any.
677 NamespaceDecl *getAnonymousNamespace() const {
678 return getFirstDecl()->AnonymousNamespace;
679 }
680
681 void setAnonymousNamespace(NamespaceDecl *D) {
682 getFirstDecl()->AnonymousNamespace = D;
683 }
684
685 /// Retrieves the canonical declaration of this namespace.
686 NamespaceDecl *getCanonicalDecl() override { return getFirstDecl(); }
687 const NamespaceDecl *getCanonicalDecl() const { return getFirstDecl(); }
688
689 SourceRange getSourceRange() const override LLVM_READONLY {
690 return SourceRange(LocStart, RBraceLoc);
691 }
692
693 SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; }
694 SourceLocation getRBraceLoc() const { return RBraceLoc; }
695 void setLocStart(SourceLocation L) { LocStart = L; }
696 void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
697
698 // Implement isa/cast/dyncast/etc.
699 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
700 static bool classofKind(Kind K) { return K == Namespace; }
701 static DeclContext *castToDeclContext(const NamespaceDecl *D) {
702 return static_cast<DeclContext *>(const_cast<NamespaceDecl*>(D));
703 }
704 static NamespaceDecl *castFromDeclContext(const DeclContext *DC) {
705 return static_cast<NamespaceDecl *>(const_cast<DeclContext*>(DC));
706 }
707};
708
709class VarDecl;
710
711/// Represent the declaration of a variable (in which case it is
712/// an lvalue) a function (in which case it is a function designator) or
713/// an enum constant.
714class ValueDecl : public NamedDecl {
715 QualType DeclType;
716
717 void anchor() override;
718
719protected:
722 : NamedDecl(DK, DC, L, N), DeclType(T) {}
723
724public:
725 QualType getType() const { return DeclType; }
726 void setType(QualType newType) { DeclType = newType; }
727
728 /// Determine whether this symbol is weakly-imported,
729 /// or declared with the weak or weak-ref attr.
730 bool isWeak() const;
731
732 /// Whether this variable is the implicit variable for a lambda init-capture.
733 /// Only VarDecl can be init captures, but both VarDecl and BindingDecl
734 /// can be captured.
735 bool isInitCapture() const;
736
737 // If this is a VarDecl, or a BindindDecl with an
738 // associated decomposed VarDecl, return that VarDecl.
741 return const_cast<ValueDecl *>(this)->getPotentiallyDecomposedVarDecl();
742 }
743
744 /// Determine whether this value is actually a function parameter pack,
745 /// init-capture pack, or structured binding pack
746 bool isParameterPack() const;
747
748 // Implement isa/cast/dyncast/etc.
749 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
750 static bool classofKind(Kind K) { return K >= firstValue && K <= lastValue; }
751};
752
753/// A struct with extended info about a syntactic
754/// name qualifier, to be used for the case of out-of-line declarations.
757
758 /// The number of "outer" template parameter lists.
759 /// The count includes all of the template parameter lists that were matched
760 /// against the template-ids occurring into the NNS and possibly (in the
761 /// case of an explicit specialization) a final "template <>".
762 unsigned NumTemplParamLists = 0;
763
764 /// A new-allocated array of size NumTemplParamLists,
765 /// containing pointers to the "outer" template parameter lists.
766 /// It includes all of the template parameter lists that were matched
767 /// against the template-ids occurring into the NNS and possibly (in the
768 /// case of an explicit specialization) a final "template <>".
770
771 QualifierInfo() = default;
772 QualifierInfo(const QualifierInfo &) = delete;
774
775 /// Sets info about "outer" template parameter lists.
778};
779
780/// Represents a ValueDecl that came out of a declarator.
781/// Contains type source information through TypeSourceInfo.
782class DeclaratorDecl : public ValueDecl {
783 // A struct representing a TInfo, a trailing requires-clause and a syntactic
784 // qualifier, to be used for the (uncommon) case of out-of-line declarations
785 // and constrained function decls.
786 struct ExtInfo : public QualifierInfo {
787 TypeSourceInfo *TInfo = nullptr;
788 AssociatedConstraint TrailingRequiresClause;
789 };
790
791 llvm::PointerUnion<TypeSourceInfo *, ExtInfo *> DeclInfo;
792
793 /// The start of the source range for this declaration,
794 /// ignoring outer template declarations.
795 SourceLocation InnerLocStart;
796
797 bool hasExtInfo() const { return isa<ExtInfo *>(DeclInfo); }
798 ExtInfo *getExtInfo() { return cast<ExtInfo *>(DeclInfo); }
799 const ExtInfo *getExtInfo() const { return cast<ExtInfo *>(DeclInfo); }
800
801protected:
804 SourceLocation StartL)
805 : ValueDecl(DK, DC, L, N, T), DeclInfo(TInfo), InnerLocStart(StartL) {}
806
807public:
808 friend class ASTDeclReader;
809 friend class ASTDeclWriter;
810
812 return hasExtInfo() ? getExtInfo()->TInfo
813 : cast<TypeSourceInfo *>(DeclInfo);
814 }
815
817 if (hasExtInfo())
818 getExtInfo()->TInfo = TI;
819 else
820 DeclInfo = TI;
821 }
822
823 /// Return start of source range ignoring outer template declarations.
824 SourceLocation getInnerLocStart() const { return InnerLocStart; }
825 void setInnerLocStart(SourceLocation L) { InnerLocStart = L; }
826
827 /// Return start of source range taking into account any outer template
828 /// declarations.
830
831 SourceRange getSourceRange() const override LLVM_READONLY;
832
833 SourceLocation getBeginLoc() const LLVM_READONLY {
834 return getOuterLocStart();
835 }
836
837 /// Retrieve the nested-name-specifier that qualifies the name of this
838 /// declaration, if it was present in the source.
840 return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
841 : std::nullopt;
842 }
843
844 /// Retrieve the nested-name-specifier (with source-location
845 /// information) that qualifies the name of this declaration, if it was
846 /// present in the source.
848 return hasExtInfo() ? getExtInfo()->QualifierLoc
850 }
851
852 void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
853
854 /// \brief Get the constraint-expression introduced by the trailing
855 /// requires-clause in the function/member declaration, or null if no
856 /// requires-clause was provided.
858 static constexpr AssociatedConstraint Null;
859 return hasExtInfo() ? getExtInfo()->TrailingRequiresClause : Null;
860 }
861
863
865 if (!hasExtInfo())
866 return {};
867 return {/*data=*/getExtInfo()->TemplParamLists,
868 /*length=*/getExtInfo()->NumTemplParamLists};
869 }
870
873
876
877 // Implement isa/cast/dyncast/etc.
878 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
879 static bool classofKind(Kind K) {
880 return K >= firstDeclarator && K <= lastDeclarator;
881 }
882};
883
884/// Structure used to store a statement, the constant value to
885/// which it was evaluated (if any), and whether or not the statement
886/// is an integral constant expression (if known).
888 /// Whether this statement was already evaluated.
889 LLVM_PREFERRED_TYPE(bool)
891
892 /// Whether this statement is being evaluated.
893 LLVM_PREFERRED_TYPE(bool)
894 unsigned IsEvaluating : 1;
895
896 /// Whether this variable is known to have constant initialization. This is
897 /// currently only computed in C++, for static / thread storage duration
898 /// variables that might have constant initialization and for variables that
899 /// are usable in constant expressions.
900 LLVM_PREFERRED_TYPE(bool)
902
903 /// Whether this variable is known to have constant destruction. That is,
904 /// whether running the destructor on the initial value is a side-effect
905 /// (and doesn't inspect any state that might have changed during program
906 /// execution). This is currently only computed if the destructor is
907 /// non-trivial.
908 LLVM_PREFERRED_TYPE(bool)
910
911 /// In C++98, whether the initializer is an ICE. This affects whether the
912 /// variable is usable in constant expressions.
913 LLVM_PREFERRED_TYPE(bool)
914 unsigned HasICEInit : 1;
915 LLVM_PREFERRED_TYPE(bool)
916 unsigned CheckedForICEInit : 1;
917
918 LLVM_PREFERRED_TYPE(bool)
919 unsigned HasSideEffects : 1;
920 LLVM_PREFERRED_TYPE(bool)
922
925
931};
932
933/// Represents a variable declaration or definition.
934class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
935public:
936 /// Initialization styles.
938 /// C-style initialization with assignment
940
941 /// Call-style initialization (C++98)
943
944 /// Direct list-initialization (C++11)
946
947 /// Parenthesized list-initialization (C++20)
949 };
950
951 /// Kinds of thread-local storage.
952 enum TLSKind {
953 /// Not a TLS variable.
955
956 /// TLS with a known-constant initializer.
958
959 /// TLS with a dynamic initializer.
961 };
962
963 /// Return the string used to specify the storage class \p SC.
964 ///
965 /// It is illegal to call this function with SC == None.
966 static const char *getStorageClassSpecifierString(StorageClass SC);
967
968protected:
969 // A pointer union of Stmt * and EvaluatedStmt *. When an EvaluatedStmt, we
970 // have allocated the auxiliary struct of information there.
971 //
972 // TODO: It is a bit unfortunate to use a PointerUnion inside the VarDecl for
973 // this as *many* VarDecls are ParmVarDecls that don't have default
974 // arguments. We could save some space by moving this pointer union to be
975 // allocated in trailing space when necessary.
976 using InitType = llvm::PointerUnion<Stmt *, EvaluatedStmt *>;
977
978 /// The initializer for this variable or, for a ParmVarDecl, the
979 /// C++ default argument.
980 mutable InitType Init;
981
982private:
983 friend class ASTDeclReader;
984 friend class ASTNodeImporter;
985 friend class StmtIteratorBase;
986
987 class VarDeclBitfields {
988 friend class ASTDeclReader;
989 friend class VarDecl;
990
991 LLVM_PREFERRED_TYPE(StorageClass)
992 unsigned SClass : 3;
993 LLVM_PREFERRED_TYPE(ThreadStorageClassSpecifier)
994 unsigned TSCSpec : 2;
995 LLVM_PREFERRED_TYPE(InitializationStyle)
996 unsigned InitStyle : 2;
997
998 /// Whether this variable is an ARC pseudo-__strong variable; see
999 /// isARCPseudoStrong() for details.
1000 LLVM_PREFERRED_TYPE(bool)
1001 unsigned ARCPseudoStrong : 1;
1002 };
1003 enum { NumVarDeclBits = 8 };
1004
1005protected:
1007
1014
1016
1018 friend class ASTDeclReader;
1019 friend class ParmVarDecl;
1020
1021 LLVM_PREFERRED_TYPE(VarDeclBitfields)
1022 unsigned : NumVarDeclBits;
1023
1024 /// Whether this parameter inherits a default argument from a
1025 /// prior declaration.
1026 LLVM_PREFERRED_TYPE(bool)
1027 unsigned HasInheritedDefaultArg : 1;
1028
1029 /// Describes the kind of default argument for this parameter. By default
1030 /// this is none. If this is normal, then the default argument is stored in
1031 /// the \c VarDecl initializer expression unless we were unable to parse
1032 /// (even an invalid) expression for the default argument.
1033 LLVM_PREFERRED_TYPE(DefaultArgKind)
1034 unsigned DefaultArgKind : 2;
1035
1036 /// Whether this parameter undergoes K&R argument promotion.
1037 LLVM_PREFERRED_TYPE(bool)
1038 unsigned IsKNRPromoted : 1;
1039
1040 /// Whether this parameter is an ObjC method parameter or not.
1041 LLVM_PREFERRED_TYPE(bool)
1042 unsigned IsObjCMethodParam : 1;
1043
1044 /// If IsObjCMethodParam, a Decl::ObjCDeclQualifier.
1045 /// Otherwise, the number of function parameter scopes enclosing
1046 /// the function parameter scope in which this parameter was
1047 /// declared.
1048 unsigned ScopeDepthOrObjCQuals : NumScopeDepthOrObjCQualsBits;
1049
1050 /// The number of parameters preceding this parameter in the
1051 /// function parameter scope in which it was declared.
1052 unsigned ParameterIndex : NumParameterIndexBits;
1053 };
1054
1056 friend class ASTDeclReader;
1057 friend class ImplicitParamDecl;
1058 friend class VarDecl;
1059
1060 LLVM_PREFERRED_TYPE(VarDeclBitfields)
1061 unsigned : NumVarDeclBits;
1062
1063 // FIXME: We need something similar to CXXRecordDecl::DefinitionData.
1064 /// Whether this variable is a definition which was demoted due to
1065 /// module merge.
1066 LLVM_PREFERRED_TYPE(bool)
1067 unsigned IsThisDeclarationADemotedDefinition : 1;
1068
1069 /// Whether this variable is the exception variable in a C++ catch
1070 /// or an Objective-C @catch statement.
1071 LLVM_PREFERRED_TYPE(bool)
1072 unsigned ExceptionVar : 1;
1073
1074 /// Whether this local variable could be allocated in the return
1075 /// slot of its function, enabling the named return value optimization
1076 /// (NRVO).
1077 LLVM_PREFERRED_TYPE(bool)
1078 unsigned NRVOVariable : 1;
1079
1080 /// Whether this variable is the for-range-declaration in a C++0x
1081 /// for-range statement.
1082 LLVM_PREFERRED_TYPE(bool)
1083 unsigned CXXForRangeDecl : 1;
1084
1085 /// Whether this variable is the for-in loop declaration in Objective-C.
1086 LLVM_PREFERRED_TYPE(bool)
1087 unsigned ObjCForDecl : 1;
1088
1089 /// Whether this variable is (C++1z) inline.
1090 LLVM_PREFERRED_TYPE(bool)
1091 unsigned IsInline : 1;
1092
1093 /// Whether this variable has (C++1z) inline explicitly specified.
1094 LLVM_PREFERRED_TYPE(bool)
1095 unsigned IsInlineSpecified : 1;
1096
1097 /// Whether this variable is (C++0x) constexpr.
1098 LLVM_PREFERRED_TYPE(bool)
1099 unsigned IsConstexpr : 1;
1100
1101 /// Whether this variable is the implicit variable for a lambda
1102 /// init-capture.
1103 LLVM_PREFERRED_TYPE(bool)
1104 unsigned IsInitCapture : 1;
1105
1106 /// Whether this local extern variable's previous declaration was
1107 /// declared in the same block scope. This controls whether we should merge
1108 /// the type of this declaration with its previous declaration.
1109 LLVM_PREFERRED_TYPE(bool)
1110 unsigned PreviousDeclInSameBlockScope : 1;
1111
1112 /// Defines kind of the ImplicitParamDecl: 'this', 'self', 'vtt', '_cmd' or
1113 /// something else.
1114 LLVM_PREFERRED_TYPE(ImplicitParamKind)
1115 unsigned ImplicitParamKind : 3;
1116
1117 LLVM_PREFERRED_TYPE(bool)
1118 unsigned EscapingByref : 1;
1119
1120 LLVM_PREFERRED_TYPE(bool)
1121 unsigned IsCXXCondDecl : 1;
1122
1123 /// Whether this variable is the implicit __range variable in a for-range
1124 /// loop.
1125 LLVM_PREFERRED_TYPE(bool)
1126 unsigned IsCXXForRangeImplicitVar : 1;
1127 };
1128
1129 union {
1130 unsigned AllBits;
1131 VarDeclBitfields VarDeclBits;
1134 };
1135
1136 VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
1137 SourceLocation IdLoc, const IdentifierInfo *Id, QualType T,
1138 TypeSourceInfo *TInfo, StorageClass SC);
1139
1141
1143 return getNextRedeclaration();
1144 }
1145
1147 return getPreviousDecl();
1148 }
1149
1151 return getMostRecentDecl();
1152 }
1153
1154public:
1156 using redecl_iterator = redeclarable_base::redecl_iterator;
1157
1164
1165 static VarDecl *Create(ASTContext &C, DeclContext *DC,
1166 SourceLocation StartLoc, SourceLocation IdLoc,
1167 const IdentifierInfo *Id, QualType T,
1168 TypeSourceInfo *TInfo, StorageClass S);
1169
1171
1172 SourceRange getSourceRange() const override LLVM_READONLY;
1173
1174 /// Returns the storage class as written in the source. For the
1175 /// computed linkage of symbol, see getLinkage.
1177 return (StorageClass) VarDeclBits.SClass;
1178 }
1180
1182 VarDeclBits.TSCSpec = TSC;
1183 assert(VarDeclBits.TSCSpec == TSC && "truncation");
1184 }
1186 return static_cast<ThreadStorageClassSpecifier>(VarDeclBits.TSCSpec);
1187 }
1188 TLSKind getTLSKind() const;
1189
1190 /// Returns true if a variable with function scope is a non-static local
1191 /// variable.
1192 bool hasLocalStorage() const {
1193 if (getStorageClass() == SC_None) {
1194 // OpenCL v1.2 s6.5.3: The __constant or constant address space name is
1195 // used to describe variables allocated in global memory and which are
1196 // accessed inside a kernel(s) as read-only variables. As such, variables
1197 // in constant address space cannot have local storage.
1198 if (getType().getAddressSpace() == LangAS::opencl_constant)
1199 return false;
1200 // Second check is for C++11 [dcl.stc]p4.
1201 return !isFileVarDecl() && getTSCSpec() == TSCS_unspecified;
1202 }
1203
1204 // Global Named Register (GNU extension)
1206 return false;
1207
1208 // Return true for: Auto, Register.
1209 // Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal.
1210
1211 return getStorageClass() >= SC_Auto;
1212 }
1213
1214 /// Returns true if a variable with function scope is a static local
1215 /// variable.
1216 bool isStaticLocal() const {
1217 return (getStorageClass() == SC_Static ||
1218 // C++11 [dcl.stc]p4
1220 && !isFileVarDecl();
1221 }
1222
1223 /// Returns true if this is a file-scope variable with internal linkage.
1225 // Calling isExternallyVisible() can trigger linkage computation/caching,
1226 // which may produce stale results when a decl's DeclContext changes after
1227 // creation (e.g., OpenMP declare mapper variables), so here we determine
1228 // it syntactically instead.
1229 if (!isFileVarDecl())
1230 return false;
1231 // Linkage is determined by enclosing class/namespace for static data
1232 // members.
1234 return true;
1235 return isInAnonymousNamespace();
1236 }
1237
1238 /// Returns true if a variable has extern or __private_extern__
1239 /// storage.
1240 bool hasExternalStorage() const {
1241 return getStorageClass() == SC_Extern ||
1243 }
1244
1245 /// Returns true for all variables that do not have local storage.
1246 ///
1247 /// This includes all global variables as well as static variables declared
1248 /// within a function.
1249 bool hasGlobalStorage() const { return !hasLocalStorage(); }
1250
1251 /// Get the storage duration of this variable, per C++ [basic.stc].
1256
1257 /// Compute the language linkage.
1259
1260 /// Determines whether this variable is a variable with external, C linkage.
1261 bool isExternC() const;
1262
1263 /// Determines whether this variable's context is, or is nested within,
1264 /// a C++ extern "C" linkage spec.
1265 bool isInExternCContext() const;
1266
1267 /// Determines whether this variable's context is, or is nested within,
1268 /// a C++ extern "C++" linkage spec.
1269 bool isInExternCXXContext() const;
1270
1271 /// Returns true for local variable declarations other than parameters.
1272 /// Note that this includes static variables inside of functions. It also
1273 /// includes variables inside blocks and expansion statements.
1274 ///
1275 /// void foo() { int x; static int y; extern int z; }
1276 bool isLocalVarDecl() const {
1277 if (getKind() != Decl::Var && getKind() != Decl::Decomposition)
1278 return false;
1279 if (const DeclContext *DC = getLexicalDeclContext())
1280 return DC->getEnclosingNonExpansionStatementContext()
1281 ->getRedeclContext()
1282 ->isFunctionOrMethod();
1283 return false;
1284 }
1285
1286 /// Similar to isLocalVarDecl but also includes parameters.
1288 return isLocalVarDecl() || getKind() == Decl::ParmVar;
1289 }
1290
1291 /// Similar to isLocalVarDecl, but excludes variables declared in blocks.
1293 if (getKind() != Decl::Var && getKind() != Decl::Decomposition)
1294 return false;
1296 return DC->isFunctionOrMethod() && DC->getDeclKind() != Decl::Block;
1297 }
1298
1299 /// Determines whether this is a static data member.
1300 ///
1301 /// This will only be true in C++, and applies to, e.g., the
1302 /// variable 'x' in:
1303 /// \code
1304 /// struct S {
1305 /// static int x;
1306 /// };
1307 /// \endcode
1308 bool isStaticDataMember() const {
1309 // If it wasn't static, it would be a FieldDecl.
1310 return getKind() != Decl::ParmVar && getDeclContext()->isRecord();
1311 }
1312
1313 VarDecl *getCanonicalDecl() override;
1314 const VarDecl *getCanonicalDecl() const {
1315 return const_cast<VarDecl*>(this)->getCanonicalDecl();
1316 }
1317
1319 /// This declaration is only a declaration.
1321
1322 /// This declaration is a tentative definition.
1324
1325 /// This declaration is definitely a definition.
1327 };
1328
1329 /// Check whether this declaration is a definition. If this could be
1330 /// a tentative definition (in C), don't check whether there's an overriding
1331 /// definition.
1336
1337 /// Check whether this variable is defined in this translation unit.
1342
1343 /// Get the tentative definition that acts as the real definition in a TU.
1344 /// Returns null if there is a proper definition available.
1347 return const_cast<VarDecl*>(this)->getActingDefinition();
1348 }
1349
1350 /// Get the real (not just tentative) definition for this declaration.
1353 return const_cast<VarDecl*>(this)->getDefinition(C);
1354 }
1358 const VarDecl *getDefinition() const {
1359 return const_cast<VarDecl*>(this)->getDefinition();
1360 }
1361
1362 /// Determine whether this is or was instantiated from an out-of-line
1363 /// definition of a static data member.
1364 bool isOutOfLine() const override;
1365
1366 /// Returns true for file scoped variable declaration.
1367 bool isFileVarDecl() const {
1368 Kind K = getKind();
1369 if (K == ParmVar || K == ImplicitParam)
1370 return false;
1371
1372 if (getLexicalDeclContext()->getRedeclContext()->isFileContext())
1373 return true;
1374
1375 if (isStaticDataMember())
1376 return true;
1377
1378 return false;
1379 }
1380
1381 /// Get the initializer for this variable, no matter which
1382 /// declaration it is attached to.
1383 const Expr *getAnyInitializer() const {
1384 const VarDecl *D;
1385 return getAnyInitializer(D);
1386 }
1387
1388 /// Get the initializer for this variable, no matter which
1389 /// declaration it is attached to. Also get that declaration.
1390 const Expr *getAnyInitializer(const VarDecl *&D) const;
1391
1392 bool hasInit() const;
1393 const Expr *getInit() const {
1394 return const_cast<VarDecl *>(this)->getInit();
1395 }
1396 Expr *getInit();
1397
1398 /// Retrieve the address of the initializer expression.
1399 Stmt **getInitAddress();
1400
1401 void setInit(Expr *I);
1402
1403 /// Get the initializing declaration of this variable, if any. This is
1404 /// usually the definition, except that for a static data member it can be
1405 /// the in-class declaration.
1408 return const_cast<VarDecl *>(this)->getInitializingDeclaration();
1409 }
1410
1411 /// Checks whether this declaration has an initializer with side effects.
1412 /// The result is cached. If the result hasn't been computed this can trigger
1413 /// deserialization and constant evaluation. By running this during
1414 /// serialization and serializing the result all clients can safely call this
1415 /// without triggering further deserialization.
1416 bool hasInitWithSideEffects() const;
1417
1418 /// Determine whether this variable's value might be usable in a
1419 /// constant expression, according to the relevant language standard.
1420 /// This only checks properties of the declaration, and does not check
1421 /// whether the initializer is in fact a constant expression.
1422 ///
1423 /// This corresponds to C++20 [expr.const]p3's notion of a
1424 /// "potentially-constant" variable.
1426
1427 /// Determine whether this variable's value can be used in a
1428 /// constant expression, according to the relevant language standard,
1429 /// including checking whether it was initialized by a constant expression.
1430 bool isUsableInConstantExpressions(const ASTContext &C) const;
1431
1434
1435 /// Attempt to evaluate the value of the initializer attached to this
1436 /// declaration, and produce notes explaining why it cannot be evaluated.
1437 /// Returns a pointer to the value if evaluation succeeded, \c nullptr
1438 /// otherwise.
1439 const APValue *evaluateValue() const;
1440
1441private:
1442 const APValue *evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> *Notes,
1443 SemaProxy *SProxy,
1444 bool IsConstantInitialization) const;
1445
1446public:
1447 /// Return the already-evaluated value of this variable's
1448 /// initializer, or \c nullptr if the value is not yet known or couldn't be
1449 /// evaluated.
1450 const APValue *getEvaluatedValue() const;
1451
1452 /// Evaluate the destruction of this variable to determine if it constitutes
1453 /// constant destruction.
1454 ///
1455 /// \pre hasConstantInitialization()
1456 /// \return \c true if this variable has constant destruction, \c false if
1457 /// not.
1459
1460 /// Evaluate the destruction of a variable that is required by the language to
1461 /// have constant destruction.
1462 ///
1463 /// \pre hasConstantInitialization()
1464 /// \return \c true if this variable has constant destruction, \c false if
1465 /// not.
1467 SemaProxy &SProxy) const;
1468
1469 /// Determine whether this variable has constant initialization.
1470 ///
1471 /// This is only set in two cases: when the language semantics require
1472 /// constant initialization (globals in C and some globals in C++), and when
1473 /// the variable is usable in constant expressions (constexpr, const int, and
1474 /// reference variables in C++).
1475 bool hasConstantInitialization() const;
1476
1477 /// Determine whether the initializer of this variable is an integer constant
1478 /// expression. For use in C++98, where this affects whether the variable is
1479 /// usable in constant expressions.
1480 bool hasICEInitializer(const ASTContext &Context) const;
1481
1482 /// Evaluate the initializer of this variable to determine whether it's a
1483 /// constant initializer. Should only be called once, after completing the
1484 /// definition of the variable.
1485 bool
1487 SemaProxy &SProxy) const;
1488
1490 VarDeclBits.InitStyle = Style;
1491 }
1492
1493 /// The style of initialization for this declaration.
1494 ///
1495 /// C-style initialization is "int x = 1;". Call-style initialization is
1496 /// a C++98 direct-initializer, e.g. "int x(1);". The Init expression will be
1497 /// the expression inside the parens or a "ClassType(a,b,c)" class constructor
1498 /// expression for class types. List-style initialization is C++11 syntax,
1499 /// e.g. "int x{1};". Clients can distinguish between different forms of
1500 /// initialization by checking this value. In particular, "int x = {1};" is
1501 /// C-style, "int x({1})" is call-style, and "int x{1};" is list-style; the
1502 /// Init expression in all three cases is an InitListExpr.
1504 return static_cast<InitializationStyle>(VarDeclBits.InitStyle);
1505 }
1506
1507 /// Whether the initializer is a direct-initializer (list or call).
1508 bool isDirectInit() const {
1509 return getInitStyle() != CInit;
1510 }
1511
1512 /// If this definition should pretend to be a declaration.
1514 return isa<ParmVarDecl>(this) ? false :
1515 NonParmVarDeclBits.IsThisDeclarationADemotedDefinition;
1516 }
1517
1518 /// This is a definition which should be demoted to a declaration.
1519 ///
1520 /// In some cases (mostly module merging) we can end up with two visible
1521 /// definitions one of which needs to be demoted to a declaration to keep
1522 /// the AST invariants.
1524 assert(isThisDeclarationADefinition() && "Not a definition!");
1525 assert(!isa<ParmVarDecl>(this) && "Cannot demote ParmVarDecls!");
1526 NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = 1;
1527 }
1528
1529 /// Determine whether this variable is the exception variable in a
1530 /// C++ catch statememt or an Objective-C \@catch statement.
1531 bool isExceptionVariable() const {
1532 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.ExceptionVar;
1533 }
1534 void setExceptionVariable(bool EV) {
1535 assert(!isa<ParmVarDecl>(this));
1536 NonParmVarDeclBits.ExceptionVar = EV;
1537 }
1538
1539 /// Determine whether this local variable can be used with the named
1540 /// return value optimization (NRVO).
1541 ///
1542 /// The named return value optimization (NRVO) works by marking certain
1543 /// non-volatile local variables of class type as NRVO objects. These
1544 /// locals can be allocated within the return slot of their containing
1545 /// function, in which case there is no need to copy the object to the
1546 /// return slot when returning from the function. Within the function body,
1547 /// each return that returns the NRVO object will have this variable as its
1548 /// NRVO candidate.
1549 bool isNRVOVariable() const {
1550 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.NRVOVariable;
1551 }
1552 void setNRVOVariable(bool NRVO) {
1553 assert(!isa<ParmVarDecl>(this));
1554 NonParmVarDeclBits.NRVOVariable = NRVO;
1555 }
1556
1557 /// Determine whether this variable is the for-range-declaration in
1558 /// a C++0x for-range statement.
1559 bool isCXXForRangeDecl() const {
1560 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.CXXForRangeDecl;
1561 }
1562 void setCXXForRangeDecl(bool FRD) {
1563 assert(!isa<ParmVarDecl>(this));
1564 NonParmVarDeclBits.CXXForRangeDecl = FRD;
1565 }
1566
1567 /// Determine whether this variable is a for-loop declaration for a
1568 /// for-in statement in Objective-C.
1569 bool isObjCForDecl() const {
1570 return NonParmVarDeclBits.ObjCForDecl;
1571 }
1572
1573 void setObjCForDecl(bool FRD) {
1574 NonParmVarDeclBits.ObjCForDecl = FRD;
1575 }
1576
1577 /// Determine whether this variable is an ARC pseudo-__strong variable. A
1578 /// pseudo-__strong variable has a __strong-qualified type but does not
1579 /// actually retain the object written into it. Generally such variables are
1580 /// also 'const' for safety. There are 3 cases where this will be set, 1) if
1581 /// the variable is annotated with the objc_externally_retained attribute, 2)
1582 /// if its 'self' in a non-init method, or 3) if its the variable in an for-in
1583 /// loop.
1584 bool isARCPseudoStrong() const { return VarDeclBits.ARCPseudoStrong; }
1585 void setARCPseudoStrong(bool PS) { VarDeclBits.ARCPseudoStrong = PS; }
1586
1587 /// Whether this variable is (C++1z) inline.
1588 bool isInline() const {
1589 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInline;
1590 }
1591 bool isInlineSpecified() const {
1592 return isa<ParmVarDecl>(this) ? false
1593 : NonParmVarDeclBits.IsInlineSpecified;
1594 }
1596 assert(!isa<ParmVarDecl>(this));
1597 NonParmVarDeclBits.IsInline = true;
1598 NonParmVarDeclBits.IsInlineSpecified = true;
1599 }
1601 assert(!isa<ParmVarDecl>(this));
1602 NonParmVarDeclBits.IsInline = true;
1603 }
1604
1605 /// Whether this variable is (C++11) constexpr.
1606 bool isConstexpr() const {
1607 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsConstexpr;
1608 }
1609 void setConstexpr(bool IC) {
1610 assert(!isa<ParmVarDecl>(this));
1611 NonParmVarDeclBits.IsConstexpr = IC;
1612 }
1613
1614 /// Whether this variable is the implicit variable for a lambda init-capture.
1615 bool isInitCapture() const {
1616 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsInitCapture;
1617 }
1618 void setInitCapture(bool IC) {
1619 assert(!isa<ParmVarDecl>(this));
1620 NonParmVarDeclBits.IsInitCapture = IC;
1621 }
1622
1623 /// Whether this local extern variable declaration's previous declaration
1624 /// was declared in the same block scope. Only correct in C++.
1626 return isa<ParmVarDecl>(this)
1627 ? false
1628 : NonParmVarDeclBits.PreviousDeclInSameBlockScope;
1629 }
1631 assert(!isa<ParmVarDecl>(this));
1632 NonParmVarDeclBits.PreviousDeclInSameBlockScope = Same;
1633 }
1634
1635 /// Indicates the capture is a __block variable that is captured by a block
1636 /// that can potentially escape (a block for which BlockDecl::doesNotEscape
1637 /// returns false).
1638 bool isEscapingByref() const;
1639
1640 /// Indicates the capture is a __block variable that is never captured by an
1641 /// escaping block.
1642 bool isNonEscapingByref() const;
1643
1645 NonParmVarDeclBits.EscapingByref = true;
1646 }
1647
1648 bool isCXXCondDecl() const {
1649 return isa<ParmVarDecl>(this) ? false : NonParmVarDeclBits.IsCXXCondDecl;
1650 }
1651
1653 assert(!isa<ParmVarDecl>(this));
1654 NonParmVarDeclBits.IsCXXCondDecl = true;
1655 }
1656
1657 /// Whether this variable is the implicit '__range' variable in C++
1658 /// range-based for loops.
1660 return isa<ParmVarDecl>(this) ? false
1661 : NonParmVarDeclBits.IsCXXForRangeImplicitVar;
1662 }
1663
1665 assert(!isa<ParmVarDecl>(this) &&
1666 "Cannot set IsCXXForRangeImplicitVar on ParmVarDecl");
1667 NonParmVarDeclBits.IsCXXForRangeImplicitVar = FRV;
1668 }
1669
1670 /// Determines if this variable's alignment is dependent.
1671 bool hasDependentAlignment() const;
1672
1673 /// Retrieve the variable declaration from which this variable could
1674 /// be instantiated, if it is an instantiation (rather than a non-template).
1676
1677 /// If this variable is an instantiated static data member of a
1678 /// class template specialization, returns the templated static data member
1679 /// from which it was instantiated.
1681
1682 /// If this variable is an instantiation of a variable template or a
1683 /// static data member of a class template, determine what kind of
1684 /// template specialization or instantiation this is.
1686
1687 /// Get the template specialization kind of this variable for the purposes of
1688 /// template instantiation. This differs from getTemplateSpecializationKind()
1689 /// for an instantiation of a class-scope explicit specialization.
1692
1693 /// If this variable is an instantiation of a variable template or a
1694 /// static data member of a class template, determine its point of
1695 /// instantiation.
1697
1698 /// If this variable is an instantiation of a static data member of a
1699 /// class template specialization, retrieves the member specialization
1700 /// information.
1702
1703 /// For a static data member that was instantiated from a static
1704 /// data member of a class template, set the template specialiation kind.
1706 SourceLocation PointOfInstantiation = SourceLocation());
1707
1708 /// Specify that this variable is an instantiation of the
1709 /// static data member VD.
1712
1713 /// Retrieves the variable template that is described by this
1714 /// variable declaration.
1715 ///
1716 /// Every variable template is represented as a VarTemplateDecl and a
1717 /// VarDecl. The former contains template properties (such as
1718 /// the template parameter lists) while the latter contains the
1719 /// actual description of the template's
1720 /// contents. VarTemplateDecl::getTemplatedDecl() retrieves the
1721 /// VarDecl that from a VarTemplateDecl, while
1722 /// getDescribedVarTemplate() retrieves the VarTemplateDecl from
1723 /// a VarDecl.
1725
1727
1728 // Is this variable known to have a definition somewhere in the complete
1729 // program? This may be true even if the declaration has internal linkage and
1730 // has no definition within this source file.
1731 bool isKnownToBeDefined() const;
1732
1733 /// Is destruction of this variable entirely suppressed? If so, the variable
1734 /// need not have a usable destructor at all.
1735 bool isNoDestroy(const ASTContext &) const;
1736
1737 /// Would the destruction of this variable have any effect, and if so, what
1738 /// kind?
1740
1741 /// Whether this variable has a flexible array member initialized with one
1742 /// or more elements. This can only be called for declarations where
1743 /// hasInit() is true.
1744 ///
1745 /// (The standard doesn't allow initializing flexible array members; this is
1746 /// a gcc/msvc extension.)
1747 bool hasFlexibleArrayInit(const ASTContext &Ctx) const;
1748
1749 /// If hasFlexibleArrayInit is true, compute the number of additional bytes
1750 /// necessary to store those elements. Otherwise, returns zero.
1751 ///
1752 /// This can only be called for declarations where hasInit() is true.
1754
1755 /// Apply a deduced address space, if one isn't already set.
1756 void assignAddressSpace(const ASTContext &Ctxt, LangAS AS);
1757 void deduceParmAddressSpace(const ASTContext &Ctxt);
1758
1759 // Implement isa/cast/dyncast/etc.
1760 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1761 static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }
1762};
1763
1764/// Defines the kind of the implicit parameter: is this an implicit parameter
1765/// with pointer to 'this', 'self', '_cmd', virtual table pointers, captured
1766/// context or something else.
1768 /// Parameter for Objective-C 'self' argument
1770
1771 /// Parameter for Objective-C '_cmd' argument
1773
1774 /// Parameter for C++ 'this' argument
1776
1777 /// Parameter for C++ virtual table pointers
1779
1780 /// Parameter for captured context
1782
1783 /// Parameter for Thread private variable
1785
1786 /// Other implicit parameter
1788};
1789
1791 void anchor() override;
1792
1793protected:
1795 const IdentifierInfo *Id, QualType Type,
1796 ImplicitParamKind ParamKind)
1797 : VarDecl(ImplicitParam, C, DC, IdLoc, IdLoc, Id, Type,
1798 /*TInfo=*/nullptr, SC_None) {
1799 NonParmVarDeclBits.ImplicitParamKind = llvm::to_underlying(ParamKind);
1800 setImplicit();
1801 }
1802
1804 : VarDecl(ImplicitParam, C, /*DC=*/nullptr, SourceLocation(),
1805 SourceLocation(), /*Id=*/nullptr, Type,
1806 /*TInfo=*/nullptr, SC_None) {
1807 NonParmVarDeclBits.ImplicitParamKind = llvm::to_underlying(ParamKind);
1808 setImplicit();
1809 }
1810
1811public:
1812 /// Create implicit parameter.
1814 SourceLocation IdLoc,
1815 const IdentifierInfo *Id, QualType T,
1816 ImplicitParamKind ParamKind);
1818 ImplicitParamKind ParamKind);
1819
1821 /// Returns the implicit parameter kind.
1823 return static_cast<ImplicitParamKind>(NonParmVarDeclBits.ImplicitParamKind);
1824 }
1825
1826 // Implement isa/cast/dyncast/etc.
1827 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1828 static bool classofKind(Kind K) { return K == ImplicitParam; }
1829};
1830
1831/// Represents a parameter to a function.
1832class ParmVarDecl : public VarDecl {
1833public:
1836
1837protected:
1839 SourceLocation IdLoc, const IdentifierInfo *Id, QualType T,
1840 TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
1841 : VarDecl(DK, C, DC, StartLoc, IdLoc, Id, T, TInfo, S) {
1842 assert(ParmVarDeclBits.HasInheritedDefaultArg == false);
1843 assert(ParmVarDeclBits.DefaultArgKind == DAK_None);
1844 assert(ParmVarDeclBits.IsKNRPromoted == false);
1845 assert(ParmVarDeclBits.IsObjCMethodParam == false);
1846 setDefaultArg(DefArg);
1847 }
1848
1849public:
1851 SourceLocation StartLoc, SourceLocation IdLoc,
1852 const IdentifierInfo *Id, QualType T,
1853 TypeSourceInfo *TInfo, StorageClass S,
1854 Expr *DefArg);
1855
1857
1858 SourceRange getSourceRange() const override LLVM_READONLY;
1859
1860 void setObjCMethodScopeInfo(unsigned parameterIndex) {
1861 ParmVarDeclBits.IsObjCMethodParam = true;
1862 setParameterIndex(parameterIndex);
1863 }
1864
1865 void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex) {
1866 assert(!ParmVarDeclBits.IsObjCMethodParam);
1867
1868 ParmVarDeclBits.ScopeDepthOrObjCQuals = scopeDepth;
1869 assert(ParmVarDeclBits.ScopeDepthOrObjCQuals == scopeDepth
1870 && "truncation!");
1871
1872 setParameterIndex(parameterIndex);
1873 }
1874
1876 return ParmVarDeclBits.IsObjCMethodParam;
1877 }
1878
1879 /// Determines whether this parameter is destroyed in the callee function.
1880 bool isDestroyedInCallee() const;
1881
1882 unsigned getFunctionScopeDepth() const {
1883 if (ParmVarDeclBits.IsObjCMethodParam) return 0;
1884 return ParmVarDeclBits.ScopeDepthOrObjCQuals;
1885 }
1886
1887 static constexpr unsigned getMaxFunctionScopeDepth() {
1888 return (1u << NumScopeDepthOrObjCQualsBits) - 1;
1889 }
1890
1891 /// Returns the index of this parameter in its prototype or method scope.
1892 unsigned getFunctionScopeIndex() const {
1893 return getParameterIndex();
1894 }
1895
1897 if (!ParmVarDeclBits.IsObjCMethodParam) return OBJC_TQ_None;
1898 return ObjCDeclQualifier(ParmVarDeclBits.ScopeDepthOrObjCQuals);
1899 }
1901 assert(ParmVarDeclBits.IsObjCMethodParam);
1902 ParmVarDeclBits.ScopeDepthOrObjCQuals = QTVal;
1903 }
1904
1905 /// True if the value passed to this parameter must undergo
1906 /// K&R-style default argument promotion:
1907 ///
1908 /// C99 6.5.2.2.
1909 /// If the expression that denotes the called function has a type
1910 /// that does not include a prototype, the integer promotions are
1911 /// performed on each argument, and arguments that have type float
1912 /// are promoted to double.
1913 bool isKNRPromoted() const {
1914 return ParmVarDeclBits.IsKNRPromoted;
1915 }
1916 void setKNRPromoted(bool promoted) {
1917 ParmVarDeclBits.IsKNRPromoted = promoted;
1918 }
1919
1921 return ExplicitObjectParameterIntroducerLoc.isValid();
1922 }
1923
1925 ExplicitObjectParameterIntroducerLoc = Loc;
1926 }
1927
1929 return ExplicitObjectParameterIntroducerLoc;
1930 }
1931
1933 const Expr *getDefaultArg() const {
1934 return const_cast<ParmVarDecl *>(this)->getDefaultArg();
1935 }
1936
1937 void setDefaultArg(Expr *defarg);
1938
1939 /// Retrieve the source range that covers the entire default
1940 /// argument.
1945 return const_cast<ParmVarDecl *>(this)->getUninstantiatedDefaultArg();
1946 }
1947
1948 /// Determines whether this parameter has a default argument,
1949 /// either parsed or not.
1950 bool hasDefaultArg() const;
1951
1952 /// Determines whether this parameter has a default argument that has not
1953 /// yet been parsed. This will occur during the processing of a C++ class
1954 /// whose member functions have default arguments, e.g.,
1955 /// @code
1956 /// class X {
1957 /// public:
1958 /// void f(int x = 17); // x has an unparsed default argument now
1959 /// }; // x has a regular default argument now
1960 /// @endcode
1962 return ParmVarDeclBits.DefaultArgKind == DAK_Unparsed;
1963 }
1964
1966 return ParmVarDeclBits.DefaultArgKind == DAK_Uninstantiated;
1967 }
1968
1969 /// Specify that this parameter has an unparsed default argument.
1970 /// The argument will be replaced with a real default argument via
1971 /// setDefaultArg when the class definition enclosing the function
1972 /// declaration that owns this default argument is completed.
1974 ParmVarDeclBits.DefaultArgKind = DAK_Unparsed;
1975 }
1976
1978 return ParmVarDeclBits.HasInheritedDefaultArg;
1979 }
1980
1981 void setHasInheritedDefaultArg(bool I = true) {
1982 ParmVarDeclBits.HasInheritedDefaultArg = I;
1983 }
1984
1985 QualType getOriginalType() const;
1986
1987 /// Sets the function declaration that owns this
1988 /// ParmVarDecl. Since ParmVarDecls are often created before the
1989 /// FunctionDecls that own them, this routine is required to update
1990 /// the DeclContext appropriately.
1992
1993 // Implement isa/cast/dyncast/etc.
1994 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1995 static bool classofKind(Kind K) { return K == ParmVar; }
1996
1997private:
1998 friend class ASTDeclReader;
1999
2000 enum { ParameterIndexSentinel = (1 << NumParameterIndexBits) - 1 };
2001 SourceLocation ExplicitObjectParameterIntroducerLoc;
2002
2003 void setParameterIndex(unsigned parameterIndex) {
2004 if (parameterIndex >= ParameterIndexSentinel) {
2005 setParameterIndexLarge(parameterIndex);
2006 return;
2007 }
2008
2009 ParmVarDeclBits.ParameterIndex = parameterIndex;
2010 assert(ParmVarDeclBits.ParameterIndex == parameterIndex && "truncation!");
2011 }
2012 unsigned getParameterIndex() const {
2013 unsigned d = ParmVarDeclBits.ParameterIndex;
2014 return d == ParameterIndexSentinel ? getParameterIndexLarge() : d;
2015 }
2016
2017 void setParameterIndexLarge(unsigned parameterIndex);
2018 unsigned getParameterIndexLarge() const;
2019};
2020
2029
2030/// Kinds of C++ special members.
2040
2041/// Kinds of defaulted postfix increment and decrement operator functions
2042/// (C++2d [over.inc.default]).
2043enum class PostfixOperatorKind : unsigned char {
2044 /// This is not a defaultable postfix increment or decrement operator.
2046 /// This is a postfix increment operator, 'operator++(int)'.
2048 /// This is a postfix decrement operator, 'operator--(int)'.
2050};
2051
2052/// Kinds of defaulted comparison operator functions.
2053enum class DefaultedComparisonKind : unsigned char {
2054 /// This is not a defaultable comparison operator.
2056 /// This is an operator== that should be implemented as a series of
2057 /// subobject comparisons.
2059 /// This is an operator<=> that should be implemented as a series of
2060 /// subobject comparisons.
2062 /// This is an operator!= that should be implemented as a rewrite in terms
2063 /// of a == comparison.
2065 /// This is an <, <=, >, or >= that should be implemented as a rewrite in
2066 /// terms of a <=> comparison.
2068};
2069
2070/// Represents a function declaration or definition.
2071///
2072/// Since a given function can be declared several times in a program,
2073/// there may be several FunctionDecls that correspond to that
2074/// function. Only one of those FunctionDecls will be found when
2075/// traversing the list of declarations in the context of the
2076/// FunctionDecl (e.g., the translation unit); this FunctionDecl
2077/// contains all of the information known about the function. Other,
2078/// previous declarations of the function are available via the
2079/// getPreviousDecl() chain.
2081 public DeclContext,
2082 public Redeclarable<FunctionDecl> {
2083 // This class stores some data in DeclContext::FunctionDeclBits
2084 // to save some space. Use the provided accessors to access it.
2085public:
2086 /// The kind of templated function a FunctionDecl can be.
2088 // Not templated.
2090 // The pattern in a function template declaration.
2092 // A non-template function that is an instantiation or explicit
2093 // specialization of a member of a templated class.
2095 // An instantiation or explicit specialization of a function template.
2096 // Note: this might have been instantiated from a templated class if it
2097 // is a class-scope explicit specialization.
2099 // A function template specialization that hasn't yet been resolved to a
2100 // particular specialized function template.
2102 // A non-template function which is in a dependent scope.
2104
2105 };
2106
2107 /// Stashed information about a defaulted/deleted function body, including
2108 /// the active FP pragma overrides (FPOptionsOverride) from the declaration
2109 /// site. These overrides are required to correctly synthesize the function
2110 /// body.
2112 : llvm::TrailingObjects<DefaultedOrDeletedFunctionInfo, DeclAccessPair,
2113 StringLiteral *> {
2114 friend TrailingObjects;
2115 unsigned NumLookups;
2116 bool HasDeletedMessage;
2117 FPOptionsOverride FPFeatures;
2118
2119 size_t numTrailingObjects(OverloadToken<DeclAccessPair>) const {
2120 return NumLookups;
2121 }
2122
2123 public:
2125 Create(ASTContext &Context, ArrayRef<DeclAccessPair> Lookups,
2126 FPOptionsOverride FPFeatures,
2127 StringLiteral *DeletedMessage = nullptr);
2128
2129 FPOptionsOverride getFPFeatures() const { return FPFeatures; }
2130
2131 /// Get the unqualified lookup results that should be used in this
2132 /// defaulted function definition.
2134 return getTrailingObjects<DeclAccessPair>(NumLookups);
2135 }
2136
2138 return HasDeletedMessage ? *getTrailingObjects<StringLiteral *>()
2139 : nullptr;
2140 }
2141
2142 void setDeletedMessage(StringLiteral *Message);
2143 };
2144
2145 /// For a defaulted function, the kind of defaulted function that it is.
2147 LLVM_PREFERRED_TYPE(CXXSpecialMemberKind)
2148 unsigned SpecialMember : 3;
2149 LLVM_PREFERRED_TYPE(DefaultedComparisonKind)
2150 unsigned Comparison : 3;
2151 LLVM_PREFERRED_TYPE(PostfixOperatorKind)
2152 unsigned PostfixOperator : 2;
2153
2154 public:
2156 : SpecialMember(llvm::to_underlying(CXXSpecialMemberKind::Invalid)),
2157 Comparison(llvm::to_underlying(DefaultedComparisonKind::None)),
2158 PostfixOperator(llvm::to_underlying(PostfixOperatorKind::None)) {}
2160 SpecialMember = llvm::to_underlying(CSM);
2161 }
2164 Comparison = llvm::to_underlying(Comp);
2165 }
2166
2168 PostfixOperator = llvm::to_underlying(PO);
2169 }
2170
2171 bool isSpecialMember() const {
2172 return static_cast<CXXSpecialMemberKind>(SpecialMember) !=
2174 }
2175 bool isComparison() const {
2176 return static_cast<DefaultedComparisonKind>(Comparison) !=
2178 }
2179 bool isPostfixOperator() const {
2180 return static_cast<PostfixOperatorKind>(PostfixOperator) !=
2182 }
2183
2184 explicit operator bool() const {
2186 }
2187
2189 return static_cast<CXXSpecialMemberKind>(SpecialMember);
2190 }
2192 return static_cast<DefaultedComparisonKind>(Comparison);
2193 }
2194
2196 return static_cast<PostfixOperatorKind>(PostfixOperator);
2197 }
2198
2199 /// Get the index of this function kind for use in diagnostics.
2200 unsigned getDiagnosticIndex() const {
2201 static_assert(llvm::to_underlying(CXXSpecialMemberKind::Invalid) >
2202 llvm::to_underlying(CXXSpecialMemberKind::Destructor),
2203 "invalid should have highest index");
2204 static_assert((unsigned)DefaultedComparisonKind::None == 0,
2205 "none should be equal to zero");
2206 static_assert((unsigned)PostfixOperatorKind::None == 0,
2207 "none should be equal to zero");
2208 return SpecialMember + Comparison + PostfixOperator;
2209 }
2210 };
2211
2212private:
2213 /// A new[]'d array of pointers to VarDecls for the formal
2214 /// parameters of this function. This is null if a prototype or if there are
2215 /// no formals.
2216 ParmVarDecl **ParamInfo = nullptr;
2217
2218 /// The active member of this union is determined by
2219 /// FunctionDeclBits.HasDefaultedOrDeletedInfo.
2220 union {
2221 /// The body of the function.
2223 /// Information about a future defaulted function definition.
2225 };
2226
2227 unsigned ODRHash;
2228
2229 /// End part of this FunctionDecl's source range.
2230 ///
2231 /// We could compute the full range in getSourceRange(). However, when we're
2232 /// dealing with a function definition deserialized from a PCH/AST file,
2233 /// we can only compute the full range once the function body has been
2234 /// de-serialized, so it's far better to have the (sometimes-redundant)
2235 /// EndRangeLoc.
2236 SourceLocation EndRangeLoc;
2237
2238 SourceLocation DefaultKWLoc;
2239
2240 /// The template or declaration that this declaration
2241 /// describes or was instantiated from, respectively.
2242 ///
2243 /// For non-templates this value will be NULL, unless this declaration was
2244 /// declared directly inside of a function template, in which case it will
2245 /// have a pointer to a FunctionDecl, stored in the NamedDecl. For function
2246 /// declarations that describe a function template, this will be a pointer to
2247 /// a FunctionTemplateDecl, stored in the NamedDecl. For member functions of
2248 /// class template specializations, this will be a MemberSpecializationInfo
2249 /// pointer containing information about the specialization.
2250 /// For function template specializations, this will be a
2251 /// FunctionTemplateSpecializationInfo, which contains information about
2252 /// the template being specialized and the template arguments involved in
2253 /// that specialization.
2254 llvm::PointerUnion<NamedDecl *, MemberSpecializationInfo *,
2257 TemplateOrSpecialization;
2258
2259 /// Provides source/type location info for the declaration name embedded in
2260 /// the DeclaratorDecl base class.
2261 DeclarationNameLoc DNLoc;
2262
2263 /// Specify that this function declaration is actually a function
2264 /// template specialization.
2265 ///
2266 /// \param C the ASTContext.
2267 ///
2268 /// \param Template the function template that this function template
2269 /// specialization specializes.
2270 ///
2271 /// \param TemplateArgs the template arguments that produced this
2272 /// function template specialization from the template.
2273 ///
2274 /// \param InsertToken If set, the insert token in the function template
2275 /// specialization set where the function template specialization data will
2276 /// be inserted.
2277 ///
2278 /// \param TSK the kind of template specialization this is.
2279 ///
2280 /// \param TemplateArgsAsWritten location info of template arguments.
2281 ///
2282 /// \param PointOfInstantiation point at which the function template
2283 /// specialization was first instantiated.
2284 void setFunctionTemplateSpecialization(
2286 TemplateArgumentList *TemplateArgs,
2287 llvm::FoldingSetInsertToken InsertToken, TemplateSpecializationKind TSK,
2288 const TemplateArgumentListInfo *TemplateArgsAsWritten,
2289 SourceLocation PointOfInstantiation);
2290
2291 /// Specify that this record is an instantiation of the
2292 /// member function FD.
2293 void setInstantiationOfMemberFunction(ASTContext &C, FunctionDecl *FD,
2295
2296 void setParams(ASTContext &C, ArrayRef<ParmVarDecl *> NewParamInfo);
2297
2298 // This is unfortunately needed because ASTDeclWriter::VisitFunctionDecl
2299 // need to access this bit but we want to avoid making ASTDeclWriter
2300 // a friend of FunctionDeclBitfields just for this.
2301 bool isDeletedBit() const { return FunctionDeclBits.IsDeleted; }
2302
2303 /// Whether an ODRHash has been stored.
2304 bool hasODRHash() const { return FunctionDeclBits.HasODRHash; }
2305
2306 /// State that an ODRHash has been stored.
2307 void setHasODRHash(bool B = true) { FunctionDeclBits.HasODRHash = B; }
2308
2309protected:
2310 FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
2311 const DeclarationNameInfo &NameInfo, QualType T,
2312 TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin,
2313 bool isInlineSpecified, ConstexprSpecKind ConstexprKind,
2314 const AssociatedConstraint &TrailingRequiresClause);
2315
2317
2321
2323 return getPreviousDecl();
2324 }
2325
2327 return getMostRecentDecl();
2328 }
2329
2330public:
2331 friend class ASTDeclReader;
2332 friend class ASTDeclWriter;
2333
2335 using redecl_iterator = redeclarable_base::redecl_iterator;
2336
2343
2344 static FunctionDecl *
2347 TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin = false,
2348 bool isInlineSpecified = false, bool hasWrittenPrototype = true,
2350 const AssociatedConstraint &TrailingRequiresClause = {}) {
2351 DeclarationNameInfo NameInfo(N, NLoc);
2352 return FunctionDecl::Create(C, DC, StartLoc, NameInfo, T, TInfo, SC,
2354 hasWrittenPrototype, ConstexprKind,
2355 TrailingRequiresClause);
2356 }
2357
2358 static FunctionDecl *
2359 Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
2360 const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo,
2361 StorageClass SC, bool UsesFPIntrin, bool isInlineSpecified,
2362 bool hasWrittenPrototype, ConstexprSpecKind ConstexprKind,
2363 const AssociatedConstraint &TrailingRequiresClause);
2364
2365 static FunctionDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
2366
2370
2371 void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
2372 bool Qualified) const override;
2373
2374 void setRangeEnd(SourceLocation E) { EndRangeLoc = E; }
2375
2377
2378 /// Returns the location of the ellipsis of a variadic function.
2380 const auto *FPT = getType()->getAs<FunctionProtoType>();
2381 if (FPT && FPT->isVariadic())
2382 return FPT->getEllipsisLoc();
2383 return SourceLocation();
2384 }
2385
2386 SourceRange getSourceRange() const override LLVM_READONLY;
2387
2388 // Function definitions.
2389 //
2390 // A function declaration may be:
2391 // - a non defining declaration,
2392 // - a definition. A function may be defined because:
2393 // - it has a body, or will have it in the case of late parsing.
2394 // - it has an uninstantiated body. The body does not exist because the
2395 // function is not used yet, but the declaration is considered a
2396 // definition and does not allow other definition of this function.
2397 // - it does not have a user specified body, but it does not allow
2398 // redefinition, because it is deleted/defaulted or is defined through
2399 // some other mechanism (alias, ifunc).
2400
2401 /// Returns true if the function has a body.
2402 ///
2403 /// The function body might be in any of the (re-)declarations of this
2404 /// function. The variant that accepts a FunctionDecl pointer will set that
2405 /// function declaration to the actual declaration containing the body (if
2406 /// there is one).
2407 bool hasBody(const FunctionDecl *&Definition) const;
2408
2409 bool hasBody() const override {
2410 const FunctionDecl* Definition;
2411 return hasBody(Definition);
2412 }
2413
2414 /// Returns whether the function has a trivial body that does not require any
2415 /// specific codegen.
2416 bool hasTrivialBody() const;
2417
2418 /// Returns true if the function has a definition that does not need to be
2419 /// instantiated.
2420 ///
2421 /// The variant that accepts a FunctionDecl pointer will set that function
2422 /// declaration to the declaration that is a definition (if there is one).
2423 ///
2424 /// \param CheckForPendingFriendDefinition If \c true, also check for friend
2425 /// declarations that were instantiated from function definitions.
2426 /// Such a declaration behaves as if it is a definition for the
2427 /// purpose of redefinition checking, but isn't actually a "real"
2428 /// definition until its body is instantiated.
2429 bool isDefined(const FunctionDecl *&Definition,
2430 bool CheckForPendingFriendDefinition = false) const;
2431
2432 bool isDefined() const {
2433 const FunctionDecl* Definition;
2434 return isDefined(Definition);
2435 }
2436
2437 /// Get the definition for this declaration.
2439 const FunctionDecl *Definition;
2440 if (isDefined(Definition))
2441 return const_cast<FunctionDecl *>(Definition);
2442 return nullptr;
2443 }
2445 return const_cast<FunctionDecl *>(this)->getDefinition();
2446 }
2447
2448 /// Retrieve the body (definition) of the function. The function body might be
2449 /// in any of the (re-)declarations of this function. The variant that accepts
2450 /// a FunctionDecl pointer will set that function declaration to the actual
2451 /// declaration containing the body (if there is one).
2452 /// NOTE: For checking if there is a body, use hasBody() instead, to avoid
2453 /// unnecessary AST de-serialization of the body.
2454 Stmt *getBody(const FunctionDecl *&Definition) const;
2455
2456 Stmt *getBody() const override {
2457 const FunctionDecl* Definition;
2458 return getBody(Definition);
2459 }
2460
2461 /// Returns whether this specific declaration of the function is also a
2462 /// definition that does not contain uninstantiated body.
2463 ///
2464 /// This does not determine whether the function has been defined (e.g., in a
2465 /// previous definition); for that information, use isDefined.
2466 ///
2467 /// Note: the function declaration does not become a definition until the
2468 /// parser reaches the definition, if called before, this function will return
2469 /// `false`.
2475
2476 /// Determine whether this specific declaration of the function is a friend
2477 /// declaration that was instantiated from a function definition. Such
2478 /// declarations behave like definitions in some contexts.
2480
2481 /// Returns whether this specific declaration of the function has a body.
2483 return (!FunctionDeclBits.HasDefaultedOrDeletedInfo && Body) ||
2485 }
2486
2487 void setBody(Stmt *B);
2488 void setLazyBody(uint64_t Offset) {
2489 FunctionDeclBits.HasDefaultedOrDeletedInfo = false;
2490 Body = LazyDeclStmtPtr(Offset);
2491 }
2492
2493 void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info);
2494 DefaultedOrDeletedFunctionInfo *getDefaultedOrDeletedInfo() const;
2495
2496 /// Determine the kind of defaulting that would be done for a given function.
2497 ///
2498 /// If the function is both a default constructor and a copy / move
2499 /// constructor (due to having a default argument for the first parameter),
2500 /// this picks CXXSpecialMemberKind::DefaultConstructor.
2501 ///
2502 /// FIXME: Check that case is properly handled by all callers.
2503 DefaultedFunctionKind getDefaultedFunctionKind() const;
2504
2508
2509 /// Whether this function is variadic.
2510 bool isVariadic() const;
2511
2512 /// Whether this function is marked as virtual explicitly.
2513 bool isVirtualAsWritten() const {
2514 return FunctionDeclBits.IsVirtualAsWritten;
2515 }
2516
2517 /// State that this function is marked as virtual explicitly.
2518 void setVirtualAsWritten(bool V) { FunctionDeclBits.IsVirtualAsWritten = V; }
2519
2520 /// Whether this virtual function is pure, i.e. makes the containing class
2521 /// abstract.
2522 bool isPureVirtual() const { return FunctionDeclBits.IsPureVirtual; }
2523 void setIsPureVirtual(bool P = true);
2524
2525 /// Whether this templated function will be late parsed.
2527 return FunctionDeclBits.IsLateTemplateParsed;
2528 }
2529
2530 /// State that this templated function will be late parsed.
2531 void setLateTemplateParsed(bool ILT = true) {
2532 FunctionDeclBits.IsLateTemplateParsed = ILT;
2533 }
2534
2536 return FunctionDeclBits.IsInstantiatedFromMemberTemplate;
2537 }
2539 FunctionDeclBits.IsInstantiatedFromMemberTemplate = Val;
2540 }
2541
2542 /// Whether this function is "trivial" in some specialized C++ senses.
2543 /// Can only be true for default constructors, copy constructors,
2544 /// copy assignment operators, and destructors. Not meaningful until
2545 /// the class has been fully built by Sema.
2546 bool isTrivial() const { return FunctionDeclBits.IsTrivial; }
2547 void setTrivial(bool IT) { FunctionDeclBits.IsTrivial = IT; }
2548
2549 bool isTrivialForCall() const { return FunctionDeclBits.IsTrivialForCall; }
2550 void setTrivialForCall(bool IT) { FunctionDeclBits.IsTrivialForCall = IT; }
2551
2552 /// Whether this function is defaulted. Valid for e.g.
2553 /// special member functions, defaulted comparisions (not methods!).
2554 bool isDefaulted() const { return FunctionDeclBits.IsDefaulted; }
2555 void setDefaulted(bool D = true) { FunctionDeclBits.IsDefaulted = D; }
2556
2557 /// Whether this function is explicitly defaulted.
2559 return FunctionDeclBits.IsExplicitlyDefaulted;
2560 }
2561
2562 /// State that this function is explicitly defaulted.
2563 void setExplicitlyDefaulted(bool ED = true) {
2564 FunctionDeclBits.IsExplicitlyDefaulted = ED;
2565 }
2566
2568 return isExplicitlyDefaulted() ? DefaultKWLoc : SourceLocation();
2569 }
2570
2572 assert((NewLoc.isInvalid() || isExplicitlyDefaulted()) &&
2573 "Can't set default loc is function isn't explicitly defaulted");
2574 DefaultKWLoc = NewLoc;
2575 }
2576
2577 /// True if this method is user-declared and was not
2578 /// deleted or defaulted on its first declaration.
2579 bool isUserProvided() const {
2580 auto *DeclAsWritten = this;
2582 DeclAsWritten = Pattern;
2583 return !(DeclAsWritten->isDeleted() ||
2584 DeclAsWritten->getCanonicalDecl()->isDefaulted());
2585 }
2586
2588 return FunctionDeclBits.IsIneligibleOrNotSelected;
2589 }
2591 FunctionDeclBits.IsIneligibleOrNotSelected = II;
2592 }
2593
2594 /// Whether falling off this function implicitly returns null/zero.
2595 /// If a more specific implicit return value is required, front-ends
2596 /// should synthesize the appropriate return statements.
2598 return FunctionDeclBits.HasImplicitReturnZero;
2599 }
2600
2601 /// State that falling off this function implicitly returns null/zero.
2602 /// If a more specific implicit return value is required, front-ends
2603 /// should synthesize the appropriate return statements.
2605 FunctionDeclBits.HasImplicitReturnZero = IRZ;
2606 }
2607
2608 /// Whether this function has a prototype, either because one
2609 /// was explicitly written or because it was "inherited" by merging
2610 /// a declaration without a prototype with a declaration that has a
2611 /// prototype.
2612 bool hasPrototype() const {
2614 }
2615
2616 /// Whether this function has a written prototype.
2617 bool hasWrittenPrototype() const {
2618 return FunctionDeclBits.HasWrittenPrototype;
2619 }
2620
2621 /// State that this function has a written prototype.
2622 void setHasWrittenPrototype(bool P = true) {
2623 FunctionDeclBits.HasWrittenPrototype = P;
2624 }
2625
2626 /// Whether this function inherited its prototype from a
2627 /// previous declaration.
2629 return FunctionDeclBits.HasInheritedPrototype;
2630 }
2631
2632 /// State that this function inherited its prototype from a
2633 /// previous declaration.
2634 void setHasInheritedPrototype(bool P = true) {
2635 FunctionDeclBits.HasInheritedPrototype = P;
2636 }
2637
2638 /// Whether this is a (C++11) constexpr function or constexpr constructor.
2639 bool isConstexpr() const {
2641 }
2643 FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(CSK);
2644 }
2646 return static_cast<ConstexprSpecKind>(FunctionDeclBits.ConstexprKind);
2647 }
2651 bool isConsteval() const {
2653 }
2654
2656 FunctionDeclBits.BodyContainsImmediateEscalatingExpression = Set;
2657 }
2658
2660 return FunctionDeclBits.BodyContainsImmediateEscalatingExpression;
2661 }
2662
2663 bool isImmediateEscalating() const;
2664
2665 // The function is a C++ immediate function.
2666 // This can be either a consteval function, or an immediate escalating
2667 // function containing an immediate escalating expression.
2668 bool isImmediateFunction() const;
2669
2670 /// Whether the instantiation of this function is pending.
2671 /// This bit is set when the decision to instantiate this function is made
2672 /// and unset if and when the function body is created. That leaves out
2673 /// cases where instantiation did not happen because the template definition
2674 /// was not seen in this TU. This bit remains set in those cases, under the
2675 /// assumption that the instantiation will happen in some other TU.
2677 return FunctionDeclBits.InstantiationIsPending;
2678 }
2679
2680 /// State that the instantiation of this function is pending.
2681 /// (see instantiationIsPending)
2683 FunctionDeclBits.InstantiationIsPending = IC;
2684 }
2685
2686 /// Indicates the function uses __try.
2687 bool usesSEHTry() const { return FunctionDeclBits.UsesSEHTry; }
2688 void setUsesSEHTry(bool UST) { FunctionDeclBits.UsesSEHTry = UST; }
2689
2690 /// Whether this function has been deleted.
2691 ///
2692 /// A function that is "deleted" (via the C++0x "= delete" syntax)
2693 /// acts like a normal function, except that it cannot actually be
2694 /// called or have its address taken. Deleted functions are
2695 /// typically used in C++ overload resolution to attract arguments
2696 /// whose type or lvalue/rvalue-ness would permit the use of a
2697 /// different overload that would behave incorrectly. For example,
2698 /// one might use deleted functions to ban implicit conversion from
2699 /// a floating-point number to an Integer type:
2700 ///
2701 /// @code
2702 /// struct Integer {
2703 /// Integer(long); // construct from a long
2704 /// Integer(double) = delete; // no construction from float or double
2705 /// Integer(long double) = delete; // no construction from long double
2706 /// };
2707 /// @endcode
2708 // If a function is deleted, its first declaration must be.
2709 bool isDeleted() const {
2710 return getCanonicalDecl()->FunctionDeclBits.IsDeleted;
2711 }
2712
2713 bool isDeletedAsWritten() const {
2714 return FunctionDeclBits.IsDeleted && !isDefaulted();
2715 }
2716
2717 void setDeletedAsWritten(bool D = true, StringLiteral *Message = nullptr);
2718
2719 /// Determines whether this function is "main", which is the
2720 /// entry point into an executable program.
2721 bool isMain() const;
2722
2723 /// Determines whether this function is a MSVCRT user defined entry
2724 /// point.
2725 bool isMSVCRTEntryPoint() const;
2726
2727 /// Determines whether this operator new or delete is one
2728 /// of the reserved global placement operators:
2729 /// void *operator new(size_t, void *);
2730 /// void *operator new[](size_t, void *);
2731 /// void operator delete(void *, void *);
2732 /// void operator delete[](void *, void *);
2733 /// These functions have special behavior under [new.delete.placement]:
2734 /// These functions are reserved, a C++ program may not define
2735 /// functions that displace the versions in the Standard C++ library.
2736 /// The provisions of [basic.stc.dynamic] do not apply to these
2737 /// reserved placement forms of operator new and operator delete.
2738 ///
2739 /// This function must be an allocation or deallocation function.
2741
2742 /// Determines whether this function is one of the replaceable
2743 /// global allocation functions:
2744 /// \code
2745 /// void *operator new(size_t);
2746 /// void *operator new(size_t, const std::nothrow_t &) noexcept;
2747 /// void *operator new[](size_t);
2748 /// void *operator new[](size_t, const std::nothrow_t &) noexcept;
2749 /// void operator delete(void *) noexcept;
2750 /// void operator delete(void *, std::size_t) noexcept; [C++1y]
2751 /// void operator delete(void *, const std::nothrow_t &) noexcept;
2752 /// void operator delete[](void *) noexcept;
2753 /// void operator delete[](void *, std::size_t) noexcept; [C++1y]
2754 /// void operator delete[](void *, const std::nothrow_t &) noexcept;
2755 /// \endcode
2756 /// These functions have special behavior under C++1y [expr.new]:
2757 /// An implementation is allowed to omit a call to a replaceable global
2758 /// allocation function. [...]
2759 ///
2760 /// If this function is an aligned allocation/deallocation function, return
2761 /// the parameter number of the requested alignment through AlignmentParam.
2762 ///
2763 /// If this function is an allocation/deallocation function that takes
2764 /// the `std::nothrow_t` tag, return true through IsNothrow,
2766 UnsignedOrNone *AlignmentParam = nullptr,
2767 bool *IsNothrow = nullptr) const {
2769 return false;
2771 AlignmentParam, IsNothrow);
2772 }
2773
2774 /// Determines whether this function is one of the replaceable global
2775 /// allocation functions described in isReplaceableGlobalAllocationFunction,
2776 /// or is a function that may be treated as such during constant evaluation.
2777 /// This adds support for potentially templated type aware global allocation
2778 /// functions of the form:
2779 /// \code
2780 /// void *operator new(type-identity, std::size_t, std::align_val_t)
2781 /// void *operator new(type-identity, std::size_t, std::align_val_t,
2782 /// const std::nothrow_t &) noexcept;
2783 /// void *operator new[](type-identity, std::size_t, std::align_val_t)
2784 /// void *operator new[](type-identity, std::size_t, std::align_val_t,
2785 /// const std::nothrow_t &) noexcept;
2786 /// void operator delete(type-identity, void*, std::size_t,
2787 /// std::align_val_t) noexcept;
2788 /// void operator delete(type-identity, void*, std::size_t,
2789 /// std::align_val_t, const std::nothrow_t&) noexcept;
2790 /// void operator delete[](type-identity, void*, std::size_t,
2791 /// std::align_val_t) noexcept;
2792 /// void operator delete[](type-identity, void*, std::size_t,
2793 /// std::align_val_t, const std::nothrow_t&) noexcept;
2794 /// \endcode
2795 /// Where `type-identity` is a specialization of std::type_identity. If the
2796 /// declaration is a templated function, it may not include a parameter pack
2797 /// in the argument list, the type-identity parameter is required to be
2798 /// dependent, and is the only permitted dependent parameter.
2800 UnsignedOrNone *AlignmentParam = nullptr,
2801 bool *IsNothrow = nullptr) const;
2802
2803 /// Determine if this function provides an inline implementation of a builtin.
2804 bool isInlineBuiltinDeclaration() const;
2805
2806 /// Determine whether this is a destroying operator delete.
2807 bool isDestroyingOperatorDelete() const;
2808 void setIsDestroyingOperatorDelete(bool IsDestroyingDelete);
2809
2810 /// Count of mandatory parameters for type aware operator new
2811 static constexpr unsigned RequiredTypeAwareNewParameterCount =
2812 /* type-identity */ 1 + /* size */ 1 + /* alignment */ 1;
2813
2814 /// Count of mandatory parameters for type aware operator delete
2815 static constexpr unsigned RequiredTypeAwareDeleteParameterCount =
2816 /* type-identity */ 1 + /* address */ 1 + /* size */ 1 +
2817 /* alignment */ 1;
2818
2819 /// Determine whether this is a type aware operator new or delete.
2820 bool isTypeAwareOperatorNewOrDelete() const;
2821 void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator = true);
2822
2824
2825 /// Compute the language linkage.
2827
2828 /// Determines whether this function is a function with
2829 /// external, C linkage.
2830 bool isExternC() const;
2831
2832 /// Determines whether this function's context is, or is nested within,
2833 /// a C++ extern "C" linkage spec.
2834 bool isInExternCContext() const;
2835
2836 /// Determines whether this function's context is, or is nested within,
2837 /// a C++ extern "C++" linkage spec.
2838 bool isInExternCXXContext() const;
2839
2840 /// Determines whether this is a global function.
2841 bool isGlobal() const;
2842
2843 /// Determines whether this function is known to be 'noreturn', through
2844 /// an attribute on its declaration or its type.
2845 bool isNoReturn() const;
2846
2847 /// Determines whether this function is known to be 'noreturn' for analyzer,
2848 /// through an `analyzer_noreturn` attribute on its declaration.
2849 bool isAnalyzerNoReturn() const;
2850
2851 /// True if the function was a definition but its body was skipped.
2852 bool hasSkippedBody() const { return FunctionDeclBits.HasSkippedBody; }
2853 void setHasSkippedBody(bool Skipped = true) {
2854 FunctionDeclBits.HasSkippedBody = Skipped;
2855 }
2856
2857 /// True if this function will eventually have a body, once it's fully parsed.
2858 bool willHaveBody() const { return FunctionDeclBits.WillHaveBody; }
2859 void setWillHaveBody(bool V = true) { FunctionDeclBits.WillHaveBody = V; }
2860
2861 /// True if this function is considered a multiversioned function.
2862 bool isMultiVersion() const {
2863 return getCanonicalDecl()->FunctionDeclBits.IsMultiVersion;
2864 }
2865
2866 /// Sets the multiversion state for this declaration and all of its
2867 /// redeclarations.
2868 void setIsMultiVersion(bool V = true) {
2869 getCanonicalDecl()->FunctionDeclBits.IsMultiVersion = V;
2870 }
2871
2872 // Sets that this is a constrained friend where the constraint refers to an
2873 // enclosing template.
2876 ->FunctionDeclBits.FriendConstraintRefersToEnclosingTemplate = V;
2877 }
2878 // Indicates this function is a constrained friend, where the constraint
2879 // refers to an enclosing template for hte purposes of [temp.friend]p9.
2881 return getCanonicalDecl()
2882 ->FunctionDeclBits.FriendConstraintRefersToEnclosingTemplate;
2883 }
2884
2885 /// Determine whether a function is a friend function that cannot be
2886 /// redeclared outside of its class, per C++ [temp.friend]p9.
2887 bool isMemberLikeConstrainedFriend() const;
2888
2889 /// Gets the kind of multiversioning attribute this declaration has. Note that
2890 /// this can return a value even if the function is not multiversion, such as
2891 /// the case of 'target'.
2893
2894
2895 /// True if this function is a multiversioned dispatch function as a part of
2896 /// the cpu_specific/cpu_dispatch functionality.
2897 bool isCPUDispatchMultiVersion() const;
2898 /// True if this function is a multiversioned processor specific function as a
2899 /// part of the cpu_specific/cpu_dispatch functionality.
2900 bool isCPUSpecificMultiVersion() const;
2901
2902 /// True if this function is a multiversioned dispatch function as a part of
2903 /// the target functionality.
2904 bool isTargetMultiVersion() const;
2905
2906 /// True if this function is the default version of a multiversioned dispatch
2907 /// function as a part of the target functionality.
2908 bool isTargetMultiVersionDefault() const;
2909
2910 /// True if this function is a multiversioned dispatch function as a part of
2911 /// the target-clones functionality.
2912 bool isTargetClonesMultiVersion() const;
2913
2914 /// True if this function is a multiversioned dispatch function as a part of
2915 /// the target-version functionality.
2916 bool isTargetVersionMultiVersion() const;
2917
2918 /// \brief Get the associated-constraints of this function declaration.
2919 /// Currently, this will either be a vector of size 1 containing the
2920 /// trailing-requires-clause or an empty vector.
2921 ///
2922 /// Use this instead of getTrailingRequiresClause for concepts APIs that
2923 /// accept an ArrayRef of constraint expressions.
2924 void
2927 ACs.emplace_back(AC);
2928 }
2929
2930 /// Get the message that indicates why this function was deleted.
2932 return FunctionDeclBits.HasDefaultedOrDeletedInfo
2933 ? DefaultedOrDeletedInfo->getDeletedMessage()
2934 : nullptr;
2935 }
2936
2937 void setPreviousDeclaration(FunctionDecl * PrevDecl);
2938
2939 FunctionDecl *getCanonicalDecl() override;
2941 return const_cast<FunctionDecl*>(this)->getCanonicalDecl();
2942 }
2943
2944 unsigned getBuiltinID(bool ConsiderWrapperFunctions = false) const;
2945
2946 // ArrayRef interface to parameters.
2948 return {ParamInfo, getNumParams()};
2949 }
2951 return {ParamInfo, getNumParams()};
2952 }
2953
2954 // Iterator access to formal parameters.
2957
2958 bool param_empty() const { return parameters().empty(); }
2959 param_iterator param_begin() { return parameters().begin(); }
2961 param_const_iterator param_begin() const { return parameters().begin(); }
2962 param_const_iterator param_end() const { return parameters().end(); }
2963 size_t param_size() const { return parameters().size(); }
2964
2965 /// Return the number of parameters this function must have based on its
2966 /// FunctionType. This is the length of the ParamInfo array after it has been
2967 /// created.
2968 unsigned getNumParams() const;
2969
2970 /// Return the number of parameters, including the implicit 'this' parameter
2971 /// if this function has one.
2972 unsigned getNumParamsIncludingThis() const;
2973
2974 const ParmVarDecl *getParamDecl(unsigned i) const {
2975 assert(i < getNumParams() && "Illegal param #");
2976 return ParamInfo[i];
2977 }
2979 assert(i < getNumParams() && "Illegal param #");
2980 return ParamInfo[i];
2981 }
2983 setParams(getASTContext(), NewParamInfo);
2984 }
2985
2986 /// Returns the minimum number of arguments needed to call this function. This
2987 /// may be fewer than the number of function parameters, if some of the
2988 /// parameters have default arguments (in C++).
2989 unsigned getMinRequiredArguments() const;
2990
2991 /// Returns the minimum number of non-object arguments needed to call this
2992 /// function. This produces the same value as getMinRequiredArguments except
2993 /// it does not count the explicit object argument, if any.
2994 unsigned getMinRequiredExplicitArguments() const;
2995
2997
2998 unsigned getNumNonObjectParams() const;
2999
3000 const ParmVarDecl *getNonObjectParameter(unsigned I) const {
3002 }
3003
3007
3008 /// Determine whether this function has a single parameter, or multiple
3009 /// parameters where all but the first have default arguments.
3010 ///
3011 /// This notion is used in the definition of copy/move constructors and
3012 /// initializer list constructors. Note that, unlike getMinRequiredArguments,
3013 /// parameter packs are not treated specially here.
3014 bool hasOneParamOrDefaultArgs() const;
3015
3016 /// Find the source location information for how the type of this function
3017 /// was written. May be absent (for example if the function was declared via
3018 /// a typedef) and may contain a different type from that of the function
3019 /// (for example if the function type was adjusted by an attribute).
3021
3023 return getType()->castAs<FunctionType>()->getReturnType();
3024 }
3025
3026 /// Attempt to compute an informative source range covering the
3027 /// function return type. This may omit qualifiers and other information with
3028 /// limited representation in the AST.
3030
3031 /// Attempt to compute an informative source range covering the
3032 /// function parameters, including the ellipsis of a variadic function.
3033 /// The source range excludes the parentheses, and is invalid if there are
3034 /// no parameters and no ellipsis.
3036
3037 /// Get the declared return type, which may differ from the actual return
3038 /// type if the return type is deduced.
3040 auto *TSI = getTypeSourceInfo();
3041 QualType T = TSI ? TSI->getType() : getType();
3042 return T->castAs<FunctionType>()->getReturnType();
3043 }
3044
3045 /// Gets the ExceptionSpecificationType as declared.
3047 auto *TSI = getTypeSourceInfo();
3048 QualType T = TSI ? TSI->getType() : getType();
3049 const auto *FPT = T->getAs<FunctionProtoType>();
3050 return FPT ? FPT->getExceptionSpecType() : EST_None;
3051 }
3052
3053 /// Attempt to compute an informative source range covering the
3054 /// function exception specification, if any.
3056
3057 /// Determine the type of an expression that calls this function.
3062
3063 /// Returns the storage class as written in the source. For the
3064 /// computed linkage of symbol, see getLinkage.
3066 return static_cast<StorageClass>(FunctionDeclBits.SClass);
3067 }
3068
3069 /// Sets the storage class as written in the source.
3071 FunctionDeclBits.SClass = SClass;
3072 }
3073
3074 /// Determine whether the "inline" keyword was specified for this
3075 /// function.
3076 bool isInlineSpecified() const { return FunctionDeclBits.IsInlineSpecified; }
3077
3078 /// Set whether the "inline" keyword was specified for this function.
3079 void setInlineSpecified(bool I) {
3080 FunctionDeclBits.IsInlineSpecified = I;
3081 FunctionDeclBits.IsInline = I;
3082 }
3083
3084 /// Determine whether the function was declared in source context
3085 /// that requires constrained FP intrinsics
3086 bool UsesFPIntrin() const { return FunctionDeclBits.UsesFPIntrin; }
3087
3088 /// Set whether the function was declared in source context
3089 /// that requires constrained FP intrinsics
3090 void setUsesFPIntrin(bool I) { FunctionDeclBits.UsesFPIntrin = I; }
3091
3092 /// Flag that this function is implicitly inline.
3093 void setImplicitlyInline(bool I = true) { FunctionDeclBits.IsInline = I; }
3094
3095 /// Determine whether this function should be inlined, because it is
3096 /// either marked "inline" or "constexpr" or is a member function of a class
3097 /// that was defined in the class body.
3098 bool isInlined() const { return FunctionDeclBits.IsInline; }
3099
3101
3102 bool isMSExternInline() const;
3103
3105
3106 bool isStatic() const { return getStorageClass() == SC_Static; }
3107
3108 /// Whether this function declaration represents an C++ overloaded
3109 /// operator, e.g., "operator+".
3111 return getOverloadedOperator() != OO_None;
3112 }
3113
3115
3116 const IdentifierInfo *getLiteralIdentifier() const;
3117
3118 /// If this function is an instantiation of a member function
3119 /// of a class template specialization, retrieves the function from
3120 /// which it was instantiated.
3121 ///
3122 /// This routine will return non-NULL for (non-templated) member
3123 /// functions of class templates and for instantiations of function
3124 /// templates. For example, given:
3125 ///
3126 /// \code
3127 /// template<typename T>
3128 /// struct X {
3129 /// void f(T);
3130 /// };
3131 /// \endcode
3132 ///
3133 /// The declaration for X<int>::f is a (non-templated) FunctionDecl
3134 /// whose parent is the class template specialization X<int>. For
3135 /// this declaration, getInstantiatedFromFunction() will return
3136 /// the FunctionDecl X<T>::A. When a complete definition of
3137 /// X<int>::A is required, it will be instantiated from the
3138 /// declaration returned by getInstantiatedFromMemberFunction().
3140
3141 /// What kind of templated function this is.
3143
3144 /// If this function is an instantiation of a member function of a
3145 /// class template specialization, retrieves the member specialization
3146 /// information.
3148
3149 /// Specify that this record is an instantiation of the
3150 /// member function FD.
3153 setInstantiationOfMemberFunction(getASTContext(), FD, TSK);
3154 }
3155
3156 /// Specify that this function declaration was instantiated from a
3157 /// FunctionDecl FD. This is only used if this is a function declaration
3158 /// declared locally inside of a function template.
3160
3162
3163 /// Retrieves the function template that is described by this
3164 /// function declaration.
3165 ///
3166 /// Every function template is represented as a FunctionTemplateDecl
3167 /// and a FunctionDecl (or something derived from FunctionDecl). The
3168 /// former contains template properties (such as the template
3169 /// parameter lists) while the latter contains the actual
3170 /// description of the template's
3171 /// contents. FunctionTemplateDecl::getTemplatedDecl() retrieves the
3172 /// FunctionDecl that describes the function template,
3173 /// getDescribedFunctionTemplate() retrieves the
3174 /// FunctionTemplateDecl from a FunctionDecl.
3176
3178
3179 /// Determine whether this function is a function template
3180 /// specialization.
3182
3183 /// If this function is actually a function template specialization,
3184 /// retrieve information about this function template specialization.
3185 /// Otherwise, returns NULL.
3187
3188 /// Determines whether this function is a function template
3189 /// specialization or a member of a class template specialization that can
3190 /// be implicitly instantiated.
3191 bool isImplicitlyInstantiable() const;
3192
3193 /// Determines if the given function was instantiated from a
3194 /// function template.
3195 bool isTemplateInstantiation() const;
3196
3197 /// Retrieve the function declaration from which this function could
3198 /// be instantiated, if it is an instantiation (rather than a non-template
3199 /// or a specialization, for example).
3200 ///
3201 /// If \p ForDefinition is \c false, explicit specializations will be treated
3202 /// as if they were implicit instantiations. This will then find the pattern
3203 /// corresponding to non-definition portions of the declaration, such as
3204 /// default arguments and the exception specification.
3205 FunctionDecl *
3206 getTemplateInstantiationPattern(bool ForDefinition = true) const;
3207
3208 /// Retrieve the primary template that this function template
3209 /// specialization either specializes or was instantiated from.
3210 ///
3211 /// If this function declaration is not a function template specialization,
3212 /// returns NULL.
3214
3215 /// Retrieve the template arguments used to produce this function
3216 /// template specialization from the primary template.
3217 ///
3218 /// If this function declaration is not a function template specialization,
3219 /// returns NULL.
3221
3222 /// Retrieve the template argument list as written in the sources,
3223 /// if any.
3224 ///
3225 /// If this function declaration is not a function template specialization
3226 /// or if it had no explicit template argument list, returns NULL.
3227 /// Note that it an explicit template argument list may be written empty,
3228 /// e.g., template<> void foo<>(char* s);
3231
3232 /// Specify that this function declaration is actually a function
3233 /// template specialization.
3234 ///
3235 /// \param Template the function template that this function template
3236 /// specialization specializes.
3237 ///
3238 /// \param TemplateArgs the template arguments that produced this
3239 /// function template specialization from the template.
3240 ///
3241 /// \param InsertToken If set, the insert token in the function template
3242 /// specialization set where the function template specialization data will
3243 /// be inserted.
3244 ///
3245 /// \param TSK the kind of template specialization this is.
3246 ///
3247 /// \param TemplateArgsAsWritten location info of template arguments.
3248 ///
3249 /// \param PointOfInstantiation point at which the function template
3250 /// specialization was first instantiated.
3253 llvm::FoldingSetInsertToken InsertToken,
3255 TemplateArgumentListInfo *TemplateArgsAsWritten = nullptr,
3256 SourceLocation PointOfInstantiation = SourceLocation()) {
3257 setFunctionTemplateSpecialization(getASTContext(), Template, TemplateArgs,
3258 InsertToken, TSK, TemplateArgsAsWritten,
3259 PointOfInstantiation);
3260 }
3261
3262 /// Specifies that this function declaration is actually a
3263 /// dependent function template specialization.
3265 ASTContext &Context, const UnresolvedSetImpl &Templates,
3266 const TemplateArgumentListInfo *TemplateArgs);
3267
3270
3271 /// Determine what kind of template instantiation this function
3272 /// represents.
3274
3275 /// Determine the kind of template specialization this function represents
3276 /// for the purpose of template instantiation.
3279
3280 /// Determine what kind of template instantiation this function
3281 /// represents.
3283 SourceLocation PointOfInstantiation = SourceLocation());
3284
3285 /// True if both __host__ and __device__ are implicit attributes and this is
3286 /// (or is a member of) an explicit template instantiation.
3288
3289 /// Retrieve the (first) point of instantiation of a function template
3290 /// specialization or a member of a class template specialization.
3291 ///
3292 /// \returns the first point of instantiation, if this function was
3293 /// instantiated from a template; otherwise, returns an invalid source
3294 /// location.
3296
3297 /// Determine whether this is or was instantiated from an out-of-line
3298 /// definition of a member function.
3299 bool isOutOfLine() const override;
3300
3301 /// Identify a memory copying or setting function.
3302 /// If the given function is a memory copy or setting function, returns
3303 /// the corresponding Builtin ID. If the function is not a memory function,
3304 /// returns 0.
3305 unsigned getMemoryFunctionKind() const;
3306
3307 /// Returns ODRHash of the function. This value is calculated and
3308 /// stored on first call, then the stored value returned on the other calls.
3309 unsigned getODRHash();
3310
3311 /// Returns cached ODRHash of the function. This must have been previously
3312 /// computed and stored.
3313 unsigned getODRHash() const;
3314
3316 // Effects may differ between declarations, but they should be propagated
3317 // from old to new on any redeclaration, so it suffices to look at
3318 // getMostRecentDecl().
3319 if (const auto *FPT =
3320 getMostRecentDecl()->getType()->getAs<FunctionProtoType>())
3321 return FPT->getFunctionEffects();
3322 return {};
3323 }
3324
3325 // Implement isa/cast/dyncast/etc.
3326 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3327 static bool classofKind(Kind K) {
3328 return K >= firstFunction && K <= lastFunction;
3329 }
3331 return static_cast<DeclContext *>(const_cast<FunctionDecl*>(D));
3332 }
3334 return static_cast<FunctionDecl *>(const_cast<DeclContext*>(DC));
3335 }
3336
3337 bool isReferenceableKernel() const;
3338};
3339
3340/// Represents a member of a struct/union/class.
3341class FieldDecl : public DeclaratorDecl, public Mergeable<FieldDecl> {
3342 /// The kinds of value we can store in StorageKind.
3343 ///
3344 /// Note that this is compatible with InClassInitStyle except for
3345 /// ISK_CapturedVLAType.
3346 enum InitStorageKind {
3347 /// If the pointer is null, there's nothing special. Otherwise,
3348 /// this is a bitfield and the pointer is the Expr* storing the
3349 /// bit-width.
3350 ISK_NoInit = (unsigned) ICIS_NoInit,
3351
3352 /// The pointer is an (optional due to delayed parsing) Expr*
3353 /// holding the copy-initializer.
3354 ISK_InClassCopyInit = (unsigned) ICIS_CopyInit,
3355
3356 /// The pointer is an (optional due to delayed parsing) Expr*
3357 /// holding the list-initializer.
3358 ISK_InClassListInit = (unsigned) ICIS_ListInit,
3359
3360 /// The pointer is a VariableArrayType* that's been captured;
3361 /// the enclosing context is a lambda or captured statement.
3362 ISK_CapturedVLAType,
3363 };
3364
3365 LLVM_PREFERRED_TYPE(bool)
3366 unsigned BitField : 1;
3367 LLVM_PREFERRED_TYPE(bool)
3368 unsigned Mutable : 1;
3369 LLVM_PREFERRED_TYPE(InitStorageKind)
3370 unsigned StorageKind : 2;
3371 mutable unsigned CachedFieldIndex : 28;
3372
3373 /// If this is a bitfield with a default member initializer, this
3374 /// structure is used to represent the two expressions.
3375 struct InitAndBitWidthStorage {
3377 Expr *BitWidth;
3378 };
3379
3380 /// Storage for either the bit-width, the in-class initializer, or
3381 /// both (via InitAndBitWidth), or the captured variable length array bound.
3382 ///
3383 /// If the storage kind is ISK_InClassCopyInit or
3384 /// ISK_InClassListInit, but the initializer is null, then this
3385 /// field has an in-class initializer that has not yet been parsed
3386 /// and attached.
3387 // FIXME: Tail-allocate this to reduce the size of FieldDecl in the
3388 // overwhelmingly common case that we have none of these things.
3389 union {
3390 // Active member if ISK is not ISK_CapturedVLAType and BitField is false.
3392 // Active member if ISK is ISK_NoInit and BitField is true.
3394 // Active member if ISK is ISK_InClass*Init and BitField is true.
3395 InitAndBitWidthStorage *InitAndBitWidth;
3396 // Active member if ISK is ISK_CapturedVLAType.
3398 };
3399
3400protected:
3402 SourceLocation IdLoc, const IdentifierInfo *Id, QualType T,
3403 TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
3404 InClassInitStyle InitStyle)
3405 : DeclaratorDecl(DK, DC, IdLoc, Id, T, TInfo, StartLoc), BitField(false),
3406 Mutable(Mutable), StorageKind((InitStorageKind)InitStyle),
3407 CachedFieldIndex(0), Init() {
3408 if (BW)
3409 setBitWidth(BW);
3410 }
3411
3412public:
3413 friend class ASTDeclReader;
3414 friend class ASTDeclWriter;
3415
3416 static FieldDecl *Create(const ASTContext &C, DeclContext *DC,
3417 SourceLocation StartLoc, SourceLocation IdLoc,
3418 const IdentifierInfo *Id, QualType T,
3419 TypeSourceInfo *TInfo, Expr *BW, bool Mutable,
3420 InClassInitStyle InitStyle);
3421
3423
3424 /// Returns the index of this field within its record,
3425 /// as appropriate for passing to ASTRecordLayout::getFieldOffset.
3426 unsigned getFieldIndex() const {
3427 const FieldDecl *Canonical = getCanonicalDecl();
3428 if (Canonical->CachedFieldIndex == 0) {
3429 Canonical->setCachedFieldIndex();
3430 assert(Canonical->CachedFieldIndex != 0);
3431 }
3432 return Canonical->CachedFieldIndex - 1;
3433 }
3434
3435private:
3436 /// Set CachedFieldIndex to the index of this field plus one.
3437 void setCachedFieldIndex() const;
3438
3439public:
3440 /// Determines whether this field is mutable (C++ only).
3441 bool isMutable() const { return Mutable; }
3442
3443 /// Determines whether this field is a bitfield.
3444 bool isBitField() const { return BitField; }
3445
3446 /// Determines whether this is an unnamed bitfield.
3447 bool isUnnamedBitField() const { return isBitField() && !getDeclName(); }
3448
3449 /// Determines whether this field is a
3450 /// representative for an anonymous struct or union. Such fields are
3451 /// unnamed and are implicitly generated by the implementation to
3452 /// store the data for the anonymous union or struct.
3453 bool isAnonymousStructOrUnion() const;
3454
3455 /// Returns the expression that represents the bit width, if this field
3456 /// is a bit field. For non-bitfields, this returns \c nullptr.
3458 if (!BitField)
3459 return nullptr;
3460 return hasInClassInitializer() ? InitAndBitWidth->BitWidth : BitWidth;
3461 }
3462
3463 /// Determines whether the bit width of this field is a constant integer.
3464 /// This may not always be the case, such as inside template-dependent
3465 /// expressions.
3466 bool hasConstantIntegerBitWidth() const;
3467
3468 /// Computes the bit width of this field, if this is a bit field.
3469 /// May not be called on non-bitfields.
3470 /// Note that in order to successfully use this function, the bitwidth
3471 /// expression must be a ConstantExpr with a valid integer result set.
3472 unsigned getBitWidthValue() const;
3473
3474 /// Set the bit-field width for this member.
3475 // Note: used by some clients (i.e., do not remove it).
3476 void setBitWidth(Expr *Width) {
3477 assert(!hasCapturedVLAType() && !BitField &&
3478 "bit width or captured type already set");
3479 assert(Width && "no bit width specified");
3482 new (getASTContext()) InitAndBitWidthStorage{Init, Width};
3483 else
3484 BitWidth = Width;
3485 BitField = true;
3486 }
3487
3488 /// Remove the bit-field width from this member.
3489 // Note: used by some clients (i.e., do not remove it).
3491 assert(isBitField() && "no bitfield width to remove");
3492 if (hasInClassInitializer()) {
3493 // Read the old initializer before we change the active union member.
3494 auto ExistingInit = InitAndBitWidth->Init;
3495 Init = ExistingInit;
3496 }
3497 BitField = false;
3498 }
3499
3500 /// Is this a zero-length bit-field? Such bit-fields aren't really bit-fields
3501 /// at all and instead act as a separator between contiguous runs of other
3502 /// bit-fields.
3503 bool isZeroLengthBitField() const;
3504
3505 /// Determine if this field is a subobject of zero size, that is, either a
3506 /// zero-length bit-field or a field of empty class type with the
3507 /// [[no_unique_address]] attribute.
3508 bool isZeroSize(const ASTContext &Ctx) const;
3509
3510 /// Determine if this field is of potentially-overlapping class type, that
3511 /// is, subobject with the [[no_unique_address]] attribute
3512 bool isPotentiallyOverlapping() const;
3513
3514 /// Get the kind of (C++11) default member initializer that this field has.
3516 return (StorageKind == ISK_CapturedVLAType ? ICIS_NoInit
3517 : (InClassInitStyle)StorageKind);
3518 }
3519
3520 /// Determine whether this member has a C++11 default member initializer.
3522 return getInClassInitStyle() != ICIS_NoInit;
3523 }
3524
3525 /// Determine whether getInClassInitializer() would return a non-null pointer
3526 /// without deserializing the initializer.
3528 return hasInClassInitializer() && (BitField ? InitAndBitWidth->Init : Init);
3529 }
3530
3531 /// Get the C++11 default member initializer for this member, or null if one
3532 /// has not been set. If a valid declaration has a default member initializer,
3533 /// but this returns null, then we have not parsed and attached it yet.
3534 Expr *getInClassInitializer() const;
3535
3536 /// Set the C++11 in-class initializer for this member.
3537 void setInClassInitializer(Expr *NewInit);
3538
3539 /// Find the FieldDecl specified in a FAM's "counted_by" attribute. Returns
3540 /// \p nullptr if either the attribute or the field doesn't exist.
3541 const FieldDecl *findCountedByField() const;
3542
3543private:
3544 void setLazyInClassInitializer(LazyDeclStmtPtr NewInit);
3545
3546public:
3547 /// Remove the C++11 in-class initializer from this member.
3549 assert(hasInClassInitializer() && "no initializer to remove");
3550 StorageKind = ISK_NoInit;
3551 if (BitField) {
3552 // Read the bit width before we change the active union member.
3553 Expr *ExistingBitWidth = InitAndBitWidth->BitWidth;
3554 BitWidth = ExistingBitWidth;
3555 }
3556 }
3557
3558 /// Determine whether this member captures the variable length array
3559 /// type.
3560 bool hasCapturedVLAType() const {
3561 return StorageKind == ISK_CapturedVLAType;
3562 }
3563
3564 /// Get the captured variable length array type.
3566 return hasCapturedVLAType() ? CapturedVLAType : nullptr;
3567 }
3568
3569 /// Set the captured variable length array type for this field.
3570 void setCapturedVLAType(const VariableArrayType *VLAType);
3571
3572 /// Returns the parent of this field declaration, which
3573 /// is the struct in which this field is defined.
3574 ///
3575 /// Returns null if this is not a normal class/struct field declaration, e.g.
3576 /// ObjCAtDefsFieldDecl, ObjCIvarDecl.
3577 const RecordDecl *getParent() const {
3578 return dyn_cast<RecordDecl>(getDeclContext());
3579 }
3580
3582 return dyn_cast<RecordDecl>(getDeclContext());
3583 }
3584
3585 SourceRange getSourceRange() const override LLVM_READONLY;
3586
3587 /// Retrieves the canonical declaration of this field.
3588 FieldDecl *getCanonicalDecl() override { return getFirstDecl(); }
3589 const FieldDecl *getCanonicalDecl() const { return getFirstDecl(); }
3590
3591 // Implement isa/cast/dyncast/etc.
3592 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3593 static bool classofKind(Kind K) { return K >= firstField && K <= lastField; }
3594
3595 void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
3596};
3597
3598/// An instance of this object exists for each enum constant
3599/// that is defined. For example, in "enum X {a,b}", each of a/b are
3600/// EnumConstantDecl's, X is an instance of EnumDecl, and the type of a/b is a
3601/// TagType for the X EnumDecl.
3603 public Mergeable<EnumConstantDecl>,
3604 public APIntStorage {
3605 Stmt *Init; // an integer constant expression
3606 bool IsUnsigned;
3607
3608protected:
3610 IdentifierInfo *Id, QualType T, Expr *E,
3611 const llvm::APSInt &V);
3612
3613public:
3614 friend class StmtIteratorBase;
3615
3618 QualType T, Expr *E,
3619 const llvm::APSInt &V);
3621
3622 const Expr *getInitExpr() const { return (const Expr*) Init; }
3623 Expr *getInitExpr() { return (Expr*) Init; }
3624 llvm::APSInt getInitVal() const {
3625 return llvm::APSInt(getValue(), IsUnsigned);
3626 }
3627
3628 void setInitExpr(Expr *E) { Init = (Stmt*) E; }
3629 void setInitVal(const ASTContext &C, const llvm::APSInt &V) {
3630 setValue(C, V);
3631 IsUnsigned = V.isUnsigned();
3632 }
3633
3634 SourceRange getSourceRange() const override LLVM_READONLY;
3635
3636 /// Retrieves the canonical declaration of this enumerator.
3639
3640 // Implement isa/cast/dyncast/etc.
3641 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3642 static bool classofKind(Kind K) { return K == EnumConstant; }
3643};
3644
3645/// Represents a field injected from an anonymous union/struct into the parent
3646/// scope. These are always implicit.
3647class IndirectFieldDecl : public ValueDecl,
3648 public Mergeable<IndirectFieldDecl> {
3649 NamedDecl **Chaining;
3650 unsigned ChainingSize;
3651
3652 IndirectFieldDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
3655
3656 void anchor() override;
3657
3658public:
3659 friend class ASTDeclReader;
3660
3661 static IndirectFieldDecl *Create(ASTContext &C, DeclContext *DC,
3662 SourceLocation L, const IdentifierInfo *Id,
3664
3665 static IndirectFieldDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
3666
3668
3669 ArrayRef<NamedDecl *> chain() const { return {Chaining, ChainingSize}; }
3670 chain_iterator chain_begin() const { return chain().begin(); }
3671 chain_iterator chain_end() const { return chain().end(); }
3672
3673 unsigned getChainingSize() const { return ChainingSize; }
3674
3676 assert(chain().size() >= 2);
3677 return cast<FieldDecl>(chain().back());
3678 }
3679
3681 assert(chain().size() >= 2);
3682 return dyn_cast<VarDecl>(chain().front());
3683 }
3684
3685 IndirectFieldDecl *getCanonicalDecl() override { return getFirstDecl(); }
3686 const IndirectFieldDecl *getCanonicalDecl() const { return getFirstDecl(); }
3687
3688 // Implement isa/cast/dyncast/etc.
3689 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3690 static bool classofKind(Kind K) { return K == IndirectField; }
3691};
3692
3693/// Represents a declaration of a type.
3694class TypeDecl : public NamedDecl {
3695 friend class ASTContext;
3696 friend class ASTReader;
3697
3698 /// This indicates the Type object that represents
3699 /// this TypeDecl. It is a cache maintained by
3700 /// ASTContext::getTypedefType, ASTContext::getTagDeclType, and
3701 /// ASTContext::getTemplateTypeParmType, and TemplateTypeParmDecl.
3702 mutable const Type *TypeForDecl = nullptr;
3703
3704 /// The start of the source range for this declaration.
3705 SourceLocation LocStart;
3706
3707 void anchor() override;
3708
3709protected:
3711 SourceLocation StartL = SourceLocation())
3712 : NamedDecl(DK, DC, L, Id), LocStart(StartL) {}
3713
3714public:
3715 // Low-level accessor. If you just want the type defined by this node,
3716 // check out ASTContext::getTypeDeclType or one of
3717 // ASTContext::getTypedefType, ASTContext::getTagType, etc. if you
3718 // already know the specific kind of node this is.
3719 const Type *getTypeForDecl() const {
3720 assert(!isa<TagDecl>(this));
3721 return TypeForDecl;
3722 }
3723 void setTypeForDecl(const Type *TD) {
3724 assert(!isa<TagDecl>(this));
3725 TypeForDecl = TD;
3726 }
3727
3728 SourceLocation getBeginLoc() const LLVM_READONLY { return LocStart; }
3729 void setLocStart(SourceLocation L) { LocStart = L; }
3730 SourceRange getSourceRange() const override LLVM_READONLY {
3731 if (LocStart.isValid())
3732 return SourceRange(LocStart, getLocation());
3733 else
3734 return SourceRange(getLocation());
3735 }
3736
3737 // Implement isa/cast/dyncast/etc.
3738 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3739 static bool classofKind(Kind K) { return K >= firstType && K <= lastType; }
3740};
3741
3742/// Base class for declarations which introduce a typedef-name.
3743class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
3744 struct alignas(8) ModedTInfo {
3745 TypeSourceInfo *first;
3746 QualType second;
3747 };
3748
3749 /// If int part is 0, we have not computed IsTransparentTag.
3750 /// Otherwise, IsTransparentTag is (getInt() >> 1).
3751 mutable llvm::PointerIntPair<
3752 llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *>, 2>
3753 MaybeModedTInfo;
3754
3755 void anchor() override;
3756
3757protected:
3759 SourceLocation StartLoc, SourceLocation IdLoc,
3760 const IdentifierInfo *Id, TypeSourceInfo *TInfo)
3761 : TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C),
3762 MaybeModedTInfo(TInfo, 0) {}
3763
3765
3769
3771 return getPreviousDecl();
3772 }
3773
3775 return getMostRecentDecl();
3776 }
3777
3778public:
3780 using redecl_iterator = redeclarable_base::redecl_iterator;
3781
3788
3789 bool isModed() const {
3790 return isa<ModedTInfo *>(MaybeModedTInfo.getPointer());
3791 }
3792
3794 return isModed() ? cast<ModedTInfo *>(MaybeModedTInfo.getPointer())->first
3795 : cast<TypeSourceInfo *>(MaybeModedTInfo.getPointer());
3796 }
3797
3799 return isModed() ? cast<ModedTInfo *>(MaybeModedTInfo.getPointer())->second
3800 : cast<TypeSourceInfo *>(MaybeModedTInfo.getPointer())
3801 ->getType();
3802 }
3803
3805 MaybeModedTInfo.setPointer(newType);
3806 }
3807
3809 MaybeModedTInfo.setPointer(new (getASTContext(), 8)
3810 ModedTInfo({unmodedTSI, modedTy}));
3811 }
3812
3813 /// Retrieves the canonical declaration of this typedef-name.
3815 const TypedefNameDecl *getCanonicalDecl() const { return getFirstDecl(); }
3816
3817 /// Retrieves the tag declaration for which this is the typedef name for
3818 /// linkage purposes, if any.
3819 ///
3820 /// \param AnyRedecl Look for the tag declaration in any redeclaration of
3821 /// this typedef declaration.
3822 TagDecl *getAnonDeclWithTypedefName(bool AnyRedecl = false) const;
3823
3824 /// Determines if this typedef shares a name and spelling location with its
3825 /// underlying tag type, as is the case with the NS_ENUM macro.
3826 bool isTransparentTag() const {
3827 if (MaybeModedTInfo.getInt())
3828 return MaybeModedTInfo.getInt() & 0x2;
3829 return isTransparentTagSlow();
3830 }
3831
3832 // These types are created lazily, use the ASTContext methods to obtain them.
3833 const Type *getTypeForDecl() const = delete;
3834 void setTypeForDecl(const Type *TD) = delete;
3835
3836 // Implement isa/cast/dyncast/etc.
3837 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3838 static bool classofKind(Kind K) {
3839 return K >= firstTypedefName && K <= lastTypedefName;
3840 }
3841
3842private:
3843 bool isTransparentTagSlow() const;
3844};
3845
3846/// Represents the declaration of a typedef-name via the 'typedef'
3847/// type specifier.
3848class TypedefDecl : public TypedefNameDecl {
3849 TypedefDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
3850 SourceLocation IdLoc, const IdentifierInfo *Id,
3851 TypeSourceInfo *TInfo)
3852 : TypedefNameDecl(Typedef, C, DC, StartLoc, IdLoc, Id, TInfo) {}
3853
3854public:
3855 static TypedefDecl *Create(ASTContext &C, DeclContext *DC,
3856 SourceLocation StartLoc, SourceLocation IdLoc,
3857 const IdentifierInfo *Id, TypeSourceInfo *TInfo);
3858 static TypedefDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
3859
3860 SourceRange getSourceRange() const override LLVM_READONLY;
3861
3862 // Implement isa/cast/dyncast/etc.
3863 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3864 static bool classofKind(Kind K) { return K == Typedef; }
3865};
3866
3867/// Represents the declaration of a typedef-name via a C++11
3868/// alias-declaration.
3869class TypeAliasDecl : public TypedefNameDecl {
3870 /// The template for which this is the pattern, if any.
3871 TypeAliasTemplateDecl *Template;
3872
3873 TypeAliasDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
3874 SourceLocation IdLoc, const IdentifierInfo *Id,
3875 TypeSourceInfo *TInfo)
3876 : TypedefNameDecl(TypeAlias, C, DC, StartLoc, IdLoc, Id, TInfo),
3877 Template(nullptr) {}
3878
3879public:
3880 static TypeAliasDecl *Create(ASTContext &C, DeclContext *DC,
3881 SourceLocation StartLoc, SourceLocation IdLoc,
3882 const IdentifierInfo *Id, TypeSourceInfo *TInfo);
3883 static TypeAliasDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
3884
3885 SourceRange getSourceRange() const override LLVM_READONLY;
3886
3889
3890 // Implement isa/cast/dyncast/etc.
3891 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3892 static bool classofKind(Kind K) { return K == TypeAlias; }
3893};
3894
3895/// Represents the declaration of a struct/union/class/enum.
3896class TagDecl : public TypeDecl,
3897 public DeclContext,
3898 public Redeclarable<TagDecl> {
3899 // This class stores some data in DeclContext::TagDeclBits
3900 // to save some space. Use the provided accessors to access it.
3901public:
3902 // This is really ugly.
3904
3905private:
3906 SourceRange BraceRange;
3907
3908 // A struct representing syntactic qualifier info,
3909 // to be used for the (uncommon) case of out-of-line declarations.
3910 using ExtInfo = QualifierInfo;
3911
3912 /// If the (out-of-line) tag declaration name
3913 /// is qualified, it points to the qualifier info (nns and range);
3914 /// otherwise, if the tag declaration is anonymous and it is part of
3915 /// a typedef or alias, it points to the TypedefNameDecl (used for mangling);
3916 /// otherwise, if the tag declaration is anonymous and it is used as a
3917 /// declaration specifier for variables, it points to the first VarDecl (used
3918 /// for mangling);
3919 /// otherwise, it is a null (TypedefNameDecl) pointer.
3920 llvm::PointerUnion<TypedefNameDecl *, ExtInfo *> TypedefNameDeclOrQualifier;
3921
3922 bool hasExtInfo() const { return isa<ExtInfo *>(TypedefNameDeclOrQualifier); }
3923 ExtInfo *getExtInfo() { return cast<ExtInfo *>(TypedefNameDeclOrQualifier); }
3924 const ExtInfo *getExtInfo() const {
3925 return cast<ExtInfo *>(TypedefNameDeclOrQualifier);
3926 }
3927
3928protected:
3929 TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
3930 SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl,
3931 SourceLocation StartL);
3932
3934
3936 return getNextRedeclaration();
3937 }
3938
3940 return getPreviousDecl();
3941 }
3942
3944 return getMostRecentDecl();
3945 }
3946
3947 /// Completes the definition of this tag declaration.
3948 ///
3949 /// This is a helper function for derived classes.
3950 void completeDefinition();
3951
3952 /// True if this decl is currently being defined.
3953 void setBeingDefined(bool V = true) { TagDeclBits.IsBeingDefined = V; }
3954
3955 void printAnonymousTagDecl(llvm::raw_ostream &OS,
3956 const PrintingPolicy &Policy) const;
3957
3958 void printAnonymousTagDeclLocation(llvm::raw_ostream &OS,
3959 const PrintingPolicy &Policy) const;
3960
3961public:
3962 friend class ASTDeclReader;
3963 friend class ASTDeclWriter;
3964
3966 using redecl_iterator = redeclarable_base::redecl_iterator;
3967
3974
3975 SourceRange getBraceRange() const { return BraceRange; }
3976 void setBraceRange(SourceRange R) { BraceRange = R; }
3977
3978 /// Return SourceLocation representing start of source
3979 /// range ignoring outer template declarations.
3981
3982 /// Return SourceLocation representing start of source
3983 /// range taking into account any outer template declarations.
3985 SourceRange getSourceRange() const override LLVM_READONLY;
3986
3987 TagDecl *getCanonicalDecl() override;
3988 const TagDecl *getCanonicalDecl() const {
3989 return const_cast<TagDecl*>(this)->getCanonicalDecl();
3990 }
3991
3992 /// Return true if this declaration is a completion definition of the type.
3993 /// Provided for consistency.
3995 return isCompleteDefinition();
3996 }
3997
3998 /// Return true if this decl has its body fully specified.
3999 bool isCompleteDefinition() const { return TagDeclBits.IsCompleteDefinition; }
4000
4001 /// True if this decl has its body fully specified.
4002 void setCompleteDefinition(bool V = true) {
4003 TagDeclBits.IsCompleteDefinition = V;
4004 }
4005
4006 /// Return true if this complete decl is
4007 /// required to be complete for some existing use.
4009 return TagDeclBits.IsCompleteDefinitionRequired;
4010 }
4011
4012 /// True if this complete decl is
4013 /// required to be complete for some existing use.
4015 TagDeclBits.IsCompleteDefinitionRequired = V;
4016 }
4017
4018 /// Return true if this decl is currently being defined.
4019 bool isBeingDefined() const { return TagDeclBits.IsBeingDefined; }
4020
4021 /// True if this tag declaration is "embedded" (i.e., defined or declared
4022 /// for the very first time) in the syntax of a declarator.
4024 return TagDeclBits.IsEmbeddedInDeclarator;
4025 }
4026
4027 /// True if this tag declaration is "embedded" (i.e., defined or declared
4028 /// for the very first time) in the syntax of a declarator.
4029 void setEmbeddedInDeclarator(bool isInDeclarator) {
4030 TagDeclBits.IsEmbeddedInDeclarator = isInDeclarator;
4031 }
4032
4033 /// True if this tag is free standing, e.g. "struct foo;".
4034 bool isFreeStanding() const { return TagDeclBits.IsFreeStanding; }
4035
4036 /// True if this tag is free standing, e.g. "struct foo;".
4038 TagDeclBits.IsFreeStanding = isFreeStanding;
4039 }
4040
4041 /// Whether this declaration declares a type that is
4042 /// dependent, i.e., a type that somehow depends on template
4043 /// parameters.
4044 bool isDependentType() const { return isDependentContext(); }
4045
4046 /// Whether this declaration was a definition in some module but was forced
4047 /// to be a declaration.
4048 ///
4049 /// Useful for clients checking if a module has a definition of a specific
4050 /// symbol and not interested in the final AST with deduplicated definitions.
4052 return TagDeclBits.IsThisDeclarationADemotedDefinition;
4053 }
4054
4055 /// Mark a definition as a declaration and maintain information it _was_
4056 /// a definition.
4058 assert(isCompleteDefinition() &&
4059 "Should demote definitions only, not forward declarations");
4060 setCompleteDefinition(false);
4061 TagDeclBits.IsThisDeclarationADemotedDefinition = true;
4062 }
4063
4064 /// Starts the definition of this tag declaration.
4065 ///
4066 /// This method should be invoked at the beginning of the definition
4067 /// of this tag declaration. It will set the tag type into a state
4068 /// where it is in the process of being defined.
4069 void startDefinition();
4070
4071 /// Returns the TagDecl that actually defines this
4072 /// struct/union/class/enum. When determining whether or not a
4073 /// struct/union/class/enum has a definition, one should use this
4074 /// method as opposed to 'isDefinition'. 'isDefinition' indicates
4075 /// whether or not a specific TagDecl is defining declaration, not
4076 /// whether or not the struct/union/class/enum type is defined.
4077 /// This method returns NULL if there is no TagDecl that defines
4078 /// the struct/union/class/enum.
4079 TagDecl *getDefinition() const;
4080
4082 if (TagDecl *Def = getDefinition())
4083 return Def;
4084 return const_cast<TagDecl *>(this);
4085 }
4086
4087 /// Determines whether this entity is in the process of being defined.
4089 if (const TagDecl *Def = getDefinition())
4090 return Def->isBeingDefined();
4091 return false;
4092 }
4093
4094 StringRef getKindName() const {
4096 }
4097
4099 return static_cast<TagKind>(TagDeclBits.TagDeclKind);
4100 }
4101
4103 TagDeclBits.TagDeclKind = llvm::to_underlying(TK);
4104 }
4105
4106 bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
4107 bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
4108 bool isClass() const { return getTagKind() == TagTypeKind::Class; }
4109 bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
4110 bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }
4111
4112 bool isStructureOrClass() const {
4113 return isStruct() || isClass() || isInterface();
4114 }
4115
4116 /// Is this tag type named, either directly or via being defined in
4117 /// a typedef of this type?
4118 ///
4119 /// C++11 [basic.link]p8:
4120 /// A type is said to have linkage if and only if:
4121 /// - it is a class or enumeration type that is named (or has a
4122 /// name for linkage purposes) and the name has linkage; ...
4123 /// C++11 [dcl.typedef]p9:
4124 /// If the typedef declaration defines an unnamed class (or enum),
4125 /// the first typedef-name declared by the declaration to be that
4126 /// class type (or enum type) is used to denote the class type (or
4127 /// enum type) for linkage purposes only.
4128 ///
4129 /// C does not have an analogous rule, but the same concept is
4130 /// nonetheless useful in some places.
4131 bool hasNameForLinkage() const {
4132 return (getDeclName() || getTypedefNameForAnonDecl());
4133 }
4134
4136 return hasExtInfo() ? nullptr
4137 : cast<TypedefNameDecl *>(TypedefNameDeclOrQualifier);
4138 }
4139
4141
4142 /// Retrieve the nested-name-specifier that qualifies the name of this
4143 /// declaration, if it was present in the source.
4145 return hasExtInfo() ? getExtInfo()->QualifierLoc.getNestedNameSpecifier()
4146 : std::nullopt;
4147 }
4148
4149 /// Retrieve the nested-name-specifier (with source-location
4150 /// information) that qualifies the name of this declaration, if it was
4151 /// present in the source.
4153 return hasExtInfo() ? getExtInfo()->QualifierLoc
4155 }
4156
4157 void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc);
4158
4160 if (!hasExtInfo())
4161 return {};
4162 return {/*data=*/getExtInfo()->TemplParamLists,
4163 /*length=*/getExtInfo()->NumTemplParamLists};
4164 }
4165
4166 // These types are created lazily, use the ASTContext methods to obtain them.
4167 const Type *getTypeForDecl() const = delete;
4168 void setTypeForDecl(const Type *TD) = delete;
4169
4170 using TypeDecl::printName;
4171 void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
4172
4175
4176 // Implement isa/cast/dyncast/etc.
4177 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4178 static bool classofKind(Kind K) { return K >= firstTag && K <= lastTag; }
4179
4181 return static_cast<DeclContext *>(const_cast<TagDecl*>(D));
4182 }
4183
4185 return static_cast<TagDecl *>(const_cast<DeclContext*>(DC));
4186 }
4187};
4188
4189/// Represents an enum. In C++11, enums can be forward-declared
4190/// with a fixed underlying type, and in C we allow them to be forward-declared
4191/// with no underlying type as an extension.
4192class EnumDecl : public TagDecl {
4193 // This class stores some data in DeclContext::EnumDeclBits
4194 // to save some space. Use the provided accessors to access it.
4195
4196 /// This represent the integer type that the enum corresponds
4197 /// to for code generation purposes. Note that the enumerator constants may
4198 /// have a different type than this does.
4199 ///
4200 /// If the underlying integer type was explicitly stated in the source
4201 /// code, this is a TypeSourceInfo* for that type. Otherwise this type
4202 /// was automatically deduced somehow, and this is a Type*.
4203 ///
4204 /// Normally if IsFixed(), this would contain a TypeSourceInfo*, but in
4205 /// some cases it won't.
4206 ///
4207 /// The underlying type of an enumeration never has any qualifiers, so
4208 /// we can get away with just storing a raw Type*, and thus save an
4209 /// extra pointer when TypeSourceInfo is needed.
4210 llvm::PointerUnion<const Type *, TypeSourceInfo *> IntegerType;
4211
4212 /// The integer type that values of this type should
4213 /// promote to. In C, enumerators are generally of an integer type
4214 /// directly, but gcc-style large enumerators (and all enumerators
4215 /// in C++) are of the enum type instead.
4216 QualType PromotionType;
4217
4218 /// If this enumeration is an instantiation of a member enumeration
4219 /// of a class template specialization, this is the member specialization
4220 /// information.
4221 MemberSpecializationInfo *SpecializationInfo = nullptr;
4222
4223 /// Store the ODRHash after first calculation.
4224 /// The corresponding flag HasODRHash is in EnumDeclBits
4225 /// and can be accessed with the provided accessors.
4226 unsigned ODRHash;
4227
4228 /// Source range covering the enum key:
4229 /// - 'enum' (unscoped)
4230 /// - 'enum class|struct' (scoped)
4231 SourceRange EnumKeyRange;
4232
4233 EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
4234 SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl,
4235 bool Scoped, bool ScopedUsingClassTag, bool Fixed);
4236
4237 void anchor() override;
4238
4239 void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED,
4241
4242 /// Sets the width in bits required to store all the
4243 /// non-negative enumerators of this enum.
4244 void setNumPositiveBits(unsigned Num) {
4245 EnumDeclBits.NumPositiveBits = Num;
4246 assert(EnumDeclBits.NumPositiveBits == Num && "can't store this bitcount");
4247 }
4248
4249 /// Returns the width in bits required to store all the
4250 /// negative enumerators of this enum. (see getNumNegativeBits)
4251 void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; }
4252
4253public:
4254 /// True if this tag declaration is a scoped enumeration. Only
4255 /// possible in C++11 mode.
4256 void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; }
4257
4258 /// If this tag declaration is a scoped enum,
4259 /// then this is true if the scoped enum was declared using the class
4260 /// tag, false if it was declared with the struct tag. No meaning is
4261 /// associated if this tag declaration is not a scoped enum.
4262 void setScopedUsingClassTag(bool ScopedUCT = true) {
4263 EnumDeclBits.IsScopedUsingClassTag = ScopedUCT;
4264 }
4265
4266 /// True if this is an Objective-C, C++11, or
4267 /// Microsoft-style enumeration with a fixed underlying type.
4268 void setFixed(bool Fixed = true) { EnumDeclBits.IsFixed = Fixed; }
4269
4270 SourceRange getEnumKeyRange() const { return EnumKeyRange; }
4271
4272 void setEnumKeyRange(SourceRange Range) { EnumKeyRange = Range; }
4273
4274private:
4275 /// True if a valid hash is stored in ODRHash.
4276 bool hasODRHash() const { return EnumDeclBits.HasODRHash; }
4277 void setHasODRHash(bool Hash = true) { EnumDeclBits.HasODRHash = Hash; }
4278
4279public:
4280 friend class ASTDeclReader;
4281
4282 EnumDecl *getCanonicalDecl() override {
4284 }
4285 const EnumDecl *getCanonicalDecl() const {
4286 return const_cast<EnumDecl*>(this)->getCanonicalDecl();
4287 }
4288
4289 EnumDecl *getPreviousDecl() {
4290 return cast_or_null<EnumDecl>(
4291 static_cast<TagDecl *>(this)->getPreviousDecl());
4292 }
4293 const EnumDecl *getPreviousDecl() const {
4294 return const_cast<EnumDecl*>(this)->getPreviousDecl();
4295 }
4296
4297 EnumDecl *getMostRecentDecl() {
4298 return cast<EnumDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl());
4299 }
4300 const EnumDecl *getMostRecentDecl() const {
4301 return const_cast<EnumDecl*>(this)->getMostRecentDecl();
4302 }
4303
4304 EnumDecl *getDefinition() const {
4305 return cast_or_null<EnumDecl>(TagDecl::getDefinition());
4306 }
4307
4308 EnumDecl *getDefinitionOrSelf() const {
4309 return cast_or_null<EnumDecl>(TagDecl::getDefinitionOrSelf());
4310 }
4311
4312 static EnumDecl *Create(ASTContext &C, DeclContext *DC,
4313 SourceLocation StartLoc, SourceLocation IdLoc,
4314 IdentifierInfo *Id, EnumDecl *PrevDecl,
4315 bool IsScoped, bool IsScopedUsingClassTag,
4316 bool IsFixed);
4318
4319 /// Overrides to provide correct range when there's an enum-base specifier
4320 /// with forward declarations.
4321 SourceRange getSourceRange() const override LLVM_READONLY;
4322
4323 /// When created, the EnumDecl corresponds to a
4324 /// forward-declared enum. This method is used to mark the
4325 /// declaration as being defined; its enumerators have already been
4326 /// added (via DeclContext::addDecl). NewType is the new underlying
4327 /// type of the enumeration type.
4328 void completeDefinition(QualType NewType,
4329 QualType PromotionType,
4330 unsigned NumPositiveBits,
4331 unsigned NumNegativeBits);
4332
4333 // Iterates through the enumerators of this enumeration.
4337
4341
4343 const EnumDecl *E = getDefinition();
4344 if (!E)
4345 E = this;
4346 return enumerator_iterator(E->decls_begin());
4347 }
4348
4350 const EnumDecl *E = getDefinition();
4351 if (!E)
4352 E = this;
4353 return enumerator_iterator(E->decls_end());
4354 }
4355
4356 /// Return the integer type that enumerators should promote to.
4357 QualType getPromotionType() const { return PromotionType; }
4358
4359 /// Set the promotion type.
4360 void setPromotionType(QualType T) { PromotionType = T; }
4361
4362 /// Return the integer type this enum decl corresponds to.
4363 /// This returns a null QualType for an enum forward definition with no fixed
4364 /// underlying type.
4366 if (!IntegerType)
4367 return QualType();
4368 if (const Type *T = dyn_cast<const Type *>(IntegerType))
4369 return QualType(T, 0);
4370 return cast<TypeSourceInfo *>(IntegerType)->getType().getUnqualifiedType();
4371 }
4372
4373 /// Set the underlying integer type.
4374 void setIntegerType(QualType T) { IntegerType = T.getTypePtrOrNull(); }
4375
4376 /// Set the underlying integer type source info.
4377 void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo) { IntegerType = TInfo; }
4378
4379 /// Return the type source info for the underlying integer type,
4380 /// if no type source info exists, return 0.
4382 return dyn_cast_if_present<TypeSourceInfo *>(IntegerType);
4383 }
4384
4385 /// Retrieve the source range that covers the underlying type if
4386 /// specified.
4387 SourceRange getIntegerTypeRange() const LLVM_READONLY;
4388
4389 /// Returns the width in bits required to store all the
4390 /// non-negative enumerators of this enum.
4391 unsigned getNumPositiveBits() const { return EnumDeclBits.NumPositiveBits; }
4392
4393 /// Returns the width in bits required to store all the
4394 /// negative enumerators of this enum. These widths include
4395 /// the rightmost leading 1; that is:
4396 ///
4397 /// MOST NEGATIVE ENUMERATOR PATTERN NUM NEGATIVE BITS
4398 /// ------------------------ ------- -----------------
4399 /// -1 1111111 1
4400 /// -10 1110110 5
4401 /// -101 1001011 8
4402 unsigned getNumNegativeBits() const { return EnumDeclBits.NumNegativeBits; }
4403
4404 /// Calculates the [Min,Max) values the enum can store based on the
4405 /// NumPositiveBits and NumNegativeBits. This matters for enums that do not
4406 /// have a fixed underlying type.
4407 void getValueRange(llvm::APInt &Max, llvm::APInt &Min) const;
4408
4409 /// Returns true if this is a C++11 scoped enumeration.
4410 bool isScoped() const { return EnumDeclBits.IsScoped; }
4411
4412 /// Returns true if this is a C++11 scoped enumeration.
4414 return EnumDeclBits.IsScopedUsingClassTag;
4415 }
4416
4417 /// Returns true if this is an Objective-C, C++11, or
4418 /// Microsoft-style enumeration with a fixed underlying type.
4419 bool isFixed() const { return EnumDeclBits.IsFixed; }
4420
4421 unsigned getODRHash();
4422
4423 /// Returns true if this can be considered a complete type.
4424 bool isComplete() const {
4425 // IntegerType is set for fixed type enums and non-fixed but implicitly
4426 // int-sized Microsoft enums.
4427 return isCompleteDefinition() || IntegerType;
4428 }
4429
4430 /// Returns true if this enum is either annotated with
4431 /// enum_extensibility(closed) or isn't annotated with enum_extensibility.
4432 bool isClosed() const;
4433
4434 /// Returns true if this enum is annotated with flag_enum and isn't annotated
4435 /// with enum_extensibility(open).
4436 bool isClosedFlag() const;
4437
4438 /// Returns true if this enum is annotated with neither flag_enum nor
4439 /// enum_extensibility(open).
4440 bool isClosedNonFlag() const;
4441
4442 /// Retrieve the enum definition from which this enumeration could
4443 /// be instantiated, if it is an instantiation (rather than a non-template).
4445
4446 /// Returns the enumeration (declared within the template)
4447 /// from which this enumeration type was instantiated, or NULL if
4448 /// this enumeration was not instantiated from any template.
4450
4451 /// If this enumeration is a member of a specialization of a
4452 /// templated class, determine what kind of template specialization
4453 /// or instantiation this is.
4455
4456 /// For an enumeration member that was instantiated from a member
4457 /// enumeration of a templated class, set the template specialiation kind.
4459 SourceLocation PointOfInstantiation = SourceLocation());
4460
4461 /// If this enumeration is an instantiation of a member enumeration of
4462 /// a class template specialization, retrieves the member specialization
4463 /// information.
4465 return SpecializationInfo;
4466 }
4467
4468 /// Specify that this enumeration is an instantiation of the
4469 /// member enumeration ED.
4472 setInstantiationOfMemberEnum(getASTContext(), ED, TSK);
4473 }
4474
4475 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4476 static bool classofKind(Kind K) { return K == Enum; }
4477};
4478
4479/// Enum that represents the different ways arguments are passed to and
4480/// returned from function calls. This takes into account the target-specific
4481/// and version-specific rules along with the rules determined by the
4482/// language.
4484 /// The argument of this type can be passed directly in registers.
4486
4487 /// The argument of this type cannot be passed directly in registers.
4488 /// Records containing this type as a subobject are not forced to be passed
4489 /// indirectly. This value is used only in C++. This value is required by
4490 /// C++ because, in uncommon situations, it is possible for a class to have
4491 /// only trivial copy/move constructors even when one of its subobjects has
4492 /// a non-trivial copy/move constructor (if e.g. the corresponding copy/move
4493 /// constructor in the derived class is deleted).
4495
4496 /// The argument of this type cannot be passed directly in registers.
4497 /// Records containing this type as a subobject are forced to be passed
4498 /// indirectly.
4500};
4501
4502/// Represents a struct/union/class. For example:
4503/// struct X; // Forward declaration, no "body".
4504/// union Y { int A, B; }; // Has body with members A and B (FieldDecls).
4505/// This decl will be marked invalid if *any* members are invalid.
4506class RecordDecl : public TagDecl {
4507 // This class stores some data in DeclContext::RecordDeclBits
4508 // to save some space. Use the provided accessors to access it.
4509public:
4510 friend class DeclContext;
4511 friend class ASTDeclReader;
4512
4513protected:
4514 RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
4515 SourceLocation StartLoc, SourceLocation IdLoc,
4516 IdentifierInfo *Id, RecordDecl *PrevDecl);
4517
4518public:
4519 static RecordDecl *Create(const ASTContext &C, TagKind TK, DeclContext *DC,
4520 SourceLocation StartLoc, SourceLocation IdLoc,
4521 IdentifierInfo *Id, RecordDecl* PrevDecl = nullptr);
4523
4525 return cast_or_null<RecordDecl>(
4526 static_cast<TagDecl *>(this)->getPreviousDecl());
4527 }
4529 return const_cast<RecordDecl*>(this)->getPreviousDecl();
4530 }
4531
4533 return cast<RecordDecl>(static_cast<TagDecl *>(this)->getMostRecentDecl());
4534 }
4536 return const_cast<RecordDecl*>(this)->getMostRecentDecl();
4537 }
4538
4540 return RecordDeclBits.HasFlexibleArrayMember;
4541 }
4542
4544 RecordDeclBits.HasFlexibleArrayMember = V;
4545 }
4546
4547 /// Whether this is an anonymous struct or union. To be an anonymous
4548 /// struct or union, it must have been declared without a name and
4549 /// there must be no objects of this type declared, e.g.,
4550 /// @code
4551 /// union { int i; float f; };
4552 /// @endcode
4553 /// is an anonymous union but neither of the following are:
4554 /// @code
4555 /// union X { int i; float f; };
4556 /// union { int i; float f; } obj;
4557 /// @endcode
4559 return RecordDeclBits.AnonymousStructOrUnion;
4560 }
4561
4563 RecordDeclBits.AnonymousStructOrUnion = Anon;
4564 }
4565
4566 bool hasObjectMember() const { return RecordDeclBits.HasObjectMember; }
4567 void setHasObjectMember(bool val) { RecordDeclBits.HasObjectMember = val; }
4568
4569 bool hasVolatileMember() const { return RecordDeclBits.HasVolatileMember; }
4570
4571 void setHasVolatileMember(bool val) {
4572 RecordDeclBits.HasVolatileMember = val;
4573 }
4574
4576 return RecordDeclBits.LoadedFieldsFromExternalStorage;
4577 }
4578
4580 RecordDeclBits.LoadedFieldsFromExternalStorage = val;
4581 }
4582
4583 /// Functions to query basic properties of non-trivial C structs.
4585 return RecordDeclBits.NonTrivialToPrimitiveDefaultInitialize;
4586 }
4587
4589 RecordDeclBits.NonTrivialToPrimitiveDefaultInitialize = V;
4590 }
4591
4593 return RecordDeclBits.NonTrivialToPrimitiveCopy;
4594 }
4595
4597 RecordDeclBits.NonTrivialToPrimitiveCopy = V;
4598 }
4599
4601 return RecordDeclBits.NonTrivialToPrimitiveDestroy;
4602 }
4603
4605 RecordDeclBits.NonTrivialToPrimitiveDestroy = V;
4606 }
4607
4609 return RecordDeclBits.HasNonTrivialToPrimitiveDefaultInitializeCUnion;
4610 }
4611
4613 RecordDeclBits.HasNonTrivialToPrimitiveDefaultInitializeCUnion = V;
4614 }
4615
4617 return RecordDeclBits.HasNonTrivialToPrimitiveDestructCUnion;
4618 }
4619
4621 RecordDeclBits.HasNonTrivialToPrimitiveDestructCUnion = V;
4622 }
4623
4625 return RecordDeclBits.HasNonTrivialToPrimitiveCopyCUnion;
4626 }
4627
4629 RecordDeclBits.HasNonTrivialToPrimitiveCopyCUnion = V;
4630 }
4631
4633 return RecordDeclBits.HasUninitializedExplicitInitFields;
4634 }
4635
4637 RecordDeclBits.HasUninitializedExplicitInitFields = V;
4638 }
4639
4640 /// Determine whether this class can be passed in registers. In C++ mode,
4641 /// it must have at least one trivial, non-deleted copy or move constructor.
4642 /// FIXME: This should be set as part of completeDefinition.
4646
4648 return static_cast<RecordArgPassingKind>(
4649 RecordDeclBits.ArgPassingRestrictions);
4650 }
4651
4653 RecordDeclBits.ArgPassingRestrictions = llvm::to_underlying(Kind);
4654 }
4655
4657 return RecordDeclBits.ParamDestroyedInCallee;
4658 }
4659
4661 RecordDeclBits.ParamDestroyedInCallee = V;
4662 }
4663
4664 bool isRandomized() const { return RecordDeclBits.IsRandomized; }
4665
4666 void setIsRandomized(bool V) { RecordDeclBits.IsRandomized = V; }
4667
4668 void reorderDecls(const SmallVectorImpl<Decl *> &Decls);
4669
4670 /// Determine whether this record is a class describing a lambda
4671 /// function object.
4672 bool isLambda() const;
4673
4674 /// Determine whether this record is a record for captured variables in
4675 /// CapturedStmt construct.
4676 bool isCapturedRecord() const;
4677
4678 /// Mark the record as a record for captured variables in CapturedStmt
4679 /// construct.
4680 void setCapturedRecord();
4681
4682 /// Returns the RecordDecl that actually defines
4683 /// this struct/union/class. When determining whether or not a
4684 /// struct/union/class is completely defined, one should use this
4685 /// method as opposed to 'isCompleteDefinition'.
4686 /// 'isCompleteDefinition' indicates whether or not a specific
4687 /// RecordDecl is a completed definition, not whether or not the
4688 /// record type is defined. This method returns NULL if there is
4689 /// no RecordDecl that defines the struct/union/tag.
4691 return cast_or_null<RecordDecl>(TagDecl::getDefinition());
4692 }
4693
4695 return cast_or_null<RecordDecl>(TagDecl::getDefinitionOrSelf());
4696 }
4697
4698 /// Returns whether this record is a union, or contains (at any nesting level)
4699 /// a union member. This is used by CMSE to warn about possible information
4700 /// leaks.
4701 bool isOrContainsUnion() const;
4702
4703 // Iterator access to field members. The field iterator only visits
4704 // the non-static data members of this class, ignoring any static
4705 // data members, functions, constructors, destructors, etc.
4707 using field_range = llvm::iterator_range<specific_decl_iterator<FieldDecl>>;
4708
4711
4713 return field_iterator(decl_iterator());
4714 }
4715
4716 // Whether there are any fields (non-static data members) in this record.
4717 bool field_empty() const {
4718 return field_begin() == field_end();
4719 }
4720
4721 /// Returns the number of fields (non-static data members) in this record.
4722 unsigned getNumFields() const {
4723 return std::distance(field_begin(), field_end());
4724 }
4725
4726 /// noload_fields - Iterate over the fields stored in this record
4727 /// that are currently loaded; don't attempt to retrieve anything
4728 /// from an external source.
4732
4737
4738 // Whether there are any fields (non-static data members) in this record.
4739 bool noload_field_empty() const {
4741 }
4742
4743 /// Note that the definition of this type is now complete.
4744 virtual void completeDefinition();
4745
4746 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4747 static bool classofKind(Kind K) {
4748 return K >= firstRecord && K <= lastRecord;
4749 }
4750
4751 /// Get whether or not this is an ms_struct which can
4752 /// be turned on with an attribute, pragma, or -mms-bitfields
4753 /// commandline option.
4754 bool isMsStruct(const ASTContext &C) const;
4755
4756 /// Whether we are allowed to insert extra padding between fields.
4757 /// These padding are added to help AddressSanitizer detect
4758 /// intra-object-overflow bugs.
4759 bool mayInsertExtraPadding(bool EmitRemark = false) const;
4760
4761 /// Finds the first data member which has a name.
4762 /// nullptr is returned if no named data member exists.
4763 const FieldDecl *findFirstNamedDataMember() const;
4764
4765 /// Get precomputed ODRHash or add a new one.
4766 unsigned getODRHash();
4767
4768private:
4769 /// Deserialize just the fields.
4770 void LoadFieldsFromExternalStorage() const;
4771
4772 /// True if a valid hash is stored in ODRHash.
4773 bool hasODRHash() const { return RecordDeclBits.ODRHash; }
4774 void setODRHash(unsigned Hash) { RecordDeclBits.ODRHash = Hash; }
4775};
4776
4777class FileScopeAsmDecl : public Decl {
4778 Expr *AsmString;
4779 SourceLocation RParenLoc;
4780
4781 FileScopeAsmDecl(DeclContext *DC, Expr *asmstring, SourceLocation StartL,
4782 SourceLocation EndL)
4783 : Decl(FileScopeAsm, DC, StartL), AsmString(asmstring), RParenLoc(EndL) {}
4784
4785 virtual void anchor();
4786
4787public:
4788 static FileScopeAsmDecl *Create(ASTContext &C, DeclContext *DC, Expr *Str,
4789 SourceLocation AsmLoc,
4790 SourceLocation RParenLoc);
4791
4792 static FileScopeAsmDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
4793
4795 SourceLocation getRParenLoc() const { return RParenLoc; }
4796 void setRParenLoc(SourceLocation L) { RParenLoc = L; }
4797 SourceRange getSourceRange() const override LLVM_READONLY {
4798 return SourceRange(getAsmLoc(), getRParenLoc());
4799 }
4800
4801 const Expr *getAsmStringExpr() const { return AsmString; }
4802 Expr *getAsmStringExpr() { return AsmString; }
4803 void setAsmString(Expr *Asm) { AsmString = Asm; }
4804
4805 std::string getAsmString() const;
4806
4807 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4808 static bool classofKind(Kind K) { return K == FileScopeAsm; }
4809};
4810
4811/// A declaration that models statements at global scope. This declaration
4812/// supports incremental and interactive C/C++.
4813///
4814/// \note This is used in libInterpreter, clang -cc1 -fincremental-extensions
4815/// and in tools such as clang-repl.
4816class TopLevelStmtDecl : public Decl, public DeclContext {
4817 friend class ASTDeclReader;
4818 friend class ASTDeclWriter;
4819
4820 Stmt *Statement = nullptr;
4821 bool IsSemiMissing = false;
4822 /// Position among all top-level statements of the session, in parse order.
4823 unsigned Ordinal = 0;
4824
4825 TopLevelStmtDecl(DeclContext *DC, SourceLocation L, Stmt *S)
4826 : Decl(TopLevelStmt, DC, L), DeclContext(TopLevelStmt), Statement(S) {}
4827
4828 virtual void anchor();
4829
4830public:
4831 static TopLevelStmtDecl *Create(ASTContext &C, Stmt *Statement);
4833
4834 SourceRange getSourceRange() const override LLVM_READONLY;
4835 Stmt *getStmt() { return Statement; }
4836 const Stmt *getStmt() const { return Statement; }
4837 void setStmt(Stmt *S);
4838 bool isSemiMissing() const { return IsSemiMissing; }
4839 void setSemiMissing(bool Missing = true) { IsSemiMissing = Missing; }
4840 unsigned getOrdinal() const { return Ordinal; }
4841
4842 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
4843 static bool classofKind(Kind K) { return K == TopLevelStmt; }
4844
4845 static DeclContext *castToDeclContext(const TopLevelStmtDecl *D) {
4846 return static_cast<DeclContext *>(const_cast<TopLevelStmtDecl *>(D));
4847 }
4848 static TopLevelStmtDecl *castFromDeclContext(const DeclContext *DC) {
4849 return static_cast<TopLevelStmtDecl *>(const_cast<DeclContext *>(DC));
4850 }
4851};
4852
4853/// Represents a block literal declaration, which is like an
4854/// unnamed FunctionDecl. For example:
4855/// ^{ statement-body } or ^(int arg1, float arg2){ statement-body }
4856class BlockDecl : public Decl, public DeclContext {
4857 // This class stores some data in DeclContext::BlockDeclBits
4858 // to save some space. Use the provided accessors to access it.
4859public:
4860 /// A class which contains all the information about a particular
4861 /// captured value.
4862 class Capture {
4863 enum {
4864 flag_isByRef = 0x1,
4865 flag_isNested = 0x2
4866 };
4867
4868 /// The variable being captured.
4869 llvm::PointerIntPair<VarDecl*, 2> VariableAndFlags;
4870
4871 /// The copy expression, expressed in terms of a DeclRef (or
4872 /// BlockDeclRef) to the captured variable. Only required if the
4873 /// variable has a C++ class type.
4874 Expr *CopyExpr;
4875
4876 public:
4877 Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
4878 : VariableAndFlags(variable,
4879 (byRef ? flag_isByRef : 0) | (nested ? flag_isNested : 0)),
4880 CopyExpr(copy) {}
4881
4882 /// The variable being captured.
4883 VarDecl *getVariable() const { return VariableAndFlags.getPointer(); }
4884
4885 /// Whether this is a "by ref" capture, i.e. a capture of a __block
4886 /// variable.
4887 bool isByRef() const { return VariableAndFlags.getInt() & flag_isByRef; }
4888
4889 bool isEscapingByref() const {
4890 return getVariable()->isEscapingByref();
4891 }
4892
4893 bool isNonEscapingByref() const {
4894 return getVariable()->isNonEscapingByref();
4895 }
4896
4897 /// Whether this is a nested capture, i.e. the variable captured
4898 /// is not from outside the immediately enclosing function/block.
4899 bool isNested() const { return VariableAndFlags.getInt() & flag_isNested; }
4900
4901 bool hasCopyExpr() const { return CopyExpr != nullptr; }
4902 Expr *getCopyExpr() const { return CopyExpr; }
4903 void setCopyExpr(Expr *e) { CopyExpr = e; }
4904 };
4905
4906private:
4907 /// A new[]'d array of pointers to ParmVarDecls for the formal
4908 /// parameters of this function. This is null if a prototype or if there are
4909 /// no formals.
4910 ParmVarDecl **ParamInfo = nullptr;
4911 unsigned NumParams = 0;
4912
4913 Stmt *Body = nullptr;
4914 TypeSourceInfo *SignatureAsWritten = nullptr;
4915
4916 const Capture *Captures = nullptr;
4917 unsigned NumCaptures = 0;
4918
4919 unsigned ManglingNumber = 0;
4920 Decl *ManglingContextDecl = nullptr;
4921
4922protected:
4923 BlockDecl(DeclContext *DC, SourceLocation CaretLoc);
4924
4925public:
4928
4930
4931 bool isVariadic() const { return BlockDeclBits.IsVariadic; }
4932 void setIsVariadic(bool value) { BlockDeclBits.IsVariadic = value; }
4933
4934 CompoundStmt *getCompoundBody() const { return (CompoundStmt*) Body; }
4935 Stmt *getBody() const override { return (Stmt*) Body; }
4936 void setBody(CompoundStmt *B) { Body = (Stmt*) B; }
4937
4938 void setSignatureAsWritten(TypeSourceInfo *Sig) { SignatureAsWritten = Sig; }
4939 TypeSourceInfo *getSignatureAsWritten() const { return SignatureAsWritten; }
4940
4941 // ArrayRef access to formal parameters.
4943 return {ParamInfo, getNumParams()};
4944 }
4946 return {ParamInfo, getNumParams()};
4947 }
4948
4949 // Iterator access to formal parameters.
4952
4953 bool param_empty() const { return parameters().empty(); }
4954 param_iterator param_begin() { return parameters().begin(); }
4956 param_const_iterator param_begin() const { return parameters().begin(); }
4957 param_const_iterator param_end() const { return parameters().end(); }
4958 size_t param_size() const { return parameters().size(); }
4959
4960 unsigned getNumParams() const { return NumParams; }
4961
4962 const ParmVarDecl *getParamDecl(unsigned i) const {
4963 assert(i < getNumParams() && "Illegal param #");
4964 return ParamInfo[i];
4965 }
4967 assert(i < getNumParams() && "Illegal param #");
4968 return ParamInfo[i];
4969 }
4970
4971 void setParams(ArrayRef<ParmVarDecl *> NewParamInfo);
4972
4973 /// True if this block (or its nested blocks) captures
4974 /// anything of local storage from its enclosing scopes.
4975 bool hasCaptures() const { return NumCaptures || capturesCXXThis(); }
4976
4977 /// Returns the number of captured variables.
4978 /// Does not include an entry for 'this'.
4979 unsigned getNumCaptures() const { return NumCaptures; }
4980
4982
4983 ArrayRef<Capture> captures() const { return {Captures, NumCaptures}; }
4984
4985 capture_const_iterator capture_begin() const { return captures().begin(); }
4986 capture_const_iterator capture_end() const { return captures().end(); }
4987
4988 bool capturesCXXThis() const { return BlockDeclBits.CapturesCXXThis; }
4989 void setCapturesCXXThis(bool B = true) { BlockDeclBits.CapturesCXXThis = B; }
4990
4992 return BlockDeclBits.BlockMissingReturnType;
4993 }
4994
4995 void setBlockMissingReturnType(bool val = true) {
4996 BlockDeclBits.BlockMissingReturnType = val;
4997 }
4998
5000 return BlockDeclBits.IsConversionFromLambda;
5001 }
5002
5003 void setIsConversionFromLambda(bool val = true) {
5004 BlockDeclBits.IsConversionFromLambda = val;
5005 }
5006
5007 bool doesNotEscape() const { return BlockDeclBits.DoesNotEscape; }
5008 void setDoesNotEscape(bool B = true) { BlockDeclBits.DoesNotEscape = B; }
5009
5010 bool canAvoidCopyToHeap() const {
5011 return BlockDeclBits.CanAvoidCopyToHeap;
5012 }
5013 void setCanAvoidCopyToHeap(bool B = true) {
5014 BlockDeclBits.CanAvoidCopyToHeap = B;
5015 }
5016
5017 bool capturesVariable(const VarDecl *var) const;
5018
5019 void setCaptures(ASTContext &Context, ArrayRef<Capture> Captures,
5020 bool CapturesCXXThis);
5021
5022 unsigned getBlockManglingNumber() const { return ManglingNumber; }
5023
5024 Decl *getBlockManglingContextDecl() const { return ManglingContextDecl; }
5025
5026 void setBlockMangling(unsigned Number, Decl *Ctx) {
5027 ManglingNumber = Number;
5028 ManglingContextDecl = Ctx;
5029 }
5030
5031 SourceRange getSourceRange() const override LLVM_READONLY;
5032
5034 if (const TypeSourceInfo *TSI = getSignatureAsWritten())
5035 if (const auto *FPT = TSI->getType()->getAs<FunctionProtoType>())
5036 return FPT->getFunctionEffects();
5037 return {};
5038 }
5039
5040 // Implement isa/cast/dyncast/etc.
5041 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5042 static bool classofKind(Kind K) { return K == Block; }
5044 return static_cast<DeclContext *>(const_cast<BlockDecl*>(D));
5045 }
5047 return static_cast<BlockDecl *>(const_cast<DeclContext*>(DC));
5048 }
5049};
5050
5051/// Represents a partial function definition.
5052///
5053/// An outlined function declaration contains the parameters and body of
5054/// a function independent of other function definition concerns such
5055/// as function name, type, and calling convention. Such declarations may
5056/// be used to hold a parameterized and transformed sequence of statements
5057/// used to generate a target dependent function definition without losing
5058/// association with the original statements. See SYCLKernelCallStmt as an
5059/// example.
5060class OutlinedFunctionDecl final
5061 : public Decl,
5062 public DeclContext,
5063 private llvm::TrailingObjects<OutlinedFunctionDecl, ImplicitParamDecl *> {
5064private:
5065 /// The number of parameters to the outlined function.
5066 unsigned NumParams;
5067
5068 /// The body of the outlined function.
5069 llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow;
5070
5071 explicit OutlinedFunctionDecl(DeclContext *DC, unsigned NumParams);
5072
5073 ImplicitParamDecl *const *getParams() const { return getTrailingObjects(); }
5074
5075 ImplicitParamDecl **getParams() { return getTrailingObjects(); }
5076
5077public:
5078 friend class ASTDeclReader;
5079 friend class ASTDeclWriter;
5081
5082 static OutlinedFunctionDecl *Create(ASTContext &C, DeclContext *DC,
5083 unsigned NumParams);
5084 static OutlinedFunctionDecl *
5085 CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams);
5086
5087 Stmt *getBody() const override;
5088 void setBody(Stmt *B);
5089
5090 bool isNothrow() const;
5091 void setNothrow(bool Nothrow = true);
5092
5093 unsigned getNumParams() const { return NumParams; }
5094
5095 ImplicitParamDecl *getParam(unsigned i) const {
5096 assert(i < NumParams);
5097 return getParams()[i];
5098 }
5099 void setParam(unsigned i, ImplicitParamDecl *P) {
5100 assert(i < NumParams);
5101 getParams()[i] = P;
5102 }
5103
5104 // Range interface to parameters.
5106 using parameter_const_range = llvm::iterator_range<parameter_const_iterator>;
5108 return {param_begin(), param_end()};
5109 }
5110 parameter_const_iterator param_begin() const { return getParams(); }
5111 parameter_const_iterator param_end() const { return getParams() + NumParams; }
5112
5113 // Implement isa/cast/dyncast/etc.
5114 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5115 static bool classofKind(Kind K) { return K == OutlinedFunction; }
5116 static DeclContext *castToDeclContext(const OutlinedFunctionDecl *D) {
5117 return static_cast<DeclContext *>(const_cast<OutlinedFunctionDecl *>(D));
5118 }
5119 static OutlinedFunctionDecl *castFromDeclContext(const DeclContext *DC) {
5120 return static_cast<OutlinedFunctionDecl *>(const_cast<DeclContext *>(DC));
5121 }
5122};
5123
5124/// Represents the body of a CapturedStmt, and serves as its DeclContext.
5125class CapturedDecl final
5126 : public Decl,
5127 public DeclContext,
5128 private llvm::TrailingObjects<CapturedDecl, ImplicitParamDecl *> {
5129protected:
5130 size_t numTrailingObjects(OverloadToken<ImplicitParamDecl>) {
5131 return NumParams;
5132 }
5133
5134private:
5135 /// The number of parameters to the outlined function.
5136 unsigned NumParams;
5137
5138 /// The position of context parameter in list of parameters.
5139 unsigned ContextParam;
5140
5141 /// The body of the outlined function.
5142 llvm::PointerIntPair<Stmt *, 1, bool> BodyAndNothrow;
5143
5144 explicit CapturedDecl(DeclContext *DC, unsigned NumParams);
5145
5146 ImplicitParamDecl *const *getParams() const { return getTrailingObjects(); }
5147
5148 ImplicitParamDecl **getParams() { return getTrailingObjects(); }
5149
5150public:
5151 friend class ASTDeclReader;
5152 friend class ASTDeclWriter;
5154
5155 static CapturedDecl *Create(ASTContext &C, DeclContext *DC,
5156 unsigned NumParams);
5157 static CapturedDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
5158 unsigned NumParams);
5159
5160 Stmt *getBody() const override;
5161 void setBody(Stmt *B);
5162
5163 bool isNothrow() const;
5164 void setNothrow(bool Nothrow = true);
5165
5166 unsigned getNumParams() const { return NumParams; }
5167
5168 ImplicitParamDecl *getParam(unsigned i) const {
5169 assert(i < NumParams);
5170 return getParams()[i];
5171 }
5172 void setParam(unsigned i, ImplicitParamDecl *P) {
5173 assert(i < NumParams);
5174 getParams()[i] = P;
5175 }
5176
5177 // ArrayRef interface to parameters.
5179 return {getParams(), getNumParams()};
5180 }
5182 return {getParams(), getNumParams()};
5183 }
5184
5185 /// Retrieve the parameter containing captured variables.
5187 assert(ContextParam < NumParams);
5188 return getParam(ContextParam);
5189 }
5190 void setContextParam(unsigned i, ImplicitParamDecl *P) {
5191 assert(i < NumParams);
5192 ContextParam = i;
5193 setParam(i, P);
5194 }
5195 unsigned getContextParamPosition() const { return ContextParam; }
5196
5198 using param_range = llvm::iterator_range<param_iterator>;
5199
5200 /// Retrieve an iterator pointing to the first parameter decl.
5201 param_iterator param_begin() const { return getParams(); }
5202 /// Retrieve an iterator one past the last parameter decl.
5203 param_iterator param_end() const { return getParams() + NumParams; }
5204
5205 // Implement isa/cast/dyncast/etc.
5206 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5207 static bool classofKind(Kind K) { return K == Captured; }
5208 static DeclContext *castToDeclContext(const CapturedDecl *D) {
5209 return static_cast<DeclContext *>(const_cast<CapturedDecl *>(D));
5210 }
5211 static CapturedDecl *castFromDeclContext(const DeclContext *DC) {
5212 return static_cast<CapturedDecl *>(const_cast<DeclContext *>(DC));
5213 }
5214};
5215
5216/// Describes a module import declaration, which makes the contents
5217/// of the named module visible in the current translation unit.
5218///
5219/// An import declaration imports the named module (or submodule). For example:
5220/// \code
5221/// @import std.vector;
5222/// \endcode
5223///
5224/// A C++20 module import declaration imports the named module or partition.
5225/// Periods are permitted in C++20 module names, but have no semantic meaning.
5226/// For example:
5227/// \code
5228/// import NamedModule;
5229/// import :SomePartition; // Must be a partition of the current module.
5230/// import Names.Like.this; // Allowed.
5231/// import :and.Also.Partition.names;
5232/// \endcode
5233///
5234/// Import declarations can also be implicitly generated from
5235/// \#include/\#import directives.
5236class ImportDecl final : public Decl,
5237 llvm::TrailingObjects<ImportDecl, SourceLocation> {
5238 friend class ASTContext;
5239 friend class ASTDeclReader;
5240 friend class ASTReader;
5241 friend TrailingObjects;
5242
5243 /// The imported module.
5244 Module *ImportedModule = nullptr;
5245
5246 /// The next import in the list of imports local to the translation
5247 /// unit being parsed (not loaded from an AST file).
5248 ///
5249 /// Includes a bit that indicates whether we have source-location information
5250 /// for each identifier in the module name.
5251 ///
5252 /// When the bit is false, we only have a single source location for the
5253 /// end of the import declaration.
5254 llvm::PointerIntPair<ImportDecl *, 1, bool> NextLocalImportAndComplete;
5255
5256 ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported,
5257 ArrayRef<SourceLocation> IdentifierLocs);
5258
5259 ImportDecl(DeclContext *DC, SourceLocation StartLoc, Module *Imported,
5260 SourceLocation EndLoc);
5261
5262 ImportDecl(EmptyShell Empty) : Decl(Import, Empty) {}
5263
5264 bool isImportComplete() const { return NextLocalImportAndComplete.getInt(); }
5265
5266 void setImportComplete(bool C) { NextLocalImportAndComplete.setInt(C); }
5267
5268 /// The next import in the list of imports local to the translation
5269 /// unit being parsed (not loaded from an AST file).
5270 ImportDecl *getNextLocalImport() const {
5271 return NextLocalImportAndComplete.getPointer();
5272 }
5273
5274 void setNextLocalImport(ImportDecl *Import) {
5275 NextLocalImportAndComplete.setPointer(Import);
5276 }
5277
5278public:
5279 /// Create a new module import declaration.
5280 static ImportDecl *Create(ASTContext &C, DeclContext *DC,
5281 SourceLocation StartLoc, Module *Imported,
5282 ArrayRef<SourceLocation> IdentifierLocs);
5283
5284 /// Create a new module import declaration for an implicitly-generated
5285 /// import.
5286 static ImportDecl *CreateImplicit(ASTContext &C, DeclContext *DC,
5287 SourceLocation StartLoc, Module *Imported,
5288 SourceLocation EndLoc);
5289
5290 /// Create a new, deserialized module import declaration.
5291 static ImportDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID,
5292 unsigned NumLocations);
5293
5294 /// Retrieve the module that was imported by the import declaration.
5295 Module *getImportedModule() const { return ImportedModule; }
5296
5297 /// Retrieves the locations of each of the identifiers that make up
5298 /// the complete module name in the import declaration.
5299 ///
5300 /// This will return an empty array if the locations of the individual
5301 /// identifiers aren't available.
5303
5304 SourceRange getSourceRange() const override LLVM_READONLY;
5305
5306 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5307 static bool classofKind(Kind K) { return K == Import; }
5308};
5309
5310/// Represents a standard C++ module export declaration.
5311///
5312/// For example:
5313/// \code
5314/// export void foo();
5315/// \endcode
5316class ExportDecl final : public Decl, public DeclContext {
5317 LLVM_DECLARE_VIRTUAL_ANCHOR_FUNCTION();
5318
5319private:
5320 friend class ASTDeclReader;
5321
5322 /// The source location for the right brace (if valid).
5323 SourceLocation RBraceLoc;
5324
5325 ExportDecl(DeclContext *DC, SourceLocation ExportLoc)
5326 : Decl(Export, DC, ExportLoc), DeclContext(Export),
5327 RBraceLoc(SourceLocation()) {}
5328
5329public:
5331 SourceLocation ExportLoc);
5333
5335 SourceLocation getRBraceLoc() const { return RBraceLoc; }
5336 void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
5337
5338 bool hasBraces() const { return RBraceLoc.isValid(); }
5339
5340 SourceLocation getEndLoc() const LLVM_READONLY {
5341 if (hasBraces())
5342 return RBraceLoc;
5343 // No braces: get the end location of the (only) declaration in context
5344 // (if present).
5345 return decls_empty() ? getLocation() : decls_begin()->getEndLoc();
5346 }
5347
5348 SourceRange getSourceRange() const override LLVM_READONLY {
5349 return SourceRange(getLocation(), getEndLoc());
5350 }
5351
5352 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5353 static bool classofKind(Kind K) { return K == Export; }
5354 static DeclContext *castToDeclContext(const ExportDecl *D) {
5355 return static_cast<DeclContext *>(const_cast<ExportDecl*>(D));
5356 }
5357 static ExportDecl *castFromDeclContext(const DeclContext *DC) {
5358 return static_cast<ExportDecl *>(const_cast<DeclContext*>(DC));
5359 }
5360};
5361
5362/// Represents an empty-declaration.
5363class EmptyDecl : public Decl {
5364 EmptyDecl(DeclContext *DC, SourceLocation L) : Decl(Empty, DC, L) {}
5365
5366 virtual void anchor();
5367
5368public:
5369 static EmptyDecl *Create(ASTContext &C, DeclContext *DC,
5370 SourceLocation L);
5371 static EmptyDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
5372
5373 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5374 static bool classofKind(Kind K) { return K == Empty; }
5375};
5376
5377/// HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
5378class HLSLBufferDecl final : public NamedDecl, public DeclContext {
5379 /// LBraceLoc - The ending location of the source range.
5380 SourceLocation LBraceLoc;
5381 /// RBraceLoc - The ending location of the source range.
5382 SourceLocation RBraceLoc;
5383 /// KwLoc - The location of the cbuffer or tbuffer keyword.
5384 SourceLocation KwLoc;
5385 /// IsCBuffer - Whether the buffer is a cbuffer (and not a tbuffer).
5386 bool IsCBuffer;
5387 /// HasValidPackoffset - Whether the buffer has valid packoffset annotations
5388 // on all declarations
5389 bool HasValidPackoffset;
5390 // LayoutStruct - Layout struct for the buffer
5391 CXXRecordDecl *LayoutStruct;
5392
5393 // For default (implicit) constant buffer, an array of references of global
5394 // decls that belong to the buffer. The decls are already parented by the
5395 // translation unit context. The array is allocated by the ASTContext
5396 // allocator in HLSLBufferDecl::CreateDefaultCBuffer.
5397 ArrayRef<Decl *> DefaultBufferDecls;
5398
5399 HLSLBufferDecl(DeclContext *DC, bool CBuffer, SourceLocation KwLoc,
5400 IdentifierInfo *ID, SourceLocation IDLoc,
5401 SourceLocation LBrace);
5402
5403 void setDefaultBufferDecls(ArrayRef<Decl *> Decls);
5404
5405public:
5406 static HLSLBufferDecl *Create(ASTContext &C, DeclContext *LexicalParent,
5407 bool CBuffer, SourceLocation KwLoc,
5408 IdentifierInfo *ID, SourceLocation IDLoc,
5409 SourceLocation LBrace);
5410 static HLSLBufferDecl *
5412 ArrayRef<Decl *> DefaultCBufferDecls);
5413 static HLSLBufferDecl *CreateDeserialized(ASTContext &C, GlobalDeclID ID);
5414
5415 SourceRange getSourceRange() const override LLVM_READONLY {
5416 return SourceRange(getLocStart(), RBraceLoc);
5417 }
5418 SourceLocation getLocStart() const LLVM_READONLY { return KwLoc; }
5419 SourceLocation getLBraceLoc() const { return LBraceLoc; }
5420 SourceLocation getRBraceLoc() const { return RBraceLoc; }
5421 void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
5422 bool isCBuffer() const { return IsCBuffer; }
5423 void setHasValidPackoffset(bool PO) { HasValidPackoffset = PO; }
5424 bool hasValidPackoffset() const { return HasValidPackoffset; }
5425 const CXXRecordDecl *getLayoutStruct() const { return LayoutStruct; }
5427
5428 // Implement isa/cast/dyncast/etc.
5429 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5430 static bool classofKind(Kind K) { return K == HLSLBuffer; }
5431 static DeclContext *castToDeclContext(const HLSLBufferDecl *D) {
5432 return static_cast<DeclContext *>(const_cast<HLSLBufferDecl *>(D));
5433 }
5434 static HLSLBufferDecl *castFromDeclContext(const DeclContext *DC) {
5435 return static_cast<HLSLBufferDecl *>(const_cast<DeclContext *>(DC));
5436 }
5437
5438 // Iterator for the buffer decls. For constant buffers explicitly declared
5439 // with `cbuffer` keyword this will the list of decls parented by this
5440 // HLSLBufferDecl (equal to `decls()`).
5441 // For implicit $Globals buffer this will be the list of default buffer
5442 // declarations stored in DefaultBufferDecls plus the implicit layout
5443 // struct (the only child of HLSLBufferDecl in this case).
5444 //
5445 // The iterator uses llvm::concat_iterator to concatenate the lists
5446 // `decls()` and `DefaultBufferDecls`. For non-default buffers
5447 // `DefaultBufferDecls` is always empty.
5449 llvm::concat_iterator<Decl *const, SmallVector<Decl *>::const_iterator,
5451 using buffer_decl_range = llvm::iterator_range<buffer_decl_iterator>;
5452
5458 bool buffer_decls_empty();
5459
5460 friend class ASTDeclReader;
5461 friend class ASTDeclWriter;
5462};
5463
5464class HLSLRootSignatureDecl final
5465 : public NamedDecl,
5466 private llvm::TrailingObjects<HLSLRootSignatureDecl,
5467 llvm::hlsl::rootsig::RootElement> {
5468 friend TrailingObjects;
5469
5470 llvm::dxbc::RootSignatureVersion Version;
5471
5472 unsigned NumElems;
5473
5474 llvm::hlsl::rootsig::RootElement *getElems() { return getTrailingObjects(); }
5475
5476 const llvm::hlsl::rootsig::RootElement *getElems() const {
5477 return getTrailingObjects();
5478 }
5479
5480 HLSLRootSignatureDecl(DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5481 llvm::dxbc::RootSignatureVersion Version,
5482 unsigned NumElems);
5483
5484public:
5485 static HLSLRootSignatureDecl *
5487 llvm::dxbc::RootSignatureVersion Version,
5489
5490 static HLSLRootSignatureDecl *CreateDeserialized(ASTContext &C,
5491 GlobalDeclID ID);
5492
5493 llvm::dxbc::RootSignatureVersion getVersion() const { return Version; }
5494
5496 return {getElems(), NumElems};
5497 }
5498
5499 // Implement isa/cast/dyncast/etc.
5500 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
5501 static bool classofKind(Kind K) { return K == HLSLRootSignature; }
5502};
5503
5504/// Insertion operator for diagnostics. This allows sending NamedDecl's
5505/// into a diagnostic with <<.
5507 const NamedDecl *ND) {
5508 PD.AddTaggedVal(reinterpret_cast<uint64_t>(ND),
5510 return PD;
5511}
5512
5513template<typename decl_type>
5515 // Note: This routine is implemented here because we need both NamedDecl
5516 // and Redeclarable to be defined.
5517 assert(RedeclLink.isFirst() &&
5518 "setPreviousDecl on a decl already in a redeclaration chain");
5519
5520 if (PrevDecl) {
5521 // Linking this declaration to a previous one may change its linkage.
5522 static_cast<decl_type *>(this)->invalidateCachedLinkage();
5523
5524 // Point to previous. Make sure that this is actually the most recent
5525 // redeclaration, or we can build invalid chains. If the most recent
5526 // redeclaration is invalid, it won't be PrevDecl, but we want it anyway.
5527 First = PrevDecl->getFirstDecl();
5528 assert(First->RedeclLink.isFirst() && "Expected first");
5529 decl_type *MostRecent = First->getNextRedeclaration();
5531
5532 // If the declaration was previously visible, a redeclaration of it remains
5533 // visible even if it wouldn't be visible by itself.
5534 static_cast<decl_type*>(this)->IdentifierNamespace |=
5535 MostRecent->getIdentifierNamespace() &
5537 } else {
5538 // Make this first.
5539 First = static_cast<decl_type*>(this);
5540 }
5541
5542 // First one will point to this one as latest.
5543 First->RedeclLink.setLatest(static_cast<decl_type*>(this));
5544
5545 assert(!isa<NamedDecl>(static_cast<decl_type*>(this)) ||
5546 cast<NamedDecl>(static_cast<decl_type*>(this))->isLinkageValid());
5547}
5548
5549// Inline function definitions.
5550
5551/// Check if the given decl is complete.
5552///
5553/// We use this function to break a cycle between the inline definitions in
5554/// Type.h and Decl.h.
5556 if (const auto *Def = ED->getDefinition())
5557 return Def->isComplete();
5558 return ED->isComplete();
5559}
5560
5561/// Check if the given decl is scoped.
5562///
5563/// We use this function to break a cycle between the inline definitions in
5564/// Type.h and Decl.h.
5565inline bool IsEnumDeclScoped(EnumDecl *ED) {
5566 return ED->isScoped();
5567}
5568
5569/// OpenMP variants are mangled early based on their OpenMP context selector.
5570/// The new name looks likes this:
5571/// <name> + OpenMPVariantManglingSeparatorStr + <mangled OpenMP context>
5572static constexpr StringRef getOpenMPVariantManglingSeparatorStr() {
5573 return "$ompvariant";
5574}
5575
5576/// Returns whether the given FunctionDecl has an __arm[_locally]_streaming
5577/// attribute.
5578bool IsArmStreamingFunction(const FunctionDecl *FD,
5579 bool IncludeLocallyStreaming);
5580
5581/// Returns whether the given FunctionDecl has Arm ZA state.
5582bool hasArmZAState(const FunctionDecl *FD);
5583
5584/// Returns whether the given FunctionDecl has Arm ZT0 state.
5585bool hasArmZT0State(const FunctionDecl *FD);
5586
5587} // namespace clang
5588
5589#endif // LLVM_CLANG_AST_DECL_H
#define V(N, I)
Provides definitions for the various language-specific address spaces.
Defines the Diagnostic-related interfaces.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
static const Decl * getCanonicalDecl(const Decl *D)
#define X(type, name)
Definition Value.h:97
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
*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.
Defines clang::OptionalUnsigned.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
Defines the clang::Visibility enumeration and various utility functions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
void setValue(const ASTContext &C, const llvm::APInt &Val)
llvm::APInt getValue() const
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:158
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
bool isNested() const
Whether this is a nested capture, i.e.
Definition Decl.h:4899
void setCopyExpr(Expr *e)
Definition Decl.h:4903
Expr * getCopyExpr() const
Definition Decl.h:4902
bool isByRef() const
Whether this is a "by ref" capture, i.e.
Definition Decl.h:4887
Capture(VarDecl *variable, bool byRef, bool nested, Expr *copy)
Definition Decl.h:4877
bool isNonEscapingByref() const
Definition Decl.h:4893
VarDecl * getVariable() const
The variable being captured.
Definition Decl.h:4883
bool isEscapingByref() const
Definition Decl.h:4889
bool hasCopyExpr() const
Definition Decl.h:4901
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition Decl.h:4856
ParmVarDecl * getParamDecl(unsigned i)
Definition Decl.h:4966
BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
Definition Decl.cpp:5544
static bool classofKind(Kind K)
Definition Decl.h:5042
CompoundStmt * getCompoundBody() const
Definition Decl.h:4934
static bool classof(const Decl *D)
Definition Decl.h:5041
unsigned getNumParams() const
Definition Decl.h:4960
unsigned getNumCaptures() const
Returns the number of captured variables.
Definition Decl.h:4979
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Definition Decl.cpp:5554
capture_const_iterator capture_begin() const
Definition Decl.h:4985
bool canAvoidCopyToHeap() const
Definition Decl.h:5010
void setDoesNotEscape(bool B=true)
Definition Decl.h:5008
param_iterator param_end()
Definition Decl.h:4955
capture_const_iterator capture_end() const
Definition Decl.h:4986
ArrayRef< Capture >::const_iterator capture_const_iterator
Definition Decl.h:4981
unsigned getBlockManglingNumber() const
Definition Decl.h:5022
param_const_iterator param_end() const
Definition Decl.h:4957
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition Decl.h:4950
size_t param_size() const
Definition Decl.h:4958
void setCapturesCXXThis(bool B=true)
Definition Decl.h:4989
void setSignatureAsWritten(TypeSourceInfo *Sig)
Definition Decl.h:4938
void setBlockMangling(unsigned Number, Decl *Ctx)
Definition Decl.h:5026
MutableArrayRef< ParmVarDecl * > parameters()
Definition Decl.h:4945
void setCanAvoidCopyToHeap(bool B=true)
Definition Decl.h:5013
param_iterator param_begin()
Definition Decl.h:4954
void setIsConversionFromLambda(bool val=true)
Definition Decl.h:5003
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.h:4935
static DeclContext * castToDeclContext(const BlockDecl *D)
Definition Decl.h:5043
void setBlockMissingReturnType(bool val=true)
Definition Decl.h:4995
FunctionEffectsRef getFunctionEffects() const
Definition Decl.h:5033
ArrayRef< Capture > captures() const
Definition Decl.h:4983
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5587
static BlockDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5762
void setIsVariadic(bool value)
Definition Decl.h:4932
bool param_empty() const
Definition Decl.h:4953
bool blockMissingReturnType() const
Definition Decl.h:4991
SourceLocation getCaretLocation() const
Definition Decl.h:4929
bool capturesCXXThis() const
Definition Decl.h:4988
bool capturesVariable(const VarDecl *var) const
Definition Decl.cpp:5578
bool doesNotEscape() const
Definition Decl.h:5007
bool hasCaptures() const
True if this block (or its nested blocks) captures anything of local storage from its enclosing scope...
Definition Decl.h:4975
Decl * getBlockManglingContextDecl() const
Definition Decl.h:5024
ArrayRef< ParmVarDecl * >::const_iterator param_const_iterator
Definition Decl.h:4951
static BlockDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:5046
const ParmVarDecl * getParamDecl(unsigned i) const
Definition Decl.h:4962
void setBody(CompoundStmt *B)
Definition Decl.h:4936
param_const_iterator param_begin() const
Definition Decl.h:4956
bool isConversionFromLambda() const
Definition Decl.h:4999
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:4942
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
Definition Decl.cpp:5565
bool isVariadic() const
Definition Decl.h:4931
TypeSourceInfo * getSignatureAsWritten() const
Definition Decl.h:4939
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition Decl.h:5128
unsigned getNumParams() const
Definition Decl.h:5166
void setBody(Stmt *B)
Definition Decl.cpp:5812
static bool classof(const Decl *D)
Definition Decl.h:5206
ImplicitParamDecl *const * param_iterator
Definition Decl.h:5197
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
Definition Decl.h:5186
ArrayRef< ImplicitParamDecl * > parameters() const
Definition Decl.h:5178
static DeclContext * castToDeclContext(const CapturedDecl *D)
Definition Decl.h:5208
size_t numTrailingObjects(OverloadToken< ImplicitParamDecl >)
Definition Decl.h:5130
static CapturedDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)
Definition Decl.cpp:5805
unsigned getContextParamPosition() const
Definition Decl.h:5195
bool isNothrow() const
Definition Decl.cpp:5814
static CapturedDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:5211
static bool classofKind(Kind K)
Definition Decl.h:5207
friend class ASTDeclReader
Definition Decl.h:5151
void setContextParam(unsigned i, ImplicitParamDecl *P)
Definition Decl.h:5190
void setNothrow(bool Nothrow=true)
Definition Decl.cpp:5815
void setParam(unsigned i, ImplicitParamDecl *P)
Definition Decl.h:5172
friend TrailingObjects
Definition Decl.h:5153
friend class ASTDeclWriter
Definition Decl.h:5152
param_iterator param_end() const
Retrieve an iterator one past the last parameter decl.
Definition Decl.h:5203
MutableArrayRef< ImplicitParamDecl * > parameters()
Definition Decl.h:5181
param_iterator param_begin() const
Retrieve an iterator pointing to the first parameter decl.
Definition Decl.h:5201
llvm::iterator_range< param_iterator > param_range
Definition Decl.h:5198
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.cpp:5811
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5168
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1751
decl_iterator - Iterates through the declarations stored within this context.
Definition DeclBase.h:2362
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition DeclBase.h:2425
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1467
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition DeclBase.h:2108
FunctionDeclBitfields FunctionDeclBits
Definition DeclBase.h:2043
TagDeclBitfields TagDeclBits
Definition DeclBase.h:2039
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
EnumDeclBitfields EnumDeclBits
Definition DeclBase.h:2040
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
BlockDeclBitfields BlockDeclBits
Definition DeclBase.h:2048
bool isRecord() const
Definition DeclBase.h:2208
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
RecordDeclBitfields RecordDeclBits
Definition DeclBase.h:2041
DeclContext(Decl::Kind K)
decl_iterator decls_end() const
Definition DeclBase.h:2407
NamespaceDeclBitfields NamespaceDeclBits
Definition DeclBase.h:2038
bool decls_empty() const
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
Definition DeclBase.h:2163
Decl::Kind getDeclKind() const
Definition DeclBase.h:2101
DeclContext * getNonTransparentContext()
decl_iterator decls_begin() const
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
Decl()=delete
SourceLocation getEndLoc() const LLVM_READONLY
Definition DeclBase.h:444
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition DeclBase.h:657
ASTContext & getASTContext() const LLVM_READONLY
Definition DeclBase.cpp:550
friend class Redeclarable
Definition DeclBase.h:334
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition DeclBase.h:1013
bool hasCachedLinkage() const
Definition DeclBase.h:430
Kind
Lists the kind of concrete classes of Decl.
Definition DeclBase.h:89
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition DeclBase.h:198
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
Definition DeclBase.h:1009
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
Definition DeclBase.cpp:637
SourceLocation getLocation() const
Definition DeclBase.h:448
@ IDNS_Ordinary
Ordinary names.
Definition DeclBase.h:144
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
Definition DeclBase.h:130
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Definition DeclBase.h:125
void setImplicit(bool I=true)
Definition DeclBase.h:603
DeclContext * getDeclContext()
Definition DeclBase.h:457
bool isInAnonymousNamespace() const
Definition DeclBase.cpp:443
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition DeclBase.h:1017
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
Definition DeclBase.h:719
friend class RecordDecl
Definition DeclBase.h:333
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition DeclBase.cpp:385
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
Definition Decl.cpp:1639
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition DeclBase.h:936
friend class DeclContext
Definition DeclBase.h:260
Kind getKind() const
Definition DeclBase.h:451
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
SourceLocation getTypeSpecEndLoc() const
Definition Decl.cpp:2011
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition Decl.h:824
static bool classofKind(Kind K)
Definition Decl.h:879
void setInnerLocStart(SourceLocation L)
Definition Decl.h:825
SourceLocation getOuterLocStart() const
Return start of source range taking into account any outer template declarations.
Definition Decl.cpp:2067
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:2071
friend class ASTDeclReader
Definition Decl.h:808
SourceLocation getTypeSpecStartLoc() const
Definition Decl.cpp:2005
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:833
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition Decl.h:857
void setTypeSourceInfo(TypeSourceInfo *TI)
Definition Decl.h:816
DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL)
Definition Decl.h:802
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Definition Decl.cpp:2017
void setTrailingRequiresClause(const AssociatedConstraint &AC)
Definition Decl.cpp:2036
friend class ASTDeclWriter
Definition Decl.h:809
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
Definition Decl.h:864
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition Decl.h:847
static bool classof(const Decl *D)
Definition Decl.h:878
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Definition Decl.h:839
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:811
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Definition Decl.cpp:2051
Provides information about a dependent function-template specialization declaration.
@ ak_nameddecl
NamedDecl *.
Definition Diagnostic.h:287
static EmptyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:6009
static bool classof(const Decl *D)
Definition Decl.h:5373
static bool classofKind(Kind K)
Definition Decl.h:5374
An instance of this object exists for each enum constant that is defined.
Definition Decl.h:3604
friend class StmtIteratorBase
Definition Decl.h:3614
EnumConstantDecl(const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
Definition Decl.cpp:5817
static EnumConstantDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5831
static bool classofKind(Kind K)
Definition Decl.h:3642
const EnumConstantDecl * getCanonicalDecl() const
Definition Decl.h:3638
void setInitExpr(Expr *E)
Definition Decl.h:3628
void setInitVal(const ASTContext &C, const llvm::APSInt &V)
Definition Decl.h:3629
llvm::APSInt getInitVal() const
Definition Decl.h:3624
EnumConstantDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this enumerator.
Definition Decl.h:3637
static bool classof(const Decl *D)
Definition Decl.h:3641
const Expr * getInitExpr() const
Definition Decl.h:3622
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5865
Represents an enum.
Definition Decl.h:4192
const EnumDecl * getMostRecentDecl() const
Definition Decl.h:4300
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
Definition Decl.h:4464
enumerator_range enumerators() const
Definition Decl.h:4338
void setFixed(bool Fixed=true)
True if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying type.
Definition Decl.h:4268
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4410
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition Decl.h:4402
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition Decl.h:4413
void setIntegerType(QualType T)
Set the underlying integer type.
Definition Decl.h:4374
llvm::iterator_range< specific_decl_iterator< EnumConstantDecl > > enumerator_range
Definition Decl.h:4335
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
Definition Decl.h:4377
enumerator_iterator enumerator_begin() const
Definition Decl.h:4342
bool isComplete() const
Returns true if this can be considered a complete type.
Definition Decl.h:4424
void setInstantiationOfMemberEnum(EnumDecl *ED, TemplateSpecializationKind TSK)
Specify that this enumeration is an instantiation of the member enumeration ED.
Definition Decl.h:4470
const EnumDecl * getCanonicalDecl() const
Definition Decl.h:4285
unsigned getODRHash()
Definition Decl.cpp:5275
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For an enumeration member that was instantiated from a member enumeration of a templated class,...
Definition Decl.cpp:5236
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition Decl.h:4381
friend class ASTDeclReader
Definition Decl.h:4280
static EnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5191
bool isClosedFlag() const
Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...
Definition Decl.cpp:5221
EnumDecl * getMostRecentDecl()
Definition Decl.h:4297
EnumDecl * getDefinitionOrSelf() const
Definition Decl.h:4308
void setScoped(bool Scoped=true)
True if this tag declaration is a scoped enumeration.
Definition Decl.h:4256
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition Decl.h:4419
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
Definition Decl.cpp:5196
void setPromotionType(QualType T)
Set the promotion type.
Definition Decl.h:4360
void setEnumKeyRange(SourceRange Range)
Definition Decl.h:4272
EnumDecl * getPreviousDecl()
Definition Decl.h:4289
SourceRange getSourceRange() const override LLVM_READONLY
Overrides to provide correct range when there's an enum-base specifier with forward declarations.
Definition Decl.cpp:5286
static bool classofKind(Kind K)
Definition Decl.h:4476
SourceRange getEnumKeyRange() const
Definition Decl.h:4270
static bool classof(const Decl *D)
Definition Decl.h:4475
EnumDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.h:4282
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
Definition Decl.h:4365
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
Definition Decl.cpp:5262
EnumDecl * getDefinition() const
Definition Decl.h:4304
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
Definition Decl.h:4391
const EnumDecl * getPreviousDecl() const
Definition Decl.h:4293
specific_decl_iterator< EnumConstantDecl > enumerator_iterator
Definition Decl.h:4334
TemplateSpecializationKind getTemplateSpecializationKind() const
If this enumeration is a member of a specialization of a templated class, determine what kind of temp...
Definition Decl.cpp:5229
void setScopedUsingClassTag(bool ScopedUCT=true)
If this tag declaration is a scoped enum, then this is true if the scoped enum was declared using the...
Definition Decl.h:4262
bool isClosed() const
Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...
Definition Decl.cpp:5215
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
Definition Decl.h:4357
EnumDecl * getTemplateInstantiationPattern() const
Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantia...
Definition Decl.cpp:5247
bool isClosedNonFlag() const
Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).
Definition Decl.cpp:5225
enumerator_iterator enumerator_end() const
Definition Decl.h:4349
void getValueRange(llvm::APInt &Max, llvm::APInt &Min) const
Calculates the [Min,Max) values the enum can store based on the NumPositiveBits and NumNegativeBits.
Definition Decl.cpp:5297
Represents a standard C++ module export declaration.
Definition Decl.h:5316
static bool classof(const Decl *D)
Definition Decl.h:5352
SourceLocation getRBraceLoc() const
Definition Decl.h:5335
SourceLocation getEndLoc() const LLVM_READONLY
Definition Decl.h:5340
SourceLocation getExportLoc() const
Definition Decl.h:5334
static bool classofKind(Kind K)
Definition Decl.h:5353
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:5348
void setRBraceLoc(SourceLocation L)
Definition Decl.h:5336
friend class ASTDeclReader
Definition Decl.h:5320
static DeclContext * castToDeclContext(const ExportDecl *D)
Definition Decl.h:5354
static ExportDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:5357
static ExportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:6210
bool hasBraces() const
Definition Decl.h:5338
This represents one expression.
Definition Expr.h:114
static DeclContext * castToDeclContext(const ExternCContextDecl *D)
Definition Decl.h:263
static bool classof(const Decl *D)
Definition Decl.h:261
static bool classofKind(Kind K)
Definition Decl.h:262
static ExternCContextDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:266
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
Definition Decl.h:3341
Expr * BitWidth
Definition Decl.h:3393
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition Decl.h:3441
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition Decl.cpp:4827
bool isBitField() const
Determines whether this field is a bitfield.
Definition Decl.h:3444
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition Decl.h:3521
FieldDecl(Kind DK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Definition Decl.h:3401
LazyDeclStmtPtr Init
Definition Decl.h:3391
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
Definition Decl.cpp:4854
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
Definition Decl.cpp:4817
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:4928
void setBitWidth(Expr *Width)
Set the bit-field width for this member.
Definition Decl.h:3476
void removeBitWidth()
Remove the bit-field width from this member.
Definition Decl.h:3490
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Definition Decl.h:3515
bool hasConstantIntegerBitWidth() const
Determines whether the bit width of this field is a constant integer.
Definition Decl.cpp:4849
friend class ASTDeclReader
Definition Decl.h:3413
static FieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:4811
void removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
Definition Decl.h:3548
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
Definition Decl.cpp:4837
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
Definition Decl.h:3426
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Definition Decl.h:3577
bool isZeroSize(const ASTContext &Ctx) const
Determine if this field is a subobject of zero size, that is, either a zero-length bit-field or a fie...
Definition Decl.cpp:4868
InitAndBitWidthStorage * InitAndBitWidth
Definition Decl.h:3395
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Definition Decl.h:3588
static bool classofKind(Kind K)
Definition Decl.h:3593
bool hasCapturedVLAType() const
Determine whether this member captures the variable length array type.
Definition Decl.h:3560
friend class ASTDeclWriter
Definition Decl.h:3414
bool isUnnamedBitField() const
Determines whether this is an unnamed bitfield.
Definition Decl.h:3447
bool isZeroLengthBitField() const
Is this a zero-length bit-field?
Definition Decl.cpp:4863
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
Definition Decl.h:3457
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
Definition Decl.cpp:4947
const FieldDecl * getCanonicalDecl() const
Definition Decl.h:3589
const FieldDecl * findCountedByField() const
Find the FieldDecl specified in a FAM's "counted_by" attribute.
Definition Decl.cpp:4957
RecordDecl * getParent()
Definition Decl.h:3581
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
Definition Decl.h:3565
bool isPotentiallyOverlapping() const
Determine if this field is of potentially-overlapping class type, that is, subobject with the [[no_un...
Definition Decl.cpp:4906
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
Definition Decl.cpp:4937
bool hasNonNullInClassInitializer() const
Determine whether getInClassInitializer() would return a non-null pointer without deserializing the i...
Definition Decl.h:3527
const VariableArrayType * CapturedVLAType
Definition Decl.h:3397
static bool classof(const Decl *D)
Definition Decl.h:3592
void setRParenLoc(SourceLocation L)
Definition Decl.h:4796
SourceLocation getAsmLoc() const
Definition Decl.h:4794
std::string getAsmString() const
Definition Decl.cpp:5969
Expr * getAsmStringExpr()
Definition Decl.h:4802
static bool classofKind(Kind K)
Definition Decl.h:4808
const Expr * getAsmStringExpr() const
Definition Decl.h:4801
SourceLocation getRParenLoc() const
Definition Decl.h:4795
static bool classof(const Decl *D)
Definition Decl.h:4807
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:4797
void setAsmString(Expr *Asm)
Definition Decl.h:4803
static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5963
CXXSpecialMemberKind asSpecialMember() const
Definition Decl.h:2188
PostfixOperatorKind asPostfixOperator() const
Definition Decl.h:2195
DefaultedFunctionKind(DefaultedComparisonKind Comp)
Definition Decl.h:2162
DefaultedFunctionKind(PostfixOperatorKind PO)
Definition Decl.h:2167
DefaultedComparisonKind asComparison() const
Definition Decl.h:2191
DefaultedFunctionKind(CXXSpecialMemberKind CSM)
Definition Decl.h:2159
unsigned getDiagnosticIndex() const
Get the index of this function kind for use in diagnostics.
Definition Decl.h:2200
Stashed information about a defaulted/deleted function body, including the active FP pragma overrides...
Definition Decl.h:2113
void setDeletedMessage(StringLiteral *Message)
Definition Decl.cpp:3187
ArrayRef< DeclAccessPair > getUnqualifiedLookups() const
Get the unqualified lookup results that should be used in this defaulted function definition.
Definition Decl.h:2133
Represents a function declaration or definition.
Definition Decl.h:2082
unsigned getMemoryFunctionKind() const
Identify a memory copying or setting function.
Definition Decl.cpp:4649
static constexpr unsigned RequiredTypeAwareDeleteParameterCount
Count of mandatory parameters for type aware operator delete.
Definition Decl.h:2815
void setInstantiationIsPending(bool IC)
State that the instantiation of this function is pending.
Definition Decl.h:2682
bool isTargetClonesMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target-clones functional...
Definition Decl.cpp:3797
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Definition Decl.h:2862
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
Definition Decl.h:2345
const ParmVarDecl * getParamDecl(unsigned i) const
Definition Decl.h:2974
ExceptionSpecificationType getExceptionSpecType() const
Gets the ExceptionSpecificationType as declared.
Definition Decl.h:3046
bool isTrivialForCall() const
Definition Decl.h:2549
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
Definition Decl.cpp:3215
ConstexprSpecKind getConstexprKind() const
Definition Decl.h:2645
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() const
Definition Decl.cpp:3199
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
Definition Decl.cpp:3925
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
Definition Decl.cpp:4280
void setPreviousDeclaration(FunctionDecl *PrevDecl)
Definition Decl.cpp:3806
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
Definition Decl.cpp:4273
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
Definition Decl.cpp:4268
void setIsPureVirtual(bool P=true)
Definition Decl.cpp:3371
const FunctionDecl * getDefinition() const
Definition Decl.h:2444
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition Decl.h:2470
unsigned getNumParamsIncludingThis() const
Return the number of parameters, including the implicit 'this' parameter if this function has one.
Definition Decl.cpp:3904
bool isImmediateFunction() const
Definition Decl.cpp:3413
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
Definition Decl.cpp:3165
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
Definition Decl.h:2874
SourceLocation getEllipsisLoc() const
Returns the location of the ellipsis of a variadic function.
Definition Decl.h:2379
static bool classofKind(Kind K)
Definition Decl.h:3327
void setHasSkippedBody(bool Skipped=true)
Definition Decl.h:2853
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
Definition Decl.cpp:4102
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
Definition Decl.cpp:3624
static FunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5746
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Definition Decl.cpp:3835
void setUsesSEHTry(bool UST)
Definition Decl.h:2688
param_iterator param_end()
Definition Decl.h:2960
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
Definition Decl.h:2931
SourceLocation getPointOfInstantiation() const
Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...
Definition Decl.cpp:4609
bool isMemberLikeConstrainedFriend() const
Determine whether a function is a friend function that cannot be redeclared outside of its class,...
Definition Decl.cpp:3739
bool hasCXXExplicitFunctionObjectParameter() const
Definition Decl.cpp:3943
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
Definition Decl.h:3098
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
Definition Decl.h:2868
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
Definition Decl.h:3086
SourceLocation getDefaultLoc() const
Definition Decl.h:2567
void setInstantiationOfMemberFunction(FunctionDecl *FD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member function FD.
Definition Decl.h:3151
bool usesSEHTry() const
Indicates the function uses __try.
Definition Decl.h:2687
void setHasWrittenPrototype(bool P=true)
State that this function has a written prototype.
Definition Decl.h:2622
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
Definition Decl.cpp:3724
QualType getReturnType() const
Definition Decl.h:3022
ArrayRef< ParmVarDecl * > parameters() const
Definition Decl.h:2947
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
Definition Decl.cpp:3779
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
Definition Decl.cpp:4339
bool isMSExternInline() const
The combination of the extern and inline keywords under MSVC forces the function to be required.
Definition Decl.cpp:3969
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
Definition Decl.h:2558
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition Decl.h:2546
bool instantiationIsPending() const
Whether the instantiation of this function is pending.
Definition Decl.h:2676
unsigned getMinRequiredExplicitArguments() const
Returns the minimum number of non-object arguments needed to call this function.
Definition Decl.cpp:3952
const FunctionDecl * getCanonicalDecl() const
Definition Decl.h:2940
bool BodyContainsImmediateEscalatingExpressions() const
Definition Decl.h:2659
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
Definition Decl.cpp:3687
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Definition Decl.cpp:4388
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
Definition Decl.h:2955
FunctionDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition Decl.h:2318
bool hasWrittenPrototype() const
Whether this function has a written prototype.
Definition Decl.h:2617
void setWillHaveBody(bool V=true)
Definition Decl.h:2859
void setDeclarationNameLoc(DeclarationNameLoc L)
Definition Decl.h:2376
bool isReplaceableGlobalAllocationFunction(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions:
Definition Decl.h:2765
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4247
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
Definition Decl.h:2612
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
Definition Decl.cpp:4398
void setUsesFPIntrin(bool I)
Set whether the function was declared in source context that requires constrained FP intrinsics.
Definition Decl.h:3090
void setDefaultLoc(SourceLocation NewLoc)
Definition Decl.h:2571
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:3820
void getAssociatedConstraints(SmallVectorImpl< AssociatedConstraint > &ACs) const
Get the associated-constraints of this function declaration.
Definition Decl.h:2925
FunctionTypeLoc getFunctionTypeLoc() const
Find the source location information for how the type of this function was written.
Definition Decl.cpp:4079
void setInstantiatedFromMemberTemplate(bool Val=true)
Definition Decl.h:2538
MutableArrayRef< ParmVarDecl * > parameters()
Definition Decl.h:2950
param_iterator param_begin()
Definition Decl.h:2959
FunctionDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition Decl.h:2322
const ParmVarDecl * getNonObjectParameter(unsigned I) const
Definition Decl.h:3000
bool isVariadic() const
Whether this function is variadic.
Definition Decl.cpp:3137
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
Definition Decl.h:2482
bool isConstexprSpecified() const
Definition Decl.h:2648
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
Definition Decl.cpp:4464
bool isDeleted() const
Whether this function has been deleted.
Definition Decl.h:2709
void setBodyContainsImmediateEscalatingExpressions(bool Set)
Definition Decl.h:2655
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Definition Decl.cpp:4404
FunctionEffectsRef getFunctionEffects() const
Definition Decl.h:3315
static DeclContext * castToDeclContext(const FunctionDecl *D)
Definition Decl.h:3330
SourceRange getExceptionSpecSourceRange() const
Attempt to compute an informative source range covering the function exception specification,...
Definition Decl.cpp:4131
bool hasBody() const override
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Definition Decl.h:2409
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
Definition Decl.cpp:3448
unsigned getODRHash()
Returns ODRHash of the function.
Definition Decl.cpp:4781
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Determine the kind of template specialization this function represents for the purpose of template in...
Definition Decl.cpp:4516
ArrayRef< ParmVarDecl * >::const_iterator param_const_iterator
Definition Decl.h:2956
FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, const AssociatedConstraint &TrailingRequiresClause)
Definition Decl.cpp:3085
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
Definition Decl.cpp:4332
void setInlineSpecified(bool I)
Set whether the "inline" keyword was specified for this function.
Definition Decl.h:3079
unsigned getNumNonObjectParams() const
Definition Decl.cpp:3947
TemplatedKind
The kind of templated function a FunctionDecl can be.
Definition Decl.h:2087
@ TK_FunctionTemplateSpecialization
Definition Decl.h:2098
@ TK_DependentFunctionTemplateSpecialization
Definition Decl.h:2101
redeclarable_base::redecl_range redecl_range
Definition Decl.h:2334
friend class ASTDeclReader
Definition Decl.h:2331
UsualDeleteParams getUsualDeleteParams() const
Definition Decl.cpp:3640
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:3065
FunctionDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition Decl.h:2326
bool isStatic() const
Definition Decl.h:3106
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:2335
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function.
Definition Decl.cpp:4622
void setTrivial(bool IT)
Definition Decl.h:2547
bool isInlineBuiltinDeclaration() const
Determine if this function provides an inline implementation of a builtin.
Definition Decl.cpp:3599
bool FriendConstraintRefersToEnclosingTemplate() const
Definition Decl.h:2880
ParmVarDecl * getParamDecl(unsigned i)
Definition Decl.h:2978
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
Definition Decl.cpp:4219
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
Definition Decl.cpp:4286
DefaultedComparisonKind getDefaultedComparisonKind() const
Definition Decl.h:2505
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition Decl.h:2639
bool isDeletedAsWritten() const
Definition Decl.h:2713
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Definition Decl.cpp:3476
ParmVarDecl * getNonObjectParameter(unsigned I)
Definition Decl.h:3004
void setHasInheritedPrototype(bool P=true)
State that this function inherited its prototype from a previous declaration.
Definition Decl.h:2634
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
Definition Decl.cpp:4453
bool isInExternCContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C" linkage spec.
Definition Decl.cpp:3695
static constexpr unsigned RequiredTypeAwareNewParameterCount
Count of mandatory parameters for type aware operator new.
Definition Decl.h:2811
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
Definition Decl.h:2522
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
Definition Decl.cpp:4297
bool isExternC() const
Determines whether this function is a function with external, C linkage.
Definition Decl.cpp:3691
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.h:2456
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
Definition Decl.h:2526
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isDefined() const
Definition Decl.h:2432
LazyDeclStmtPtr Body
The body of the function.
Definition Decl.h:2222
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
Definition Decl.h:2597
bool isImmediateEscalating() const
Definition Decl.cpp:3384
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
Definition Decl.h:2518
bool hasSkippedBody() const
True if the function was a definition but its body was skipped.
Definition Decl.h:2852
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
Definition Decl.cpp:3628
static bool classof(const Decl *D)
Definition Decl.h:3326
void setFunctionTemplateSpecialization(FunctionTemplateDecl *Template, TemplateArgumentList *TemplateArgs, llvm::FoldingSetInsertToken InsertToken, TemplateSpecializationKind TSK=TSK_ImplicitInstantiation, TemplateArgumentListInfo *TemplateArgsAsWritten=nullptr, SourceLocation PointOfInstantiation=SourceLocation())
Specify that this function declaration is actually a function template specialization.
Definition Decl.h:3251
void setLateTemplateParsed(bool ILT=true)
State that this templated function will be late parsed.
Definition Decl.h:2531
bool isUsableAsGlobalAllocationFunctionInConstantEvaluation(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions described in i...
Definition Decl.cpp:3499
DefaultedOrDeletedFunctionInfo * DefaultedOrDeletedInfo
Information about a future defaulted function definition.
Definition Decl.h:2224
FunctionDecl * getDefinition()
Get the definition for this declaration.
Definition Decl.h:2438
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
Definition Decl.cpp:3632
bool isInExternCXXContext() const
Determines whether this function's context is, or is nested within, a C++ extern "C++" linkage spec.
Definition Decl.cpp:3701
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
Definition Decl.cpp:3441
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
Definition Decl.h:3093
bool isTargetVersionMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target-version functiona...
Definition Decl.cpp:3801
void setTrivialForCall(bool IT)
Definition Decl.h:2550
bool param_empty() const
Definition Decl.h:2958
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
Definition Decl.cpp:3636
void setLazyBody(uint64_t Offset)
Definition Decl.h:2488
friend class ASTDeclWriter
Definition Decl.h:2332
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
Definition Decl.cpp:3228
void setRangeEnd(SourceLocation E)
Definition Decl.h:2374
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
Definition Decl.cpp:3775
bool isDefaulted() const
Whether this function is defaulted.
Definition Decl.h:2554
bool isIneligibleOrNotSelected() const
Definition Decl.h:2587
bool isReferenceableKernel() const
Definition Decl.cpp:5753
void setIneligibleOrNotSelected(bool II)
Definition Decl.h:2590
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:4645
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
Definition Decl.h:3110
FunctionDecl * getInstantiatedFromDecl() const
Definition Decl.cpp:4292
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
Determine what kind of template instantiation this function represents.
Definition Decl.cpp:4561
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any.
Definition Decl.cpp:4213
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
Definition Decl.cpp:4205
void setConstexprKind(ConstexprSpecKind CSK)
Definition Decl.h:2642
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
Definition Decl.cpp:4492
param_const_iterator param_begin() const
Definition Decl.h:2961
bool doesDeclarationForceExternallyVisibleDefinition() const
For a function declaration in C or C++, determine whether this declaration causes the definition to b...
Definition Decl.cpp:4019
void setDefaulted(bool D=true)
Definition Decl.h:2555
bool isConsteval() const
Definition Decl.h:2651
bool isTargetMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the target functionality.
Definition Decl.cpp:3783
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
Definition Decl.h:2579
bool isAnalyzerNoReturn() const
Determines whether this function is known to be 'noreturn' for analyzer, through an analyzer_noreturn...
Definition Decl.cpp:3735
DefaultedFunctionKind getDefaultedFunctionKind() const
Determine the kind of defaulting that would be done for a given function.
Definition Decl.cpp:3304
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
Definition Decl.h:3039
void setStorageClass(StorageClass SClass)
Sets the storage class as written in the source.
Definition Decl.h:3070
void setBody(Stmt *B)
Definition Decl.cpp:3296
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition Decl.h:2513
bool isGlobal() const
Determines whether this is a global function.
Definition Decl.cpp:3705
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
Definition Decl.cpp:3957
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
Definition Decl.cpp:3174
bool isImplicitHDExplicitInstantiation() const
True if both host and device are implicit attributes and this is (or is a member of) an explicit temp...
Definition Decl.cpp:4589
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted.
Definition Decl.h:2563
param_const_iterator param_end() const
Definition Decl.h:2962
bool hasInheritedPrototype() const
Whether this function inherited its prototype from a previous declaration.
Definition Decl.h:2628
bool isTargetMultiVersionDefault() const
True if this function is the default version of a multiversioned dispatch function as a part of the t...
Definition Decl.cpp:3788
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
Definition Decl.cpp:4240
bool isInlineDefinitionExternallyVisible() const
For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...
Definition Decl.cpp:4153
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Definition Decl.cpp:3899
size_t param_size() const
Definition Decl.h:2963
DeclarationNameInfo getNameInfo() const
Definition Decl.h:2367
Redeclarable< FunctionDecl > redeclarable_base
Definition Decl.h:2316
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
Definition Decl.cpp:3204
SourceRange getParametersSourceRange() const
Attempt to compute an informative source range covering the function parameters, including the ellips...
Definition Decl.cpp:4115
static FunctionDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:3333
void setHasImplicitReturnZero(bool IRZ)
State that falling off this function implicitly returns null/zero.
Definition Decl.h:2604
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition Decl.h:3076
MultiVersionKind getMultiVersionKind() const
Gets the kind of multiversioning attribute this declaration has.
Definition Decl.cpp:3761
void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
Appends a human-readable name for this declaration into the given stream.
Definition Decl.cpp:3129
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
Definition Decl.h:2982
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Definition Decl.h:2858
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Definition Decl.cpp:4414
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Definition Decl.h:3058
bool isInstantiatedFromMemberTemplate() const
Definition Decl.h:2535
An immutable set of FunctionEffects and possibly conditions attached to them.
Definition TypeBase.h:5403
Represents a prototype with parameter type info, e.g.
Definition TypeBase.h:5605
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
Definition TypeBase.h:5940
SourceLocation getEllipsisLoc() const
Definition TypeBase.h:6039
Declaration of a template function.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Wrapper for source info for functions.
Definition TypeLoc.h:1675
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4744
static HLSLBufferDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:5434
buffer_decl_iterator buffer_decls_begin() const
Definition Decl.cpp:6080
static DeclContext * castToDeclContext(const HLSLBufferDecl *D)
Definition Decl.h:5431
bool isCBuffer() const
Definition Decl.h:5422
const CXXRecordDecl * getLayoutStruct() const
Definition Decl.h:5425
SourceLocation getLBraceLoc() const
Definition Decl.h:5419
SourceLocation getLocStart() const LLVM_READONLY
Definition Decl.h:5418
friend class ASTDeclReader
Definition Decl.h:5460
void addLayoutStruct(CXXRecordDecl *LS)
Definition Decl.cpp:6060
bool buffer_decls_empty()
Definition Decl.cpp:6092
SourceLocation getRBraceLoc() const
Definition Decl.h:5420
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:5415
void setRBraceLoc(SourceLocation L)
Definition Decl.h:5421
friend class ASTDeclWriter
Definition Decl.h:5461
bool hasValidPackoffset() const
Definition Decl.h:5424
llvm::concat_iterator< Decl *const, SmallVector< Decl * >::const_iterator, decl_iterator > buffer_decl_iterator
Definition Decl.h:5448
static bool classofKind(Kind K)
Definition Decl.h:5430
llvm::iterator_range< buffer_decl_iterator > buffer_decl_range
Definition Decl.h:5451
void setHasValidPackoffset(bool PO)
Definition Decl.h:5423
static HLSLBufferDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:6054
buffer_decl_iterator buffer_decls_end() const
Definition Decl.cpp:6086
static HLSLBufferDecl * CreateDefaultCBuffer(ASTContext &C, DeclContext *LexicalParent, ArrayRef< Decl * > DefaultCBufferDecls)
Definition Decl.cpp:6043
buffer_decl_range buffer_decls() const
Definition Decl.h:5453
static bool classof(const Decl *D)
Definition Decl.h:5429
static HLSLRootSignatureDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:6121
ArrayRef< llvm::hlsl::rootsig::RootElement > getRootElements() const
Definition Decl.h:5495
llvm::dxbc::RootSignatureVersion getVersion() const
Definition Decl.h:5493
static bool classofKind(Kind K)
Definition Decl.h:5501
static bool classof(const Decl *D)
Definition Decl.h:5500
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
static bool classofKind(Kind K)
Definition Decl.h:1828
ImplicitParamDecl(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, const IdentifierInfo *Id, QualType Type, ImplicitParamKind ParamKind)
Definition Decl.h:1794
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Definition Decl.h:1822
static bool classof(const Decl *D)
Definition Decl.h:1827
ImplicitParamDecl(ASTContext &C, QualType Type, ImplicitParamKind ParamKind)
Definition Decl.h:1803
static ImplicitParamDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5727
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:6192
static ImportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumLocations)
Create a new, deserialized module import declaration.
Definition Decl.cpp:6179
friend class ASTReader
Definition Decl.h:5240
friend class ASTDeclReader
Definition Decl.h:5239
friend class ASTContext
Definition Decl.h:5238
static bool classof(const Decl *D)
Definition Decl.h:5306
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
Definition Decl.cpp:6185
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition Decl.h:5295
static bool classofKind(Kind K)
Definition Decl.h:5307
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
Definition Decl.cpp:6169
const IndirectFieldDecl * getCanonicalDecl() const
Definition Decl.h:3686
static bool classofKind(Kind K)
Definition Decl.h:3690
static bool classof(const Decl *D)
Definition Decl.h:3689
FieldDecl * getAnonField() const
Definition Decl.h:3675
static IndirectFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5859
friend class ASTDeclReader
Definition Decl.h:3659
unsigned getChainingSize() const
Definition Decl.h:3673
IndirectFieldDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.h:3685
chain_iterator chain_end() const
Definition Decl.h:3671
chain_iterator chain_begin() const
Definition Decl.h:3670
ArrayRef< NamedDecl * > chain() const
Definition Decl.h:3669
VarDecl * getVarDecl() const
Definition Decl.h:3680
ArrayRef< NamedDecl * >::const_iterator chain_iterator
Definition Decl.h:3667
static bool classofKind(Kind K)
Definition Decl.h:568
void setMSAsmLabel(StringRef Name)
Definition Decl.cpp:5680
bool isResolvedMSAsmLabel() const
Definition Decl.h:561
bool isGnuLocal() const
Definition Decl.h:553
static bool classof(const Decl *D)
Definition Decl.h:567
void setLocStart(SourceLocation L)
Definition Decl.h:554
LabelStmt * getStmt() const
Definition Decl.h:550
StringRef getMSAsmLabel() const
Definition Decl.h:563
void setStmt(LabelStmt *T)
Definition Decl.h:551
void setMSAsmLabelResolved()
Definition Decl.h:564
static LabelDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5675
bool isMSAsmLabel() const
Definition Decl.h:560
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:556
LabelStmt - Represents a label, which has a substatement.
Definition Stmt.h:2157
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Visibility getVisibility() const
Definition Visibility.h:89
Provides information a specialization of a member of a class template, which may be a member function...
Describes a module or submodule.
Definition Module.h:340
This represents a decl that may have a name.
Definition Decl.h:276
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition Decl.h:489
ExplicitVisibilityKind
Kinds of explicit visibility.
Definition Decl.h:454
@ VisibilityForValue
Do an LV computation for, ultimately, a non-type declaration.
Definition Decl.h:463
@ VisibilityForType
Do an LV computation for, ultimately, a type.
Definition Decl.h:458
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
Definition Decl.cpp:1184
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition Decl.h:297
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition Decl.h:288
LinkageInfo getLinkageAndVisibility() const
Determines the linkage and visibility of this entity.
Definition Decl.cpp:1229
bool isLinkageValid() const
True if the computed linkage is valid.
Definition Decl.cpp:1087
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition Decl.h:303
bool isPlaceholderVar(const LangOptions &LangOpts) const
Definition Decl.cpp:1097
Visibility getVisibility() const
Determines the visibility of this entity.
Definition Decl.h:446
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
Definition Decl.h:481
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
Definition Decl.h:431
static bool classof(const Decl *D)
Definition Decl.h:512
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition Decl.h:342
std::string getQualifiedNameAsString() const
Definition Decl.cpp:1683
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
Definition Decl.h:319
std::optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const
If visibility was explicitly specified for this declaration, return that visibility.
Definition Decl.cpp:1316
NamedDecl * getMostRecentDecl()
Definition Decl.h:503
virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const
Appends a human-readable name for this declaration into the given stream.
Definition Decl.cpp:1849
bool declarationReplaces(const NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context,...
Definition Decl.cpp:1873
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
Definition Decl.cpp:1171
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
Definition Decl.cpp:1209
void printQualifiedName(raw_ostream &OS) const
Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...
Definition Decl.cpp:1690
static bool classofKind(Kind K)
Definition Decl.h:513
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const
Pretty-print the unqualified name of this declaration.
Definition Decl.cpp:1675
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Definition Decl.cpp:1977
bool hasLinkage() const
Determine whether this declaration has linkage.
Definition Decl.cpp:1945
const NamedDecl * getMostRecentDecl() const
Definition Decl.h:506
bool isExternallyVisible() const
Definition Decl.h:435
void setDeclName(DeclarationName N)
Set the name of this declaration.
Definition Decl.h:345
ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const
Determine if the declaration obeys the reserved identifier rules of the given language.
Definition Decl.cpp:1134
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition Decl.h:399
const NamedDecl * getUnderlyingDecl() const
Definition Decl.h:499
void printNestedNameSpecifier(raw_ostream &OS) const
Print only the nested name specifier part of a fully-qualified name, including the '::' at the end.
Definition Decl.cpp:1717
bool isExternallyDeclarable() const
Determine whether this declaration can be redeclared in a different translation unit.
Definition Decl.h:441
Represents C++ namespaces and their aliases.
Definition Decl.h:575
const NamespaceDecl * getNamespace() const
Definition Decl.h:581
NamedDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N)
Definition Decl.h:288
static bool classof(const Decl *D)
Definition Decl.h:585
NamespaceDecl * getNamespace()
Definition DeclCXX.cpp:3351
static bool classofKind(Kind K)
Definition Decl.h:586
Represent a C++ namespace.
Definition Decl.h:594
NamespaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this namespace.
Definition Decl.h:686
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:627
SourceLocation getRBraceLoc() const
Definition Decl.h:694
const NamespaceDecl * getCanonicalDecl() const
Definition Decl.h:687
void setAnonymousNamespace(NamespaceDecl *D)
Definition Decl.h:681
static bool classofKind(Kind K)
Definition Decl.h:700
void setNested(bool Nested)
Set whether this is a nested namespace declaration.
Definition Decl.h:662
static DeclContext * castToDeclContext(const NamespaceDecl *D)
Definition Decl.h:701
friend class ASTDeclReader
Definition Decl.h:616
void setLocStart(SourceLocation L)
Definition Decl.h:695
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:693
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
Definition Decl.h:645
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition Decl.h:650
static bool classof(const Decl *D)
Definition Decl.h:699
static NamespaceDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:704
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:689
friend class ASTDeclWriter
Definition Decl.h:617
void setInline(bool Inline)
Set whether this is an inline namespace declaration.
Definition Decl.h:653
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
Definition Decl.h:677
bool isNested() const
Returns true if this is a nested namespace declaration.
Definition Decl.h:659
static NamespaceDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition DeclCXX.cpp:3382
void setRBraceLoc(SourceLocation L)
Definition Decl.h:696
redeclarable_base::redecl_range redecl_range
Definition Decl.h:626
bool isRedundantInlineQualifierFor(DeclarationName Name) const
Returns true if the inline qualifier for Name is redundant.
Definition Decl.h:665
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ImplicitParamDecl * getParam(unsigned i) const
Definition Decl.h:5095
const ImplicitParamDecl *const * parameter_const_iterator
Definition Decl.h:5105
parameter_const_range parameters() const
Definition Decl.h:5107
static bool classof(const Decl *D)
Definition Decl.h:5114
static OutlinedFunctionDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:5119
static DeclContext * castToDeclContext(const OutlinedFunctionDecl *D)
Definition Decl.h:5116
friend class ASTDeclReader
Definition Decl.h:5078
void setNothrow(bool Nothrow=true)
Definition Decl.cpp:5791
parameter_const_iterator param_end() const
Definition Decl.h:5111
static bool classofKind(Kind K)
Definition Decl.h:5115
llvm::iterator_range< parameter_const_iterator > parameter_const_range
Definition Decl.h:5106
static OutlinedFunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)
Definition Decl.cpp:5779
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition Decl.cpp:5785
void setParam(unsigned i, ImplicitParamDecl *P)
Definition Decl.h:5099
friend class ASTDeclWriter
Definition Decl.h:5079
parameter_const_iterator param_begin() const
Definition Decl.h:5110
unsigned getNumParams() const
Definition Decl.h:5093
Represents a parameter to a function.
Definition Decl.h:1832
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
Definition Decl.h:1913
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition Decl.h:1892
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
Definition Decl.h:1900
static bool classofKind(Kind K)
Definition Decl.h:1995
void setDefaultArg(Expr *defarg)
Definition Decl.cpp:3028
static ParmVarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:2980
SourceLocation getExplicitObjectParamThisLoc() const
Definition Decl.h:1928
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
Definition Decl.h:1973
ParmVarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.h:1838
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
Definition Decl.h:1961
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
Definition Decl.cpp:3033
void setUninstantiatedDefaultArg(Expr *arg)
Definition Decl.cpp:3053
bool isObjCMethodParameter() const
Definition Decl.h:1875
ObjCDeclQualifier getObjCDeclQualifier() const
Definition Decl.h:1896
static constexpr unsigned getMaxFunctionScopeDepth()
Definition Decl.h:1887
const Expr * getDefaultArg() const
Definition Decl.h:1933
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1865
bool hasUninstantiatedDefaultArg() const
Definition Decl.h:1965
void setObjCMethodScopeInfo(unsigned parameterIndex)
Definition Decl.h:1860
bool isDestroyedInCallee() const
Determines whether this parameter is destroyed in the callee function.
Definition Decl.cpp:3001
bool hasInheritedDefaultArg() const
Definition Decl.h:1977
bool isExplicitObjectParameter() const
Definition Decl.h:1920
void setKNRPromoted(bool promoted)
Definition Decl.h:1916
friend class ASTDeclReader
Definition Decl.h:1998
QualType getOriginalType() const
Definition Decl.cpp:2972
const Expr * getUninstantiatedDefaultArg() const
Definition Decl.h:1944
void setExplicitObjectParameterLoc(SourceLocation Loc)
Definition Decl.h:1924
Expr * getDefaultArg()
Definition Decl.cpp:3016
Expr * getUninstantiatedDefaultArg()
Definition Decl.cpp:3058
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Definition Decl.cpp:3064
unsigned getFunctionScopeDepth() const
Definition Decl.h:1882
void setHasInheritedDefaultArg(bool I=true)
Definition Decl.h:1981
void setOwningFunction(DeclContext *FD)
Sets the function declaration that owns this ParmVarDecl.
Definition Decl.h:1991
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:2986
static bool classof(const Decl *D)
Definition Decl.h:1994
Represents a #pragma comment line.
Definition Decl.h:169
StringRef getArg() const
Definition Decl.h:192
static PragmaCommentDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned ArgSize)
Definition Decl.cpp:5623
friend class ASTDeclReader
Definition Decl.h:170
friend class ASTDeclWriter
Definition Decl.h:171
static bool classof(const Decl *D)
Definition Decl.h:195
PragmaMSCommentKind getCommentKind() const
Definition Decl.h:190
static bool classofKind(Kind K)
Definition Decl.h:196
Represents a #pragma detect_mismatch line.
Definition Decl.h:203
StringRef getName() const
Definition Decl.h:224
static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NameValueSize)
Definition Decl.cpp:5648
StringRef getValue() const
Definition Decl.h:225
static bool classofKind(Kind K)
Definition Decl.h:229
static bool classof(const Decl *D)
Definition Decl.h:228
A (possibly-)qualified type.
Definition TypeBase.h:938
Represents a struct/union/class.
Definition Decl.h:4506
bool hasLoadedFieldsFromExternalStorage() const
Definition Decl.h:4575
unsigned getODRHash()
Get precomputed ODRHash or add a new one.
Definition Decl.cpp:5526
bool hasNonTrivialToPrimitiveDestructCUnion() const
Definition Decl.h:4616
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
Definition Decl.cpp:5354
bool hasNonTrivialToPrimitiveCopyCUnion() const
Definition Decl.h:4624
bool isMsStruct(const ASTContext &C) const
Get whether or not this is an ms_struct which can be turned on with an attribute, pragma,...
Definition Decl.cpp:5420
void setAnonymousStructOrUnion(bool Anon)
Definition Decl.h:4562
bool canPassInRegisters() const
Determine whether this class can be passed in registers.
Definition Decl.h:4643
field_range noload_fields() const
noload_fields - Iterate over the fields stored in this record that are currently loaded; don't attemp...
Definition Decl.h:4729
unsigned getNumFields() const
Returns the number of fields (non-static data members) in this record.
Definition Decl.h:4722
RecordArgPassingKind getArgPassingRestrictions() const
Definition Decl.h:4647
RecordDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl)
Definition Decl.cpp:5316
bool hasVolatileMember() const
Definition Decl.h:4569
bool hasFlexibleArrayMember() const
Definition Decl.h:4539
bool hasNonTrivialToPrimitiveDefaultInitializeCUnion() const
Definition Decl.h:4608
const FieldDecl * findFirstNamedDataMember() const
Finds the first data member which has a name.
Definition Decl.cpp:5512
field_iterator noload_field_begin() const
Definition Decl.cpp:5393
const RecordDecl * getMostRecentDecl() const
Definition Decl.h:4535
void setArgPassingRestrictions(RecordArgPassingKind Kind)
Definition Decl.h:4652
void setNonTrivialToPrimitiveCopy(bool V)
Definition Decl.h:4596
bool hasObjectMember() const
Definition Decl.h:4566
bool isNonTrivialToPrimitiveDestroy() const
Definition Decl.h:4600
bool isNonTrivialToPrimitiveCopy() const
Definition Decl.h:4592
bool isCapturedRecord() const
Determine whether this record is a record for captured variables in CapturedStmt construct.
Definition Decl.cpp:5360
void setHasNonTrivialToPrimitiveCopyCUnion(bool V)
Definition Decl.h:4628
field_iterator field_end() const
Definition Decl.h:4712
field_range fields() const
Definition Decl.h:4709
llvm::iterator_range< specific_decl_iterator< FieldDecl > > field_range
Definition Decl.h:4707
bool isRandomized() const
Definition Decl.h:4664
void setHasNonTrivialToPrimitiveDestructCUnion(bool V)
Definition Decl.h:4620
friend class ASTDeclReader
Definition Decl.h:4511
static bool classofKind(Kind K)
Definition Decl.h:4747
void setHasFlexibleArrayMember(bool V)
Definition Decl.h:4543
void setParamDestroyedInCallee(bool V)
Definition Decl.h:4660
void setNonTrivialToPrimitiveDestroy(bool V)
Definition Decl.h:4604
void setHasObjectMember(bool val)
Definition Decl.h:4567
void setHasVolatileMember(bool val)
Definition Decl.h:4571
void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)
Definition Decl.h:4612
void reorderDecls(const SmallVectorImpl< Decl * > &Decls)
Definition Decl.cpp:5431
void setIsRandomized(bool V)
Definition Decl.h:4666
bool isParamDestroyedInCallee() const
Definition Decl.h:4656
static RecordDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5347
bool noload_field_empty() const
Definition Decl.h:4739
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
Definition Decl.cpp:5468
static bool classof(const Decl *D)
Definition Decl.h:4746
RecordDecl * getMostRecentDecl()
Definition Decl.h:4532
const RecordDecl * getPreviousDecl() const
Definition Decl.h:4528
bool isOrContainsUnion() const
Returns whether this record is a union, or contains (at any nesting level) a union member.
Definition Decl.cpp:5368
virtual void completeDefinition()
Note that the definition of this type is now complete.
Definition Decl.cpp:5399
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
Definition Decl.h:4690
bool hasUninitializedExplicitInitFields() const
Definition Decl.h:4632
field_iterator noload_field_end() const
Definition Decl.h:4734
void setCapturedRecord()
Mark the record as a record for captured variables in CapturedStmt construct.
Definition Decl.cpp:5364
specific_decl_iterator< FieldDecl > field_iterator
Definition Decl.h:4706
void setHasUninitializedExplicitInitFields(bool V)
Definition Decl.h:4636
RecordDecl * getPreviousDecl()
Definition Decl.h:4524
void setNonTrivialToPrimitiveDefaultInitialize(bool V)
Definition Decl.h:4588
RecordDecl * getDefinitionOrSelf() const
Definition Decl.h:4694
bool isNonTrivialToPrimitiveDefaultInitialize() const
Functions to query basic properties of non-trivial C structs.
Definition Decl.h:4584
friend class DeclContext
Definition Decl.h:4510
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Definition Decl.h:4558
void setHasLoadedFieldsFromExternalStorage(bool val) const
Definition Decl.h:4579
bool field_empty() const
Definition Decl.h:4717
field_iterator field_begin() const
Definition Decl.cpp:5383
TranslationUnitDecl * getNextRedeclaration() const
Redeclarable(const ASTContext &Ctx)
DeclLink RedeclLink
Points to the next redeclaration in the chain.
llvm::iterator_range< redecl_iterator > redecl_range
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Definition Decl.h:5514
static DeclLink PreviousDeclLink(decl_type *D)
Classes implementing SemaProxy present a restricted view of the (possibly mutating) actions and queri...
Definition SemaProxy.h:29
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition Stmt.h:85
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
void AddTaggedVal(uint64_t V, DiagnosticsEngine::ArgumentKind Kind) const
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1844
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3898
TagDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
void setTagKind(TagKind TK)
Definition Decl.h:4102
void setCompleteDefinitionRequired(bool V=true)
True if this complete decl is required to be complete for some existing use.
Definition Decl.h:4014
static TagDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:4184
SourceRange getBraceRange() const
Definition Decl.h:3975
TagTypeKind TagKind
Definition Decl.h:3903
bool isBeingDefined() const
Return true if this decl is currently being defined.
Definition Decl.h:4019
void demoteThisDefinitionToDeclaration()
Mark a definition as a declaration and maintain information it was a definition.
Definition Decl.h:4057
TagDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition Decl.h:3943
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
Definition Decl.cpp:5037
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition Decl.h:3994
bool isEnum() const
Definition Decl.h:4110
void setEmbeddedInDeclarator(bool isInDeclarator)
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
Definition Decl.h:4029
SourceLocation getInnerLocStart() const
Return SourceLocation representing start of source range ignoring outer template declarations.
Definition Decl.h:3980
bool isEmbeddedInDeclarator() const
True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...
Definition Decl.h:4023
bool isStructureOrClass() const
Definition Decl.h:4112
StringRef getKindName() const
Definition Decl.h:4094
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Definition Decl.h:3999
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition Decl.h:4152
bool isStruct() const
Definition Decl.h:4106
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:3966
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition Decl.h:4135
static bool classofKind(Kind K)
Definition Decl.h:4178
void startDefinition()
Starts the definition of this tag declaration.
Definition Decl.cpp:5014
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:5007
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
Definition Decl.cpp:5009
friend class ASTDeclReader
Definition Decl.h:3962
SourceLocation getOuterLocStart() const
Return SourceLocation representing start of source range taking into account any outer template decla...
Definition Decl.cpp:4997
bool isCompleteDefinitionRequired() const
Return true if this complete decl is required to be complete for some existing use.
Definition Decl.h:4008
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5001
void printAnonymousTagDeclLocation(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Definition Decl.cpp:5071
bool isEntityBeingDefined() const
Determines whether this entity is in the process of being defined.
Definition Decl.h:4088
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:4034
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
Definition Decl.h:4159
bool isUnion() const
Definition Decl.h:4109
void setBeingDefined(bool V=true)
True if this decl is currently being defined.
Definition Decl.h:3953
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Definition Decl.cpp:5051
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Definition Decl.cpp:5150
void completeDefinition()
Completes the definition of this tag declaration.
Definition Decl.cpp:5025
bool isInterface() const
Definition Decl.h:4107
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override
Pretty-print the unqualified name of this declaration.
Definition Decl.cpp:5136
friend class ASTDeclWriter
Definition Decl.h:3963
void setTypeForDecl(const Type *TD)=delete
static bool classof(const Decl *D)
Definition Decl.h:4177
Redeclarable< TagDecl > redeclarable_base
Definition Decl.h:3933
bool isClass() const
Definition Decl.h:4108
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Definition Decl.h:4144
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type?
Definition Decl.h:4131
void setFreeStanding(bool isFreeStanding=true)
True if this tag is free standing, e.g. "struct foo;".
Definition Decl.h:4037
TagKind getTagKind() const
Definition Decl.h:4098
TagDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition Decl.h:3935
TagDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition Decl.h:3939
bool isThisDeclarationADemotedDefinition() const
Whether this declaration was a definition in some module but was forced to be a declaration.
Definition Decl.h:4051
redeclarable_base::redecl_range redecl_range
Definition Decl.h:3965
static DeclContext * castToDeclContext(const TagDecl *D)
Definition Decl.h:4180
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
Definition Decl.h:4044
void printAnonymousTagDecl(llvm::raw_ostream &OS, const PrintingPolicy &Policy) const
Definition Decl.cpp:5095
const Type * getTypeForDecl() const =delete
TagDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setBraceRange(SourceRange R)
Definition Decl.h:3976
TagDecl * getDefinitionOrSelf() const
Definition Decl.h:4081
TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, SourceLocation StartL)
Definition Decl.cpp:4980
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
Definition Decl.h:4002
A convenient class for passing around template argument information.
A template argument list.
Stores a list of template parameters for a TemplateDecl and its derived classes.
A declaration that models statements at global scope.
Definition Decl.h:4816
static bool classofKind(Kind K)
Definition Decl.h:4843
const Stmt * getStmt() const
Definition Decl.h:4836
void setSemiMissing(bool Missing=true)
Definition Decl.h:4839
unsigned getOrdinal() const
Definition Decl.h:4840
static bool classof(const Decl *D)
Definition Decl.h:4842
static TopLevelStmtDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5987
friend class ASTDeclReader
Definition Decl.h:4817
bool isSemiMissing() const
Definition Decl.h:4838
friend class ASTDeclWriter
Definition Decl.h:4818
static DeclContext * castToDeclContext(const TopLevelStmtDecl *D)
Definition Decl.h:4845
static TopLevelStmtDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:4848
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5993
void setStmt(Stmt *S)
Definition Decl.cpp:5997
The top declaration context.
Definition Decl.h:107
static TranslationUnitDecl * castFromDeclContext(const DeclContext *DC)
Definition Decl.h:156
static DeclContext * castToDeclContext(const TranslationUnitDecl *D)
Definition Decl.h:153
redeclarable_base::redecl_range redecl_range
Definition Decl.h:133
const TranslationUnitDecl * getCanonicalDecl() const
Definition Decl.h:162
static bool classofKind(Kind K)
Definition Decl.h:152
NamespaceDecl * getAnonymousNamespace() const
Definition Decl.h:145
TranslationUnitDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
ASTContext & getASTContext() const
Definition Decl.h:143
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:134
static bool classof(const Decl *D)
Definition Decl.h:151
TranslationUnitDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this translation unit.
Definition Decl.h:161
TranslationUnitDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setAnonymousNamespace(NamespaceDecl *D)
Definition Decl.cpp:5601
static TypeAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5933
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Definition Decl.h:3887
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
Definition Decl.h:3888
static bool classof(const Decl *D)
Definition Decl.h:3891
static bool classofKind(Kind K)
Definition Decl.h:3892
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5948
Declaration of an alias template.
void setLocStart(SourceLocation L)
Definition Decl.h:3729
static bool classofKind(Kind K)
Definition Decl.h:3739
void setTypeForDecl(const Type *TD)
Definition Decl.h:3723
friend class ASTReader
Definition Decl.h:3696
const Type * getTypeForDecl() const
Definition Decl.h:3719
friend class ASTContext
Definition Decl.h:3695
static bool classof(const Decl *D)
Definition Decl.h:3738
TypeDecl(Kind DK, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, SourceLocation StartL=SourceLocation())
Definition Decl.h:3710
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.h:3730
SourceLocation getBeginLoc() const LLVM_READONLY
Definition Decl.h:3728
A container of type source information.
Definition TypeBase.h:8640
The base class of the type hierarchy.
Definition TypeBase.h:1879
const T * castAs() const
Member-template castAs<specific type>.
Definition TypeBase.h:9589
const T * getAs() const
Member-template getAs<specific type>'.
Definition TypeBase.h:9522
static bool classofKind(Kind K)
Definition Decl.h:3864
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:5939
static TypedefDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:5920
static bool classof(const Decl *D)
Definition Decl.h:3863
Base class for declarations which introduce a typedef-name.
Definition Decl.h:3743
TypedefNameDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition Decl.h:3766
TypeSourceInfo * getTypeSourceInfo() const
Definition Decl.h:3793
Redeclarable< TypedefNameDecl > redeclarable_base
Definition Decl.h:3764
TypedefNameDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition Decl.h:3770
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
Definition Decl.h:3808
redeclarable_base::redecl_range redecl_range
Definition Decl.h:3779
const Type * getTypeForDecl() const =delete
TypedefNameDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
TypedefNameDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setTypeForDecl(const Type *TD)=delete
bool isModed() const
Definition Decl.h:3789
static bool classof(const Decl *D)
Definition Decl.h:3837
const TypedefNameDecl * getCanonicalDecl() const
Definition Decl.h:3815
TypedefNameDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition Decl.h:3774
TypedefNameDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition Decl.h:3758
QualType getUnderlyingType() const
Definition Decl.h:3798
bool isTransparentTag() const
Determines if this typedef shares a name and spelling location with its underlying tag type,...
Definition Decl.h:3826
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:3780
TypedefNameDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this typedef-name.
Definition Decl.h:3814
void setTypeSourceInfo(TypeSourceInfo *newType)
Definition Decl.h:3804
static bool classofKind(Kind K)
Definition Decl.h:3838
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes,...
Definition Decl.cpp:5883
A set of unresolved declarations.
static bool classof(const Decl *D)
Definition Decl.h:749
ValueDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T)
Definition Decl.h:720
void setType(QualType newType)
Definition Decl.h:726
QualType getType() const
Definition Decl.h:725
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition Decl.cpp:5701
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
Definition Decl.cpp:5689
static bool classofKind(Kind K)
Definition Decl.h:750
VarDecl * getPotentiallyDecomposedVarDecl()
Definition DeclCXX.cpp:3695
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.cpp:5695
const VarDecl * getPotentiallyDecomposedVarDecl() const
Definition Decl.h:740
Represents a variable declaration or definition.
Definition Decl.h:934
const VarDecl * getDefinition() const
Definition Decl.h:1358
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition Decl.cpp:2802
void setObjCForDecl(bool FRD)
Definition Decl.h:1573
Stmt ** getInitAddress()
Retrieve the address of the initializer expression.
Definition Decl.cpp:2424
const VarDecl * getInitializingDeclaration() const
Definition Decl.h:1407
void setCXXForRangeDecl(bool FRD)
Definition Decl.h:1562
DefinitionKind isThisDeclarationADefinition() const
Definition Decl.h:1333
bool isFunctionOrMethodVarDecl() const
Similar to isLocalVarDecl, but excludes variables declared in blocks.
Definition Decl.h:1292
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition Decl.h:1606
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
Definition Decl.cpp:2925
TLSKind getTLSKind() const
Definition Decl.cpp:2149
@ DAK_Uninstantiated
Definition Decl.h:1011
bool hasInit() const
Definition Decl.cpp:2400
bool hasICEInitializer(const ASTContext &Context) const
Determine whether the initializer of this variable is an integer constant expression.
Definition Decl.cpp:2649
redeclarable_base::redecl_range redecl_range
Definition Decl.h:1155
ParmVarDeclBitfields ParmVarDeclBits
Definition Decl.h:1132
void setARCPseudoStrong(bool PS)
Definition Decl.h:1585
VarDecl * getNextRedeclarationImpl() override
Returns the next redeclaration or itself if this is the only decl.
Definition Decl.h:1142
@ NumParameterIndexBits
Definition Decl.h:1006
void setInitStyle(InitializationStyle Style)
Definition Decl.h:1489
void setEscapingByref()
Definition Decl.h:1644
redeclarable_base::redecl_iterator redecl_iterator
Definition Decl.h:1156
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setCXXForRangeImplicitVar(bool FRV)
Definition Decl.h:1664
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition Decl.h:1503
void setInitCapture(bool IC)
Definition Decl.h:1618
bool evaluateConstantDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes, SemaProxy &SProxy) const
Evaluate the destruction of a variable that is required by the language to have constant destruction.
DefinitionKind hasDefinition() const
Definition Decl.h:1339
static const char * getStorageClassSpecifierString(StorageClass SC)
Return the string used to specify the storage class SC.
Definition Decl.cpp:2102
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition Decl.cpp:2171
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member.
Definition Decl.cpp:2463
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Definition Decl.cpp:2238
bool hasFlexibleArrayInit(const ASTContext &Ctx) const
Whether this variable has a flexible array member initialized with one or more elements.
Definition Decl.cpp:2854
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed?
Definition Decl.cpp:2828
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
Definition Decl.h:1615
bool isCXXCondDecl() const
Definition Decl.h:1648
friend class StmtIteratorBase
Definition Decl.h:985
const APValue * getEvaluatedValue() const
Return the already-evaluated value of this variable's initializer, or nullptr if the value is not yet...
Definition Decl.cpp:2641
InitializationStyle
Initialization styles.
Definition Decl.h:937
@ ListInit
Direct list-initialization (C++11)
Definition Decl.h:945
@ CInit
C-style initialization with assignment.
Definition Decl.h:939
@ ParenListInit
Parenthesized list-initialization (C++20)
Definition Decl.h:948
@ CallInit
Call-style initialization (C++98)
Definition Decl.h:942
void setCXXCondDecl()
Definition Decl.h:1652
bool isObjCForDecl() const
Determine whether this variable is a for-loop declaration for a for-in statement in Objective-C.
Definition Decl.h:1569
void setStorageClass(StorageClass SC)
Definition Decl.cpp:2144
void setPreviousDeclInSameBlockScope(bool Same)
Definition Decl.h:1630
bool isInternalLinkageFileVar() const
Returns true if this is a file-scope variable with internal linkage.
Definition Decl.h:1224
bool hasInitWithSideEffects() const
Checks whether this declaration has an initializer with side effects.
Definition Decl.cpp:2446
bool isInlineSpecified() const
Definition Decl.h:1591
bool isStaticDataMember() const
Determines whether this is a static data member.
Definition Decl.h:1308
static VarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)
Definition Decl.cpp:2138
VarDecl * getTemplateInstantiationPattern() const
Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...
Definition Decl.cpp:2719
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
Definition Decl.h:1249
VarDeclBitfields VarDeclBits
Definition Decl.h:1131
CharUnits getFlexibleArrayInitChars(const ASTContext &Ctx) const
If hasFlexibleArrayInit is true, compute the number of additional bytes necessary to store those elem...
Definition Decl.cpp:2869
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
Definition Decl.cpp:2661
void assignAddressSpace(const ASTContext &Ctxt, LangAS AS)
Apply a deduced address space, if one isn't already set.
Definition Decl.cpp:2932
bool isCXXForRangeDecl() const
Determine whether this variable is the for-range-declaration in a C++0x for-range statement.
Definition Decl.h:1559
friend class ASTDeclReader
Definition Decl.h:983
LanguageLinkage getLanguageLinkage() const
Compute the language linkage.
Definition Decl.cpp:2222
static bool classofKind(Kind K)
Definition Decl.h:1761
unsigned AllBits
Definition Decl.h:1130
const VarDecl * getDefinition(ASTContext &C) const
Definition Decl.h:1352
friend class ASTNodeImporter
Definition Decl.h:984
EvaluatedStmt * getEvaluatedStmt() const
Definition Decl.cpp:2564
bool mightBeUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value might be usable in a constant expression, according to the re...
Definition Decl.cpp:2479
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
Definition Decl.cpp:2550
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction.
static bool classof(const Decl *D)
Definition Decl.h:1760
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
Definition Decl.h:1549
void setInlineSpecified()
Definition Decl.h:1595
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
Definition Decl.h:1216
const VarDecl * getCanonicalDecl() const
Definition Decl.h:1314
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
Definition Decl.cpp:2764
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
Definition Decl.h:1367
bool isCXXForRangeImplicitVar() const
Whether this variable is the implicit '__range' variable in C++ range-based for loops.
Definition Decl.h:1659
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
Definition Decl.h:1531
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template,...
Definition Decl.cpp:2897
void setTSCSpec(ThreadStorageClassSpecifier TSC)
Definition Decl.h:1181
void setNRVOVariable(bool NRVO)
Definition Decl.h:1552
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
Definition Decl.cpp:2843
bool isInline() const
Whether this variable is (C++1z) inline.
Definition Decl.h:1588
ThreadStorageClassSpecifier getTSCSpec() const
Definition Decl.h:1185
const Expr * getInit() const
Definition Decl.h:1393
bool isNonEscapingByref() const
Indicates the capture is a __block variable that is never captured by an escaping block.
Definition Decl.cpp:2707
bool isInExternCContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec.
Definition Decl.cpp:2230
NonParmVarDeclBitfields NonParmVarDeclBits
Definition Decl.h:1133
bool checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes, SemaProxy &SProxy) const
Evaluate the initializer of this variable to determine whether it's a constant initializer.
Definition Decl.cpp:2677
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
Definition Decl.h:1240
InitType Init
The initializer for this variable or, for a ParmVarDecl, the C++ default argument.
Definition Decl.h:980
const APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
Definition Decl.cpp:2568
Redeclarable< VarDecl > redeclarable_base
Definition Decl.h:1140
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Definition Decl.h:1584
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
Definition Decl.h:1192
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
Definition Decl.cpp:2431
void setConstexpr(bool IC)
Definition Decl.h:1609
TLSKind
Kinds of thread-local storage.
Definition Decl.h:952
@ TLS_Static
TLS with a known-constant initializer.
Definition Decl.h:957
@ TLS_Dynamic
TLS with a dynamic initializer.
Definition Decl.h:960
@ TLS_None
Not a TLS variable.
Definition Decl.h:954
void setInit(Expr *I)
Definition Decl.cpp:2470
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
Definition Decl.cpp:2347
@ TentativeDefinition
This declaration is a tentative definition.
Definition Decl.h:1323
@ DeclarationOnly
This declaration is only a declaration.
Definition Decl.h:1320
@ Definition
This declaration is definitely a definition.
Definition Decl.h:1326
@ NumScopeDepthOrObjCQualsBits
Definition Decl.h:1015
void setDescribedVarTemplate(VarTemplateDecl *Template)
Definition Decl.cpp:2807
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
Definition Decl.cpp:2226
VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)
Definition Decl.cpp:2115
void deduceParmAddressSpace(const ASTContext &Ctxt)
Definition Decl.cpp:2953
llvm::PointerUnion< Stmt *, EvaluatedStmt * > InitType
Definition Decl.h:976
bool isLocalVarDecl() const
Returns true for local variable declarations other than parameters.
Definition Decl.h:1276
bool isDirectInit() const
Whether the initializer is a direct-initializer (list or call).
Definition Decl.h:1508
VarDecl * getMostRecentDeclImpl() override
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition Decl.h:1150
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Definition Decl.h:1252
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition Decl.h:1176
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Definition Decl.cpp:2703
void setImplicitlyInline()
Definition Decl.h:1600
bool isThisDeclarationADemotedDefinition() const
If this definition should pretend to be a declaration.
Definition Decl.h:1513
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
Definition Decl.h:1625
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
Definition Decl.cpp:2521
bool isInExternCXXContext() const
Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec.
Definition Decl.cpp:2234
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition Decl.cpp:2792
bool hasDependentAlignment() const
Determines if this variable's alignment is dependent.
Definition Decl.cpp:2711
TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const
Get the template specialization kind of this variable for the purposes of template instantiation.
Definition Decl.cpp:2782
VarDecl * getDefinition()
Definition Decl.h:1355
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
Definition Decl.h:1287
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Definition Decl.cpp:2771
const VarDecl * getActingDefinition() const
Definition Decl.h:1346
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
Definition Decl.h:1383
void setExceptionVariable(bool EV)
Definition Decl.h:1534
bool isKnownToBeDefined() const
Definition Decl.cpp:2811
VarDecl * getPreviousDeclImpl() override
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition Decl.h:1146
void demoteThisDefinitionToDeclaration()
This is a definition which should be demoted to a declaration.
Definition Decl.h:1523
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Definition Decl.cpp:2890
Declaration of a variable template.
Represents a C array with a specified size that is not an integer-constant-expression.
Definition TypeBase.h:4064
Defines the Linkage enumeration and various utility functions.
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
Definition Address.h:330
LazyOffsetPtr< Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt > LazyDeclStmtPtr
A lazy pointer to a statement.
PragmaMSCommentKind
Definition PragmaKinds.h:14
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition Specifiers.h:36
InClassInitStyle
In-class initialization styles for non-static data members.
Definition Specifiers.h:275
@ ICIS_CopyInit
Copy initialization.
Definition Specifiers.h:277
@ ICIS_ListInit
Direct list-initialization.
Definition Specifiers.h:278
@ ICIS_NoInit
No in-class initializer.
Definition Specifiers.h:276
bool IsEnumDeclComplete(EnumDecl *ED)
Check if the given decl is complete.
Definition Decl.h:5555
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.
Definition Linkage.h:63
StorageClass
Storage classes.
Definition Specifiers.h:252
@ SC_Auto
Definition Specifiers.h:260
@ SC_PrivateExtern
Definition Specifiers.h:257
@ SC_Extern
Definition Specifiers.h:255
@ SC_Register
Definition Specifiers.h:261
@ SC_Static
Definition Specifiers.h:256
@ SC_None
Definition Specifiers.h:254
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition Specifiers.h:239
@ TSCS_thread_local
C++11 thread_local.
Definition Specifiers.h:245
@ TSCS_unspecified
Definition Specifiers.h:240
static constexpr StringRef getOpenMPVariantManglingSeparatorStr()
OpenMP variants are mangled early based on their OpenMP context selector.
Definition Decl.h:5572
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition Linkage.h:24
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition Linkage.h:54
@ Asm
Assembly: we accept this only so that we can preprocess it.
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition Specifiers.h:341
@ SD_Thread
Thread storage duration.
Definition Specifiers.h:344
@ SD_Static
Static storage duration.
Definition Specifiers.h:345
@ SD_Automatic
Automatic storage duration (most local variables).
Definition Specifiers.h:343
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
bool hasArmZT0State(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZT0 state.
Definition Decl.cpp:6235
TagTypeKind
The kind of a tag type.
Definition TypeBase.h:6262
@ Interface
The "__interface" keyword.
Definition TypeBase.h:6267
@ Struct
The "struct" keyword.
Definition TypeBase.h:6264
@ Class
The "class" keyword.
Definition TypeBase.h:6273
@ Union
The "union" keyword.
Definition TypeBase.h:6270
@ Enum
The "enum" keyword.
Definition TypeBase.h:6276
bool IsEnumDeclScoped(EnumDecl *ED)
Check if the given decl is scoped.
Definition Decl.h:5565
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
Definition Decl.h:2053
@ Relational
This is an <, <=, >, or >= that should be implemented as a rewrite in terms of a <=> comparison.
Definition Decl.h:2067
@ NotEqual
This is an operator!= that should be implemented as a rewrite in terms of a == comparison.
Definition Decl.h:2064
@ ThreeWay
This is an operator<=> that should be implemented as a series of subobject comparisons.
Definition Decl.h:2061
@ None
This is not a defaultable comparison operator.
Definition Decl.h:2055
LangAS
Defines the address space values used by the address space qualifier of QualType.
RecordArgPassingKind
Enum that represents the different ways arguments are passed to and returned from function calls.
Definition Decl.h:4483
@ CanPassInRegs
The argument of this type can be passed directly in registers.
Definition Decl.h:4485
@ CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
Definition Decl.h:4499
@ CannotPassInRegs
The argument of this type cannot be passed directly in registers.
Definition Decl.h:4494
CXXSpecialMemberKind
Kinds of C++ special members.
Definition Decl.h:2031
MultiVersionKind
Definition Decl.h:2021
bool isExternalFormalLinkage(Linkage L)
Definition Linkage.h:117
PostfixOperatorKind
Kinds of defaulted postfix increment and decrement operator functions (C++2d [over....
Definition Decl.h:2043
@ Decrement
This is a postfix decrement operator, 'operator--(int)'.
Definition Decl.h:2049
@ None
This is not a defaultable postfix increment or decrement operator.
Definition Decl.h:2045
@ Increment
This is a postfix increment operator, 'operator++(int)'.
Definition Decl.h:2047
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition Specifiers.h:192
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition Specifiers.h:198
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6251
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
Definition Decl.cpp:6214
ReservedIdentifierStatus
bool isExternallyVisible(Linkage L)
Definition Linkage.h:90
ImplicitParamKind
Defines the kind of the implicit parameter: is this an implicit parameter with pointer to 'this',...
Definition Decl.h:1767
@ CXXThis
Parameter for C++ 'this' argument.
Definition Decl.h:1775
@ ThreadPrivateVar
Parameter for Thread private variable.
Definition Decl.h:1784
@ CXXVTT
Parameter for C++ virtual table pointers.
Definition Decl.h:1778
@ ObjCSelf
Parameter for Objective-C 'self' argument.
Definition Decl.h:1769
@ ObjCCmd
Parameter for Objective-C '_cmd' argument.
Definition Decl.h:1772
@ CapturedContext
Parameter for captured context.
Definition Decl.h:1781
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_None
no exception specification
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition Visibility.h:34
bool hasArmZAState(const FunctionDecl *FD)
Returns whether the given FunctionDecl has Arm ZA state.
Definition Decl.cpp:6228
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
#define false
Definition stdbool.h:26
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
bool isNull() const
Definition Decl.h:101
AssociatedConstraint(const Expr *ConstraintExpr, UnsignedOrNone ArgPackSubstIndex=std::nullopt)
Definition Decl.h:95
const Expr * ConstraintExpr
Definition Decl.h:90
UnsignedOrNone ArgPackSubstIndex
Definition Decl.h:91
constexpr AssociatedConstraint()=default
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition DeclBase.h:102
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Structure used to store a statement, the constant value to which it was evaluated (if any),...
Definition Decl.h:887
unsigned CheckedForICEInit
Definition Decl.h:916
unsigned WasEvaluated
Whether this statement was already evaluated.
Definition Decl.h:890
unsigned HasConstantInitialization
Whether this variable is known to have constant initialization.
Definition Decl.h:901
LazyDeclStmtPtr Value
Definition Decl.h:923
unsigned HasICEInit
In C++98, whether the initializer is an ICE.
Definition Decl.h:914
unsigned HasSideEffects
Definition Decl.h:919
APValue Evaluated
Definition Decl.h:924
unsigned CheckedForSideEffects
Definition Decl.h:921
unsigned IsEvaluating
Whether this statement is being evaluated.
Definition Decl.h:894
unsigned HasConstantDestruction
Whether this variable is known to have constant destruction.
Definition Decl.h:909
static StringRef getTagTypeKindName(TagTypeKind Kind)
Definition TypeBase.h:6301
Describes how types, statements, expressions, and declarations should be printed.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
Definition Decl.h:755
QualifierInfo & operator=(const QualifierInfo &)=delete
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
Definition Decl.h:769
NestedNameSpecifierLoc QualifierLoc
Definition Decl.h:756
QualifierInfo(const QualifierInfo &)=delete
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
Definition Decl.h:762
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
Sets info about "outer" template parameter lists.
Definition Decl.cpp:2082
The parameters to pass to a usual operator delete.
Definition ExprCXX.h:2349