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