clang 22.0.0git
DeclBase.h
Go to the documentation of this file.
1//===- DeclBase.h - Base 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 and DeclContext interfaces.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_DECLBASE_H
14#define LLVM_CLANG_AST_DECLBASE_H
15
18#include "clang/AST/DeclID.h"
22#include "clang/Basic/LLVM.h"
26#include "llvm/ADT/ArrayRef.h"
27#include "llvm/ADT/PointerIntPair.h"
28#include "llvm/ADT/PointerUnion.h"
29#include "llvm/ADT/iterator.h"
30#include "llvm/ADT/iterator_range.h"
31#include "llvm/Support/Casting.h"
32#include "llvm/Support/Compiler.h"
33#include "llvm/Support/PrettyStackTrace.h"
34#include "llvm/Support/VersionTuple.h"
35#include <algorithm>
36#include <cassert>
37#include <cstddef>
38#include <iterator>
39#include <string>
40#include <type_traits>
41#include <utility>
42
43namespace clang {
44
45class ASTContext;
46class ASTMutationListener;
47class Attr;
48class BlockDecl;
49class DeclContext;
50class ExternalSourceSymbolAttr;
51class FunctionDecl;
52class FunctionType;
53class IdentifierInfo;
54enum class Linkage : unsigned char;
55class LinkageSpecDecl;
56class Module;
57class NamedDecl;
58class ObjCContainerDecl;
59class ObjCMethodDecl;
60struct PrintingPolicy;
61class RecordDecl;
62class SourceManager;
63class Stmt;
64class StoredDeclsMap;
65class TemplateDecl;
66class TemplateParameterList;
67class TranslationUnitDecl;
68class UsingDirectiveDecl;
69
70/// Captures the result of checking the availability of a
71/// declaration.
77};
78
79/// Decl - This represents one declaration (or definition), e.g. a variable,
80/// typedef, function, struct, etc.
81///
82/// Note: There are objects tacked on before the *beginning* of Decl
83/// (and its subclasses) in its Decl::operator new(). Proper alignment
84/// of all subclasses (not requiring more than the alignment of Decl) is
85/// asserted in DeclBase.cpp.
86class alignas(8) Decl {
87public:
88 /// Lists the kind of concrete classes of Decl.
89 enum Kind {
90#define DECL(DERIVED, BASE) DERIVED,
91#define ABSTRACT_DECL(DECL)
92#define DECL_RANGE(BASE, START, END) \
93 first##BASE = START, last##BASE = END,
94#define LAST_DECL_RANGE(BASE, START, END) \
95 first##BASE = START, last##BASE = END
96#include "clang/AST/DeclNodes.inc"
97 };
98
99 /// A placeholder type used to construct an empty shell of a
100 /// decl-derived type that will be filled in later (e.g., by some
101 /// deserialization method).
102 struct EmptyShell {};
103
104 /// IdentifierNamespace - The different namespaces in which
105 /// declarations may appear. According to C99 6.2.3, there are
106 /// four namespaces, labels, tags, members and ordinary
107 /// identifiers. C++ describes lookup completely differently:
108 /// certain lookups merely "ignore" certain kinds of declarations,
109 /// usually based on whether the declaration is of a type, etc.
110 ///
111 /// These are meant as bitmasks, so that searches in
112 /// C++ can look into the "tag" namespace during ordinary lookup.
113 ///
114 /// Decl currently provides 15 bits of IDNS bits.
116 /// Labels, declared with 'x:' and referenced with 'goto x'.
117 IDNS_Label = 0x0001,
118
119 /// Tags, declared with 'struct foo;' and referenced with
120 /// 'struct foo'. All tags are also types. This is what
121 /// elaborated-type-specifiers look for in C.
122 /// This also contains names that conflict with tags in the
123 /// same scope but that are otherwise ordinary names (non-type
124 /// template parameters and indirect field declarations).
125 IDNS_Tag = 0x0002,
126
127 /// Types, declared with 'struct foo', typedefs, etc.
128 /// This is what elaborated-type-specifiers look for in C++,
129 /// but note that it's ill-formed to find a non-tag.
130 IDNS_Type = 0x0004,
131
132 /// Members, declared with object declarations within tag
133 /// definitions. In C, these can only be found by "qualified"
134 /// lookup in member expressions. In C++, they're found by
135 /// normal lookup.
136 IDNS_Member = 0x0008,
137
138 /// Namespaces, declared with 'namespace foo {}'.
139 /// Lookup for nested-name-specifiers find these.
141
142 /// Ordinary names. In C, everything that's not a label, tag,
143 /// member, or function-local extern ends up here.
145
146 /// Objective C \@protocol.
148
149 /// This declaration is a friend function. A friend function
150 /// declaration is always in this namespace but may also be in
151 /// IDNS_Ordinary if it was previously declared.
153
154 /// This declaration is a friend class. A friend class
155 /// declaration is always in this namespace but may also be in
156 /// IDNS_Tag|IDNS_Type if it was previously declared.
158
159 /// This declaration is a using declaration. A using declaration
160 /// *introduces* a number of other declarations into the current
161 /// scope, and those declarations use the IDNS of their targets,
162 /// but the actual using declarations go in this namespace.
163 IDNS_Using = 0x0200,
164
165 /// This declaration is a C++ operator declared in a non-class
166 /// context. All such operators are also in IDNS_Ordinary.
167 /// C++ lexical operator lookup looks for these.
169
170 /// This declaration is a function-local extern declaration of a
171 /// variable or function. This may also be IDNS_Ordinary if it
172 /// has been declared outside any function. These act mostly like
173 /// invisible friend declarations, but are also visible to unqualified
174 /// lookup within the scope of the declaring function.
176
177 /// This declaration is an OpenMP user defined reduction construction.
179
180 /// This declaration is an OpenMP user defined mapper.
182 };
183
184 /// ObjCDeclQualifier - 'Qualifiers' written next to the return and
185 /// parameter types in method declarations. Other than remembering
186 /// them and mangling them into the method's signature string, these
187 /// are ignored by the compiler; they are consumed by certain
188 /// remote-messaging frameworks.
189 ///
190 /// in, inout, and out are mutually exclusive and apply only to
191 /// method parameters. bycopy and byref are mutually exclusive and
192 /// apply only to method parameters (?). oneway applies only to
193 /// results. All of these expect their corresponding parameter to
194 /// have a particular type. None of this is currently enforced by
195 /// clang.
196 ///
197 /// This should be kept in sync with ObjCDeclSpec::ObjCDeclQualifier.
206
207 /// The nullability qualifier is set when the nullability of the
208 /// result or parameter was expressed via a context-sensitive
209 /// keyword.
211 };
212
213 /// The kind of ownership a declaration has, for visibility purposes.
214 /// This enumeration is designed such that higher values represent higher
215 /// levels of name hiding.
216 enum class ModuleOwnershipKind : unsigned char {
217 /// This declaration is not owned by a module.
218 Unowned,
219
220 /// This declaration has an owning module, but is globally visible
221 /// (typically because its owning module is visible and we know that
222 /// modules cannot later become hidden in this compilation).
223 /// After serialization and deserialization, this will be converted
224 /// to VisibleWhenImported.
225 Visible,
226
227 /// This declaration has an owning module, and is visible when that
228 /// module is imported.
230
231 /// This declaration has an owning module, and is visible to lookups
232 /// that occurs within that module. And it is reachable in other module
233 /// when the owning module is transitively imported.
235
236 /// This declaration has an owning module, but is only visible to
237 /// lookups that occur within that module.
238 /// The discarded declarations in global module fragment belongs
239 /// to this group too.
241 };
242
243protected:
244 /// The next declaration within the same lexical
245 /// DeclContext. These pointers form the linked list that is
246 /// traversed via DeclContext's decls_begin()/decls_end().
247 ///
248 /// The extra three bits are used for the ModuleOwnershipKind.
249 llvm::PointerIntPair<Decl *, 3, ModuleOwnershipKind> NextInContextAndBits;
250
251private:
252 friend class DeclContext;
253
254 struct MultipleDC {
255 DeclContext *SemanticDC;
256 DeclContext *LexicalDC;
257 };
258
259 /// DeclCtx - Holds either a DeclContext* or a MultipleDC*.
260 /// For declarations that don't contain C++ scope specifiers, it contains
261 /// the DeclContext where the Decl was declared.
262 /// For declarations with C++ scope specifiers, it contains a MultipleDC*
263 /// with the context where it semantically belongs (SemanticDC) and the
264 /// context where it was lexically declared (LexicalDC).
265 /// e.g.:
266 ///
267 /// namespace A {
268 /// void f(); // SemanticDC == LexicalDC == 'namespace A'
269 /// }
270 /// void A::f(); // SemanticDC == namespace 'A'
271 /// // LexicalDC == global namespace
272 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
273
274 bool isInSemaDC() const { return isa<DeclContext *>(DeclCtx); }
275 bool isOutOfSemaDC() const { return isa<MultipleDC *>(DeclCtx); }
276
277 MultipleDC *getMultipleDC() const { return cast<MultipleDC *>(DeclCtx); }
278
279 DeclContext *getSemanticDC() const { return cast<DeclContext *>(DeclCtx); }
280
281 /// Loc - The location of this decl.
282 SourceLocation Loc;
283
284 /// DeclKind - This indicates which class this is.
285 LLVM_PREFERRED_TYPE(Kind)
286 unsigned DeclKind : 7;
287
288 /// InvalidDecl - This indicates a semantic error occurred.
289 LLVM_PREFERRED_TYPE(bool)
290 unsigned InvalidDecl : 1;
291
292 /// HasAttrs - This indicates whether the decl has attributes or not.
293 LLVM_PREFERRED_TYPE(bool)
294 unsigned HasAttrs : 1;
295
296 /// Implicit - Whether this declaration was implicitly generated by
297 /// the implementation rather than explicitly written by the user.
298 LLVM_PREFERRED_TYPE(bool)
299 unsigned Implicit : 1;
300
301 /// Whether this declaration was "used", meaning that a definition is
302 /// required.
303 LLVM_PREFERRED_TYPE(bool)
304 unsigned Used : 1;
305
306 /// Whether this declaration was "referenced".
307 /// The difference with 'Used' is whether the reference appears in a
308 /// evaluated context or not, e.g. functions used in uninstantiated templates
309 /// are regarded as "referenced" but not "used".
310 LLVM_PREFERRED_TYPE(bool)
311 unsigned Referenced : 1;
312
313 /// Whether this declaration is a top-level declaration (function,
314 /// global variable, etc.) that is lexically inside an objc container
315 /// definition.
316 LLVM_PREFERRED_TYPE(bool)
317 unsigned TopLevelDeclInObjCContainer : 1;
318
319 /// Whether statistic collection is enabled.
320 static bool StatisticsEnabled;
321
322protected:
323 friend class ASTDeclMerger;
324 friend class ASTDeclReader;
325 friend class ASTDeclWriter;
326 friend class ASTNodeImporter;
327 friend class ASTReader;
329 friend class LinkageComputer;
330 friend class RecordDecl;
331 template<typename decl_type> friend class Redeclarable;
332
333 /// Access - Used by C++ decls for the access specifier.
334 // NOTE: VC++ treats enums as signed, avoid using the AccessSpecifier enum
335 LLVM_PREFERRED_TYPE(AccessSpecifier)
337
338 /// Whether this declaration was loaded from an AST file.
339 LLVM_PREFERRED_TYPE(bool)
340 unsigned FromASTFile : 1;
341
342 /// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
343 LLVM_PREFERRED_TYPE(IdentifierNamespace)
344 unsigned IdentifierNamespace : 14;
345
346 /// If 0, we have not computed the linkage of this declaration.
347 LLVM_PREFERRED_TYPE(Linkage)
348 mutable unsigned CacheValidAndLinkage : 3;
349
350 /// Allocate memory for a deserialized declaration.
351 ///
352 /// This routine must be used to allocate memory for any declaration that is
353 /// deserialized from a module file.
354 ///
355 /// \param Size The size of the allocated object.
356 /// \param Ctx The context in which we will allocate memory.
357 /// \param ID The global ID of the deserialized declaration.
358 /// \param Extra The amount of extra space to allocate after the object.
359 void *operator new(std::size_t Size, const ASTContext &Ctx, GlobalDeclID ID,
360 std::size_t Extra = 0);
361
362 /// Allocate memory for a non-deserialized declaration.
363 void *operator new(std::size_t Size, const ASTContext &Ctx,
364 DeclContext *Parent, std::size_t Extra = 0);
365
366private:
367 bool AccessDeclContextCheck() const;
368
369 /// Get the module ownership kind to use for a local lexical child of \p DC,
370 /// which may be either a local or (rarely) an imported declaration.
371 static ModuleOwnershipKind getModuleOwnershipKindForChildOf(DeclContext *DC) {
372 if (DC) {
373 auto *D = cast<Decl>(DC);
374 auto MOK = D->getModuleOwnershipKind();
375 if (MOK != ModuleOwnershipKind::Unowned &&
376 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
377 return MOK;
378 // If D is not local and we have no local module storage, then we don't
379 // need to track module ownership at all.
380 }
382 }
383
384public:
385 Decl() = delete;
386 Decl(const Decl&) = delete;
387 Decl(Decl &&) = delete;
388 Decl &operator=(const Decl&) = delete;
389 Decl &operator=(Decl&&) = delete;
390
391protected:
393 : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
394 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(false), HasAttrs(false),
395 Implicit(false), Used(false), Referenced(false),
396 TopLevelDeclInObjCContainer(false), Access(AS_none), FromASTFile(0),
398 CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
399 if (StatisticsEnabled) add(DK);
400 }
401
403 : DeclKind(DK), InvalidDecl(false), HasAttrs(false), Implicit(false),
404 Used(false), Referenced(false), TopLevelDeclInObjCContainer(false),
407 CacheValidAndLinkage(llvm::to_underlying(Linkage::Invalid)) {
408 if (StatisticsEnabled) add(DK);
409 }
410
411 virtual ~Decl();
412
414 return static_cast<Linkage>(CacheValidAndLinkage);
415 }
416
417 void setCachedLinkage(Linkage L) const {
418 CacheValidAndLinkage = llvm::to_underlying(L);
419 }
420
421 bool hasCachedLinkage() const {
423 }
424
425public:
426 /// Source range that this declaration covers.
427 virtual SourceRange getSourceRange() const LLVM_READONLY {
429 }
430
431 SourceLocation getBeginLoc() const LLVM_READONLY {
432 return getSourceRange().getBegin();
433 }
434
435 SourceLocation getEndLoc() const LLVM_READONLY {
436 return getSourceRange().getEnd();
437 }
438
439 SourceLocation getLocation() const { return Loc; }
441
442 Kind getKind() const { return static_cast<Kind>(DeclKind); }
443 const char *getDeclKindName() const;
444
446 const Decl *getNextDeclInContext() const {return NextInContextAndBits.getPointer();}
447
449 if (isInSemaDC())
450 return getSemanticDC();
451 return getMultipleDC()->SemanticDC;
452 }
454 return const_cast<Decl*>(this)->getDeclContext();
455 }
456
457 /// Return the non transparent context.
458 /// See the comment of `DeclContext::isTransparentContext()` for the
459 /// definition of transparent context.
462 return const_cast<Decl *>(this)->getNonTransparentDeclContext();
463 }
464
465 /// Find the innermost non-closure ancestor of this declaration,
466 /// walking up through blocks, lambdas, etc. If that ancestor is
467 /// not a code context (!isFunctionOrMethod()), returns null.
468 ///
469 /// A declaration may be its own non-closure context.
471 const Decl *getNonClosureContext() const {
472 return const_cast<Decl*>(this)->getNonClosureContext();
473 }
474
477 return const_cast<Decl*>(this)->getTranslationUnitDecl();
478 }
479
480 bool isInAnonymousNamespace() const;
481
482 bool isInStdNamespace() const;
483
484 // Return true if this is a FileContext Decl.
485 bool isFileContextDecl() const;
486
487 /// Whether it resembles a flexible array member. This is a static member
488 /// because we want to be able to call it with a nullptr. That allows us to
489 /// perform non-Decl specific checks based on the object's type and strict
490 /// flex array level.
491 static bool isFlexibleArrayMemberLike(
492 const ASTContext &Context, const Decl *D, QualType Ty,
493 LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel,
494 bool IgnoreTemplateOrMacroSubstitution);
495
496 ASTContext &getASTContext() const LLVM_READONLY;
497
498 /// Helper to get the language options from the ASTContext.
499 /// Defined out of line to avoid depending on ASTContext.h.
500 const LangOptions &getLangOpts() const LLVM_READONLY;
501
503 Access = AS;
504 assert(AccessDeclContextCheck());
505 }
506
508 assert(AccessDeclContextCheck());
509 return AccessSpecifier(Access);
510 }
511
512 /// Retrieve the access specifier for this declaration, even though
513 /// it may not yet have been properly set.
515 return AccessSpecifier(Access);
516 }
517
518 bool hasAttrs() const { return HasAttrs; }
519
520 void setAttrs(const AttrVec& Attrs) {
521 return setAttrsImpl(Attrs, getASTContext());
522 }
523
525 return const_cast<AttrVec&>(const_cast<const Decl*>(this)->getAttrs());
526 }
527
528 const AttrVec &getAttrs() const;
529 void dropAttrs();
530 void addAttr(Attr *A);
531
532 using attr_iterator = AttrVec::const_iterator;
533 using attr_range = llvm::iterator_range<attr_iterator>;
534
536 return attr_range(attr_begin(), attr_end());
537 }
538
540 return hasAttrs() ? getAttrs().begin() : nullptr;
541 }
543 return hasAttrs() ? getAttrs().end() : nullptr;
544 }
545
546 template <typename... Ts> void dropAttrs() {
547 if (!HasAttrs) return;
548
549 AttrVec &Vec = getAttrs();
550 llvm::erase_if(Vec, [](Attr *A) { return isa<Ts...>(A); });
551
552 if (Vec.empty())
553 HasAttrs = false;
554 }
555
556 template <typename T> void dropAttr() { dropAttrs<T>(); }
557
558 template <typename T>
559 llvm::iterator_range<specific_attr_iterator<T>> specific_attrs() const {
560 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
561 }
562
563 template <typename T>
566 }
567
568 template <typename T>
571 }
572
573 template<typename T> T *getAttr() const {
574 return hasAttrs() ? getSpecificAttr<T>(getAttrs()) : nullptr;
575 }
576
577 template<typename T> bool hasAttr() const {
578 return hasAttrs() && hasSpecificAttr<T>(getAttrs());
579 }
580
581 /// getMaxAlignment - return the maximum alignment specified by attributes
582 /// on this decl, 0 if there are none.
583 unsigned getMaxAlignment() const;
584
585 /// setInvalidDecl - Indicates the Decl had a semantic error. This
586 /// allows for graceful error recovery.
587 void setInvalidDecl(bool Invalid = true);
588 bool isInvalidDecl() const { return (bool) InvalidDecl; }
589
590 /// isImplicit - Indicates whether the declaration was implicitly
591 /// generated by the implementation. If false, this declaration
592 /// was written explicitly in the source code.
593 bool isImplicit() const { return Implicit; }
594 void setImplicit(bool I = true) { Implicit = I; }
595
596 /// Whether *any* (re-)declaration of the entity was used, meaning that
597 /// a definition is required.
598 ///
599 /// \param CheckUsedAttr When true, also consider the "used" attribute
600 /// (in addition to the "used" bit set by \c setUsed()) when determining
601 /// whether the function is used.
602 bool isUsed(bool CheckUsedAttr = true) const;
603
604 /// Set whether the declaration is used, in the sense of odr-use.
605 ///
606 /// This should only be used immediately after creating a declaration.
607 /// It intentionally doesn't notify any listeners.
608 void setIsUsed() { getCanonicalDecl()->Used = true; }
609
610 /// Mark the declaration used, in the sense of odr-use.
611 ///
612 /// This notifies any mutation listeners in addition to setting a bit
613 /// indicating the declaration is used.
614 void markUsed(ASTContext &C);
615
616 /// Whether any declaration of this entity was referenced.
617 bool isReferenced() const;
618
619 /// Whether this declaration was referenced. This should not be relied
620 /// upon for anything other than debugging.
621 bool isThisDeclarationReferenced() const { return Referenced; }
622
623 void setReferenced(bool R = true) { Referenced = R; }
624
625 /// When doing manipulations which might change the computed linkage,
626 /// such as changing the DeclContext after the declaration has already been
627 /// used, invalidating the cache will make sure its linkage will be
628 /// recomputed.
630
631 /// Whether this declaration is a top-level declaration (function,
632 /// global variable, etc.) that is lexically inside an objc container
633 /// definition.
635 return TopLevelDeclInObjCContainer;
636 }
637
639 TopLevelDeclInObjCContainer = V;
640 }
641
642 /// Looks on this and related declarations for an applicable
643 /// external source symbol attribute.
644 ExternalSourceSymbolAttr *getExternalSourceSymbolAttr() const;
645
646 /// Whether this declaration was marked as being private to the
647 /// module in which it was defined.
648 bool isModulePrivate() const {
650 }
651
652 /// Whether this declaration was a local declaration to a C++20
653 /// named module.
654 bool isModuleLocal() const;
655
656 /// Whether this declaration was exported in a lexical context.
657 /// e.g.:
658 ///
659 /// export namespace A {
660 /// void f1(); // isInExportDeclContext() == true
661 /// }
662 /// void A::f1(); // isInExportDeclContext() == false
663 ///
664 /// namespace B {
665 /// void f2(); // isInExportDeclContext() == false
666 /// }
667 /// export void B::f2(); // isInExportDeclContext() == true
668 bool isInExportDeclContext() const;
669
672 }
673
674 /// Whether this declaration comes from another module unit.
675 bool isInAnotherModuleUnit() const;
676
677 /// Whether this declaration comes from the same module unit being compiled.
678 bool isInCurrentModuleUnit() const;
679
680 /// Whether the definition of the declaration should be emitted in external
681 /// sources.
682 bool shouldEmitInExternalSource() const;
683
684 /// Whether this declaration comes from explicit global module.
685 bool isFromExplicitGlobalModule() const;
686
687 /// Whether this declaration comes from global module.
688 bool isFromGlobalModule() const;
689
690 /// Whether this declaration comes from a named module.
691 bool isInNamedModule() const;
692
693 /// Whether this declaration comes from a header unit.
694 bool isFromHeaderUnit() const;
695
696 /// Return true if this declaration has an attribute which acts as
697 /// definition of the entity, such as 'alias' or 'ifunc'.
698 bool hasDefiningAttr() const;
699
700 /// Return this declaration's defining attribute if it has one.
701 const Attr *getDefiningAttr() const;
702
703protected:
704 /// Specify that this declaration was marked as being private
705 /// to the module in which it was defined.
707 // The module-private specifier has no effect on unowned declarations.
708 // FIXME: We should track this in some way for source fidelity.
710 return;
712 }
713
714public:
715 /// Set the FromASTFile flag. This indicates that this declaration
716 /// was deserialized and not parsed from source code and enables
717 /// features such as module ownership information.
719 FromASTFile = true;
720 }
721
722 /// Set the owning module ID. This may only be called for
723 /// deserialized Decls.
724 void setOwningModuleID(unsigned ID);
725
726public:
727 /// Determine the availability of the given declaration.
728 ///
729 /// This routine will determine the most restrictive availability of
730 /// the given declaration (e.g., preferring 'unavailable' to
731 /// 'deprecated').
732 ///
733 /// \param Message If non-NULL and the result is not \c
734 /// AR_Available, will be set to a (possibly empty) message
735 /// describing why the declaration has not been introduced, is
736 /// deprecated, or is unavailable.
737 ///
738 /// \param EnclosingVersion The version to compare with. If empty, assume the
739 /// deployment target version.
740 ///
741 /// \param RealizedPlatform If non-NULL and the availability result is found
742 /// in an available attribute it will set to the platform which is written in
743 /// the available attribute.
745 getAvailability(std::string *Message = nullptr,
746 VersionTuple EnclosingVersion = VersionTuple(),
747 StringRef *RealizedPlatform = nullptr) const;
748
749 /// Retrieve the version of the target platform in which this
750 /// declaration was introduced.
751 ///
752 /// \returns An empty version tuple if this declaration has no 'introduced'
753 /// availability attributes, or the version tuple that's specified in the
754 /// attribute otherwise.
755 VersionTuple getVersionIntroduced() const;
756
757 /// Determine whether this declaration is marked 'deprecated'.
758 ///
759 /// \param Message If non-NULL and the declaration is deprecated,
760 /// this will be set to the message describing why the declaration
761 /// was deprecated (which may be empty).
762 bool isDeprecated(std::string *Message = nullptr) const {
763 return getAvailability(Message) == AR_Deprecated;
764 }
765
766 /// Determine whether this declaration is marked 'unavailable'.
767 ///
768 /// \param Message If non-NULL and the declaration is unavailable,
769 /// this will be set to the message describing why the declaration
770 /// was made unavailable (which may be empty).
771 bool isUnavailable(std::string *Message = nullptr) const {
772 return getAvailability(Message) == AR_Unavailable;
773 }
774
775 /// Determine whether this is a weak-imported symbol.
776 ///
777 /// Weak-imported symbols are typically marked with the
778 /// 'weak_import' attribute, but may also be marked with an
779 /// 'availability' attribute where we're targing a platform prior to
780 /// the introduction of this feature.
781 bool isWeakImported() const;
782
783 /// Determines whether this symbol can be weak-imported,
784 /// e.g., whether it would be well-formed to add the weak_import
785 /// attribute.
786 ///
787 /// \param IsDefinition Set to \c true to indicate that this
788 /// declaration cannot be weak-imported because it has a definition.
789 bool canBeWeakImported(bool &IsDefinition) const;
790
791 /// Determine whether this declaration came from an AST file (such as
792 /// a precompiled header or module) rather than having been parsed.
793 bool isFromASTFile() const { return FromASTFile; }
794
795 /// Retrieve the global declaration ID associated with this
796 /// declaration, which specifies where this Decl was loaded from.
798
799 /// Retrieve the global ID of the module that owns this particular
800 /// declaration.
801 unsigned getOwningModuleID() const;
802
803private:
804 Module *getOwningModuleSlow() const;
805
806protected:
807 bool hasLocalOwningModuleStorage() const;
808
809public:
810 /// Get the imported owning module, if this decl is from an imported
811 /// (non-local) module.
813 if (!isFromASTFile() || !hasOwningModule())
814 return nullptr;
815
816 return getOwningModuleSlow();
817 }
818
819 /// Get the local owning module, if known. Returns nullptr if owner is
820 /// not yet known or declaration is not from a module.
822 if (isFromASTFile() || !hasOwningModule())
823 return nullptr;
824
826 "owned local decl but no local module storage");
827 return reinterpret_cast<Module *const *>(this)[-1];
828 }
830 assert(!isFromASTFile() && hasOwningModule() &&
832 "should not have a cached owning module");
833 reinterpret_cast<Module **>(this)[-1] = M;
834 }
835
836 /// Is this declaration owned by some module?
837 bool hasOwningModule() const {
839 }
840
841 /// Get the module that owns this declaration (for visibility purposes).
844 }
845
846 /// Get the top level owning named module that owns this declaration if any.
847 /// \returns nullptr if the declaration is not owned by a named module.
849
850 /// Get the module that owns this declaration for linkage purposes.
851 /// There only ever is such a standard C++ module.
853
854 /// Determine whether this declaration is definitely visible to name lookup,
855 /// independent of whether the owning module is visible.
856 /// Note: The declaration may be visible even if this returns \c false if the
857 /// owning module is visible within the query context. This is a low-level
858 /// helper function; most code should be calling Sema::isVisible() instead.
861 }
862
863 bool isReachable() const {
864 return (int)getModuleOwnershipKind() <=
866 }
867
868 /// Set that this declaration is globally visible, even if it came from a
869 /// module that is not visible.
873 }
874
875 /// Get the kind of module ownership for this declaration.
877 return NextInContextAndBits.getInt();
878 }
879
880 /// Set whether this declaration is hidden from name lookup.
885 "no storage available for owning module for this declaration");
886 NextInContextAndBits.setInt(MOK);
887 }
888
889 unsigned getIdentifierNamespace() const {
890 return IdentifierNamespace;
891 }
892
893 bool isInIdentifierNamespace(unsigned NS) const {
894 return getIdentifierNamespace() & NS;
895 }
896
897 static unsigned getIdentifierNamespaceForKind(Kind DK);
898
901 }
902
903 static bool isTagIdentifierNamespace(unsigned NS) {
904 // TagDecls have Tag and Type set and may also have TagFriend.
905 return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
906 }
907
908 /// getLexicalDeclContext - The declaration context where this Decl was
909 /// lexically declared (LexicalDC). May be different from
910 /// getDeclContext() (SemanticDC).
911 /// e.g.:
912 ///
913 /// namespace A {
914 /// void f(); // SemanticDC == LexicalDC == 'namespace A'
915 /// }
916 /// void A::f(); // SemanticDC == namespace 'A'
917 /// // LexicalDC == global namespace
919 if (isInSemaDC())
920 return getSemanticDC();
921 return getMultipleDC()->LexicalDC;
922 }
924 return const_cast<Decl*>(this)->getLexicalDeclContext();
925 }
926
927 /// Determine whether this declaration is declared out of line (outside its
928 /// semantic context).
929 virtual bool isOutOfLine() const;
930
931 /// setDeclContext - Set both the semantic and lexical DeclContext
932 /// to DC.
933 void setDeclContext(DeclContext *DC);
934
936
937 /// Determine whether this declaration is a templated entity (whether it is
938 // within the scope of a template parameter).
939 bool isTemplated() const;
940
941 /// Determine the number of levels of template parameter surrounding this
942 /// declaration.
943 unsigned getTemplateDepth() const;
944
945 /// isDefinedOutsideFunctionOrMethod - This predicate returns true if this
946 /// scoped decl is defined outside the current function or method. This is
947 /// roughly global variables and functions, but also handles enums (which
948 /// could be defined inside or outside a function etc).
950 return getParentFunctionOrMethod() == nullptr;
951 }
952
953 /// Determine whether a substitution into this declaration would occur as
954 /// part of a substitution into a dependent local scope. Such a substitution
955 /// transitively substitutes into all constructs nested within this
956 /// declaration.
957 ///
958 /// This recognizes non-defining declarations as well as members of local
959 /// classes and lambdas:
960 /// \code
961 /// template<typename T> void foo() { void bar(); }
962 /// template<typename T> void foo2() { class ABC { void bar(); }; }
963 /// template<typename T> inline int x = [](){ return 0; }();
964 /// \endcode
966
967 /// If this decl is defined inside a function/method/block it returns
968 /// the corresponding DeclContext, otherwise it returns null.
969 const DeclContext *
970 getParentFunctionOrMethod(bool LexicalParent = false) const;
971 DeclContext *getParentFunctionOrMethod(bool LexicalParent = false) {
972 return const_cast<DeclContext *>(
973 const_cast<const Decl *>(this)->getParentFunctionOrMethod(
974 LexicalParent));
975 }
976
977 /// Retrieves the "canonical" declaration of the given declaration.
978 virtual Decl *getCanonicalDecl() { return this; }
979 const Decl *getCanonicalDecl() const {
980 return const_cast<Decl*>(this)->getCanonicalDecl();
981 }
982
983 /// Whether this particular Decl is a canonical one.
984 bool isCanonicalDecl() const { return getCanonicalDecl() == this; }
985
986protected:
987 /// Returns the next redeclaration or itself if this is the only decl.
988 ///
989 /// Decl subclasses that can be redeclared should override this method so that
990 /// Decl::redecl_iterator can iterate over them.
991 virtual Decl *getNextRedeclarationImpl() { return this; }
992
993 /// Implementation of getPreviousDecl(), to be overridden by any
994 /// subclass that has a redeclaration chain.
995 virtual Decl *getPreviousDeclImpl() { return nullptr; }
996
997 /// Implementation of getMostRecentDecl(), to be overridden by any
998 /// subclass that has a redeclaration chain.
999 virtual Decl *getMostRecentDeclImpl() { return this; }
1000
1001public:
1002 /// Iterates through all the redeclarations of the same decl.
1004 /// Current - The current declaration.
1005 Decl *Current = nullptr;
1006 Decl *Starter;
1007
1008 public:
1009 using value_type = Decl *;
1010 using reference = const value_type &;
1011 using pointer = const value_type *;
1012 using iterator_category = std::forward_iterator_tag;
1013 using difference_type = std::ptrdiff_t;
1014
1015 redecl_iterator() = default;
1016 explicit redecl_iterator(Decl *C) : Current(C), Starter(C) {}
1017
1018 reference operator*() const { return Current; }
1019 value_type operator->() const { return Current; }
1020
1022 assert(Current && "Advancing while iterator has reached end");
1023 // Get either previous decl or latest decl.
1024 Decl *Next = Current->getNextRedeclarationImpl();
1025 assert(Next && "Should return next redeclaration or itself, never null!");
1026 Current = (Next != Starter) ? Next : nullptr;
1027 return *this;
1028 }
1029
1031 redecl_iterator tmp(*this);
1032 ++(*this);
1033 return tmp;
1034 }
1035
1037 return x.Current == y.Current;
1038 }
1039
1041 return x.Current != y.Current;
1042 }
1043 };
1044
1045 using redecl_range = llvm::iterator_range<redecl_iterator>;
1046
1047 /// Returns an iterator range for all the redeclarations of the same
1048 /// decl. It will iterate at least once (when this decl is the only one).
1051 }
1052
1054 return redecl_iterator(const_cast<Decl *>(this));
1055 }
1056
1058
1059 /// Retrieve the previous declaration that declares the same entity
1060 /// as this declaration, or NULL if there is no previous declaration.
1062
1063 /// Retrieve the previous declaration that declares the same entity
1064 /// as this declaration, or NULL if there is no previous declaration.
1065 const Decl *getPreviousDecl() const {
1066 return const_cast<Decl *>(this)->getPreviousDeclImpl();
1067 }
1068
1069 /// True if this is the first declaration in its redeclaration chain.
1070 bool isFirstDecl() const {
1071 return getPreviousDecl() == nullptr;
1072 }
1073
1074 /// Retrieve the most recent declaration that declares the same entity
1075 /// as this declaration (which may be this declaration).
1077
1078 /// Retrieve the most recent declaration that declares the same entity
1079 /// as this declaration (which may be this declaration).
1080 const Decl *getMostRecentDecl() const {
1081 return const_cast<Decl *>(this)->getMostRecentDeclImpl();
1082 }
1083
1084 /// getBody - If this Decl represents a declaration for a body of code,
1085 /// such as a function or method definition, this method returns the
1086 /// top-level Stmt* of that body. Otherwise this method returns null.
1087 virtual Stmt* getBody() const { return nullptr; }
1088
1089 /// Returns true if this \c Decl represents a declaration for a body of
1090 /// code, such as a function or method definition.
1091 /// Note that \c hasBody can also return true if any redeclaration of this
1092 /// \c Decl represents a declaration for a body of code.
1093 virtual bool hasBody() const { return getBody() != nullptr; }
1094
1095 /// getBodyRBrace - Gets the right brace of the body, if a body exists.
1096 /// This works whether the body is a CompoundStmt or a CXXTryStmt.
1098
1099 // global temp stats (until we have a per-module visitor)
1100 static void add(Kind k);
1101 static void EnableStatistics();
1102 static void PrintStats();
1103
1104 /// isTemplateParameter - Determines whether this declaration is a
1105 /// template parameter.
1106 bool isTemplateParameter() const;
1107
1108 /// isTemplateParameter - Determines whether this declaration is a
1109 /// template parameter pack.
1110 bool isTemplateParameterPack() const;
1111
1112 /// Whether this declaration is a parameter pack.
1113 bool isParameterPack() const;
1114
1115 /// returns true if this declaration is a template
1116 bool isTemplateDecl() const;
1117
1118 /// Whether this declaration is a function or function template.
1120 return (DeclKind >= Decl::firstFunction &&
1121 DeclKind <= Decl::lastFunction) ||
1122 DeclKind == FunctionTemplate;
1123 }
1124
1125 /// If this is a declaration that describes some template, this
1126 /// method returns that template declaration.
1127 ///
1128 /// Note that this returns nullptr for partial specializations, because they
1129 /// are not modeled as TemplateDecls. Use getDescribedTemplateParams to handle
1130 /// those cases.
1132
1133 /// If this is a declaration that describes some template or partial
1134 /// specialization, this returns the corresponding template parameter list.
1136
1137 /// Returns the function itself, or the templated function if this is a
1138 /// function template.
1139 FunctionDecl *getAsFunction() LLVM_READONLY;
1140
1142 return const_cast<Decl *>(this)->getAsFunction();
1143 }
1144
1145 /// Changes the namespace of this declaration to reflect that it's
1146 /// a function-local extern declaration.
1147 ///
1148 /// These declarations appear in the lexical context of the extern
1149 /// declaration, but in the semantic context of the enclosing namespace
1150 /// scope.
1152 Decl *Prev = getPreviousDecl();
1153 IdentifierNamespace &= ~IDNS_Ordinary;
1154
1155 // It's OK for the declaration to still have the "invisible friend" flag or
1156 // the "conflicts with tag declarations in this scope" flag for the outer
1157 // scope.
1158 assert((IdentifierNamespace & ~(IDNS_OrdinaryFriend | IDNS_Tag)) == 0 &&
1159 "namespace is not ordinary");
1160
1162 if (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary)
1164 }
1165
1166 /// Determine whether this is a block-scope declaration with linkage.
1167 /// This will either be a local variable declaration declared 'extern', or a
1168 /// local function declaration.
1169 bool isLocalExternDecl() const {
1171 }
1172
1173 /// Changes the namespace of this declaration to reflect that it's
1174 /// the object of a friend declaration.
1175 ///
1176 /// These declarations appear in the lexical context of the friending
1177 /// class, but in the semantic context of the actual entity. This property
1178 /// applies only to a specific decl object; other redeclarations of the
1179 /// same entity may not (and probably don't) share this property.
1180 void setObjectOfFriendDecl(bool PerformFriendInjection = false) {
1181 unsigned OldNS = IdentifierNamespace;
1182 assert((OldNS & (IDNS_Tag | IDNS_Ordinary |
1185 "namespace includes neither ordinary nor tag");
1186 assert(!(OldNS & ~(IDNS_Tag | IDNS_Ordinary | IDNS_Type |
1189 "namespace includes other than ordinary or tag");
1190
1191 Decl *Prev = getPreviousDecl();
1193
1194 if (OldNS & (IDNS_Tag | IDNS_TagFriend)) {
1196 if (PerformFriendInjection ||
1197 (Prev && Prev->getIdentifierNamespace() & IDNS_Tag))
1199 }
1200
1201 if (OldNS & (IDNS_Ordinary | IDNS_OrdinaryFriend |
1204 if (PerformFriendInjection ||
1205 (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary))
1207 }
1208 }
1209
1210 /// Clears the namespace of this declaration.
1211 ///
1212 /// This is useful if we want this declaration to be available for
1213 /// redeclaration lookup but otherwise hidden for ordinary name lookups.
1215
1217 FOK_None, ///< Not a friend object.
1218 FOK_Declared, ///< A friend of a previously-declared entity.
1219 FOK_Undeclared ///< A friend of a previously-undeclared entity.
1221
1222 /// Determines whether this declaration is the object of a
1223 /// friend declaration and, if so, what kind.
1224 ///
1225 /// There is currently no direct way to find the associated FriendDecl.
1227 unsigned mask =
1229 if (!mask) return FOK_None;
1231 : FOK_Undeclared);
1232 }
1233
1234 /// Specifies that this declaration is a C++ overloaded non-member.
1236 assert(getKind() == Function || getKind() == FunctionTemplate);
1238 "visible non-member operators should be in ordinary namespace");
1240 }
1241
1242 static bool classofKind(Kind K) { return true; }
1243 static DeclContext *castToDeclContext(const Decl *);
1244 static Decl *castFromDeclContext(const DeclContext *);
1245
1246 void print(raw_ostream &Out, unsigned Indentation = 0,
1247 bool PrintInstantiation = false) const;
1248 void print(raw_ostream &Out, const PrintingPolicy &Policy,
1249 unsigned Indentation = 0, bool PrintInstantiation = false) const;
1250 static void printGroup(Decl** Begin, unsigned NumDecls,
1251 raw_ostream &Out, const PrintingPolicy &Policy,
1252 unsigned Indentation = 0);
1253
1254 // Debuggers don't usually respect default arguments.
1255 void dump() const;
1256
1257 // Same as dump(), but forces color printing.
1258 void dumpColor() const;
1259
1260 void dump(raw_ostream &Out, bool Deserialize = false,
1261 ASTDumpOutputFormat OutputFormat = ADOF_Default) const;
1262
1263 /// \return Unique reproducible object identifier
1264 int64_t getID() const;
1265
1266 /// Looks through the Decl's underlying type to extract a FunctionType
1267 /// when possible. This includes direct FunctionDecls, along with various
1268 /// function types and typedefs. This includes function pointers/references,
1269 /// member function pointers, and optionally if \p BlocksToo is set
1270 /// Objective-C block pointers. Returns nullptr if the type underlying the
1271 /// Decl does not have a FunctionType.
1272 const FunctionType *getFunctionType(bool BlocksToo = true) const;
1273
1274 // Looks through the Decl's underlying type to determine if it's a
1275 // function pointer type.
1276 bool isFunctionPointerType() const;
1277
1278private:
1279 void setAttrsImpl(const AttrVec& Attrs, ASTContext &Ctx);
1280 void setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,
1281 ASTContext &Ctx);
1282
1283protected:
1285};
1286
1287/// Determine whether two declarations declare the same entity.
1288inline bool declaresSameEntity(const Decl *D1, const Decl *D2) {
1289 if (!D1 || !D2)
1290 return false;
1291
1292 if (D1 == D2)
1293 return true;
1294
1295 return D1->getCanonicalDecl() == D2->getCanonicalDecl();
1296}
1297
1298/// PrettyStackTraceDecl - If a crash occurs, indicate that it happened when
1299/// doing something to a specific decl.
1300class PrettyStackTraceDecl : public llvm::PrettyStackTraceEntry {
1301 const Decl *TheDecl;
1303 SourceManager &SM;
1304 const char *Message;
1305
1306public:
1308 SourceManager &sm, const char *Msg)
1309 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1310
1311 void print(raw_ostream &OS) const override;
1312};
1313} // namespace clang
1314
1315// Required to determine the layout of the PointerUnion<NamedDecl*> before
1316// seeing the NamedDecl definition being first used in DeclListNode::operator*.
1317namespace llvm {
1318 template <> struct PointerLikeTypeTraits<::clang::NamedDecl *> {
1319 static inline void *getAsVoidPointer(::clang::NamedDecl *P) { return P; }
1320 static inline ::clang::NamedDecl *getFromVoidPointer(void *P) {
1321 return static_cast<::clang::NamedDecl *>(P);
1322 }
1323 static constexpr int NumLowBitsAvailable = 3;
1324 };
1325}
1326
1327namespace clang {
1328/// A list storing NamedDecls in the lookup tables.
1330 friend class ASTContext; // allocate, deallocate nodes.
1331 friend class StoredDeclsList;
1332public:
1333 using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>;
1334 class iterator {
1336 friend class StoredDeclsList;
1337
1338 Decls Ptr;
1339 iterator(Decls Node) : Ptr(Node) { }
1340 public:
1343 using pointer = void;
1345 using iterator_category = std::forward_iterator_tag;
1346
1347 iterator() = default;
1348
1350 assert(Ptr && "dereferencing end() iterator");
1351 if (DeclListNode *CurNode = dyn_cast<DeclListNode *>(Ptr))
1352 return CurNode->D;
1353 return cast<NamedDecl *>(Ptr);
1354 }
1355 void operator->() const { } // Unsupported.
1356 bool operator==(const iterator &X) const { return Ptr == X.Ptr; }
1357 bool operator!=(const iterator &X) const { return Ptr != X.Ptr; }
1358 inline iterator &operator++() { // ++It
1359 assert(!Ptr.isNull() && "Advancing empty iterator");
1360
1361 if (DeclListNode *CurNode = dyn_cast<DeclListNode *>(Ptr))
1362 Ptr = CurNode->Rest;
1363 else
1364 Ptr = nullptr;
1365 return *this;
1366 }
1367 iterator operator++(int) { // It++
1368 iterator temp = *this;
1369 ++(*this);
1370 return temp;
1371 }
1372 // Enables the pattern for (iterator I =..., E = I.end(); I != E; ++I)
1373 iterator end() { return iterator(); }
1374 };
1375private:
1376 NamedDecl *D = nullptr;
1377 Decls Rest = nullptr;
1378 DeclListNode(NamedDecl *ND) : D(ND) {}
1379};
1380
1381/// The results of name lookup within a DeclContext.
1383 using Decls = DeclListNode::Decls;
1384
1385 /// When in collection form, this is what the Data pointer points to.
1386 Decls Result;
1387
1388public:
1390 DeclContextLookupResult(Decls Result) : Result(Result) {}
1391
1395
1396 iterator begin() { return iterator(Result); }
1397 iterator end() { return iterator(); }
1399 return const_cast<DeclContextLookupResult*>(this)->begin();
1400 }
1401 const_iterator end() const { return iterator(); }
1402
1403 bool empty() const { return Result.isNull(); }
1404 bool isSingleResult() const { return isa_and_present<NamedDecl *>(Result); }
1405 reference front() const { return *begin(); }
1406
1407 // Find the first declaration of the given type in the list. Note that this
1408 // is not in general the earliest-declared declaration, and should only be
1409 // used when it's not possible for there to be more than one match or where
1410 // it doesn't matter which one is found.
1411 template<class T> T *find_first() const {
1412 for (auto *D : *this)
1413 if (T *Decl = dyn_cast<T>(D))
1414 return Decl;
1415
1416 return nullptr;
1417 }
1418};
1419
1420/// Only used by CXXDeductionGuideDecl.
1421enum class DeductionCandidate : unsigned char {
1422 Normal,
1423 Copy,
1424 Aggregate,
1425};
1426
1427enum class RecordArgPassingKind;
1429enum class ObjCImplementationControl;
1430enum class LinkageSpecLanguageIDs;
1431
1432/// DeclContext - This is used only as base class of specific decl types that
1433/// can act as declaration contexts. These decls are (only the top classes
1434/// that directly derive from DeclContext are mentioned, not their subclasses):
1435///
1436/// TranslationUnitDecl
1437/// ExternCContext
1438/// NamespaceDecl
1439/// TagDecl
1440/// OMPDeclareReductionDecl
1441/// OMPDeclareMapperDecl
1442/// FunctionDecl
1443/// ObjCMethodDecl
1444/// ObjCContainerDecl
1445/// LinkageSpecDecl
1446/// ExportDecl
1447/// BlockDecl
1448/// CapturedDecl
1450 /// For makeDeclVisibleInContextImpl
1451 friend class ASTDeclReader;
1452 /// For checking the new bits in the Serialization part.
1453 friend class ASTDeclWriter;
1454 /// For reconcileExternalVisibleStorage, CreateStoredDeclsMap,
1455 /// hasNeedToReconcileExternalVisibleStorage
1456 friend class ExternalASTSource;
1457 /// For CreateStoredDeclsMap
1459 /// For hasNeedToReconcileExternalVisibleStorage,
1460 /// hasLazyLocalLexicalLookups, hasLazyExternalLexicalLookups
1461 friend class ASTWriter;
1462
1463protected:
1464 enum { NumOdrHashBits = 25 };
1465
1466 // We use uint64_t in the bit-fields below since some bit-fields
1467 // cross the unsigned boundary and this breaks the packing.
1468
1469 /// Stores the bits used by DeclContext.
1470 /// If modified NumDeclContextBit, the ctor of DeclContext and the accessor
1471 /// methods in DeclContext should be updated appropriately.
1473 friend class DeclContext;
1474 /// DeclKind - This indicates which class this is.
1475 LLVM_PREFERRED_TYPE(Decl::Kind)
1476 uint64_t DeclKind : 7;
1477
1478 /// Whether this declaration context also has some external
1479 /// storage that contains additional declarations that are lexically
1480 /// part of this context.
1481 LLVM_PREFERRED_TYPE(bool)
1482 mutable uint64_t ExternalLexicalStorage : 1;
1483
1484 /// Whether this declaration context also has some external
1485 /// storage that contains additional declarations that are visible
1486 /// in this context.
1487 LLVM_PREFERRED_TYPE(bool)
1488 mutable uint64_t ExternalVisibleStorage : 1;
1489
1490 /// Whether this declaration context has had externally visible
1491 /// storage added since the last lookup. In this case, \c LookupPtr's
1492 /// invariant may not hold and needs to be fixed before we perform
1493 /// another lookup.
1494 LLVM_PREFERRED_TYPE(bool)
1495 mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1496
1497 /// If \c true, this context may have local lexical declarations
1498 /// that are missing from the lookup table.
1499 LLVM_PREFERRED_TYPE(bool)
1500 mutable uint64_t HasLazyLocalLexicalLookups : 1;
1501
1502 /// If \c true, the external source may have lexical declarations
1503 /// that are missing from the lookup table.
1504 LLVM_PREFERRED_TYPE(bool)
1505 mutable uint64_t HasLazyExternalLexicalLookups : 1;
1506
1507 /// If \c true, lookups should only return identifier from
1508 /// DeclContext scope (for example TranslationUnit). Used in
1509 /// LookupQualifiedName()
1510 LLVM_PREFERRED_TYPE(bool)
1511 mutable uint64_t UseQualifiedLookup : 1;
1512 };
1513
1514 /// Number of bits in DeclContextBitfields.
1515 enum { NumDeclContextBits = 13 };
1516
1517 /// Stores the bits used by NamespaceDecl.
1518 /// If modified NumNamespaceDeclBits and the accessor
1519 /// methods in NamespaceDecl should be updated appropriately.
1521 friend class NamespaceDecl;
1522 /// For the bits in DeclContextBitfields
1523 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1524 uint64_t : NumDeclContextBits;
1525
1526 /// True if this is an inline namespace.
1527 LLVM_PREFERRED_TYPE(bool)
1528 uint64_t IsInline : 1;
1529
1530 /// True if this is a nested-namespace-definition.
1531 LLVM_PREFERRED_TYPE(bool)
1532 uint64_t IsNested : 1;
1533 };
1534
1535 /// Number of inherited and non-inherited bits in NamespaceDeclBitfields.
1537
1538 /// Stores the bits used by TagDecl.
1539 /// If modified NumTagDeclBits and the accessor
1540 /// methods in TagDecl should be updated appropriately.
1542 friend class TagDecl;
1543 /// For the bits in DeclContextBitfields
1544 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1545 uint64_t : NumDeclContextBits;
1546
1547 /// The TagKind enum.
1548 LLVM_PREFERRED_TYPE(TagTypeKind)
1549 uint64_t TagDeclKind : 3;
1550
1551 /// True if this is a definition ("struct foo {};"), false if it is a
1552 /// declaration ("struct foo;"). It is not considered a definition
1553 /// until the definition has been fully processed.
1554 LLVM_PREFERRED_TYPE(bool)
1555 uint64_t IsCompleteDefinition : 1;
1556
1557 /// True if this is currently being defined.
1558 LLVM_PREFERRED_TYPE(bool)
1559 uint64_t IsBeingDefined : 1;
1560
1561 /// True if this tag declaration is "embedded" (i.e., defined or declared
1562 /// for the very first time) in the syntax of a declarator.
1563 LLVM_PREFERRED_TYPE(bool)
1564 uint64_t IsEmbeddedInDeclarator : 1;
1565
1566 /// True if this tag is free standing, e.g. "struct foo;".
1567 LLVM_PREFERRED_TYPE(bool)
1568 uint64_t IsFreeStanding : 1;
1569
1570 /// Has the full definition of this type been required by a use somewhere in
1571 /// the TU.
1572 LLVM_PREFERRED_TYPE(bool)
1573 uint64_t IsCompleteDefinitionRequired : 1;
1574
1575 /// Whether this tag is a definition which was demoted due to
1576 /// a module merge.
1577 LLVM_PREFERRED_TYPE(bool)
1578 uint64_t IsThisDeclarationADemotedDefinition : 1;
1579 };
1580
1581 /// Number of inherited and non-inherited bits in TagDeclBitfields.
1583
1584 /// Stores the bits used by EnumDecl.
1585 /// If modified NumEnumDeclBit and the accessor
1586 /// methods in EnumDecl should be updated appropriately.
1588 friend class EnumDecl;
1589 /// For the bits in TagDeclBitfields.
1590 LLVM_PREFERRED_TYPE(TagDeclBitfields)
1591 uint64_t : NumTagDeclBits;
1592
1593 /// Width in bits required to store all the non-negative
1594 /// enumerators of this enum.
1595 uint64_t NumPositiveBits : 8;
1596
1597 /// Width in bits required to store all the negative
1598 /// enumerators of this enum.
1599 uint64_t NumNegativeBits : 8;
1600
1601 /// True if this tag declaration is a scoped enumeration. Only
1602 /// possible in C++11 mode.
1603 LLVM_PREFERRED_TYPE(bool)
1604 uint64_t IsScoped : 1;
1605
1606 /// If this tag declaration is a scoped enum,
1607 /// then this is true if the scoped enum was declared using the class
1608 /// tag, false if it was declared with the struct tag. No meaning is
1609 /// associated if this tag declaration is not a scoped enum.
1610 LLVM_PREFERRED_TYPE(bool)
1611 uint64_t IsScopedUsingClassTag : 1;
1612
1613 /// True if this is an enumeration with fixed underlying type. Only
1614 /// possible in C++11, Microsoft extensions, or Objective C mode.
1615 LLVM_PREFERRED_TYPE(bool)
1616 uint64_t IsFixed : 1;
1617
1618 /// True if a valid hash is stored in ODRHash.
1619 LLVM_PREFERRED_TYPE(bool)
1620 uint64_t HasODRHash : 1;
1621 };
1622
1623 /// Number of inherited and non-inherited bits in EnumDeclBitfields.
1625
1626 /// Stores the bits used by RecordDecl.
1627 /// If modified NumRecordDeclBits and the accessor
1628 /// methods in RecordDecl should be updated appropriately.
1630 friend class RecordDecl;
1631 /// For the bits in TagDeclBitfields.
1632 LLVM_PREFERRED_TYPE(TagDeclBitfields)
1633 uint64_t : NumTagDeclBits;
1634
1635 /// This is true if this struct ends with a flexible
1636 /// array member (e.g. int X[]) or if this union contains a struct that does.
1637 /// If so, this cannot be contained in arrays or other structs as a member.
1638 LLVM_PREFERRED_TYPE(bool)
1639 uint64_t HasFlexibleArrayMember : 1;
1640
1641 /// Whether this is the type of an anonymous struct or union.
1642 LLVM_PREFERRED_TYPE(bool)
1643 uint64_t AnonymousStructOrUnion : 1;
1644
1645 /// This is true if this struct has at least one member
1646 /// containing an Objective-C object pointer type.
1647 LLVM_PREFERRED_TYPE(bool)
1648 uint64_t HasObjectMember : 1;
1649
1650 /// This is true if struct has at least one member of
1651 /// 'volatile' type.
1652 LLVM_PREFERRED_TYPE(bool)
1653 uint64_t HasVolatileMember : 1;
1654
1655 /// Whether the field declarations of this record have been loaded
1656 /// from external storage. To avoid unnecessary deserialization of
1657 /// methods/nested types we allow deserialization of just the fields
1658 /// when needed.
1659 LLVM_PREFERRED_TYPE(bool)
1660 mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1661
1662 /// Basic properties of non-trivial C structs.
1663 LLVM_PREFERRED_TYPE(bool)
1664 uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1665 LLVM_PREFERRED_TYPE(bool)
1666 uint64_t NonTrivialToPrimitiveCopy : 1;
1667 LLVM_PREFERRED_TYPE(bool)
1668 uint64_t NonTrivialToPrimitiveDestroy : 1;
1669
1670 /// The following bits indicate whether this is or contains a C union that
1671 /// is non-trivial to default-initialize, destruct, or copy. These bits
1672 /// imply the associated basic non-triviality predicates declared above.
1673 LLVM_PREFERRED_TYPE(bool)
1674 uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
1675 LLVM_PREFERRED_TYPE(bool)
1676 uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
1677 LLVM_PREFERRED_TYPE(bool)
1678 uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
1679
1680 /// True if any field is marked as requiring explicit initialization with
1681 /// [[clang::require_explicit_initialization]].
1682 /// In C++, this is also set for types without a user-provided default
1683 /// constructor, and is propagated from any base classes and/or member
1684 /// variables whose types are aggregates.
1685 LLVM_PREFERRED_TYPE(bool)
1686 uint64_t HasUninitializedExplicitInitFields : 1;
1687
1688 /// Indicates whether this struct is destroyed in the callee.
1689 LLVM_PREFERRED_TYPE(bool)
1690 uint64_t ParamDestroyedInCallee : 1;
1691
1692 /// Represents the way this type is passed to a function.
1693 LLVM_PREFERRED_TYPE(RecordArgPassingKind)
1694 uint64_t ArgPassingRestrictions : 2;
1695
1696 /// Indicates whether this struct has had its field layout randomized.
1697 LLVM_PREFERRED_TYPE(bool)
1698 uint64_t IsRandomized : 1;
1699
1700 /// True if a valid hash is stored in ODRHash. This should shave off some
1701 /// extra storage and prevent CXXRecordDecl to store unused bits.
1702 uint64_t ODRHash : NumOdrHashBits;
1703 };
1704
1705 /// Number of inherited and non-inherited bits in RecordDeclBitfields.
1707
1708 /// Stores the bits used by OMPDeclareReductionDecl.
1709 /// If modified NumOMPDeclareReductionDeclBits and the accessor
1710 /// methods in OMPDeclareReductionDecl should be updated appropriately.
1713 /// For the bits in DeclContextBitfields
1714 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1715 uint64_t : NumDeclContextBits;
1716
1717 /// Kind of initializer,
1718 /// function call or omp_priv<init_expr> initialization.
1719 LLVM_PREFERRED_TYPE(OMPDeclareReductionInitKind)
1720 uint64_t InitializerKind : 2;
1721 };
1722
1723 /// Number of inherited and non-inherited bits in
1724 /// OMPDeclareReductionDeclBitfields.
1726
1727 /// Stores the bits used by FunctionDecl.
1728 /// If modified NumFunctionDeclBits and the accessor
1729 /// methods in FunctionDecl and CXXDeductionGuideDecl
1730 /// (for DeductionCandidateKind) should be updated appropriately.
1732 friend class FunctionDecl;
1733 /// For DeductionCandidateKind
1735 /// For the bits in DeclContextBitfields.
1736 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1737 uint64_t : NumDeclContextBits;
1738
1739 LLVM_PREFERRED_TYPE(StorageClass)
1740 uint64_t SClass : 3;
1741 LLVM_PREFERRED_TYPE(bool)
1742 uint64_t IsInline : 1;
1743 LLVM_PREFERRED_TYPE(bool)
1744 uint64_t IsInlineSpecified : 1;
1745
1746 LLVM_PREFERRED_TYPE(bool)
1747 uint64_t IsVirtualAsWritten : 1;
1748 LLVM_PREFERRED_TYPE(bool)
1749 uint64_t IsPureVirtual : 1;
1750 LLVM_PREFERRED_TYPE(bool)
1751 uint64_t HasInheritedPrototype : 1;
1752 LLVM_PREFERRED_TYPE(bool)
1753 uint64_t HasWrittenPrototype : 1;
1754 LLVM_PREFERRED_TYPE(bool)
1755 uint64_t IsDeleted : 1;
1756 /// Used by CXXMethodDecl
1757 LLVM_PREFERRED_TYPE(bool)
1758 uint64_t IsTrivial : 1;
1759
1760 /// This flag indicates whether this function is trivial for the purpose of
1761 /// calls. This is meaningful only when this function is a copy/move
1762 /// constructor or a destructor.
1763 LLVM_PREFERRED_TYPE(bool)
1764 uint64_t IsTrivialForCall : 1;
1765
1766 LLVM_PREFERRED_TYPE(bool)
1767 uint64_t IsDefaulted : 1;
1768 LLVM_PREFERRED_TYPE(bool)
1769 uint64_t IsExplicitlyDefaulted : 1;
1770 LLVM_PREFERRED_TYPE(bool)
1771 uint64_t HasDefaultedOrDeletedInfo : 1;
1772
1773 /// For member functions of complete types, whether this is an ineligible
1774 /// special member function or an unselected destructor. See
1775 /// [class.mem.special].
1776 LLVM_PREFERRED_TYPE(bool)
1777 uint64_t IsIneligibleOrNotSelected : 1;
1778
1779 LLVM_PREFERRED_TYPE(bool)
1780 uint64_t HasImplicitReturnZero : 1;
1781 LLVM_PREFERRED_TYPE(bool)
1782 uint64_t IsLateTemplateParsed : 1;
1783 LLVM_PREFERRED_TYPE(bool)
1784 uint64_t IsInstantiatedFromMemberTemplate : 1;
1785
1786 /// Kind of contexpr specifier as defined by ConstexprSpecKind.
1787 LLVM_PREFERRED_TYPE(ConstexprSpecKind)
1788 uint64_t ConstexprKind : 2;
1789 LLVM_PREFERRED_TYPE(bool)
1790 uint64_t BodyContainsImmediateEscalatingExpression : 1;
1791
1792 LLVM_PREFERRED_TYPE(bool)
1793 uint64_t InstantiationIsPending : 1;
1794
1795 /// Indicates if the function uses __try.
1796 LLVM_PREFERRED_TYPE(bool)
1797 uint64_t UsesSEHTry : 1;
1798
1799 /// Indicates if the function was a definition
1800 /// but its body was skipped.
1801 LLVM_PREFERRED_TYPE(bool)
1802 uint64_t HasSkippedBody : 1;
1803
1804 /// Indicates if the function declaration will
1805 /// have a body, once we're done parsing it.
1806 LLVM_PREFERRED_TYPE(bool)
1807 uint64_t WillHaveBody : 1;
1808
1809 /// Indicates that this function is a multiversioned
1810 /// function using attribute 'target'.
1811 LLVM_PREFERRED_TYPE(bool)
1812 uint64_t IsMultiVersion : 1;
1813
1814 /// Only used by CXXDeductionGuideDecl. Indicates the kind
1815 /// of the Deduction Guide that is implicitly generated
1816 /// (used during overload resolution).
1817 LLVM_PREFERRED_TYPE(DeductionCandidate)
1818 uint64_t DeductionCandidateKind : 2;
1819
1820 /// Store the ODRHash after first calculation.
1821 LLVM_PREFERRED_TYPE(bool)
1822 uint64_t HasODRHash : 1;
1823
1824 /// Indicates if the function uses Floating Point Constrained Intrinsics
1825 LLVM_PREFERRED_TYPE(bool)
1826 uint64_t UsesFPIntrin : 1;
1827
1828 // Indicates this function is a constrained friend, where the constraint
1829 // refers to an enclosing template for hte purposes of [temp.friend]p9.
1830 LLVM_PREFERRED_TYPE(bool)
1831 uint64_t FriendConstraintRefersToEnclosingTemplate : 1;
1832 };
1833
1834 /// Number of inherited and non-inherited bits in FunctionDeclBitfields.
1836
1837 /// Stores the bits used by CXXConstructorDecl. If modified
1838 /// NumCXXConstructorDeclBits and the accessor
1839 /// methods in CXXConstructorDecl should be updated appropriately.
1842 /// For the bits in FunctionDeclBitfields.
1843 LLVM_PREFERRED_TYPE(FunctionDeclBitfields)
1844 uint64_t : NumFunctionDeclBits;
1845
1846 /// 19 bits to fit in the remaining available space.
1847 /// Note that this makes CXXConstructorDeclBitfields take
1848 /// exactly 64 bits and thus the width of NumCtorInitializers
1849 /// will need to be shrunk if some bit is added to NumDeclContextBitfields,
1850 /// NumFunctionDeclBitfields or CXXConstructorDeclBitfields.
1851 uint64_t NumCtorInitializers : 16;
1852 LLVM_PREFERRED_TYPE(bool)
1853 uint64_t IsInheritingConstructor : 1;
1854
1855 /// Whether this constructor has a trail-allocated explicit specifier.
1856 LLVM_PREFERRED_TYPE(bool)
1857 uint64_t HasTrailingExplicitSpecifier : 1;
1858 /// If this constructor does't have a trail-allocated explicit specifier.
1859 /// Whether this constructor is explicit specified.
1860 LLVM_PREFERRED_TYPE(bool)
1861 uint64_t IsSimpleExplicit : 1;
1862 };
1863
1864 /// Number of inherited and non-inherited bits in CXXConstructorDeclBitfields.
1866
1867 /// Stores the bits used by ObjCMethodDecl.
1868 /// If modified NumObjCMethodDeclBits and the accessor
1869 /// methods in ObjCMethodDecl should be updated appropriately.
1871 friend class ObjCMethodDecl;
1872
1873 /// For the bits in DeclContextBitfields.
1874 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1875 uint64_t : NumDeclContextBits;
1876
1877 /// The conventional meaning of this method; an ObjCMethodFamily.
1878 /// This is not serialized; instead, it is computed on demand and
1879 /// cached.
1880 LLVM_PREFERRED_TYPE(ObjCMethodFamily)
1881 mutable uint64_t Family : ObjCMethodFamilyBitWidth;
1882
1883 /// instance (true) or class (false) method.
1884 LLVM_PREFERRED_TYPE(bool)
1885 uint64_t IsInstance : 1;
1886 LLVM_PREFERRED_TYPE(bool)
1887 uint64_t IsVariadic : 1;
1888
1889 /// True if this method is the getter or setter for an explicit property.
1890 LLVM_PREFERRED_TYPE(bool)
1891 uint64_t IsPropertyAccessor : 1;
1892
1893 /// True if this method is a synthesized property accessor stub.
1894 LLVM_PREFERRED_TYPE(bool)
1895 uint64_t IsSynthesizedAccessorStub : 1;
1896
1897 /// Method has a definition.
1898 LLVM_PREFERRED_TYPE(bool)
1899 uint64_t IsDefined : 1;
1900
1901 /// Method redeclaration in the same interface.
1902 LLVM_PREFERRED_TYPE(bool)
1903 uint64_t IsRedeclaration : 1;
1904
1905 /// Is redeclared in the same interface.
1906 LLVM_PREFERRED_TYPE(bool)
1907 mutable uint64_t HasRedeclaration : 1;
1908
1909 /// \@required/\@optional
1910 LLVM_PREFERRED_TYPE(ObjCImplementationControl)
1911 uint64_t DeclImplementation : 2;
1912
1913 /// in, inout, etc.
1914 LLVM_PREFERRED_TYPE(Decl::ObjCDeclQualifier)
1915 uint64_t objcDeclQualifier : 7;
1916
1917 /// Indicates whether this method has a related result type.
1918 LLVM_PREFERRED_TYPE(bool)
1919 uint64_t RelatedResultType : 1;
1920
1921 /// Whether the locations of the selector identifiers are in a
1922 /// "standard" position, a enum SelectorLocationsKind.
1923 LLVM_PREFERRED_TYPE(SelectorLocationsKind)
1924 uint64_t SelLocsKind : 2;
1925
1926 /// Whether this method overrides any other in the class hierarchy.
1927 ///
1928 /// A method is said to override any method in the class's
1929 /// base classes, its protocols, or its categories' protocols, that has
1930 /// the same selector and is of the same kind (class or instance).
1931 /// A method in an implementation is not considered as overriding the same
1932 /// method in the interface or its categories.
1933 LLVM_PREFERRED_TYPE(bool)
1934 uint64_t IsOverriding : 1;
1935
1936 /// Indicates if the method was a definition but its body was skipped.
1937 LLVM_PREFERRED_TYPE(bool)
1938 uint64_t HasSkippedBody : 1;
1939 };
1940
1941 /// Number of inherited and non-inherited bits in ObjCMethodDeclBitfields.
1943
1944 /// Stores the bits used by ObjCContainerDecl.
1945 /// If modified NumObjCContainerDeclBits and the accessor
1946 /// methods in ObjCContainerDecl should be updated appropriately.
1948 friend class ObjCContainerDecl;
1949 /// For the bits in DeclContextBitfields
1950 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1951 uint32_t : NumDeclContextBits;
1952
1953 // Not a bitfield but this saves space.
1954 // Note that ObjCContainerDeclBitfields is full.
1955 SourceLocation AtStart;
1956 };
1957
1958 /// Number of inherited and non-inherited bits in ObjCContainerDeclBitfields.
1959 /// Note that here we rely on the fact that SourceLocation is 32 bits
1960 /// wide. We check this with the static_assert in the ctor of DeclContext.
1962
1963 /// Stores the bits used by LinkageSpecDecl.
1964 /// If modified NumLinkageSpecDeclBits and the accessor
1965 /// methods in LinkageSpecDecl should be updated appropriately.
1967 friend class LinkageSpecDecl;
1968 /// For the bits in DeclContextBitfields.
1969 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1970 uint64_t : NumDeclContextBits;
1971
1972 /// The language for this linkage specification.
1973 LLVM_PREFERRED_TYPE(LinkageSpecLanguageIDs)
1974 uint64_t Language : 3;
1975
1976 /// True if this linkage spec has braces.
1977 /// This is needed so that hasBraces() returns the correct result while the
1978 /// linkage spec body is being parsed. Once RBraceLoc has been set this is
1979 /// not used, so it doesn't need to be serialized.
1980 LLVM_PREFERRED_TYPE(bool)
1981 uint64_t HasBraces : 1;
1982 };
1983
1984 /// Number of inherited and non-inherited bits in LinkageSpecDeclBitfields.
1986
1987 /// Stores the bits used by BlockDecl.
1988 /// If modified NumBlockDeclBits and the accessor
1989 /// methods in BlockDecl should be updated appropriately.
1991 friend class BlockDecl;
1992 /// For the bits in DeclContextBitfields.
1993 LLVM_PREFERRED_TYPE(DeclContextBitfields)
1994 uint64_t : NumDeclContextBits;
1995
1996 LLVM_PREFERRED_TYPE(bool)
1997 uint64_t IsVariadic : 1;
1998 LLVM_PREFERRED_TYPE(bool)
1999 uint64_t CapturesCXXThis : 1;
2000 LLVM_PREFERRED_TYPE(bool)
2001 uint64_t BlockMissingReturnType : 1;
2002 LLVM_PREFERRED_TYPE(bool)
2003 uint64_t IsConversionFromLambda : 1;
2004
2005 /// A bit that indicates this block is passed directly to a function as a
2006 /// non-escaping parameter.
2007 LLVM_PREFERRED_TYPE(bool)
2008 uint64_t DoesNotEscape : 1;
2009
2010 /// A bit that indicates whether it's possible to avoid coying this block to
2011 /// the heap when it initializes or is assigned to a local variable with
2012 /// automatic storage.
2013 LLVM_PREFERRED_TYPE(bool)
2014 uint64_t CanAvoidCopyToHeap : 1;
2015 };
2016
2017 /// Number of inherited and non-inherited bits in BlockDeclBitfields.
2019
2020 /// Pointer to the data structure used to lookup declarations
2021 /// within this context (or a DependentStoredDeclsMap if this is a
2022 /// dependent context). We maintain the invariant that, if the map
2023 /// contains an entry for a DeclarationName (and we haven't lazily
2024 /// omitted anything), then it contains all relevant entries for that
2025 /// name (modulo the hasExternalDecls() flag).
2026 mutable StoredDeclsMap *LookupPtr = nullptr;
2027
2028protected:
2029 /// This anonymous union stores the bits belonging to DeclContext and classes
2030 /// deriving from it. The goal is to use otherwise wasted
2031 /// space in DeclContext to store data belonging to derived classes.
2032 /// The space saved is especially significient when pointers are aligned
2033 /// to 8 bytes. In this case due to alignment requirements we have a
2034 /// little less than 8 bytes free in DeclContext which we can use.
2035 /// We check that none of the classes in this union is larger than
2036 /// 8 bytes with static_asserts in the ctor of DeclContext.
2037 union {
2050
2051 static_assert(sizeof(DeclContextBitfields) <= 8,
2052 "DeclContextBitfields is larger than 8 bytes!");
2053 static_assert(sizeof(NamespaceDeclBitfields) <= 8,
2054 "NamespaceDeclBitfields is larger than 8 bytes!");
2055 static_assert(sizeof(TagDeclBitfields) <= 8,
2056 "TagDeclBitfields is larger than 8 bytes!");
2057 static_assert(sizeof(EnumDeclBitfields) <= 8,
2058 "EnumDeclBitfields is larger than 8 bytes!");
2059 static_assert(sizeof(RecordDeclBitfields) <= 8,
2060 "RecordDeclBitfields is larger than 8 bytes!");
2061 static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8,
2062 "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
2063 static_assert(sizeof(FunctionDeclBitfields) <= 8,
2064 "FunctionDeclBitfields is larger than 8 bytes!");
2065 static_assert(sizeof(CXXConstructorDeclBitfields) <= 8,
2066 "CXXConstructorDeclBitfields is larger than 8 bytes!");
2067 static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
2068 "ObjCMethodDeclBitfields is larger than 8 bytes!");
2069 static_assert(sizeof(ObjCContainerDeclBitfields) <= 8,
2070 "ObjCContainerDeclBitfields is larger than 8 bytes!");
2071 static_assert(sizeof(LinkageSpecDeclBitfields) <= 8,
2072 "LinkageSpecDeclBitfields is larger than 8 bytes!");
2073 static_assert(sizeof(BlockDeclBitfields) <= 8,
2074 "BlockDeclBitfields is larger than 8 bytes!");
2075 };
2076
2077 /// FirstDecl - The first declaration stored within this declaration
2078 /// context.
2079 mutable Decl *FirstDecl = nullptr;
2080
2081 /// LastDecl - The last declaration stored within this declaration
2082 /// context. FIXME: We could probably cache this value somewhere
2083 /// outside of the DeclContext, to reduce the size of DeclContext by
2084 /// another pointer.
2085 mutable Decl *LastDecl = nullptr;
2086
2087 /// Build up a chain of declarations.
2088 ///
2089 /// \returns the first/last pair of declarations.
2090 static std::pair<Decl *, Decl *>
2091 BuildDeclChain(ArrayRef<Decl*> Decls, bool FieldsAlreadyLoaded);
2092
2094
2095public:
2097
2098 // For use when debugging; hasValidDeclKind() will always return true for
2099 // a correctly constructed object within its lifetime.
2100 bool hasValidDeclKind() const;
2101
2103 return static_cast<Decl::Kind>(DeclContextBits.DeclKind);
2104 }
2105
2106 const char *getDeclKindName() const;
2107
2108 /// getParent - Returns the containing DeclContext.
2110 return cast<Decl>(this)->getDeclContext();
2111 }
2112 const DeclContext *getParent() const {
2113 return const_cast<DeclContext*>(this)->getParent();
2114 }
2115
2116 /// getLexicalParent - Returns the containing lexical DeclContext. May be
2117 /// different from getParent, e.g.:
2118 ///
2119 /// namespace A {
2120 /// struct S;
2121 /// }
2122 /// struct A::S {}; // getParent() == namespace 'A'
2123 /// // getLexicalParent() == translation unit
2124 ///
2126 return cast<Decl>(this)->getLexicalDeclContext();
2127 }
2129 return const_cast<DeclContext*>(this)->getLexicalParent();
2130 }
2131
2133
2135 return const_cast<DeclContext*>(this)->getLookupParent();
2136 }
2137
2139 return cast<Decl>(this)->getASTContext();
2140 }
2141
2142 bool isClosure() const { return getDeclKind() == Decl::Block; }
2143
2144 /// Return this DeclContext if it is a BlockDecl. Otherwise, return the
2145 /// innermost enclosing BlockDecl or null if there are no enclosing blocks.
2146 const BlockDecl *getInnermostBlockDecl() const;
2147
2148 bool isObjCContainer() const {
2149 switch (getDeclKind()) {
2150 case Decl::ObjCCategory:
2151 case Decl::ObjCCategoryImpl:
2152 case Decl::ObjCImplementation:
2153 case Decl::ObjCInterface:
2154 case Decl::ObjCProtocol:
2155 return true;
2156 default:
2157 return false;
2158 }
2159 }
2160
2161 bool isFunctionOrMethod() const {
2162 switch (getDeclKind()) {
2163 case Decl::Block:
2164 case Decl::Captured:
2165 case Decl::ObjCMethod:
2166 case Decl::TopLevelStmt:
2167 return true;
2168 default:
2169 return getDeclKind() >= Decl::firstFunction &&
2170 getDeclKind() <= Decl::lastFunction;
2171 }
2172 }
2173
2174 /// Test whether the context supports looking up names.
2175 bool isLookupContext() const {
2176 return !isFunctionOrMethod() && getDeclKind() != Decl::LinkageSpec &&
2177 getDeclKind() != Decl::Export;
2178 }
2179
2180 bool isFileContext() const {
2181 return getDeclKind() == Decl::TranslationUnit ||
2182 getDeclKind() == Decl::Namespace;
2183 }
2184
2185 bool isTranslationUnit() const {
2186 return getDeclKind() == Decl::TranslationUnit;
2187 }
2188
2189 bool isRecord() const {
2190 return getDeclKind() >= Decl::firstRecord &&
2191 getDeclKind() <= Decl::lastRecord;
2192 }
2193
2194 bool isRequiresExprBody() const {
2195 return getDeclKind() == Decl::RequiresExprBody;
2196 }
2197
2198 bool isNamespace() const { return getDeclKind() == Decl::Namespace; }
2199
2200 bool isStdNamespace() const;
2201
2202 bool isInlineNamespace() const;
2203
2204 /// Determines whether this context is dependent on a
2205 /// template parameter.
2206 bool isDependentContext() const;
2207
2208 /// isTransparentContext - Determines whether this context is a
2209 /// "transparent" context, meaning that the members declared in this
2210 /// context are semantically declared in the nearest enclosing
2211 /// non-transparent (opaque) context but are lexically declared in
2212 /// this context. For example, consider the enumerators of an
2213 /// enumeration type:
2214 /// @code
2215 /// enum E {
2216 /// Val1
2217 /// };
2218 /// @endcode
2219 /// Here, E is a transparent context, so its enumerator (Val1) will
2220 /// appear (semantically) that it is in the same context of E.
2221 /// Examples of transparent contexts include: enumerations (except for
2222 /// C++0x scoped enums), C++ linkage specifications and export declaration.
2223 bool isTransparentContext() const;
2224
2225 /// Determines whether this context or some of its ancestors is a
2226 /// linkage specification context that specifies C linkage.
2227 bool isExternCContext() const;
2228
2229 /// Retrieve the nearest enclosing C linkage specification context.
2230 const LinkageSpecDecl *getExternCContext() const;
2231
2232 /// Determines whether this context or some of its ancestors is a
2233 /// linkage specification context that specifies C++ linkage.
2234 bool isExternCXXContext() const;
2235
2236 /// Determine whether this declaration context is equivalent
2237 /// to the declaration context DC.
2238 bool Equals(const DeclContext *DC) const {
2239 return DC && this->getPrimaryContext() == DC->getPrimaryContext();
2240 }
2241
2242 /// Determine whether this declaration context semantically encloses the
2243 /// declaration context DC.
2244 bool Encloses(const DeclContext *DC) const;
2245
2246 /// Determine whether this declaration context lexically encloses the
2247 /// declaration context DC.
2248 bool LexicallyEncloses(const DeclContext *DC) const;
2249
2250 /// Find the nearest non-closure ancestor of this context,
2251 /// i.e. the innermost semantic parent of this context which is not
2252 /// a closure. A context may be its own non-closure ancestor.
2255 return const_cast<DeclContext*>(this)->getNonClosureAncestor();
2256 }
2257
2258 // Retrieve the nearest context that is not a transparent context.
2261 return const_cast<DeclContext *>(this)->getNonTransparentContext();
2262 }
2263
2264 /// getPrimaryContext - There may be many different
2265 /// declarations of the same entity (including forward declarations
2266 /// of classes, multiple definitions of namespaces, etc.), each with
2267 /// a different set of declarations. This routine returns the
2268 /// "primary" DeclContext structure, which will contain the
2269 /// information needed to perform name lookup into this context.
2272 return const_cast<DeclContext*>(this)->getPrimaryContext();
2273 }
2274
2275 /// getRedeclContext - Retrieve the context in which an entity conflicts with
2276 /// other entities of the same name, or where it is a redeclaration if the
2277 /// two entities are compatible. This skips through transparent contexts.
2280 return const_cast<DeclContext *>(this)->getRedeclContext();
2281 }
2282
2283 /// Retrieve the nearest enclosing namespace context.
2286 return const_cast<DeclContext *>(this)->getEnclosingNamespaceContext();
2287 }
2288
2289 /// Retrieve the outermost lexically enclosing record context.
2292 return const_cast<DeclContext *>(this)->getOuterLexicalRecordContext();
2293 }
2294
2295 /// Test if this context is part of the enclosing namespace set of
2296 /// the context NS, as defined in C++0x [namespace.def]p9. If either context
2297 /// isn't a namespace, this is equivalent to Equals().
2298 ///
2299 /// The enclosing namespace set of a namespace is the namespace and, if it is
2300 /// inline, its enclosing namespace, recursively.
2301 bool InEnclosingNamespaceSetOf(const DeclContext *NS) const;
2302
2303 /// Collects all of the declaration contexts that are semantically
2304 /// connected to this declaration context.
2305 ///
2306 /// For declaration contexts that have multiple semantically connected but
2307 /// syntactically distinct contexts, such as C++ namespaces, this routine
2308 /// retrieves the complete set of such declaration contexts in source order.
2309 /// For example, given:
2310 ///
2311 /// \code
2312 /// namespace N {
2313 /// int x;
2314 /// }
2315 /// namespace N {
2316 /// int y;
2317 /// }
2318 /// \endcode
2319 ///
2320 /// The \c Contexts parameter will contain both definitions of N.
2321 ///
2322 /// \param Contexts Will be cleared and set to the set of declaration
2323 /// contexts that are semanticaly connected to this declaration context,
2324 /// in source order, including this context (which may be the only result,
2325 /// for non-namespace contexts).
2327
2328 /// decl_iterator - Iterates through the declarations stored
2329 /// within this context.
2331 /// Current - The current declaration.
2332 Decl *Current = nullptr;
2333
2334 public:
2335 using value_type = Decl *;
2336 using reference = const value_type &;
2337 using pointer = const value_type *;
2338 using iterator_category = std::forward_iterator_tag;
2339 using difference_type = std::ptrdiff_t;
2340
2341 decl_iterator() = default;
2342 explicit decl_iterator(Decl *C) : Current(C) {}
2343
2344 reference operator*() const { return Current; }
2345
2346 // This doesn't meet the iterator requirements, but it's convenient
2347 value_type operator->() const { return Current; }
2348
2350 Current = Current->getNextDeclInContext();
2351 return *this;
2352 }
2353
2355 decl_iterator tmp(*this);
2356 ++(*this);
2357 return tmp;
2358 }
2359
2361 return x.Current == y.Current;
2362 }
2363
2365 return x.Current != y.Current;
2366 }
2367 };
2368
2369 using decl_range = llvm::iterator_range<decl_iterator>;
2370
2371 /// decls_begin/decls_end - Iterate over the declarations stored in
2372 /// this context.
2374 decl_iterator decls_begin() const;
2376 bool decls_empty() const;
2377
2378 /// noload_decls_begin/end - Iterate over the declarations stored in this
2379 /// context that are currently loaded; don't attempt to retrieve anything
2380 /// from an external source.
2383 }
2386
2387 /// specific_decl_iterator - Iterates over a subrange of
2388 /// declarations stored in a DeclContext, providing only those that
2389 /// are of type SpecificDecl (or a class derived from it). This
2390 /// iterator is used, for example, to provide iteration over just
2391 /// the fields within a RecordDecl (with SpecificDecl = FieldDecl).
2392 template<typename SpecificDecl>
2394 /// Current - The current, underlying declaration iterator, which
2395 /// will either be NULL or will point to a declaration of
2396 /// type SpecificDecl.
2398
2399 /// SkipToNextDecl - Advances the current position up to the next
2400 /// declaration of type SpecificDecl that also meets the criteria
2401 /// required by Acceptable.
2402 void SkipToNextDecl() {
2403 while (*Current && !isa<SpecificDecl>(*Current))
2404 ++Current;
2405 }
2406
2407 public:
2408 using value_type = SpecificDecl *;
2409 // TODO: Add reference and pointer types (with some appropriate proxy type)
2410 // if we ever have a need for them.
2411 using reference = void;
2412 using pointer = void;
2414 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2415 using iterator_category = std::forward_iterator_tag;
2416
2418
2419 /// specific_decl_iterator - Construct a new iterator over a
2420 /// subset of the declarations the range [C,
2421 /// end-of-declarations). If A is non-NULL, it is a pointer to a
2422 /// member function of SpecificDecl that should return true for
2423 /// all of the SpecificDecl instances that will be in the subset
2424 /// of iterators. For example, if you want Objective-C instance
2425 /// methods, SpecificDecl will be ObjCMethodDecl and A will be
2426 /// &ObjCMethodDecl::isInstanceMethod.
2428 SkipToNextDecl();
2429 }
2430
2431 value_type operator*() const { return cast<SpecificDecl>(*Current); }
2432
2433 // This doesn't meet the iterator requirements, but it's convenient
2434 value_type operator->() const { return **this; }
2435
2437 ++Current;
2438 SkipToNextDecl();
2439 return *this;
2440 }
2441
2443 specific_decl_iterator tmp(*this);
2444 ++(*this);
2445 return tmp;
2446 }
2447
2449 const specific_decl_iterator& y) {
2450 return x.Current == y.Current;
2451 }
2452
2454 const specific_decl_iterator& y) {
2455 return x.Current != y.Current;
2456 }
2457 };
2458
2459 /// Iterates over a filtered subrange of declarations stored
2460 /// in a DeclContext.
2461 ///
2462 /// This iterator visits only those declarations that are of type
2463 /// SpecificDecl (or a class derived from it) and that meet some
2464 /// additional run-time criteria. This iterator is used, for
2465 /// example, to provide access to the instance methods within an
2466 /// Objective-C interface (with SpecificDecl = ObjCMethodDecl and
2467 /// Acceptable = ObjCMethodDecl::isInstanceMethod).
2468 template<typename SpecificDecl, bool (SpecificDecl::*Acceptable)() const>
2470 /// Current - The current, underlying declaration iterator, which
2471 /// will either be NULL or will point to a declaration of
2472 /// type SpecificDecl.
2474
2475 /// SkipToNextDecl - Advances the current position up to the next
2476 /// declaration of type SpecificDecl that also meets the criteria
2477 /// required by Acceptable.
2478 void SkipToNextDecl() {
2479 while (*Current &&
2480 (!isa<SpecificDecl>(*Current) ||
2481 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2482 ++Current;
2483 }
2484
2485 public:
2486 using value_type = SpecificDecl *;
2487 // TODO: Add reference and pointer types (with some appropriate proxy type)
2488 // if we ever have a need for them.
2489 using reference = void;
2490 using pointer = void;
2492 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2493 using iterator_category = std::forward_iterator_tag;
2494
2496
2497 /// filtered_decl_iterator - Construct a new iterator over a
2498 /// subset of the declarations the range [C,
2499 /// end-of-declarations). If A is non-NULL, it is a pointer to a
2500 /// member function of SpecificDecl that should return true for
2501 /// all of the SpecificDecl instances that will be in the subset
2502 /// of iterators. For example, if you want Objective-C instance
2503 /// methods, SpecificDecl will be ObjCMethodDecl and A will be
2504 /// &ObjCMethodDecl::isInstanceMethod.
2506 SkipToNextDecl();
2507 }
2508
2509 value_type operator*() const { return cast<SpecificDecl>(*Current); }
2510 value_type operator->() const { return cast<SpecificDecl>(*Current); }
2511
2513 ++Current;
2514 SkipToNextDecl();
2515 return *this;
2516 }
2517
2519 filtered_decl_iterator tmp(*this);
2520 ++(*this);
2521 return tmp;
2522 }
2523
2525 const filtered_decl_iterator& y) {
2526 return x.Current == y.Current;
2527 }
2528
2530 const filtered_decl_iterator& y) {
2531 return x.Current != y.Current;
2532 }
2533 };
2534
2535 /// Add the declaration D into this context.
2536 ///
2537 /// This routine should be invoked when the declaration D has first
2538 /// been declared, to place D into the context where it was
2539 /// (lexically) defined. Every declaration must be added to one
2540 /// (and only one!) context, where it can be visited via
2541 /// [decls_begin(), decls_end()). Once a declaration has been added
2542 /// to its lexical context, the corresponding DeclContext owns the
2543 /// declaration.
2544 ///
2545 /// If D is also a NamedDecl, it will be made visible within its
2546 /// semantic context via makeDeclVisibleInContext.
2547 void addDecl(Decl *D);
2548
2549 /// Add the declaration D into this context, but suppress
2550 /// searches for external declarations with the same name.
2551 ///
2552 /// Although analogous in function to addDecl, this removes an
2553 /// important check. This is only useful if the Decl is being
2554 /// added in response to an external search; in all other cases,
2555 /// addDecl() is the right function to use.
2556 /// See the ASTImporter for use cases.
2557 void addDeclInternal(Decl *D);
2558
2559 /// Add the declaration D to this context without modifying
2560 /// any lookup tables.
2561 ///
2562 /// This is useful for some operations in dependent contexts where
2563 /// the semantic context might not be dependent; this basically
2564 /// only happens with friends.
2565 void addHiddenDecl(Decl *D);
2566
2567 /// Removes a declaration from this context.
2568 void removeDecl(Decl *D);
2569
2570 /// Checks whether a declaration is in this context.
2571 bool containsDecl(Decl *D) const;
2572
2573 /// Checks whether a declaration is in this context.
2574 /// This also loads the Decls from the external source before the check.
2575 bool containsDeclAndLoad(Decl *D) const;
2576
2579
2580 /// lookup - Find the declarations (if any) with the given Name in
2581 /// this context. Returns a range of iterators that contains all of
2582 /// the declarations with this name, with object, function, member,
2583 /// and enumerator names preceding any tag name. Note that this
2584 /// routine will not look into parent contexts.
2586
2587 /// Find the declarations with the given name that are visible
2588 /// within this context; don't attempt to retrieve anything from an
2589 /// external source.
2591
2592 /// A simplistic name lookup mechanism that performs name lookup
2593 /// into this declaration context without consulting the external source.
2594 ///
2595 /// This function should almost never be used, because it subverts the
2596 /// usual relationship between a DeclContext and the external source.
2597 /// See the ASTImporter for the (few, but important) use cases.
2598 ///
2599 /// FIXME: This is very inefficient; replace uses of it with uses of
2600 /// noload_lookup.
2603
2604 /// Makes a declaration visible within this context.
2605 ///
2606 /// This routine makes the declaration D visible to name lookup
2607 /// within this context and, if this is a transparent context,
2608 /// within its parent contexts up to the first enclosing
2609 /// non-transparent context. Making a declaration visible within a
2610 /// context does not transfer ownership of a declaration, and a
2611 /// declaration can be visible in many contexts that aren't its
2612 /// lexical context.
2613 ///
2614 /// If D is a redeclaration of an existing declaration that is
2615 /// visible from this context, as determined by
2616 /// NamedDecl::declarationReplaces, the previous declaration will be
2617 /// replaced with D.
2619
2620 /// all_lookups_iterator - An iterator that provides a view over the results
2621 /// of looking up every possible name.
2623
2624 using lookups_range = llvm::iterator_range<all_lookups_iterator>;
2625
2626 lookups_range lookups() const;
2627 // Like lookups(), but avoids loading external declarations.
2628 // If PreserveInternalState, avoids building lookup data structures too.
2629 lookups_range noload_lookups(bool PreserveInternalState) const;
2630
2631 /// Iterators over all possible lookups within this context.
2634
2635 /// Iterators over all possible lookups within this context that are
2636 /// currently loaded; don't attempt to retrieve anything from an external
2637 /// source.
2640
2641 struct udir_iterator;
2642
2644 llvm::iterator_adaptor_base<udir_iterator, lookup_iterator,
2647
2650
2652 };
2653
2654 using udir_range = llvm::iterator_range<udir_iterator>;
2655
2657
2658 // These are all defined in DependentDiagnostic.h.
2659 class ddiag_iterator;
2660
2661 using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2662
2663 inline ddiag_range ddiags() const;
2664
2665 // Low-level accessors
2666
2667 /// Mark that there are external lexical declarations that we need
2668 /// to include in our lookup table (and that are not available as external
2669 /// visible lookups). These extra lookup results will be found by walking
2670 /// the lexical declarations of this context. This should be used only if
2671 /// setHasExternalLexicalStorage() has been called on any decl context for
2672 /// which this is the primary context.
2674 assert(this == getPrimaryContext() &&
2675 "should only be called on primary context");
2676 DeclContextBits.HasLazyExternalLexicalLookups = true;
2677 }
2678
2679 /// Retrieve the internal representation of the lookup structure.
2680 /// This may omit some names if we are lazily building the structure.
2682
2683 /// Ensure the lookup structure is fully-built and return it.
2685
2686 /// Whether this DeclContext has external storage containing
2687 /// additional declarations that are lexically in this context.
2689 return DeclContextBits.ExternalLexicalStorage;
2690 }
2691
2692 /// State whether this DeclContext has external storage for
2693 /// declarations lexically in this context.
2694 void setHasExternalLexicalStorage(bool ES = true) const {
2695 DeclContextBits.ExternalLexicalStorage = ES;
2696 }
2697
2698 /// Whether this DeclContext has external storage containing
2699 /// additional declarations that are visible in this context.
2701 return DeclContextBits.ExternalVisibleStorage;
2702 }
2703
2704 /// State whether this DeclContext has external storage for
2705 /// declarations visible in this context.
2706 void setHasExternalVisibleStorage(bool ES = true) const {
2707 DeclContextBits.ExternalVisibleStorage = ES;
2708 if (ES && LookupPtr)
2709 DeclContextBits.NeedToReconcileExternalVisibleStorage = true;
2710 }
2711
2712 /// Determine whether the given declaration is stored in the list of
2713 /// declarations lexically within this context.
2714 bool isDeclInLexicalTraversal(const Decl *D) const {
2715 return D && (D->NextInContextAndBits.getPointer() || D == FirstDecl ||
2716 D == LastDecl);
2717 }
2718
2719 void setUseQualifiedLookup(bool use = true) const {
2720 DeclContextBits.UseQualifiedLookup = use;
2721 }
2722
2724 return DeclContextBits.UseQualifiedLookup;
2725 }
2726
2727 static bool classof(const Decl *D);
2728 static bool classof(const DeclContext *D) { return true; }
2729
2730 void dumpAsDecl() const;
2731 void dumpAsDecl(const ASTContext *Ctx) const;
2732 void dumpDeclContext() const;
2733 void dumpLookups() const;
2734 void dumpLookups(llvm::raw_ostream &OS, bool DumpDecls = false,
2735 bool Deserialize = false) const;
2736
2737private:
2738 lookup_result lookupImpl(DeclarationName Name,
2739 const DeclContext *OriginalLookupDC) const;
2740
2741 /// Whether this declaration context has had externally visible
2742 /// storage added since the last lookup. In this case, \c LookupPtr's
2743 /// invariant may not hold and needs to be fixed before we perform
2744 /// another lookup.
2745 bool hasNeedToReconcileExternalVisibleStorage() const {
2746 return DeclContextBits.NeedToReconcileExternalVisibleStorage;
2747 }
2748
2749 /// State that this declaration context has had externally visible
2750 /// storage added since the last lookup. In this case, \c LookupPtr's
2751 /// invariant may not hold and needs to be fixed before we perform
2752 /// another lookup.
2753 void setNeedToReconcileExternalVisibleStorage(bool Need = true) const {
2754 DeclContextBits.NeedToReconcileExternalVisibleStorage = Need;
2755 }
2756
2757 /// If \c true, this context may have local lexical declarations
2758 /// that are missing from the lookup table.
2759 bool hasLazyLocalLexicalLookups() const {
2760 return DeclContextBits.HasLazyLocalLexicalLookups;
2761 }
2762
2763 /// If \c true, this context may have local lexical declarations
2764 /// that are missing from the lookup table.
2765 void setHasLazyLocalLexicalLookups(bool HasLLLL = true) const {
2766 DeclContextBits.HasLazyLocalLexicalLookups = HasLLLL;
2767 }
2768
2769 /// If \c true, the external source may have lexical declarations
2770 /// that are missing from the lookup table.
2771 bool hasLazyExternalLexicalLookups() const {
2772 return DeclContextBits.HasLazyExternalLexicalLookups;
2773 }
2774
2775 /// If \c true, the external source may have lexical declarations
2776 /// that are missing from the lookup table.
2777 void setHasLazyExternalLexicalLookups(bool HasLELL = true) const {
2778 DeclContextBits.HasLazyExternalLexicalLookups = HasLELL;
2779 }
2780
2781 void reconcileExternalVisibleStorage() const;
2782 bool LoadLexicalDeclsFromExternalStorage() const;
2783
2784 StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
2785
2786 void loadLazyLocalLexicalLookups();
2787 void buildLookupImpl(DeclContext *DCtx, bool Internal);
2788 void makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal,
2789 bool Rediscoverable);
2790 void makeDeclVisibleInContextImpl(NamedDecl *D, bool Internal);
2791};
2792
2793inline bool Decl::isTemplateParameter() const {
2794 return getKind() == TemplateTypeParm || getKind() == NonTypeTemplateParm ||
2795 getKind() == TemplateTemplateParm;
2796}
2797
2798// Specialization selected when ToTy is not a known subclass of DeclContext.
2799template <class ToTy,
2800 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2802 static const ToTy *doit(const DeclContext *Val) {
2803 return static_cast<const ToTy*>(Decl::castFromDeclContext(Val));
2804 }
2805
2806 static ToTy *doit(DeclContext *Val) {
2807 return static_cast<ToTy*>(Decl::castFromDeclContext(Val));
2808 }
2809};
2810
2811// Specialization selected when ToTy is a known subclass of DeclContext.
2812template <class ToTy>
2814 static const ToTy *doit(const DeclContext *Val) {
2815 return static_cast<const ToTy*>(Val);
2816 }
2817
2818 static ToTy *doit(DeclContext *Val) {
2819 return static_cast<ToTy*>(Val);
2820 }
2821};
2822
2823} // namespace clang
2824
2825namespace llvm {
2826
2827/// isa<T>(DeclContext*)
2828template <typename To>
2829struct isa_impl<To, ::clang::DeclContext> {
2830 static bool doit(const ::clang::DeclContext &Val) {
2831 return To::classofKind(Val.getDeclKind());
2832 }
2833};
2834
2835/// cast<T>(DeclContext*)
2836template<class ToTy>
2837struct cast_convert_val<ToTy,
2839 static const ToTy &doit(const ::clang::DeclContext &Val) {
2841 }
2842};
2843
2844template<class ToTy>
2845struct cast_convert_val<ToTy, ::clang::DeclContext, ::clang::DeclContext> {
2846 static ToTy &doit(::clang::DeclContext &Val) {
2848 }
2849};
2850
2851template<class ToTy>
2852struct cast_convert_val<ToTy,
2853 const ::clang::DeclContext*, const ::clang::DeclContext*> {
2854 static const ToTy *doit(const ::clang::DeclContext *Val) {
2855 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2856 }
2857};
2858
2859template<class ToTy>
2860struct cast_convert_val<ToTy, ::clang::DeclContext*, ::clang::DeclContext*> {
2861 static ToTy *doit(::clang::DeclContext *Val) {
2862 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2863 }
2864};
2865
2866/// Implement cast_convert_val for Decl -> DeclContext conversions.
2867template<class FromTy>
2868struct cast_convert_val< ::clang::DeclContext, FromTy, FromTy> {
2869 static ::clang::DeclContext &doit(const FromTy &Val) {
2870 return *FromTy::castToDeclContext(&Val);
2871 }
2872};
2873
2874template<class FromTy>
2875struct cast_convert_val< ::clang::DeclContext, FromTy*, FromTy*> {
2876 static ::clang::DeclContext *doit(const FromTy *Val) {
2877 return FromTy::castToDeclContext(Val);
2878 }
2879};
2880
2881template<class FromTy>
2882struct cast_convert_val< const ::clang::DeclContext, FromTy, FromTy> {
2883 static const ::clang::DeclContext &doit(const FromTy &Val) {
2884 return *FromTy::castToDeclContext(&Val);
2885 }
2886};
2887
2888template<class FromTy>
2889struct cast_convert_val< const ::clang::DeclContext, FromTy*, FromTy*> {
2890 static const ::clang::DeclContext *doit(const FromTy *Val) {
2891 return FromTy::castToDeclContext(Val);
2892 }
2893};
2894
2895} // namespace llvm
2896
2897#endif // LLVM_CLANG_AST_DECLBASE_H
#define V(N, I)
Definition: ASTContext.h:3597
NodeId Parent
Definition: ASTDiff.cpp:191
DynTypedNode Node
StringRef P
static char ID
Definition: Arena.cpp:183
const Decl * D
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
#define X(type, name)
Definition: Value.h:145
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
#define SM(sm)
Definition: OffloadArch.cpp:16
SourceLocation Loc
Definition: SemaObjC.cpp:754
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
SourceLocation Begin
__device__ int
__PTRDIFF_TYPE__ ptrdiff_t
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:188
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:429
Writes an AST file containing the contents of a translation unit.
Definition: ASTWriter.h:97
Attr - This represents one attribute.
Definition: Attr.h:44
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:4630
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2604
Represents a C++ deduction guide declaration.
Definition: DeclCXX.h:1979
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1382
reference front() const
Definition: DeclBase.h:1405
DeclContextLookupResult(Decls Result)
Definition: DeclBase.h:1390
const_iterator begin() const
Definition: DeclBase.h:1398
DeclListNode::iterator iterator
Definition: DeclBase.h:1392
const_iterator end() const
Definition: DeclBase.h:1401
Stores the bits used by BlockDecl.
Definition: DeclBase.h:1990
Stores the bits used by CXXConstructorDecl.
Definition: DeclBase.h:1840
Stores the bits used by DeclContext.
Definition: DeclBase.h:1472
Stores the bits used by EnumDecl.
Definition: DeclBase.h:1587
Stores the bits used by FunctionDecl.
Definition: DeclBase.h:1731
Stores the bits used by LinkageSpecDecl.
Definition: DeclBase.h:1966
Stores the bits used by NamespaceDecl.
Definition: DeclBase.h:1520
Stores the bits used by OMPDeclareReductionDecl.
Definition: DeclBase.h:1711
Stores the bits used by ObjCContainerDecl.
Definition: DeclBase.h:1947
Stores the bits used by ObjCMethodDecl.
Definition: DeclBase.h:1870
Stores the bits used by RecordDecl.
Definition: DeclBase.h:1629
Stores the bits used by TagDecl.
Definition: DeclBase.h:1541
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
Definition: DeclLookups.h:28
An iterator over the dependent diagnostics in a dependent context.
decl_iterator - Iterates through the declarations stored within this context.
Definition: DeclBase.h:2330
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2338
decl_iterator operator++(int)
Definition: DeclBase.h:2354
value_type operator->() const
Definition: DeclBase.h:2347
friend bool operator!=(decl_iterator x, decl_iterator y)
Definition: DeclBase.h:2364
friend bool operator==(decl_iterator x, decl_iterator y)
Definition: DeclBase.h:2360
decl_iterator & operator++()
Definition: DeclBase.h:2349
Iterates over a filtered subrange of declarations stored in a DeclContext.
Definition: DeclBase.h:2469
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2493
filtered_decl_iterator(DeclContext::decl_iterator C)
filtered_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
Definition: DeclBase.h:2505
friend bool operator==(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
Definition: DeclBase.h:2524
filtered_decl_iterator operator++(int)
Definition: DeclBase.h:2518
friend bool operator!=(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
Definition: DeclBase.h:2529
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
Definition: DeclBase.h:2492
filtered_decl_iterator & operator++()
Definition: DeclBase.h:2512
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
Definition: DeclBase.h:2393
specific_decl_iterator(DeclContext::decl_iterator C)
specific_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
Definition: DeclBase.h:2427
friend bool operator==(const specific_decl_iterator &x, const specific_decl_iterator &y)
Definition: DeclBase.h:2448
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:2415
specific_decl_iterator operator++(int)
Definition: DeclBase.h:2442
friend bool operator!=(const specific_decl_iterator &x, const specific_decl_iterator &y)
Definition: DeclBase.h:2453
specific_decl_iterator & operator++()
Definition: DeclBase.h:2436
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
Definition: DeclBase.h:2414
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1449
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Definition: DeclBase.h:2109
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
Definition: DeclBase.cpp:2174
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
Definition: DeclBase.h:2238
lookup_result::iterator lookup_iterator
Definition: DeclBase.h:2578
bool isRequiresExprBody() const
Definition: DeclBase.h:2194
void dumpAsDecl() const
Definition: ASTDumper.cpp:245
FunctionDeclBitfields FunctionDeclBits
Definition: DeclBase.h:2044
bool isFileContext() const
Definition: DeclBase.h:2180
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context.
Definition: DeclBase.h:2706
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
Definition: DeclBase.cpp:2077
all_lookups_iterator noload_lookups_begin() const
Iterators over all possible lookups within this context that are currently loaded; don't attempt to r...
void dumpLookups(llvm::raw_ostream &OS, bool DumpDecls=false, bool Deserialize=false) const
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
Definition: DeclBase.cpp:1550
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
Definition: DeclBase.cpp:1392
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
Definition: DeclBase.cpp:1271
bool isObjCContainer() const
Definition: DeclBase.h:2148
ObjCMethodDeclBitfields ObjCMethodDeclBits
Definition: DeclBase.h:2046
TagDeclBitfields TagDeclBits
Definition: DeclBase.h:2040
ASTContext & getParentASTContext() const
Definition: DeclBase.h:2138
lookups_range noload_lookups(bool PreserveInternalState) const
Definition: DeclLookups.h:89
const DeclContext * getParent() const
Definition: DeclBase.h:2112
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Definition: DeclBase.cpp:1424
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1358
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
Definition: DeclBase.cpp:2059
const DeclContext * getRedeclContext() const
Definition: DeclBase.h:2279
EnumDeclBitfields EnumDeclBits
Definition: DeclBase.h:2041
CXXConstructorDeclBitfields CXXConstructorDeclBits
Definition: DeclBase.h:2045
bool isClosure() const
Definition: DeclBase.h:2142
static bool classof(const DeclContext *D)
Definition: DeclBase.h:2728
const Decl * getNonClosureAncestor() const
Definition: DeclBase.h:2254
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
Definition: DeclBase.h:2125
bool isNamespace() const
Definition: DeclBase.h:2198
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1879
void dumpLookups() const
Definition: ASTDumper.cpp:270
@ NumOMPDeclareReductionDeclBits
Definition: DeclBase.h:1725
bool isLookupContext() const
Test whether the context supports looking up names.
Definition: DeclBase.h:2175
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
Definition: DeclBase.cpp:1325
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:2700
const DeclContext * getPrimaryContext() const
Definition: DeclBase.h:2271
ObjCContainerDeclBitfields ObjCContainerDeclBits
Definition: DeclBase.h:2047
const char * getDeclKindName() const
Definition: DeclBase.cpp:188
BlockDeclBitfields BlockDeclBits
Definition: DeclBase.h:2049
bool isTranslationUnit() const
Definition: DeclBase.h:2185
bool isRecord() const
Definition: DeclBase.h:2189
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context.
Definition: DeclBase.cpp:1536
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:2022
llvm::iterator_range< udir_iterator > udir_range
Definition: DeclBase.h:2654
all_lookups_iterator lookups_end() const
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
Definition: DeclBase.h:2673
RecordDeclBitfields RecordDeclBits
Definition: DeclBase.h:2042
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
Definition: DeclBase.h:2079
decl_iterator noload_decls_begin() const
Definition: DeclBase.h:2384
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
Definition: DeclBase.cpp:1801
lookups_range lookups() const
Definition: DeclLookups.h:75
const DeclContext * getLookupParent() const
Definition: DeclBase.h:2134
bool shouldUseQualifiedLookup() const
Definition: DeclBase.h:2723
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
Definition: DeclBase.cpp:1667
void removeDecl(Decl *D)
Removes a declaration from this context.
Definition: DeclBase.cpp:1712
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1793
llvm::iterator_range< decl_iterator > decl_range
Definition: DeclBase.h:2369
void dumpDeclContext() const
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
Definition: DeclBase.cpp:1816
decl_iterator decls_end() const
Definition: DeclBase.h:2375
bool hasValidDeclKind() const
Definition: DeclBase.cpp:179
bool isStdNamespace() const
Definition: DeclBase.cpp:1342
ddiag_range ddiags() const
llvm::iterator_adaptor_base< udir_iterator, lookup_iterator, typename lookup_iterator::iterator_category, UsingDirectiveDecl * > udir_iterator_base
Definition: DeclBase.h:2646
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Definition: DeclBase.cpp:1951
static bool classof(const Decl *D)
Definition: DeclBase.cpp:1289
const DeclContext * getNonTransparentContext() const
Definition: DeclBase.h:2260
const RecordDecl * getOuterLexicalRecordContext() const
Definition: DeclBase.h:2291
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
Definition: DeclBase.cpp:1662
llvm::iterator_range< DeclContext::ddiag_iterator > ddiag_range
Definition: DeclBase.h:2661
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:2688
void setUseQualifiedLookup(bool use=true) const
Definition: DeclBase.h:2719
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Definition: DeclBase.cpp:2040
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
Definition: DeclBase.h:2085
NamespaceDeclBitfields NamespaceDeclBits
Definition: DeclBase.h:2039
all_lookups_iterator lookups_begin() const
Iterators over all possible lookups within this context.
llvm::iterator_range< all_lookups_iterator > lookups_range
Definition: DeclBase.h:2624
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:2381
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1459
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
Definition: DeclBase.cpp:2048
const DeclContext * getEnclosingNamespaceContext() const
Definition: DeclBase.h:2285
bool decls_empty() const
Definition: DeclBase.cpp:1655
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2373
bool isInlineNamespace() const
Definition: DeclBase.cpp:1337
DeclContextBitfields DeclContextBits
Definition: DeclBase.h:2038
bool isFunctionOrMethod() const
Definition: DeclBase.h:2161
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context.
Definition: DeclBase.h:2694
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
Definition: DeclBase.cpp:1309
StoredDeclsMap * LookupPtr
Pointer to the data structure used to lookup declarations within this context (or a DependentStoredDe...
Definition: DeclBase.h:2026
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Definition: DeclBase.cpp:1409
all_lookups_iterator noload_lookups_end() const
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
Definition: DeclBase.cpp:1413
LinkageSpecDeclBitfields LinkageSpecDeclBits
Definition: DeclBase.h:2048
decl_iterator noload_decls_end() const
Definition: DeclBase.h:2385
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
Definition: DeclBase.h:2681
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically encloses the declaration context DC.
Definition: DeclBase.cpp:1428
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
Definition: DeclBase.cpp:1767
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
Definition: DeclBase.cpp:1983
OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits
Definition: DeclBase.h:2043
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
Definition: DeclBase.h:2714
Decl::Kind getDeclKind() const
Definition: DeclBase.h:2102
DeclContext * getNonTransparentContext()
Definition: DeclBase.cpp:1450
decl_iterator decls_begin() const
Definition: DeclBase.cpp:1649
bool LexicallyEncloses(const DeclContext *DC) const
Determine whether this declaration context lexically encloses the declaration context DC.
Definition: DeclBase.cpp:1439
const DeclContext * getLexicalParent() const
Definition: DeclBase.h:2128
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:1345
reference operator*() const
Definition: DeclBase.h:1349
bool operator==(const iterator &X) const
Definition: DeclBase.h:1356
bool operator!=(const iterator &X) const
Definition: DeclBase.h:1357
A list storing NamedDecls in the lookup tables.
Definition: DeclBase.h:1329
llvm::PointerUnion< NamedDecl *, DeclListNode * > Decls
Definition: DeclBase.h:1333
Iterates through all the redeclarations of the same decl.
Definition: DeclBase.h:1003
friend bool operator!=(redecl_iterator x, redecl_iterator y)
Definition: DeclBase.h:1040
value_type operator->() const
Definition: DeclBase.h:1019
redecl_iterator & operator++()
Definition: DeclBase.h:1021
redecl_iterator operator++(int)
Definition: DeclBase.h:1030
friend bool operator==(redecl_iterator x, redecl_iterator y)
Definition: DeclBase.h:1036
std::ptrdiff_t difference_type
Definition: DeclBase.h:1013
reference operator*() const
Definition: DeclBase.h:1018
std::forward_iterator_tag iterator_category
Definition: DeclBase.h:1012
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
Decl()=delete
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:1061
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1076
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
Definition: DeclBase.cpp:319
bool isInStdNamespace() const
Definition: DeclBase.cpp:427
unsigned CacheValidAndLinkage
If 0, we have not computed the linkage of this declaration.
Definition: DeclBase.h:348
bool isInCurrentModuleUnit() const
Whether this declaration comes from the same module unit being compiled.
Definition: DeclBase.cpp:1159
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:435
Decl(Decl &&)=delete
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:648
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
Definition: DeclBase.cpp:263
bool isTemplateDecl() const
returns true if this declaration is a template
Definition: DeclBase.cpp:259
static void add(Kind k)
Definition: DeclBase.cpp:226
Module * getTopLevelOwningNamedModule() const
Get the top level owning named module that owns this declaration if any.
Definition: DeclBase.cpp:130
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Definition: DeclBase.h:1226
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
Definition: DeclBase.h:1119
bool isModuleLocal() const
Whether this declaration was a local declaration to a C++20 named module.
Definition: DeclBase.cpp:1130
bool isFromGlobalModule() const
Whether this declaration comes from global module.
Definition: DeclBase.cpp:1180
T * getAttr() const
Definition: DeclBase.h:573
static bool isFlexibleArrayMemberLike(const ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
Definition: DeclBase.cpp:437
bool hasAttrs() const
Definition: DeclBase.h:518
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:524
void setOwningModuleID(unsigned ID)
Set the owning module ID.
Definition: DeclBase.cpp:123
void addAttr(Attr *A)
Definition: DeclBase.cpp:1022
attr_iterator attr_end() const
Definition: DeclBase.h:542
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:593
void setAttrs(const AttrVec &Attrs)
Definition: DeclBase.h:520
void dropAttrs()
Definition: DeclBase.h:546
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
Definition: DeclBase.h:771
bool hasLocalOwningModuleStorage() const
Definition: DeclBase.cpp:143
void dumpColor() const
Definition: ASTDumper.cpp:239
const Decl * getPreviousDecl() const
Retrieve the previous declaration that declares the same entity as this declaration,...
Definition: DeclBase.h:1065
bool isFunctionPointerType() const
Definition: DeclBase.cpp:1227
bool isInNamedModule() const
Whether this declaration comes from a named module.
Definition: DeclBase.cpp:1184
const TranslationUnitDecl * getTranslationUnitDecl() const
Definition: DeclBase.h:476
virtual ~Decl()
bool isReachable() const
Definition: DeclBase.h:863
ExternalSourceSymbolAttr * getExternalSourceSymbolAttr() const
Looks on this and related declarations for an applicable external source symbol attribute.
Definition: DeclBase.cpp:590
void setFromASTFile()
Set the FromASTFile flag.
Definition: DeclBase.h:718
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
Definition: DeclBase.h:1151
Decl(Kind DK, DeclContext *DC, SourceLocation L)
Definition: DeclBase.h:392
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
Definition: Decl.cpp:99
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
Definition: DeclBase.h:995
Decl(Kind DK, EmptyShell Empty)
Definition: DeclBase.h:402
llvm::iterator_range< redecl_iterator > redecl_range
Definition: DeclBase.h:1045
const Decl * getCanonicalDecl() const
Definition: DeclBase.h:979
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
Definition: DeclBase.cpp:848
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
Definition: DeclBase.h:876
bool isParameterPack() const
Whether this declaration is a parameter pack.
Definition: DeclBase.cpp:244
ASTMutationListener * getASTMutationListener() const
Definition: DeclBase.cpp:534
bool hasCachedLinkage() const
Definition: DeclBase.h:421
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
Definition: DeclBase.cpp:538
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
Definition: DeclBase.cpp:753
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:156
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
Definition: DeclBase.h:859
DeclContext * getParentFunctionOrMethod(bool LexicalParent=false)
Definition: DeclBase.h:971
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:89
void clearIdentifierNamespace()
Clears the namespace of this declaration.
Definition: DeclBase.h:1214
AttrVec::const_iterator attr_iterator
Definition: DeclBase.h:532
static unsigned getIdentifierNamespaceForKind(Kind DK)
Definition: DeclBase.cpp:867
void setTopLevelDeclInObjCContainer(bool V=true)
Definition: DeclBase.h:638
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
Definition: DeclBase.h:1087
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Definition: DeclBase.cpp:568
bool isInIdentifierNamespace(unsigned NS) const
Definition: DeclBase.h:893
bool isFileContextDecl() const
Definition: DeclBase.cpp:432
static Decl * castFromDeclContext(const DeclContext *)
Definition: DeclBase.cpp:1050
@ FOK_Undeclared
A friend of a previously-undeclared entity.
Definition: DeclBase.h:1219
@ FOK_None
Not a friend object.
Definition: DeclBase.h:1217
@ FOK_Declared
A friend of a previously-declared entity.
Definition: DeclBase.h:1218
Decl * getNextDeclInContext()
Definition: DeclBase.h:445
bool isInvisibleOutsideTheOwningModule() const
Definition: DeclBase.h:670
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
Definition: DeclBase.cpp:286
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
Definition: DeclBase.cpp:1121
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
Definition: DeclBase.cpp:1076
static bool isTagIdentifierNamespace(unsigned NS)
Definition: DeclBase.h:903
int64_t getID() const
Definition: DeclBase.cpp:1195
bool isReferenced() const
Whether any declaration of this entity was referenced.
Definition: DeclBase.cpp:578
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
Definition: DeclBase.cpp:1199
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:984
bool isInAnotherModuleUnit() const
Whether this declaration comes from another module unit.
Definition: DeclBase.cpp:1138
llvm::PointerIntPair< Decl *, 3, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
Definition: DeclBase.h:249
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
Definition: DeclBase.h:842
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
Definition: DeclBase.cpp:298
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Definition: DeclBase.h:1070
bool isFromExplicitGlobalModule() const
Whether this declaration comes from explicit global module.
Definition: DeclBase.cpp:1176
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Definition: DeclBase.cpp:251
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:812
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
Definition: DeclBase.cpp:819
void dropAttrs()
Definition: DeclBase.cpp:1015
static DeclContext * castToDeclContext(const Decl *)
Definition: DeclBase.cpp:1063
const DeclContext * getDeclContext() const
Definition: DeclBase.h:453
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
Definition: DeclBase.h:198
@ OBJC_TQ_Byref
Definition: DeclBase.h:204
@ OBJC_TQ_Oneway
Definition: DeclBase.h:205
@ OBJC_TQ_Bycopy
Definition: DeclBase.h:203
@ OBJC_TQ_None
Definition: DeclBase.h:199
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Definition: DeclBase.h:210
@ OBJC_TQ_Inout
Definition: DeclBase.h:201
void dump() const
Definition: ASTDumper.cpp:220
const TemplateParameterList * getDescribedTemplateParams() const
If this is a declaration that describes some template or partial specialization, this returns the cor...
Definition: DeclBase.cpp:276
void invalidateCachedLinkage()
When doing manipulations which might change the computed linkage, such as changing the DeclContext af...
Definition: DeclBase.h:629
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
Definition: DeclBase.h:1180
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:793
attr_iterator attr_begin() const
Definition: DeclBase.h:539
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
Definition: DeclBase.cpp:400
const Attr * getDefiningAttr() const
Return this declaration's defining attribute if it has one.
Definition: DeclBase.cpp:616
Linkage getCachedLinkage() const
Definition: DeclBase.h:413
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
Definition: DeclBase.h:2793
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
Definition: DeclBase.cpp:1239
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
Definition: DeclBase.h:1093
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
Definition: DeclBase.cpp:1267
bool isInvalidDecl() const
Definition: DeclBase.h:588
unsigned getIdentifierNamespace() const
Definition: DeclBase.h:889
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
Definition: DeclBase.h:340
const Decl * getMostRecentDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
Definition: DeclBase.h:1080
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
Definition: DeclBase.h:991
Decl & operator=(Decl &&)=delete
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
Definition: DeclBase.cpp:611
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
Definition: DeclBase.h:1169
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Definition: DeclBase.h:559
friend class CXXClassMemberWrapper
Definition: DeclBase.h:328
void setAccess(AccessSpecifier AS)
Definition: DeclBase.h:502
SourceLocation getLocation() const
Definition: DeclBase.h:439
redecl_iterator redecls_end() const
Definition: DeclBase.h:1057
const char * getDeclKindName() const
Definition: DeclBase.cpp:147
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Definition: DeclBase.h:115
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
Definition: DeclBase.h:168
@ IDNS_TagFriend
This declaration is a friend class.
Definition: DeclBase.h:157
@ IDNS_Ordinary
Ordinary names.
Definition: DeclBase.h:144
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
Definition: DeclBase.h:130
@ IDNS_OMPReduction
This declaration is an OpenMP user defined reduction construction.
Definition: DeclBase.h:178
@ IDNS_Label
Labels, declared with 'x:' and referenced with 'goto x'.
Definition: DeclBase.h:117
@ IDNS_Member
Members, declared with object declarations within tag definitions.
Definition: DeclBase.h:136
@ IDNS_OMPMapper
This declaration is an OpenMP user defined mapper.
Definition: DeclBase.h:181
@ IDNS_ObjCProtocol
Objective C @protocol.
Definition: DeclBase.h:147
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
Definition: DeclBase.h:140
@ IDNS_OrdinaryFriend
This declaration is a friend function.
Definition: DeclBase.h:152
@ IDNS_Using
This declaration is a using declaration.
Definition: DeclBase.h:163
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
Definition: DeclBase.h:175
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
Definition: DeclBase.h:125
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
Definition: DeclBase.h:762
AccessSpecifier getAccessUnsafe() const
Retrieve the access specifier for this declaration, even though it may not yet have been properly set...
Definition: DeclBase.h:514
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
Definition: DeclBase.cpp:234
void setLocalOwningModule(Module *M)
Definition: DeclBase.h:829
const DeclContext * getNonTransparentDeclContext() const
Definition: DeclBase.h:461
void setImplicit(bool I=true)
Definition: DeclBase.h:594
void setReferenced(bool R=true)
Definition: DeclBase.h:623
const DeclContext * getLexicalDeclContext() const
Definition: DeclBase.h:923
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
Definition: DeclBase.h:621
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: DeclBase.h:1049
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
Definition: DeclBase.h:608
unsigned Access
Access - Used by C++ decls for the access specifier.
Definition: DeclBase.h:336
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
Definition: DeclBase.h:634
void setLocation(SourceLocation L)
Definition: DeclBase.h:440
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
Definition: DeclBase.cpp:553
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
Definition: DeclBase.h:949
DeclContext * getDeclContext()
Definition: DeclBase.h:448
attr_range attrs() const
Definition: DeclBase.h:535
AccessSpecifier getAccess() const
Definition: DeclBase.h:507
const Decl * getNextDeclInContext() const
Definition: DeclBase.h:446
bool isInAnonymousNamespace() const
Definition: DeclBase.cpp:417
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:431
redecl_iterator redecls_begin() const
Definition: DeclBase.h:1053
static void EnableStatistics()
Definition: DeclBase.cpp:198
TranslationUnitDecl * getTranslationUnitDecl()
Definition: DeclBase.cpp:509
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
Definition: DeclBase.cpp:805
specific_attr_iterator< T > specific_attr_end() const
Definition: DeclBase.h:569
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
Definition: DeclBase.h:999
bool hasOwningModule() const
Is this declaration owned by some module?
Definition: DeclBase.h:837
Decl(const Decl &)=delete
void setCachedLinkage(Linkage L) const
Definition: DeclBase.h:417
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
Definition: DeclBase.h:706
bool isFromHeaderUnit() const
Whether this declaration comes from a header unit.
Definition: DeclBase.cpp:1188
void dropAttr()
Definition: DeclBase.h:556
static void PrintStats()
Definition: DeclBase.cpp:202
llvm::iterator_range< attr_iterator > attr_range
Definition: DeclBase.h:533
specific_attr_iterator< T > specific_attr_begin() const
Definition: DeclBase.h:564
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
AttrVec & getAttrs()
Definition: DeclBase.h:524
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
Definition: DeclBase.cpp:360
Module * getOwningModuleForLinkage() const
Get the module that owns this declaration for linkage purposes.
Definition: Decl.cpp:1636
bool hasTagIdentifierNamespace() const
Definition: DeclBase.h:899
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:918
bool hasAttr() const
Definition: DeclBase.h:577
friend class DeclContext
Definition: DeclBase.h:252
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
Definition: DeclBase.h:1235
void setLexicalDeclContext(DeclContext *DC)
Definition: DeclBase.cpp:364
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:978
ModuleOwnershipKind
The kind of ownership a declaration has, for visibility purposes.
Definition: DeclBase.h:216
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
@ Unowned
This declaration is not owned by a module.
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
@ Visible
This declaration has an owning module, but is globally visible (typically because its owning module i...
Kind getKind() const
Definition: DeclBase.h:442
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
Definition: DeclBase.h:881
Module * getLocalOwningModule() const
Get the local owning module, if known.
Definition: DeclBase.h:821
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
Definition: DeclBase.cpp:530
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:427
GlobalDeclID getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Definition: DeclBase.cpp:107
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
Definition: DeclBase.cpp:115
static bool classofKind(Kind K)
Definition: DeclBase.h:1242
bool shouldEmitInExternalSource() const
Whether the definition of the declaration should be emitted in external sources.
Definition: DeclBase.cpp:1168
Decl & operator=(const Decl &)=delete
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
Definition: DeclBase.h:870
const Decl * getNonClosureContext() const
Definition: DeclBase.h:471
The name of a declaration.
A dependently-generated diagnostic.
Represents an enum.
Definition: Decl.h:4000
Abstract interface for external sources of AST nodes.
Represents a function declaration or definition.
Definition: Decl.h:1999
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: TypeBase.h:4478
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:434
Represents a linkage specification.
Definition: DeclCXX.h:3009
Describes a module or submodule.
Definition: Module.h:144
This represents a decl that may have a name.
Definition: Decl.h:273
Represent a C++ namespace.
Definition: Decl.h:591
This represents '#pragma omp declare reduction ...' directive.
Definition: DeclOpenMP.h:177
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:948
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
Definition: DeclBase.h:1300
void print(raw_ostream &OS) const override
Definition: DeclBase.cpp:333
PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg)
Definition: DeclBase.h:1307
A (possibly-)qualified type.
Definition: TypeBase.h:937
Represents a struct/union/class.
Definition: Decl.h:4305
Provides common interface for the Decls that can be redeclared.
Definition: Redeclarable.h:84
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:85
An array of decls optimized for the common case of only containing one entry.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3710
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:396
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:74
The top declaration context.
Definition: Decl.h:104
Represents C++ using-directive.
Definition: DeclCXX.h:3090
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
Definition: AttrIterator.h:36
The JSON file list parser is used to communicate input to InstallAPI.
ASTDumpOutputFormat
Used to specify the format for printing AST dump information.
@ ADOF_Default
bool isa(CodeGen::Address addr)
Definition: Address.h:330
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
@ ObjCMethodFamilyBitWidth
ConstexprSpecKind
Define the kind of constexpr specifier.
Definition: Specifiers.h:35
LinkageSpecLanguageIDs
Represents the language in a linkage specification.
Definition: DeclCXX.h:3001
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:123
@ AS_none
Definition: Specifiers.h:127
OMPDeclareReductionInitKind
Definition: DeclOpenMP.h:161
StorageClass
Storage classes.
Definition: Specifiers.h:248
ObjCMethodFamily
A family of Objective-C methods.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
Definition: Linkage.h:24
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
TagTypeKind
The kind of a tag type.
Definition: TypeBase.h:5906
@ FunctionTemplate
The name was classified as a function template name.
AvailabilityResult
Captures the result of checking the availability of a declaration.
Definition: DeclBase.h:72
@ AR_NotYetIntroduced
Definition: DeclBase.h:74
@ AR_Available
Definition: DeclBase.h:73
@ AR_Deprecated
Definition: DeclBase.h:75
@ AR_Unavailable
Definition: DeclBase.h:76
ObjCImplementationControl
Definition: DeclObjC.h:118
RecordArgPassingKind
Enum that represents the different ways arguments are passed to and returned from function calls.
Definition: Decl.h:4282
const FunctionProtoType * T
DeductionCandidate
Only used by CXXDeductionGuideDecl.
Definition: DeclBase.h:1421
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1288
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
#define true
Definition: stdbool.h:25
#define false
Definition: stdbool.h:26
UsingDirectiveDecl * operator*() const
Definition: DeclBase.cpp:2168
udir_iterator(lookup_iterator I)
Definition: DeclBase.h:2649
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
Definition: DeclBase.h:102
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
static ToTy * doit(DeclContext *Val)
Definition: DeclBase.h:2818
static const ToTy * doit(const DeclContext *Val)
Definition: DeclBase.h:2814
static const ToTy * doit(const DeclContext *Val)
Definition: DeclBase.h:2802
static ToTy * doit(DeclContext *Val)
Definition: DeclBase.h:2806
static void * getAsVoidPointer(::clang::NamedDecl *P)
Definition: DeclBase.h:1319
static inline ::clang::NamedDecl * getFromVoidPointer(void *P)
Definition: DeclBase.h:1320
::clang::DeclContext & doit(const FromTy &Val)
Definition: DeclBase.h:2869
::clang::DeclContext * doit(const FromTy *Val)
Definition: DeclBase.h:2876
static const ::clang::DeclContext & doit(const FromTy &Val)
Definition: DeclBase.h:2883
static const ::clang::DeclContext * doit(const FromTy *Val)
Definition: DeclBase.h:2890
static bool doit(const ::clang::DeclContext &Val)
Definition: DeclBase.h:2830