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