clang 10.0.0git

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
clang::DeclContext Class Reference

DeclContext - This is used only as base class of specific decl types that can act as declaration contexts. More...

`#include "clang/AST/DeclBase.h"`

Inheritance diagram for clang::DeclContext:
[legend]
Collaboration diagram for clang::DeclContext:
[legend]

## Classes
class | all_lookups_iterator
| all_lookups_iterator - An iterator that provides a view over the results of looking up every possible name. More...
class | ddiag_iterator
| An iterator over the dependent diagnostics in a dependent context. More...
class | decl_iterator
| decl_iterator - Iterates through the declarations stored within this context. More...
class | filtered_decl_iterator
| Iterates over a filtered subrange of declarations stored in a DeclContext. More...
class | specific_decl_iterator
| specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it). More...
struct | udir_iterator

## Public Types
using | decl_range = llvm::iterator_range< decl_iterator >
using | lookup_result = DeclContextLookupResult
using | lookup_iterator = lookup_result::iterator
using | lookups_range = llvm::iterator_range< all_lookups_iterator >
using | udir_iterator_base = llvm::iterator_adaptor_base< udir_iterator, lookup_iterator, std::random_access_iterator_tag, UsingDirectiveDecl * >
using | udir_range = llvm::iterator_range< udir_iterator >
using | ddiag_range = llvm::iterator_range< DeclContext::ddiag_iterator >

## Public Member Functions
| ~DeclContext ()
Decl::Kind | getDeclKind () const
const char * | getDeclKindName () const
DeclContext * | getParent ()
| getParent - Returns the containing DeclContext. More...
const DeclContext * | getParent () const
DeclContext * | getLexicalParent ()
| getLexicalParent - Returns the containing lexical DeclContext. More...
const DeclContext * | getLexicalParent () const
DeclContext * | getLookupParent ()
| Find the parent context of this context that will be used for unqualified name lookup. More...
const DeclContext * | getLookupParent () const
ASTContext & | getParentASTContext () const
bool | isClosure () const
const BlockDecl * | getInnermostBlockDecl () const
| Return this DeclContext if it is a BlockDecl. More...
bool | isObjCContainer () const
bool | isFunctionOrMethod () const
bool | isLookupContext () const
| Test whether the context supports looking up names. More...
bool | isFileContext () const
bool | isTranslationUnit () const
bool | isRecord () const
bool | isNamespace () const
bool | isStdNamespace () const
bool | isInlineNamespace () const
bool | isDependentContext () const
| Determines whether this context is dependent on a template parameter. More...
bool | isTransparentContext () const
| isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context. More...
bool | isExternCContext () const
| Determines whether this context or some of its ancestors is a linkage specification context that specifies C linkage. More...
const LinkageSpecDecl * | getExternCContext () const
| Retrieve the nearest enclosing C linkage specification context. More...
bool | isExternCXXContext () const
| Determines whether this context or some of its ancestors is a linkage specification context that specifies C++ linkage. More...
bool | Equals (const DeclContext *DC) const
| Determine whether this declaration context is equivalent to the declaration context DC. More...
bool | Encloses (const DeclContext *DC) const
| Determine whether this declaration context encloses the declaration context DC. More...
Decl * | getNonClosureAncestor ()
| Find the nearest non-closure ancestor of this context, i.e. More...
const Decl * | getNonClosureAncestor () const
DeclContext * | getPrimaryContext ()
| getPrimaryContext - There may be many different declarations of the same entity (including forward declarations of classes, multiple definitions of namespaces, etc.), each with a different set of declarations. More...
const DeclContext * | getPrimaryContext () const
DeclContext * | getRedeclContext ()
| getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same name, or where it is a redeclaration if the two entities are compatible. More...
const DeclContext * | getRedeclContext () const
DeclContext * | getEnclosingNamespaceContext ()
| Retrieve the nearest enclosing namespace context. More...
const DeclContext * | getEnclosingNamespaceContext () const
RecordDecl * | getOuterLexicalRecordContext ()
| Retrieve the outermost lexically enclosing record context. More...
const RecordDecl * | getOuterLexicalRecordContext () const
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 [namespace.def]p9. More...
void | collectAllContexts (SmallVectorImpl< DeclContext *> &Contexts)
| Collects all of the declaration contexts that are semantically connected to this declaration context. More...
decl_range | decls () const
| decls_begin/decls_end - Iterate over the declarations stored in this context. More...
decl_iterator | decls_begin () const
decl_iterator | decls_end () const
bool | decls_empty () const
decl_range | noload_decls () const
| noload_decls_begin/end - Iterate over the declarations stored in this context that are currently loaded; don't attempt to retrieve anything from an external source. More...
decl_iterator | noload_decls_begin () const
decl_iterator | noload_decls_end () const
void | addDecl (Decl *D)
| Add the declaration D into this context. More...
void | addDeclInternal (Decl *D)
| Add the declaration D into this context, but suppress searches for external declarations with the same name. More...
void | addHiddenDecl (Decl *D)
| Add the declaration D to this context without modifying any lookup tables. More...
void | removeDecl (Decl *D)
| Removes a declaration from this context. More...
bool | containsDecl (Decl *D) const
| Checks whether a declaration is in this context. More...
bool | containsDeclAndLoad (Decl *D) const
| Checks whether a declaration is in this context. More...
lookup_result | lookup (DeclarationName Name) const
| lookup - Find the declarations (if any) with the given Name in this context. More...
lookup_result | noload_lookup (DeclarationName Name)
| Find the declarations with the given name that are visible within this context; don't attempt to retrieve anything from an external source. More...
void | localUncachedLookup (DeclarationName Name, SmallVectorImpl< NamedDecl *> &Results)
| A simplistic name lookup mechanism that performs name lookup into this declaration context without consulting the external source. More...
void | makeDeclVisibleInContext (NamedDecl *D)
| Makes a declaration visible within this context. More...
lookups_range | lookups () const
lookups_range | noload_lookups (bool PreserveInternalState) const
all_lookups_iterator | lookups_begin () const
| Iterators over all possible lookups within this context. More...
all_lookups_iterator | lookups_end () const
all_lookups_iterator | noload_lookups_begin () const
| Iterators over all possible lookups within this context that are currently loaded; don't attempt to retrieve anything from an external source. More...
all_lookups_iterator | noload_lookups_end () const
udir_range | using_directives () const
| Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context. More...
ddiag_range | ddiags () const
void | setMustBuildLookupTable ()
| Mark that there are external lexical declarations that we need to include in our lookup table (and that are not available as external visible lookups). More...
StoredDeclsMap * | getLookupPtr () const
| Retrieve the internal representation of the lookup structure. More...
StoredDeclsMap * | buildLookup ()
| Ensure the lookup structure is fully-built and return it. More...
bool | hasExternalLexicalStorage () const
| Whether this DeclContext has external storage containing additional declarations that are lexically in this context. More...
void | setHasExternalLexicalStorage (bool ES=true) const
| State whether this DeclContext has external storage for declarations lexically in this context. More...
bool | hasExternalVisibleStorage () const
| Whether this DeclContext has external storage containing additional declarations that are visible in this context. More...
void | setHasExternalVisibleStorage (bool ES=true) const
| State whether this DeclContext has external storage for declarations visible in this context. More...
bool | isDeclInLexicalTraversal (const Decl *D) const
| Determine whether the given declaration is stored in the list of declarations lexically within this context. More...
bool | setUseQualifiedLookup (bool use=true) const
bool | shouldUseQualifiedLookup () const
void | dumpDeclContext () const
void | dumpLookups () const
void | dumpLookups (llvm::raw_ostream &OS, bool DumpDecls=false, bool Deserialize=false) const

## Static Public Member Functions
static bool | classof (const Decl *D)
static bool | classof (const DeclContext *D)

## Protected Member Functions
| DeclContext (Decl::Kind K)

## Static Protected Member Functions
static std::pair< Decl *, Decl * > | BuildDeclChain (ArrayRef< Decl *> Decls, bool FieldsAlreadyLoaded)
| Build up a chain of declarations. More...

## Protected Attributes
union {
DeclContextBitfields DeclContextBits
TagDeclBitfields TagDeclBits
EnumDeclBitfields EnumDeclBits
RecordDeclBitfields RecordDeclBits
OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits
FunctionDeclBitfields FunctionDeclBits
CXXConstructorDeclBitfields CXXConstructorDeclBits
ObjCMethodDeclBitfields ObjCMethodDeclBits
ObjCContainerDeclBitfields ObjCContainerDeclBits
LinkageSpecDeclBitfields LinkageSpecDeclBits
BlockDeclBitfields BlockDeclBits
}; |
| This anonymous union stores the bits belonging to DeclContext and classes deriving from it. More...
Decl * | FirstDecl = nullptr
| FirstDecl - The first declaration stored within this declaration context. More...
Decl * | LastDecl = nullptr
| LastDecl - The last declaration stored within this declaration context. More...

## Friends
class | ASTDeclReader
| For makeDeclVisibleInContextImpl. More...
class | ExternalASTSource
| For reconcileExternalVisibleStorage, CreateStoredDeclsMap, hasNeedToReconcileExternalVisibleStorage. More...
class | DependentDiagnostic
| For CreateStoredDeclsMap. More...
class | ASTWriter
| For hasNeedToReconcileExternalVisibleStorage, hasLazyLocalLexicalLookups, hasLazyExternalLexicalLookups. More...

## Detailed Description

DeclContext - This is used only as base class of specific decl types that can act as declaration contexts.

These decls are (only the top classes that directly derive from DeclContext are mentioned, not their subclasses):

TranslationUnitDecl ExternCContext NamespaceDecl TagDecl OMPDeclareReductionDecl OMPDeclareMapperDecl FunctionDecl ObjCMethodDecl ObjCContainerDecl LinkageSpecDecl ExportDecl BlockDecl CapturedDecl

Definition at line 1271 of file DeclBase.h.

## Member Typedef Documentation

## ◆ ddiag_range

using clang::DeclContext::ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>

Definition at line 2321 of file DeclBase.h.

## ◆ decl_range

using clang::DeclContext::decl_range = llvm::iterator_range<decl_iterator>

Definition at line 2029 of file DeclBase.h.

## ◆ lookup_iterator

using clang::DeclContext::lookup_iterator = lookup_result::iterator

Definition at line 2238 of file DeclBase.h.

## ◆ lookup_result

using clang::DeclContext::lookup_result = DeclContextLookupResult

Definition at line 2237 of file DeclBase.h.

## ◆ lookups_range

using clang::DeclContext::lookups_range = llvm::iterator_range<all_lookups_iterator>

Definition at line 2284 of file DeclBase.h.

## ◆ udir_iterator_base

using clang::DeclContext::udir_iterator_base = llvm::iterator_adaptor_base<udir_iterator, lookup_iterator, std::random_access_iterator_tag, UsingDirectiveDecl *>

Definition at line 2306 of file DeclBase.h.

## ◆ udir_range

using clang::DeclContext::udir_range = llvm::iterator_range<udir_iterator>

Definition at line 2314 of file DeclBase.h.

## Constructor & Destructor Documentation

## ◆ DeclContext()

DeclContext::DeclContext | ( | Decl::Kind | K | ) |
| protected

Definition at line 1006 of file DeclBase.cpp.

Referenced by clang::ObjCInterfaceDecl::lookupPrivateMethod().

## ◆ ~DeclContext()

DeclContext::~DeclContext | ( |  | ) |
| default

Referenced by classof().

## Member Function Documentation

## ◆ addDecl()

void DeclContext::addDecl | ( | Decl * | D | ) |

Add the declaration D into this context.

This routine should be invoked when the declaration D has first been declared, to place D into the context where it was (lexically) defined. Every declaration must be added to one (and only one!) context, where it can be visited via [decls_begin(), decls_end()). Once a declaration has been added to its lexical context, the corresponding DeclContext owns the declaration.

If D is also a NamedDecl, it will be made visible within its semantic context via makeDeclVisibleInContext.

Definition at line 1524 of file DeclBase.cpp.

Referenced by clang::Sema::ActOnOpenMPDeclareMapperDirectiveVarDecl(), clang::Sema::ActOnPragmaMSComment(), clang::Sema::ActOnStartCategoryImplementation(), clang::Sema::ActOnStartCategoryInterface(), addFieldToRecordDecl(), clang::ObjCImplDecl::addPropertyImplementation(), clang::Sema::CheckImplementationIvars(), clang::CodeGen::CGOpenMPRuntimeNVPTX::clear(), clang::Sema::createImplicitModuleImportForErrorRecovery(), clang::ASTContext::getBlockDescriptorExtendedType(), clang::ASTContext::getBlockDescriptorType(), clang::CodeGen::CodeGenModule::getObjCFastEnumerationStateType(), getPreviousDeclForInstantiation(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), clang::Sema::ProcessPropertyDecl(), clang::Sema::PushUsingDirective(), clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::TemplateDeclInstantiator::VisitVarDecl().

## ◆ addDeclInternal()

void DeclContext::addDeclInternal | ( | Decl * | D | ) |

Add the declaration D into this context, but suppress searches for external declarations with the same name.

Although analogous in function to addDecl, this removes an important check. This is only useful if the Decl is being added in response to an external search; in all other cases, addDecl() is the right function to use. See the ASTImporter for use cases.

Definition at line 1532 of file DeclBase.cpp.

Referenced by clang::ASTNodeImporter::ImportDeclContext(), clang::ASTNodeImporter::VisitAccessSpecDecl(), clang::ASTNodeImporter::VisitClassTemplateSpecializationDecl(), clang::ASTNodeImporter::VisitEmptyDecl(), clang::ASTNodeImporter::VisitFriendDecl(), clang::ASTNodeImporter::VisitLifetimeExtendedTemporaryDecl(), clang::ASTNodeImporter::VisitLinkageSpecDecl(), clang::ASTNodeImporter::VisitObjCCategoryImplDecl(), clang::ASTNodeImporter::VisitObjCPropertyImplDecl(), clang::ASTNodeImporter::VisitStaticAssertDecl(), and clang::ASTNodeImporter::VisitVarTemplateSpecializationDecl().

## ◆ addHiddenDecl()

void DeclContext::addHiddenDecl | ( | Decl * | D | ) |

Add the declaration D to this context without modifying any lookup tables.

This is useful for some operations in dependent contexts where the semantic context might not be dependent; this basically only happens with friends.

Definition at line 1498 of file DeclBase.cpp.

References clang::ASTContext::addedLocalImportDecl(), clang::Decl::getASTContext(), clang::Decl::getLexicalDeclContext(), clang::Decl::getNextDeclInContext(), and clang::Decl::isFromASTFile().

Referenced by buildCaptureDecl(), clang::Sema::BuildVariableInstantiation(), FinishForRangeVarDecl(), and clang::TemplateDeclInstantiator::VisitVarDecl().

## ◆ BuildDeclChain()

std::pair< Decl *, Decl * > DeclContext::BuildDeclChain | ( | ArrayRef< Decl *> | Decls,
|  | bool | FieldsAlreadyLoaded
| ) |  |
| static protected

Build up a chain of declarations.

Returns
  the first/last pair of declarations.

Definition at line 1257 of file DeclBase.cpp.

References clang::ExternalASTSource::FindExternalLexicalDecls(), and clang::Decl::NextInContextAndBits.

Referenced by clang::RecordDecl::isMsStruct().

## ◆ buildLookup()

StoredDeclsMap * DeclContext::buildLookup | ( |  | ) |

Ensure the lookup structure is fully-built and return it.

buildLookup - Build the lookup data structure with all of the declarations in this DeclContext (and any other contexts linked to it or transparent contexts nested within it) and return it.

Note that the produced map may miss out declarations from an external source. If it does, those entries will be marked with the 'hasExternalDecls' flag.

Definition at line 1547 of file DeclBase.cpp.

Referenced by lookups().

## ◆ classof() [1/2]

bool DeclContext::classof | ( | const Decl * | D | ) |
| static

Definition at line 1016 of file DeclBase.cpp.

References clang::Decl::getKind(), and ~DeclContext().

## ◆ classof() [2/2]

static bool clang::DeclContext::classof | ( | const DeclContext * | D | ) |
| inline static

Definition at line 2390 of file DeclBase.h.

References clang::C.

## ◆ collectAllContexts()

void DeclContext::collectAllContexts | ( | SmallVectorImpl< DeclContext *> & | Contexts | ) |

Collects all of the declaration contexts that are semantically connected to this declaration context.

For declaration contexts that have multiple semantically connected but syntactically distinct contexts, such as C++ namespaces, this routine retrieves the complete set of such declaration contexts in source order. For example, given:

namespace N {
int x;
}
namespace N {
int y;
}

The `Contexts` parameter will contain both definitions of N.

Parameters

  Contexts | Will be cleared and set to the set of declaration contexts that are semanticaly connected to this declaration context, in source order, including this context (which may be the only result, for non-namespace contexts).

Definition at line 1240 of file DeclBase.cpp.

## ◆ containsDecl()

bool DeclContext::containsDecl | ( | Decl * | D | ) | const

Checks whether a declaration is in this context.

Definition at line 1401 of file DeclBase.cpp.

References clang::Decl::getLexicalDeclContext(), and clang::Decl::NextInContextAndBits.

Referenced by clang::Sema::CreateUnaryExprOrTypeTraitExpr(), and clang::ASTNodeImporter::ImportDeclContext().

## ◆ containsDeclAndLoad()

bool DeclContext::containsDeclAndLoad | ( | Decl * | D | ) | const

Checks whether a declaration is in this context.

This also loads the Decls from the external source before the check.

Definition at line 1406 of file DeclBase.cpp.

## ◆ ddiags()

DeclContext::ddiag_range clang::DeclContext::ddiags | ( |  | ) | const
| inline

Definition at line 175 of file DependentDiagnostic.h.

Referenced by clang::Sema::PerformDependentDiagnostics().

## ◆ decls()

decl_range clang::DeclContext::decls | ( |  | ) | const
| inline

decls_begin/decls_end - Iterate over the declarations stored in this context.

Definition at line 2033 of file DeclBase.h.

Referenced by clang::ODRHash::AddCXXRecordDecl(), clang::ODRHash::AddEnumDecl(), clang::ODRHash::AddFunctionDecl(), AddInterfaceResults(), clang::CallGraph::addNodesForBlocks(), AddProtocolResults(), AllTrivialInitializers(), CheckAbstractClassUsage(), checkExportedDeclContext(), checkForMultipleExportedDefaultConstructors(), DiagnoseNamespaceInlineMismatch(), clang::Sema::DiagnoseUnusedNestedTypedefs(), clang::ASTNodeTraverser< ASTDumper, TextNodeDumper >::dumpDeclContext(), findDefaultInitializer(), clang::for(), clang::cross_tu::CrossTranslationUnitContext::getLookupName(), clang::ASTReader::getOwningModuleNameForDiagnostic(), GroupNewVirtualOverloads(), clang::ASTNodeImporter::ImportDeclContext(), clang::index::IndexingContext::indexDeclContext(), clang::Sema::InstantiateClassMembers(), isFunctionLocalClass(), isImportedDeclContext(), ReferenceDllExportedMembers(), and Scan().

## ◆ decls_begin()

DeclContext::decl_iterator DeclContext::decls_begin | ( |  | ) | const

Definition at line 1388 of file DeclBase.cpp.

Referenced by cleanupDeallocOrFinalize(), clang::EnumDecl::enumerator_begin(), findUserDeclaredCtor(), GCRewriteFinalize(), clang::ExportDecl::getEndLoc(), hasSuperInitCall(), isTrackedVar(), MethodsAndNestedClassesComplete(), and clang::LexicallyOrderedRecursiveASTVisitor< Derived >::TraverseDeclContextHelper().

## ◆ decls_empty()

bool DeclContext::decls_empty | ( |  | ) | const

Definition at line 1394 of file DeclBase.cpp.

Referenced by clang::ExportDecl::getEndLoc().

## ◆ decls_end()

decl_iterator clang::DeclContext::decls_end | ( |  | ) | const
| inline

Definition at line 2035 of file DeclBase.h.

Referenced by cleanupDeallocOrFinalize(), clang::EnumDecl::enumerator_end(), findUserDeclaredCtor(), GCRewriteFinalize(), hasSuperInitCall(), isTrackedVar(), MethodsAndNestedClassesComplete(), and clang::LexicallyOrderedRecursiveASTVisitor< Derived >::TraverseDeclContextHelper().

## ◆ dumpDeclContext()

LLVM_DUMP_METHOD void DeclContext::dumpDeclContext | ( |  | ) | const

Definition at line 210 of file DeclPrinter.cpp.

References getParent(), clang::ASTContext::getPrintingPolicy(), and isTranslationUnit().

## ◆ dumpLookups() [1/2]

LLVM_DUMP_METHOD void DeclContext::dumpLookups | ( |  | ) | const

Definition at line 207 of file ASTDumper.cpp.

References clang::ASTContext::getCommentCommandTraits(), clang::SourceManager::getDiagnostics(), getParent(), clang::ASTContext::getPrintingPolicy(), clang::DiagnosticsEngine::getShowColors(), clang::ASTContext::getSourceManager(), isTranslationUnit(), P, and SM.

## ◆ dumpLookups() [2/2]

void clang::DeclContext::dumpLookups | ( | llvm::raw_ostream & | OS,
|  | bool | DumpDecls = `false`,
|  | bool | Deserialize = `false`
| ) |  | const

## ◆ Encloses()

bool DeclContext::Encloses | ( | const DeclContext * | DC | ) | const

Determine whether this declaration context encloses the declaration context DC.

Definition at line 1161 of file DeclBase.cpp.

References getParent(), and getPrimaryContext().

Referenced by clang::Sema::ActOnUsingDirective(), CheckExplicitInstantiationScope(), clang::Sema::CheckShadow(), CheckTemplateSpecializationScope(), diagnoseInstanceReference(), DiagnoseTwoPhaseLookup(), DoMarkVarDeclReferenced(), findOuterContext(), and clang::Sema::tryCaptureOpenMPLambdas().

## ◆ Equals()

bool clang::DeclContext::Equals | ( | const DeclContext * | DC | ) | const
| inline

Determine whether this declaration context is equivalent to the declaration context DC.

Definition at line 1908 of file DeclBase.h.

References getPrimaryContext().

Referenced by clang::Sema::CheckShadow(), CheckTemplateSpecializationScope(), CloneDesignatedInitExpr(), diagnoseInstanceReference(), clang::Sema::FindInstantiatedDecl(), findOuterContext(), getStackIndexOfNearestEnclosingCaptureReadyLambda(), InEnclosingNamespaceSetOf(), and clang::CXXRecordDecl::isCurrentInstantiation().

## ◆ getDeclKind()

Decl::Kind clang::DeclContext::getDeclKind | ( |  | ) | const
| inline

Definition at line 1777 of file DeclBase.h.

References clang::Decl::getDeclKindName().

Referenced by clang::ODRHash::AddFunctionDecl(), clang::Decl::castFromDeclContext(), clang::serialization::getDefinitiveDeclContext(), getExternCContext(), clang::ExplicitSpecifier::getFromDecl(), getKind(), clang::Sema::getObjCContainerKind(), getOutermostFuncOrBlockContext(), clang::VarDecl::isFunctionOrMethodVarDecl(), isLinkageSpecContext(), IsUsingDirectiveInToplevelContext(), and LookupMethodInReceiverType().

## ◆ getDeclKindName()

const char * DeclContext::getDeclKindName | ( |  | ) | const

Definition at line 155 of file DeclBase.cpp.

## ◆ getEnclosingNamespaceContext() [1/2]

DeclContext * DeclContext::getEnclosingNamespaceContext | ( |  | ) |

Retrieve the nearest enclosing namespace context.

Definition at line 1765 of file DeclBase.cpp.

References getParent(), getPrimaryContext(), and isFileContext().

Referenced by CheckExplicitInstantiationScope(), isDefinedInClangModule(), clang::AnalysisDeclContext::isInStdNamespace(), and LazyInitialize().

## ◆ getEnclosingNamespaceContext() [2/2]

const DeclContext* clang::DeclContext::getEnclosingNamespaceContext | ( |  | ) | const
| inline

Definition at line 1945 of file DeclBase.h.

## ◆ getExternCContext()

const LinkageSpecDecl * DeclContext::getExternCContext | ( |  | ) | const

Retrieve the nearest enclosing C linkage specification context.

Definition at line 1146 of file DeclBase.cpp.

References getDeclKind(), getLexicalParent(), and clang::LinkageSpecDecl::lang_c.

Referenced by clang::Sema::CheckLiteralOperatorDeclaration(), and clang::Sema::CheckTemplateDeclScope().

## ◆ getInnermostBlockDecl()

const BlockDecl * DeclContext::getInnermostBlockDecl | ( |  | ) | const

Return this DeclContext if it is a BlockDecl.

Otherwise, return the innermost enclosing BlockDecl or null if there are no enclosing blocks.

Definition at line 1058 of file DeclBase.cpp.

References getParent(), and isClosure().

## ◆ getLexicalParent() [1/2]

DeclContext* clang::DeclContext::getLexicalParent | ( |  | ) |
| inline

getLexicalParent - Returns the containing lexical DeclContext.

May be different from getParent, e.g.:

namespace A { struct S; } struct A::S {}; // getParent() == namespace 'A' // getLexicalParent() == translation unit

Definition at line 1800 of file DeclBase.h.

References clang::Decl::getLexicalDeclContext().

Referenced by clang::Sema::ActOnFinishRequiresExpr(), clang::ODRHash::AddFunctionDecl(), clang::Sema::CheckShadow(), clang::Sema::DefineDefaultedComparison(), clang::Sema::getContainingDC(), clang::Sema::getCurrentMangleNumberContext(), getEnclosingExportDecl(), getExternCContext(), getOuterLexicalRecordContext(), clang::Sema::inferCUDATargetForImplicitSpecialMember(), isInInlineFunction(), clang::Decl::isLexicallyWithinFunctionOrMethod(), and isLinkageSpecContext().

## ◆ getLexicalParent() [2/2]

const DeclContext* clang::DeclContext::getLexicalParent | ( |  | ) | const
| inline

Definition at line 1803 of file DeclBase.h.

## ◆ getLookupParent() [1/2]

DeclContext * DeclContext::getLookupParent | ( |  | ) |

Find the parent context of this context that will be used for unqualified name lookup.

Generally, the parent lookup context is the semantic context. However, for a friend function the parent lookup context is the lexical context, which is the class in which the friend is declared.

Definition at line 1042 of file DeclBase.cpp.

References clang::isLambdaCallOperator().

Referenced by AddTopLevelDeclarationToHash(), and findRecordWithDependentBasesOfEnclosingMethod().

## ◆ getLookupParent() [2/2]

const DeclContext* clang::DeclContext::getLookupParent | ( |  | ) | const
| inline

Definition at line 1809 of file DeclBase.h.

## ◆ getLookupPtr()

StoredDeclsMap* clang::DeclContext::getLookupPtr | ( |  | ) | const
| inline

Retrieve the internal representation of the lookup structure.

This may omit some names if we are lazily building the structure.

Definition at line 2341 of file DeclBase.h.

Referenced by noload_lookups().

## ◆ getNonClosureAncestor() [1/2]

Decl * DeclContext::getNonClosureAncestor | ( |  | ) |

Find the nearest non-closure ancestor of this context, i.e.

the innermost semantic parent of this context which is not a closure. A context may be its own non-closure ancestor.

Definition at line 998 of file DeclBase.cpp.

References getNonClosureContext().

Referenced by LookupMethodInReceiverType().

## ◆ getNonClosureAncestor() [2/2]

const Decl* clang::DeclContext::getNonClosureAncestor | ( |  | ) | const
| inline

Definition at line 1920 of file DeclBase.h.

## ◆ getOuterLexicalRecordContext() [1/2]

RecordDecl * DeclContext::getOuterLexicalRecordContext | ( |  | ) |

Retrieve the outermost lexically enclosing record context.

Definition at line 1773 of file DeclBase.cpp.

References getLexicalParent(), and isRecord().

Referenced by clang::Sema::InstantiateInClassInitializer().

## ◆ getOuterLexicalRecordContext() [2/2]

const RecordDecl* clang::DeclContext::getOuterLexicalRecordContext | ( |  | ) | const
| inline

Definition at line 1951 of file DeclBase.h.

## ◆ getParent() [1/2]

DeclContext* clang::DeclContext::getParent | ( |  | ) |
| inline

getParent - Returns the containing DeclContext.

Definition at line 1784 of file DeclBase.h.

References clang::Decl::getDeclContext().

Referenced by clang::Sema::ActOnFinishFullExpr(), clang::Sema::ActOnSEHTryBlock(), clang::Sema::ActOnUsingDirective(), clang::ODRHash::AddCXXRecordDecl(), clang::ODRHash::AddFunctionDecl(), clang::Sema::adjustContextForLocalExternDecl(), adjustCVQualifiersForCXXThisWithinLambda(), clang::Sema::CheckConstructorAccess(), CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(), clang::Sema::CheckParmsForFunctionDef(), clang::Sema::CheckQualifiedMemberReference(), clang::Sema::CheckShadow(), clang::Sema::CheckUsingShadowDecl(), ClassifyImplicitMemberAccess(), CollectEnclosingNamespace(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::ento::ExprEngine::CreateCXXTemporaryObject(), clang::Sema::createLambdaClosureType(), clang::ASTContext::DeclMustBeEmitted(), DiagnoseNamespaceInlineMismatch(), DiagnoseTwoPhaseLookup(), dumpDeclContext(), dumpLookups(), EmitObjectDelete(), Encloses(), clang::Sema::FindInstantiatedDecl(), findOuterContext(), findRecordWithDependentBasesOfEnclosingMethod(), getBestNamespaceSubstr(), clang::BodyFarm::getBody(), clang::CXXMethodDecl::getCorrespondingMethodDeclaredInClass(), clang::Sema::getCurMethodDecl(), clang::Sema::getCurrentMangleNumberContext(), getEnclosingNamespaceContext(), clang::Sema::getFunctionLevelDeclContext(), getInnermostBlockDecl(), clang::getLambdaAwareParentOfDeclContext(), getNullabilityCompletenessCheckFileID(), getOutermostEnclosingLambda(), getOutermostFuncOrBlockContext(), clang::getParameterABISpelling(), clang::CXXMethodDecl::getParent(), getRedeclContext(), clang::AnalysisDeclContext::getSelfDecl(), getStaticBooleanValue(), getStorageClass(), getTagInjectionContext(), clang::CXXMethodDecl::getThisObjectType(), clang::CXXMethodDecl::getThisType(), clang::Decl::getTranslationUnitDecl(), handleGslAnnotatedTypes(), clang::CodeGen::CodeGenModule::HasHiddenLTOVisibility(), InEnclosingNamespaceSetOf(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::Sema::InstantiateFunctionDeclaration(), isAncestorDeclContextOf(), clang::ento::CallEvent::isCalled(), clang::CXXRecordDecl::isCurrentInstantiation(), isDeclContextInNamespace(), IsDisallowedCopyOrAssign(), clang::FunctionDecl::isGlobal(), clang::Decl::isInAnonymousNamespace(), clang::Sema::IsInsideALocalClassWithinATemplateFunction(), clang::CXXMethodDecl::isLambdaStaticInvoker(), isReferenceToNonConstCapture(), IsUsingDirectiveInToplevelContext(), clang::MangleContext::mangleBlock(), clang::CodeGen::CGRecordLayout::print(), clang::FieldDecl::setCapturedVLAType(), clang::Sema::tryCaptureVariable(), tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(), clang::FunctionCallFilterCCC::ValidateCandidate(), clang::ento::ExprEngine::VisitCommonDeclRefExpr(), clang::ASTDeclWriter::VisitDecl(), clang::TextNodeDumper::VisitFunctionDecl(), and clang::ASTDeclWriter::VisitNamespaceDecl().

## ◆ getParent() [2/2]

const DeclContext* clang::DeclContext::getParent | ( |  | ) | const
| inline

Definition at line 1787 of file DeclBase.h.

## ◆ getParentASTContext()

ASTContext& clang::DeclContext::getParentASTContext | ( |  | ) | const
| inline

Definition at line 1813 of file DeclBase.h.

References clang::Decl::getASTContext().

Referenced by disambiguateSpellingInScope(), findVar(), clang::CXXRecordDecl::getLambdaContextDecl(), clang::Type::getObjCSubstitutions(), lookups(), clang::QualType::substObjCMemberType(), and clang::FunctionCallFilterCCC::ValidateCandidate().

## ◆ getPrimaryContext() [1/2]

DeclContext * DeclContext::getPrimaryContext | ( |  | ) |

getPrimaryContext - There may be many different declarations of the same entity (including forward declarations of classes, multiple definitions of namespaces, etc.), each with a different set of declarations.

This routine returns the "primary" DeclContext structure, which will contain the information needed to perform name lookup into this context.

Definition at line 1171 of file DeclBase.cpp.

References clang::TagDecl::getDefinition(), and clang::TagDecl::isBeingDefined().

Referenced by clang::ASTImporterLookupTable::add(), CollectEnclosingNamespace(), clang::ASTImporterLookupTable::dump(), clang::ASTDumper::dumpLookups(), Encloses(), Equals(), findRecordWithDependentBasesOfEnclosingMethod(), getEnclosingNamespaceContext(), clang::Sema::getScopeForContext(), isImportedDeclContext(), lookups(), makeDeclVisibleInContext(), MightInstantiateTo(), noload_lookups(), clang::ASTImporterLookupTable::remove(), and clang::ASTDeclWriter::VisitNamespaceDecl().

## ◆ getPrimaryContext() [2/2]

const DeclContext* clang::DeclContext::getPrimaryContext | ( |  | ) | const
| inline

Definition at line 1931 of file DeclBase.h.

## ◆ getRedeclContext() [1/2]

DeclContext * DeclContext::getRedeclContext | ( |  | ) |

getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same name, or where it is a redeclaration if the two entities are compatible.

This skips through transparent contexts.

Definition at line 1747 of file DeclBase.cpp.

References clang::ASTContext::getLangOpts(), getParent(), isRecord(), and isTransparentContext().

Referenced by clang::ASTImporterLookupTable::add(), adjustDeclContextForDeclaratorDecl(), clang::Sema::CheckCompleteVariableDeclaration(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckDependentFunctionTemplateSpecialization(), CheckExplicitInstantiationScope(), checkExportedDecl(), clang::Sema::CheckFunctionTemplateSpecialization(), clang::Sema::CheckObjCDeclScope(), CheckOperatorNewDeleteDeclarationScope(), clang::Sema::CheckShadow(), clang::Sema::CheckTemplateDeclScope(), CheckTemplateSpecializationScope(), clang::Sema::CheckUsingDeclQualifier(), CloneDesignatedInitExpr(), clang::ASTReader::CompleteRedeclChain(), clang::LinkageComputer::computeLVForDecl(), clang::TypeName::createNestedNameSpecifierForScopeOf(), clang::NamedDecl::declarationReplaces(), clang::ASTContext::forEachMultiversionedFunctionVersion(), getContextForScopeMatching(), getDeclForLocalLookup(), clang::getDeclUsageType(), clang::NamedDecl::getExplicitVisibility(), getFunctionStorageClass(), getStorageClass(), clang::NamedDecl::isCXXClassMember(), clang::VarDecl::isFileVarDecl(), clang::VarDecl::isFunctionOrMethodVarDecl(), clang::FunctionDecl::isMain(), clang::FunctionDecl::isMSVCRTEntryPoint(), clang::FunctionDecl::isReplaceableGlobalAllocationFunction(), clang::FunctionDecl::isReservedGlobalPlacementOperator(), isSameEntity(), clang::ASTImporterLookupTable::remove(), shouldConsiderLinkage(), shouldIgnoreDueToReservedName(), ShouldWarnAboutMissingPrototype(), and clang::ASTDeclWriter::VisitNamespaceDecl().

## ◆ getRedeclContext() [2/2]

const DeclContext* clang::DeclContext::getRedeclContext | ( |  | ) | const
| inline

Definition at line 1939 of file DeclBase.h.

## ◆ hasExternalLexicalStorage()

bool clang::DeclContext::hasExternalLexicalStorage | ( |  | ) | const
| inline

Whether this DeclContext has external storage containing additional declarations that are lexically in this context.

Definition at line 2348 of file DeclBase.h.

Referenced by clang::ExternalASTMerger::CanComplete(), clang::ExternalASTMerger::CompleteType(), clang::RecordDecl::field_begin(), clang::ASTContext::getASTRecordLayout(), isDiagnosedResult(), and clang::RecordDecl::isMsStruct().

## ◆ hasExternalVisibleStorage()

bool clang::DeclContext::hasExternalVisibleStorage | ( |  | ) | const
| inline

Whether this DeclContext has external storage containing additional declarations that are visible in this context.

Definition at line 2360 of file DeclBase.h.

Referenced by clang::ExternalASTMerger::CanComplete(), clang::ASTReader::completeVisibleDeclsMap(), clang::ASTDumper::dumpLookups(), and lookups().

## ◆ InEnclosingNamespaceSetOf()

bool DeclContext::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 [namespace.def]p9.

If either context isn't a namespace, this is equivalent to Equals().

The enclosing namespace set of a namespace is the namespace and, if it is inline, its enclosing namespace, recursively.

Definition at line 1784 of file DeclBase.cpp.

References Equals(), and getParent().

Referenced by clang::Sema::CheckDependentFunctionTemplateSpecialization(), CheckExplicitInstantiationScope(), and clang::Sema::CheckFunctionTemplateSpecialization().

## ◆ isClosure()

bool clang::DeclContext::isClosure | ( |  | ) | const
| inline

Definition at line 1817 of file DeclBase.h.

Referenced by getInnermostBlockDecl().

## ◆ isDeclInLexicalTraversal()

bool clang::DeclContext::isDeclInLexicalTraversal | ( | const Decl * | D | ) | const
| inline

Determine whether the given declaration is stored in the list of declarations lexically within this context.

Definition at line 2374 of file DeclBase.h.

References clang::Decl::NextInContextAndBits.

Referenced by clang::ASTReader::FindExternalLexicalDecls().

## ◆ isDependentContext()

bool DeclContext::isDependentContext | ( |  | ) | const

Determines whether this context is dependent on a template parameter.

Definition at line 1091 of file DeclBase.cpp.

Referenced by clang::Sema::ActOnFinishFunctionBody(), clang::ASTRecordWriter::AddFunctionDefinition(), AddKeywordsToConsumer(), clang::CXXMethodDecl::addOverriddenMethod(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::AdjustDestructorExceptionSpec(), buildDeclareReductionRef(), buildUserDefinedMapperRef(), clang::Sema::BuildVariableInstantiation(), CanDeclareSpecialMemberFunction(), clang::Sema::canFullyTypeCheckRedeclaration(), checkAllocateClauses(), clang::Sema::CheckExplicitlyDefaultedFunction(), checkForMultipleExportedDefaultConstructors(), CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(), checkMoveAssignmentForRepeatedMove(), checkOpenMPLoop(), CheckOperatorDeleteDeclaration(), clang::Sema::CheckPureMethod(), clang::Sema::CheckTemplateArgument(), clang::Sema::CheckTemplatePartialSpecializationArgs(), checkTypeMappable(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::checkVarDeclRedefinition(), computeDeclRefDependence(), clang::Sema::DeclareImplicitDeductionGuides(), clang::ASTContext::DeclMustBeEmitted(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), DiagnoseBaseOrMemInitializerOrder(), clang::Sema::FinalizeVarWithDestructor(), clang::Sema::FindInstantiatedDecl(), findRecordWithDependentBasesOfEnclosingMethod(), clang::CXXRecordDecl::forallBases(), getCurrentInstantiationOf(), clang::Sema::getEmissionStatus(), getStackIndexOfNearestEnclosingCaptureReadyLambda(), clang::CXXRecordDecl::hasAnyDependentBases(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::TemplateArgument::isDependent(), clang::TagDecl::isDependentType(), IsDerivedFromInclusive(), clang::TemplateArgument::isInstantiationDependent(), isNonNegativeIntegerValue(), isOdrUseContext(), clang::Expr::isPotentialConstantExpr(), clang::Sema::LookupParsedName(), clang::Sema::LookupQualifiedName(), clang::Sema::MarkBaseAndMemberDestructorsReferenced(), clang::Sema::MarkVTableUsed(), clang::CXXRecordDecl::mayBeAbstract(), clang::Sema::MaybeBindToTemporary(), clang::serialization::needsAnonymousDeclarationNumber(), clang::Sema::RequireCompleteDeclContext(), clang::Sema::SetCtorInitializers(), clang::Sema::shouldLinkDependentDeclWithPrevious(), clang::Sema::ShouldWarnIfUnusedFileScopedDecl(), clang::Sema::startLambdaDefinition(), and tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs().

## ◆ isExternCContext()

bool DeclContext::isExternCContext | ( |  | ) | const

Determines whether this context or some of its ancestors is a linkage specification context that specifies C linkage.

Definition at line 1142 of file DeclBase.cpp.

References isLinkageSpecContext(), and clang::LinkageSpecDecl::lang_c.

Referenced by clang::Sema::ActOnStartOpenMPDeclareTargetDirective(), clang::Sema::CheckTemplateDeclScope(), clang::VarDecl::isInExternCContext(), clang::FunctionDecl::isInExternCContext(), and clang::CXXRecordDecl::isInterfaceLike().

## ◆ isExternCXXContext()

bool DeclContext::isExternCXXContext | ( |  | ) | const

Determines whether this context or some of its ancestors is a linkage specification context that specifies C++ linkage.

Definition at line 1157 of file DeclBase.cpp.

References isLinkageSpecContext(), and clang::LinkageSpecDecl::lang_cxx.

Referenced by clang::Sema::ActOnStartOpenMPDeclareTargetDirective(), clang::VarDecl::isInExternCXXContext(), and clang::FunctionDecl::isInExternCXXContext().

## ◆ isFileContext()

bool clang::DeclContext::isFileContext | ( |  | ) | const
| inline

Definition at line 1854 of file DeclBase.h.

Referenced by clang::Sema::ActOnFinishObjCImplementation(), clang::Sema::ActOnStartOpenMPDeclareTargetDirective(), clang::ASTUnit::addFileLevelDecl(), clang::ODRHash::AddFunctionDecl(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::CheckCompleteVariableDeclaration(), checkExportedDecl(), clang::Sema::CheckTemplateDeclScope(), CheckTemplateSpecializationScope(), CollectEnclosingNamespace(), clang::LinkageComputer::computeLVForDecl(), computeShadowedDeclKind(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createLambdaClosureType(), clang::Sema::FindInstantiatedDecl(), findOuterContext(), clang::ASTWriter::getDeclID(), getEnclosingNamespaceContext(), getStorageClass(), getTagInjectionContext(), clang::Sema::getTemplateInstantiationArgs(), clang::Sema::hasVisibleMemberSpecialization(), clang::CXXRecordDecl::isCurrentInstantiation(), clang::VarDecl::isFileVarDecl(), isInInlineFunction(), isNamespaceOrTranslationUnitScope(), isNamespaceScope(), LookupQualifiedNameInUsingDirectives(), MightInstantiateTo(), shouldConsiderLinkage(), clang::Sema::shouldLinkDependentDeclWithPrevious(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().

## ◆ isFunctionOrMethod()

bool clang::DeclContext::isFunctionOrMethod | ( |  | ) | const
| inline

Definition at line 1836 of file DeclBase.h.

Referenced by clang::Sema::ActOnSEHTryBlock(), clang::CodeCompletionBuilder::addParentContext(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::BuildVariableInstantiation(), clang::Sema::CheckParmsForFunctionDef(), CheckTemplateSpecializationScope(), computeCachedProperties(), clang::LinkageComputer::computeLVForDecl(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createLambdaClosureType(), DoMarkVarDeclReferenced(), clang::Sema::FindInstantiatedDecl(), getContextForScopeMatching(), clang::getDeclUsageType(), getFunctionStorageClass(), clang::getParameterABISpelling(), clang::LifetimeExtendedTemporaryDecl::getStorageDuration(), getTagInjectionContext(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), isConsumerInterestedIn(), isDeclWithinFunction(), clang::VarDecl::isFunctionOrMethodVarDecl(), clang::Decl::isLexicallyWithinFunctionOrMethod(), clang::serialization::needsAnonymousDeclarationNumber(), clang::NamedDecl::printNestedNameSpecifier(), clang::Sema::PushUsingDirective(), shouldConsiderLinkage(), ShouldDiagnoseUnusedDecl(), shouldIgnoreDueToReservedName(), clang::TemplateDeclInstantiator::VisitFunctionDecl(), clang::ASTDeclReader::VisitVarDeclImpl(), and warnAboutAmbiguousFunction().

## ◆ isInlineNamespace()

bool DeclContext::isInlineNamespace | ( |  | ) | const

Definition at line 1070 of file DeclBase.cpp.

Referenced by CollectEnclosingNamespace().

## ◆ isLookupContext()

bool clang::DeclContext::isLookupContext | ( |  | ) | const
| inline

Test whether the context supports looking up names.

Definition at line 1849 of file DeclBase.h.

References isFunctionOrMethod().

Referenced by isImportedDeclContext().

## ◆ isNamespace()

bool clang::DeclContext::isNamespace | ( |  | ) | const
| inline

Definition at line 1868 of file DeclBase.h.

References isStdNamespace().

Referenced by clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), isDeclContextInNamespace(), clang::FunctionDecl::isGlobal(), clang::Sema::IsInsideALocalClassWithinATemplateFunction(), isStdNamespace(), and isTemplate().

## ◆ isObjCContainer()

bool clang::DeclContext::isObjCContainer | ( |  | ) | const
| inline

Definition at line 1823 of file DeclBase.h.

Referenced by clang::Sema::CodeCompleteObjCMethodDecl(), and LookupMethodInReceiverType().

## ◆ isRecord()

bool clang::DeclContext::isRecord | ( |  | ) | const
| inline

Definition at line 1863 of file DeclBase.h.

Referenced by clang::comments::Sema::checkDeprecatedCommand(), CheckExplicitInstantiationScope(), clang::Sema::CheckQualifiedMemberReference(), clang::Sema::CheckShadow(), CheckTemplateSpecializationScope(), clang::Sema::CheckUsingDeclQualifier(), ClassifyMemberExpr(), clang::LinkageComputer::computeLVForDecl(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createLambdaClosureType(), clang::getDeclUsageType(), getOuterLexicalRecordContext(), getRedeclContext(), clang::Sema::getShadowedDeclaration(), haveIncompatibleLanguageLinkages(), clang::NamedDecl::isCXXClassMember(), isDeclExternC(), isDeclWithinFunction(), clang::RecordDecl::isInjectedClassName(), clang::VarDecl::isStaticDataMember(), clang::Sema::MergeVarDecl(), shouldConsiderLinkage(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().

## ◆ isStdNamespace()

bool DeclContext::isStdNamespace | ( |  | ) | const

Definition at line 1075 of file DeclBase.cpp.

References clang::IdentifierInfo::isStr().

Referenced by clang::AnalysisDeclContext::isInStdNamespace(), clang::Decl::isInStdNamespace(), and clang::Sema::isLibstdcxxEagerExceptionSpecHack().

## ◆ isTranslationUnit()

bool clang::DeclContext::isTranslationUnit | ( |  | ) | const
| inline

Definition at line 1859 of file DeclBase.h.

Referenced by clang::CodeCompletionBuilder::addParentContext(), AddTopLevelDeclarationToHash(), clang::TypeName::createNestedNameSpecifierForScopeOf(), clang::TypeName::createOuterNNS(), dumpDeclContext(), dumpLookups(), clang::getParameterABISpelling(), clang::Decl::getParentFunctionOrMethod(), getStackIndexOfNearestEnclosingCaptureReadyLambda(), clang::Sema::getTemplateInstantiationArgs(), clang::Decl::getTranslationUnitDecl(), isDeclContextInNamespace(), IsDisallowedCopyOrAssign(), clang::Sema::IsInsideALocalClassWithinATemplateFunction(), clang::FunctionDecl::isReplaceableGlobalAllocationFunction(), clang::FunctionDecl::isReservedGlobalPlacementOperator(), isTemplate(), LookupDirect(), clang::Parser::ParseTopLevelDecl(), and RedeclForcesDefC99().

## ◆ isTransparentContext()

bool DeclContext::isTransparentContext | ( |  | ) | const

isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.

For example, consider the enumerators of an enumeration type:

enum E {
Val1
};

Here, E is a transparent context, so its enumerator (Val1) will appear (semantically) that it is in the same context of E. Examples of transparent contexts include: enumerations (except for C++0x scoped enums), and C++ linkage specifications.

Definition at line 1123 of file DeclBase.cpp.

Referenced by clang::Sema::CheckQualifiedMemberReference(), and getRedeclContext().

## ◆ localUncachedLookup()

void DeclContext::localUncachedLookup | ( | DeclarationName | Name,
|  | SmallVectorImpl< NamedDecl *> & | Results
| ) |  |

A simplistic name lookup mechanism that performs name lookup into this declaration context without consulting the external source.

This function should almost never be used, because it subverts the usual relationship between a DeclContext and the external source. See the ASTImporter for the (few, but important) use cases.

FIXME: This is very inefficient; replace uses of it with uses of noload_lookup.

Definition at line 1709 of file DeclBase.cpp.

## ◆ lookup()

DeclContext::lookup_result DeclContext::lookup | ( | DeclarationName | Name | ) | const

lookup - Find the declarations (if any) with the given Name in this context.

Returns a range of iterators that contains all of the declarations with this name, with object, function, member, and enumerator names preceding any tag name. Note that this routine will not look into parent contexts.

Definition at line 1612 of file DeclBase.cpp.

Referenced by clang::Sema::BuildBlockForLambdaConversion(), clang::Sema::CheckCompletedCXXClass(), ClassImplementsAllMethodsAndProperties(), configureBlocksRuntimeObject(), clang::Sema::DeclareImplicitDeductionGuides(), findImplicitlyDeclaredEqualityComparisons(), clang::ObjCPropertyDecl::findPropertyDecl(), clang::ASTContext::forEachMultiversionedFunctionVersion(), clang::CodeGen::CodeGenModule::GetAddrOfConstantCFString(), clang::CXXMethodDecl::getCorrespondingMethodDeclaredInClass(), clang::ComparisonCategoryInfo::ValueInfo::getIntValue(), clang::ObjCContainerDecl::getIvarDecl(), clang::ObjCContainerDecl::getMethod(), clang::ASTContext::getObjCMethodRedeclaration(), clang::ObjCContainerDecl::HasUserDeclaredSetterMethod(), clang::Sema::InstantiateClassMembers(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::TemplateDeclInstantiator::InstantiateTypedefNameDecl(), LookupDirect(), lookupStdNamespace(), clang::TreeTransform< Derived >::RebuildShuffleVectorExpr(), and clang::ASTDeclReader::VisitDecl().

## ◆ lookups()

DeclContext::lookups_range clang::DeclContext::lookups | ( |  | ) | const
| inline

Definition at line 75 of file DeclLookups.h.

References clang::DeclContext::all_lookups_iterator::all_lookups_iterator(), buildLookup(), clang::ExternalASTSource::completeVisibleDeclsMap(), clang::ASTContext::getExternalSource(), getParentASTContext(), getPrimaryContext(), and hasExternalVisibleStorage().

Referenced by clang::ASTDumper::dumpLookups().

## ◆ lookups_begin()

all_lookups_iterator clang::DeclContext::lookups_begin | ( |  | ) | const

Iterators over all possible lookups within this context.

## ◆ lookups_end()

all_lookups_iterator clang::DeclContext::lookups_end | ( |  | ) | const

## ◆ makeDeclVisibleInContext()

void DeclContext::makeDeclVisibleInContext | ( | NamedDecl * | D | ) |

Makes a declaration visible within this context.

This routine makes the declaration D visible to name lookup within this context and, if this is a transparent context, within its parent contexts up to the first enclosing non-transparent context. Making a declaration visible within a context does not transfer ownership of a declaration, and a declaration can be visible in many contexts that aren't its lexical context.

If D is a redeclaration of an existing declaration that is visible from this context, as determined by NamedDecl::declarationReplaces, the previous declaration will be replaced with D.

Definition at line 1802 of file DeclBase.cpp.

References clang::StoredDeclsList::AddSubsequentDecl(), clang::C, clang::Decl::getDeclContext(), clang::NamedDecl::getDeclName(), clang::Decl::getLexicalDeclContext(), getPrimaryContext(), clang::StoredDeclsList::HandleRedeclaration(), clang::StoredDeclsList::isNull(), clang::StoredDeclsList::setHasExternalDecls(), clang::StoredDeclsList::setOnlyValue(), and shouldBeHidden().

Referenced by clang::Sema::BuildVariableInstantiation(), clang::Sema::CheckImplementationIvars(), DiagnoseNamespaceInlineMismatch(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().

## ◆ noload_decls()

decl_range clang::DeclContext::noload_decls | ( |  | ) | const
| inline

noload_decls_begin/end - Iterate over the declarations stored in this context that are currently loaded; don't attempt to retrieve anything from an external source.

Definition at line 2041 of file DeclBase.h.

Referenced by AddLazyVectorDecls(), and clang::ASTNodeTraverser< ASTDumper, TextNodeDumper >::dumpDeclContext().

## ◆ noload_decls_begin()

decl_iterator clang::DeclContext::noload_decls_begin | ( |  | ) | const
| inline

Definition at line 2044 of file DeclBase.h.

## ◆ noload_decls_end()

decl_iterator clang::DeclContext::noload_decls_end | ( |  | ) | const
| inline

Definition at line 2045 of file DeclBase.h.

## ◆ noload_lookup()

DeclContext::lookup_result DeclContext::noload_lookup | ( | DeclarationName | Name | ) |

Find the declarations with the given name that are visible within this context; don't attempt to retrieve anything from an external source.

Definition at line 1677 of file DeclBase.cpp.

## ◆ noload_lookups()

DeclContext::lookups_range clang::DeclContext::noload_lookups | ( | bool | PreserveInternalState | ) | const
| inline

Definition at line 89 of file DeclLookups.h.

References clang::DeclContext::all_lookups_iterator::all_lookups_iterator(), getLookupPtr(), and getPrimaryContext().

Referenced by clang::ASTDumper::dumpLookups().

## ◆ noload_lookups_begin()

all_lookups_iterator clang::DeclContext::noload_lookups_begin | ( |  | ) | const

Iterators over all possible lookups within this context that are currently loaded; don't attempt to retrieve anything from an external source.

## ◆ noload_lookups_end()

all_lookups_iterator clang::DeclContext::noload_lookups_end | ( |  | ) | const

## ◆ removeDecl()

void DeclContext::removeDecl | ( | Decl * | D | ) |

Removes a declaration from this context.

Definition at line 1444 of file DeclBase.cpp.

References clang::Decl::getDeclContext(), clang::Decl::getLexicalDeclContext(), clang::Decl::NextInContextAndBits, and shouldBeHidden().

Referenced by clang::Sema::HideUsingShadowDecl(), and clang::ASTNodeImporter::ImportDeclContext().

## ◆ setHasExternalLexicalStorage()

void clang::DeclContext::setHasExternalLexicalStorage | ( | bool | ES = `true` | ) | const
| inline

State whether this DeclContext has external storage for declarations lexically in this context.

Definition at line 2354 of file DeclBase.h.

Referenced by isDiagnosedResult(), and clang::serialization::reader::ASTDeclContextNameLookupTrait::ReadDataInto().

## ◆ setHasExternalVisibleStorage()

void clang::DeclContext::setHasExternalVisibleStorage | ( | bool | ES = `true` | ) | const
| inline

State whether this DeclContext has external storage for declarations visible in this context.

Definition at line 2366 of file DeclBase.h.

## ◆ setMustBuildLookupTable()

void clang::DeclContext::setMustBuildLookupTable | ( |  | ) |
| inline

Mark that there are external lexical declarations that we need to include in our lookup table (and that are not available as external visible lookups).

These extra lookup results will be found by walking the lexical declarations of this context. This should be used only if setHasExternalLexicalStorage() has been called on any decl context for which this is the primary context.

Definition at line 2333 of file DeclBase.h.

Referenced by isDiagnosedResult().

## ◆ setUseQualifiedLookup()

bool clang::DeclContext::setUseQualifiedLookup | ( | bool | use = `true` | ) | const
| inline

Definition at line 2379 of file DeclBase.h.

## ◆ shouldUseQualifiedLookup()

bool clang::DeclContext::shouldUseQualifiedLookup | ( |  | ) | const
| inline

Definition at line 2385 of file DeclBase.h.

References clang::classof().

## ◆ using_directives()

DeclContext::udir_range DeclContext::using_directives | ( |  | ) | const

Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.

Definition at line 1911 of file DeclBase.cpp.

References clang::DeclContextLookupResult::begin(), clang::C, clang::StoredDeclsMap::DestroyAll(), clang::DeclContextLookupResult::end(), and clang::Result.

Referenced by LookupQualifiedNameInUsingDirectives().

## Friends And Related Function Documentation

## ◆ ASTDeclReader

friend class ASTDeclReader
| friend

For makeDeclVisibleInContextImpl.

Definition at line 1273 of file DeclBase.h.

## ◆ ASTWriter

friend class ASTWriter
| friend

For hasNeedToReconcileExternalVisibleStorage, hasLazyLocalLexicalLookups, hasLazyExternalLexicalLookups.

Definition at line 1281 of file DeclBase.h.

## ◆ DependentDiagnostic

friend class DependentDiagnostic
| friend

For CreateStoredDeclsMap.

Definition at line 1278 of file DeclBase.h.

## ◆ ExternalASTSource

friend class ExternalASTSource
| friend

For reconcileExternalVisibleStorage, CreateStoredDeclsMap, hasNeedToReconcileExternalVisibleStorage.

Definition at line 1276 of file DeclBase.h.

## Member Data Documentation

## ◆ @43

union { ... }

This anonymous union stores the bits belonging to DeclContext and classes deriving from it.

The goal is to use otherwise wasted space in DeclContext to store data belonging to derived classes. The space saved is especially significient when pointers are aligned to 8 bytes. In this case due to alignment requirements we have a little less than 8 bytes free in DeclContext which we can use. We check that none of the classes in this union is larger than 8 bytes with static_asserts in the ctor of DeclContext.

## ◆ BlockDeclBits

BlockDeclBitfields clang::DeclContext::BlockDeclBits

Definition at line 1730 of file DeclBase.h.

Referenced by clang::BlockDecl::blockMissingReturnType(), clang::BlockDecl::canAvoidCopyToHeap(), clang::BlockDecl::capturesCXXThis(), clang::BlockDecl::doesNotEscape(), clang::BlockDecl::isConversionFromLambda(), clang::BlockDecl::isVariadic(), clang::BlockDecl::setBlockMissingReturnType(), clang::BlockDecl::setCanAvoidCopyToHeap(), clang::BlockDecl::setCapturesCXXThis(), clang::BlockDecl::setDoesNotEscape(), clang::BlockDecl::setIsConversionFromLambda(), and clang::BlockDecl::setIsVariadic().

## ◆ CXXConstructorDeclBits

CXXConstructorDeclBitfields clang::DeclContext::CXXConstructorDeclBits

Definition at line 1726 of file DeclBase.h.

## ◆ DeclContextBits

DeclContextBitfields clang::DeclContext::DeclContextBits

Definition at line 1720 of file DeclBase.h.

## ◆ EnumDeclBits

EnumDeclBitfields clang::DeclContext::EnumDeclBits

Definition at line 1722 of file DeclBase.h.

Referenced by clang::EnumDecl::getNumNegativeBits(), clang::EnumDecl::getNumPositiveBits(), clang::EnumDecl::isFixed(), clang::EnumDecl::isScoped(), and clang::EnumDecl::isScopedUsingClassTag().

## ◆ FirstDecl

Decl* clang::DeclContext::FirstDecl = nullptr
| mutable protected

FirstDecl - The first declaration stored within this declaration context.

Definition at line 1758 of file DeclBase.h.

Referenced by clang::RecordDecl::field_begin(), and clang::RecordDecl::isMsStruct().

## ◆ FunctionDeclBits

FunctionDeclBitfields clang::DeclContext::FunctionDeclBits

Definition at line 1725 of file DeclBase.h.

Referenced by clang::FunctionDecl::doesThisDeclarationHaveABody(), clang::FunctionDecl::getBody(), clang::FunctionDecl::getConstexprKind(), clang::FunctionDecl::getDefaultedFunctionInfo(), clang::FunctionDecl::getStorageClass(), clang::FunctionDecl::hasImplicitReturnZero(), clang::FunctionDecl::hasInheritedPrototype(), clang::FunctionDecl::hasSkippedBody(), clang::FunctionDecl::hasWrittenPrototype(), clang::FunctionDecl::instantiationIsPending(), clang::FunctionDecl::isConsteval(), clang::FunctionDecl::isConstexpr(), clang::FunctionDecl::isConstexprSpecified(), clang::FunctionDecl::isDefaulted(), clang::FunctionDecl::isDeletedAsWritten(), clang::FunctionDecl::isExplicitlyDefaulted(), clang::FunctionDecl::isInlined(), clang::FunctionDecl::isInlineSpecified(), clang::FunctionDecl::isLateTemplateParsed(), clang::FunctionDecl::isPure(), clang::FunctionDecl::isTrivial(), clang::FunctionDecl::isTrivialForCall(), clang::FunctionDecl::isVirtualAsWritten(), clang::FunctionDecl::setBody(), clang::FunctionDecl::setConstexprKind(), clang::FunctionDecl::setDefaulted(), clang::FunctionDecl::setDefaultedFunctionInfo(), clang::FunctionDecl::setDeletedAsWritten(), clang::FunctionDecl::setExplicitlyDefaulted(), clang::FunctionDecl::setHasImplicitReturnZero(), clang::FunctionDecl::setHasInheritedPrototype(), clang::FunctionDecl::setHasSkippedBody(), clang::FunctionDecl::setHasWrittenPrototype(), clang::FunctionDecl::setImplicitlyInline(), clang::FunctionDecl::setInlineSpecified(), clang::FunctionDecl::setInstantiationIsPending(), clang::FunctionDecl::setLateTemplateParsed(), clang::FunctionDecl::setLazyBody(), clang::FunctionDecl::setPure(), clang::FunctionDecl::setStorageClass(), clang::FunctionDecl::setTrivial(), clang::FunctionDecl::setTrivialForCall(), clang::FunctionDecl::setUsesFPIntrin(), clang::FunctionDecl::setUsesSEHTry(), clang::FunctionDecl::setVirtualAsWritten(), clang::FunctionDecl::setWillHaveBody(), clang::FunctionDecl::usesFPIntrin(), clang::FunctionDecl::usesSEHTry(), and clang::FunctionDecl::willHaveBody().

## ◆ LastDecl

Decl* clang::DeclContext::LastDecl = nullptr
| mutable protected

LastDecl - The last declaration stored within this declaration context.

FIXME: We could probably cache this value somewhere outside of the DeclContext, to reduce the size of DeclContext by another pointer.

Definition at line 1764 of file DeclBase.h.

Referenced by clang::RecordDecl::isMsStruct().

## ◆ LinkageSpecDeclBits

LinkageSpecDeclBitfields clang::DeclContext::LinkageSpecDeclBits

Definition at line 1729 of file DeclBase.h.

## ◆ ObjCContainerDeclBits

ObjCContainerDeclBitfields clang::DeclContext::ObjCContainerDeclBits

Definition at line 1728 of file DeclBase.h.

## ◆ ObjCMethodDeclBits

ObjCMethodDeclBitfields clang::DeclContext::ObjCMethodDeclBits

Definition at line 1727 of file DeclBase.h.

Referenced by clang::ObjCMethodDecl::getMethodFamily(), and clang::ObjCInterfaceDecl::lookupPrivateMethod().

## ◆ OMPDeclareReductionDeclBits

OMPDeclareReductionDeclBitfields clang::DeclContext::OMPDeclareReductionDeclBits

Definition at line 1724 of file DeclBase.h.

## ◆ RecordDeclBits

RecordDeclBitfields clang::DeclContext::RecordDeclBits

Definition at line 1723 of file DeclBase.h.

Referenced by clang::RecordDecl::getArgPassingRestrictions(), clang::RecordDecl::hasFlexibleArrayMember(), clang::RecordDecl::hasLoadedFieldsFromExternalStorage(), clang::RecordDecl::hasNonTrivialToPrimitiveCopyCUnion(), clang::RecordDecl::hasNonTrivialToPrimitiveDefaultInitializeCUnion(), clang::RecordDecl::hasNonTrivialToPrimitiveDestructCUnion(), clang::RecordDecl::hasObjectMember(), clang::RecordDecl::hasVolatileMember(), clang::RecordDecl::isAnonymousStructOrUnion(), clang::RecordDecl::isNonTrivialToPrimitiveCopy(), clang::RecordDecl::isNonTrivialToPrimitiveDefaultInitialize(), clang::RecordDecl::isNonTrivialToPrimitiveDestroy(), clang::RecordDecl::isParamDestroyedInCallee(), clang::RecordDecl::setAnonymousStructOrUnion(), clang::RecordDecl::setArgPassingRestrictions(), clang::RecordDecl::setHasFlexibleArrayMember(), clang::RecordDecl::setHasLoadedFieldsFromExternalStorage(), clang::RecordDecl::setHasNonTrivialToPrimitiveCopyCUnion(), clang::RecordDecl::setHasNonTrivialToPrimitiveDefaultInitializeCUnion(), clang::RecordDecl::setHasNonTrivialToPrimitiveDestructCUnion(), clang::RecordDecl::setHasObjectMember(), clang::RecordDecl::setHasVolatileMember(), clang::RecordDecl::setNonTrivialToPrimitiveCopy(), clang::RecordDecl::setNonTrivialToPrimitiveDefaultInitialize(), clang::RecordDecl::setNonTrivialToPrimitiveDestroy(), and clang::RecordDecl::setParamDestroyedInCallee().

## ◆ TagDeclBits

TagDeclBitfields clang::DeclContext::TagDeclBits

Definition at line 1721 of file DeclBase.h.

Referenced by clang::TagDecl::getTagKind(), clang::TagDecl::isBeingDefined(), clang::TagDecl::isCompleteDefinition(), clang::TagDecl::isCompleteDefinitionRequired(), clang::TagDecl::isEmbeddedInDeclarator(), clang::TagDecl::isFreeStanding(), clang::TagDecl::mayHaveOutOfDateDef(), clang::TagDecl::setBeingDefined(), clang::TagDecl::setCompleteDefinition(), clang::TagDecl::setCompleteDefinitionRequired(), clang::TagDecl::setEmbeddedInDeclarator(), clang::TagDecl::setFreeStanding(), clang::TagDecl::setMayHaveOutOfDateDef(), and clang::TagDecl::setTagKind().

The documentation for this class was generated from the following files:

- include/clang/AST/DeclBase.h
- include/clang/AST/DeclLookups.h
- include/clang/AST/DependentDiagnostic.h
- lib/AST/ASTDumper.cpp
- lib/AST/DeclBase.cpp
- lib/AST/DeclPrinter.cpp