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