clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
clang::DeclContext Class Reference

#include <DeclBase.h>

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

List of all members.

Classes

class  all_lookups_iterator
class  ddiag_iterator
class  decl_iterator
class  filtered_decl_iterator
 Iterates over a filtered subrange of declarations stored in a DeclContext. More...
class  specific_decl_iterator

Public Types

typedef llvm::iterator_range
< decl_iterator
decl_range
typedef NamedDecl ** lookup_iterator
typedef NamedDecl *const * lookup_const_iterator
typedef DeclContextLookupResult lookup_result
typedef
DeclContextLookupConstResult 
lookup_const_result
typedef llvm::iterator_range
< all_lookups_iterator
lookups_range
typedef llvm::iterator_range
< UsingDirectiveDecl *const * > 
udir_range
typedef llvm::iterator_range
< DeclContext::ddiag_iterator
ddiag_range

Public Member Functions

 ~DeclContext ()
Decl::Kind getDeclKind () const
const char * getDeclKindName () const
DeclContextgetParent ()
 getParent - Returns the containing DeclContext.
const DeclContextgetParent () const
DeclContextgetLexicalParent ()
const DeclContextgetLexicalParent () const
DeclContextgetLookupParent ()
 Find the parent context of this context that will be used for unqualified name lookup.
const DeclContextgetLookupParent () const
ASTContextgetParentASTContext () const
bool isClosure () const
bool isObjCContainer () const
bool isFunctionOrMethod () const
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.
bool isTransparentContext () const
bool isExternCContext () const
 Determines whether this context or some of its ancestors is a linkage specification context that specifies C linkage.
bool isExternCXXContext () const
 Determines whether this context or some of its ancestors is a linkage specification context that specifies C++ linkage.
bool Equals (const DeclContext *DC) const
 Determine whether this declaration context is equivalent to the declaration context DC.
bool Encloses (const DeclContext *DC) const
 Determine whether this declaration context encloses the declaration context DC.
DeclgetNonClosureAncestor ()
 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.
const DeclgetNonClosureAncestor () const
DeclContextgetPrimaryContext ()
const DeclContextgetPrimaryContext () const
DeclContextgetRedeclContext ()
const DeclContextgetRedeclContext () const
DeclContextgetEnclosingNamespaceContext ()
 Retrieve the nearest enclosing namespace context.
const DeclContextgetEnclosingNamespaceContext () const
RecordDeclgetOuterLexicalRecordContext ()
 Retrieve the outermost lexically enclosing record context.
const RecordDeclgetOuterLexicalRecordContext () 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. If either context isn't a namespace, this is equivalent to Equals().
void collectAllContexts (SmallVectorImpl< DeclContext * > &Contexts)
 Collects all of the declaration contexts that are semantically connected to this declaration context.
decl_range decls () const
decl_iterator decls_begin () const
decl_iterator decls_end () const
bool decls_empty () const
decl_range noload_decls () const
decl_iterator noload_decls_begin () const
decl_iterator noload_decls_end () const
void addDecl (Decl *D)
 Add the declaration D into this context.
void addDeclInternal (Decl *D)
 Add the declaration D into this context, but suppress searches for external declarations with the same name.
void addHiddenDecl (Decl *D)
 Add the declaration D to this context without modifying any lookup tables.
void removeDecl (Decl *D)
 Removes a declaration from this context.
bool containsDecl (Decl *D) const
 Checks whether a declaration is in this context.
lookup_result lookup (DeclarationName Name)
lookup_const_result lookup (DeclarationName Name) const
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.
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.
void makeDeclVisibleInContext (NamedDecl *D)
 Makes a declaration visible within this context.
lookups_range lookups () const
lookups_range noload_lookups () const
all_lookups_iterator lookups_begin () const
 Iterators over all possible lookups within this context.
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.
all_lookups_iterator noload_lookups_end () const
udir_range using_directives () const
ddiag_range ddiags () const
void setMustBuildLookupTable ()
 Mark the lookup table as needing to be built. This should be used only if setHasExternalLexicalStorage() has been called on any decl context for which this is the primary context.
StoredDeclsMapgetLookupPtr () const
 Retrieve the internal representation of the lookup structure. This may omit some names if we are lazily building the structure.
StoredDeclsMapbuildLookup ()
 Ensure the lookup structure is fully-built and return it.
bool hasExternalLexicalStorage () const
 Whether this DeclContext has external storage containing additional declarations that are lexically in this context.
void setHasExternalLexicalStorage (bool ES=true)
 State whether this DeclContext has external storage for declarations lexically in this context.
bool hasExternalVisibleStorage () const
 Whether this DeclContext has external storage containing additional declarations that are visible in this context.
void setHasExternalVisibleStorage (bool ES=true)
 State whether this DeclContext has external storage for declarations visible in this context.
bool isDeclInLexicalTraversal (const Decl *D) const
 Determine whether the given declaration is stored in the list of declarations lexically within this context.
void dumpDeclContext () const
void dumpLookups () const
void dumpLookups (llvm::raw_ostream &OS, bool DumpDecls=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.

Protected Attributes

DeclFirstDecl
DeclLastDecl

Friends

class ExternalASTSource
class ASTDeclReader
class ASTWriter
class DependentDiagnostic

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 NamespaceDecl FunctionDecl TagDecl ObjCMethodDecl ObjCContainerDecl LinkageSpecDecl BlockDecl

Definition at line 1025 of file DeclBase.h.


Member Typedef Documentation

Definition at line 1601 of file DeclBase.h.

typedef llvm::iterator_range<decl_iterator> clang::DeclContext::decl_range

Definition at line 1320 of file DeclBase.h.

lookup_const_iterator - An iterator that provides non-mutable access to the results of lookup up a name within this context.

Definition at line 1529 of file DeclBase.h.

Definition at line 1532 of file DeclBase.h.

lookup_iterator - An iterator that provides access to the results of looking up a name within this context.

Definition at line 1525 of file DeclBase.h.

Definition at line 1531 of file DeclBase.h.

Definition at line 1579 of file DeclBase.h.

typedef llvm::iterator_range<UsingDirectiveDecl * const *> clang::DeclContext::udir_range

Definition at line 1596 of file DeclBase.h.


Constructor & Destructor Documentation

clang::DeclContext::DeclContext ( Decl::Kind  K) [inline, protected]

Definition at line 1075 of file DeclBase.h.

Definition at line 785 of file DeclBase.cpp.


Member Function Documentation

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 1194 of file DeclBase.cpp.

References addHiddenDecl().

Referenced by clang::Sema::ActOnCapturedRegionStart(), clang::Sema::ActOnEmptyDeclaration(), clang::Sema::ActOnExceptionDeclarator(), clang::Sema::ActOnFileScopeAsmDecl(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFriendTypeDecl(), clang::Sema::ActOnLambdaExpr(), clang::Sema::ActOnModuleImport(), clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::ActOnOpenMPPrivateClause(), clang::Sema::ActOnOpenMPThreadprivateDirective(), clang::Sema::ActOnPropertyImplDecl(), clang::Sema::ActOnStartCategoryImplementation(), clang::Sema::ActOnStartCategoryInterface(), clang::Sema::ActOnStartLinkageSpecification(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ActOnTemplatedFriendTag(), addAsFieldToClosureType(), addBlockPointerConversion(), clang::ObjCImplDecl::addClassMethod(), addFunctionPointerConversion(), clang::ObjCImplDecl::addInstanceMethod(), clang::ObjCImplDecl::addPropertyImplementation(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::buildInitCaptureField(), clang::Sema::BuildStaticAssertDeclaration(), clang::Sema::BuildUsingDeclaration(), clang::Sema::BuildUsingShadowDecl(), captureInCapturedRegion(), captureThis(), clang::Sema::CheckImplementationIvars(), CreateAAPCSABIBuiltinVaListDecl(), CreateAArch64ABIBuiltinVaListDecl(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createImplicitModuleImportForErrorRecovery(), clang::Sema::createLambdaClosureType(), CreatePowerABIBuiltinVaListDecl(), clang::Sema::CreatePropertyDecl(), CreateSystemZBuiltinVaListDecl(), CreateX86_64ABIBuiltinVaListDecl(), clang::Sema::DeclareGlobalAllocationFunction(), clang::Sema::DeclareImplicitCopyAssignment(), clang::Sema::DeclareImplicitCopyConstructor(), clang::Sema::DeclareImplicitDefaultConstructor(), clang::Sema::DeclareImplicitDestructor(), clang::Sema::DeclareImplicitMoveAssignment(), clang::Sema::DeclareImplicitMoveConstructor(), clang::CodeGen::CodeGenModule::GetAddrOfConstantString(), clang::ASTContext::getBlockDescriptorExtendedType(), clang::ASTContext::getBlockDescriptorType(), clang::ASTContext::getCFConstantStringType(), clang::CodeGen::CodeGenModule::getObjCFastEnumerationStateType(), clang::ASTContext::getObjCSuperType(), clang::Sema::HandleField(), clang::Sema::HandleMSProperty(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::Sema::LazilyCreateBuiltin(), clang::CompilerInstance::loadModule(), clang::Sema::ProcessPropertyDecl(), clang::Sema::PushUsingDirective(), clang::FunctionDecl::setDeclsInPrototypeScope(), clang::Sema::tryCaptureVariable(), and clang::TemplateDeclInstantiator::VisitCXXMethodDecl().

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 1168 of file DeclBase.cpp.

References clang::ASTContext::addedLocalImportDecl(), FirstDecl, clang::Decl::getASTContext(), clang::Decl::getLexicalDeclContext(), clang::Decl::getNextDeclInContext(), clang::Decl::isFromASTFile(), LastDecl, clang::Decl::NextInContextAndBits, and Record.

Referenced by clang::Sema::ActOnAccessSpecifier(), clang::Sema::ActOnOpenMPFirstprivateClause(), addDecl(), addDeclInternal(), clang::Sema::BuildVariableInstantiation(), and FinishForRangeVarDecl().

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 969 of file DeclBase.cpp.

References clang::Decl::NextInContextAndBits.

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 1243 of file DeclBase.cpp.

References collectAllContexts(), Contexts, decls_begin(), decls_end(), and getPrimaryContext().

Referenced by lookup(), lookups(), visitLocalLookupResults(), and clang::ASTDeclWriter::VisitNamespaceDecl().

bool DeclContext::classof ( const Decl D) [static]
static bool clang::DeclContext::classof ( const DeclContext D) [inline, static]

Definition at line 1652 of file DeclBase.h.

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:
ContextsWill 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 952 of file DeclBase.cpp.

References clang::NamedDecl::getMostRecentDecl(), and clang::Decl::getPreviousDecl().

Referenced by buildLookup(), and noload_lookup().

Checks whether a declaration is in this context.

Definition at line 1120 of file DeclBase.cpp.

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

Referenced by clang::FunctionDecl::setDeclsInPrototypeScope().

Definition at line 1113 of file DeclBase.cpp.

References FirstDecl, and hasExternalLexicalStorage().

Referenced by clang::LinkageSpecDecl::getLocEnd().

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

Definition at line 2227 of file ASTDumper.cpp.

void clang::DeclContext::dumpLookups ( llvm::raw_ostream &  OS,
bool  DumpDecls = false 
) const
bool DeclContext::Encloses ( const DeclContext DC) const
bool clang::DeclContext::Equals ( const DeclContext DC) const [inline]
const char * DeclContext::getDeclKindName ( ) const

Definition at line 97 of file DeclBase.cpp.

Definition at line 1238 of file DeclBase.h.

References getEnclosingNamespaceContext().

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 1106 of file DeclBase.h.

Referenced by clang::Sema::ActOnReenterFunctionContext(), basicGVALinkageForVariable(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::getContainingDC(), clang::Sema::getCurrentMangleNumberContext(), getLexicalParent(), getLookupParent(), getOuterLexicalRecordContext(), isDependentContext(), isInInlineFunction(), and isLinkageSpecContext().

Definition at line 1109 of file DeclBase.h.

References getLexicalParent().

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 793 of file DeclBase.cpp.

References getLexicalParent(), getParent(), getRedeclContext(), isFileContext(), and isRecord().

Referenced by clang::Sema::CheckClassTemplate(), clang::Sema::CheckTemplateIdType(), getLookupParent(), LookupVisibleDecls(), and synthesizeCurrentNestedNameSpecifier().

Definition at line 1115 of file DeclBase.h.

References getLookupParent().

Retrieve the internal representation of the lookup structure. This may omit some names if we are lazily building the structure.

Definition at line 1617 of file DeclBase.h.

Referenced by ddiags(), and noload_lookups().

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 759 of file DeclBase.cpp.

References getNonClosureContext().

Referenced by getNonClosureAncestor(), clang::Sema::isSelfExpr(), and LookupMethodInReceiverType().

Definition at line 1213 of file DeclBase.h.

References getNonClosureAncestor().

Retrieve the outermost lexically enclosing record context.

Definition at line 1444 of file DeclBase.cpp.

References getLexicalParent(), and isRecord().

Referenced by clang::Sema::BuildCXXDefaultInitExpr(), getOuterLexicalRecordContext(), and clang::Sema::InstantiateInClassInitializer().

Definition at line 1244 of file DeclBase.h.

References getOuterLexicalRecordContext().

getParent - Returns the containing DeclContext.

Reimplemented in clang::CXXMethodDecl.

Definition at line 1090 of file DeclBase.h.

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnSuperScopeSpecifier(), clang::Sema::ActOnTag(), clang::Sema::ActOnUsingDirective(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::Sema::BuildMemberReferenceExpr(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckConstexprFunctionBody(), checkModuleImportContext(), clang::Sema::CheckQualifiedMemberReference(), clang::Sema::CheckTemplateDeclScope(), clang::Sema::CheckUsingShadowDecl(), ClassifyImplicitMemberAccess(), CollectEnclosingNamespace(), clang::PredefinedExpr::ComputeName(), clang::Sema::CreateCapturedStmtRecordDecl(), createFriendTagNNSFixIt(), clang::Sema::createLambdaClosureType(), clang::ASTContext::DeclMustBeEmitted(), diagnoseBadDirectAccess(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseInvalidRedeclaration(), DiagnoseNamespaceInlineMismatch(), clang::Sema::diagnoseQualifiedDeclaration(), DiagnoseTwoPhaseLookup(), diagnoseUncapturableValueReference(), dumpDeclContext(), Encloses(), clang::Sema::FindInstantiatedDecl(), findOuterContext(), clang::ObjCMethodDecl::findPropertyDecl(), clang::Sema::getCurMethodDecl(), clang::ASTContext::getDeclAlign(), getEnclosingNamespaceContext(), clang::ento::LikelyFalsePositiveSuppressionBRVisitor::getEndPath(), clang::Sema::getFunctionLevelDeclContext(), clang::getLambdaAwareParentOfDeclContext(), getLookupParent(), getLVForNamespaceScopeDecl(), getNonClosureContext(), getOutermostEnclosingLambda(), getOutermostFuncOrBlockContext(), getParent(), clang::CodeCompletionTUInfo::getParentName(), getRedeclContext(), clang::Sema::getTemplateInstantiationArgs(), clang::Decl::getTranslationUnitDecl(), handleIBOutletCollection(), HandleTagNumbering(), InEnclosingNamespaceSetOf(), clang::Sema::InstantiateMemInitializers(), clang::ento::CheckerContext::isCLibraryFunction(), clang::CXXRecordDecl::isCurrentInstantiation(), isDependentContext(), clang::Decl::isInAnonymousNamespace(), clang::Sema::IsInsideALocalClassWithinATemplateFunction(), IsInStdNamespace(), isInStdNamespace(), clang::Expr::isPotentialConstantExpr(), isReferenceToNonConstCapture(), isStdNamespace(), IsUsingDirectiveInToplevelContext(), clang::MangleContext::mangleBlock(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), MaybeAddOverrideCalls(), clang::CodeGen::CGRecordLayout::print(), clang::NamedDecl::printQualifiedName(), recoverFromMSUnqualifiedLookup(), recoverFromTypeInKnownDependentBase(), clang::Sema::SubstituteExplicitTemplateArguments(), clang::FunctionCallFilterCCC::ValidateCandidate(), clang::ASTDeclWriter::VisitDecl(), and clang::ASTDeclWriter::VisitNamespaceDecl().

const DeclContext* clang::DeclContext::getParent ( ) const [inline]

Reimplemented in clang::CXXMethodDecl.

Definition at line 1093 of file DeclBase.h.

References getParent().

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 889 of file DeclBase.cpp.

References clang::ObjCInterfaceDecl::getDefinition(), clang::ObjCProtocolDecl::getDefinition(), clang::TagDecl::getDefinition(), clang::TypeDecl::getTypeForDecl(), and clang::TagDecl::isBeingDefined().

Referenced by buildLookup(), CollectEnclosingNamespace(), ddiags(), Encloses(), Equals(), getEnclosingNamespaceContext(), getPrimaryContext(), getPrimaryContextForMerging(), clang::Sema::getScopeForContext(), clang::Sema::getScopeForDeclContext(), lookup(), lookups(), LookupVisibleDecls(), makeDeclVisibleInContext(), MightInstantiateTo(), noload_lookup(), noload_lookups(), removeDecl(), synthesizeCurrentNestedNameSpecifier(), visitLocalLookupResults(), and clang::ASTDeclWriter::VisitNamespaceDecl().

Definition at line 1224 of file DeclBase.h.

References getPrimaryContext().

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 1428 of file DeclBase.cpp.

References getParent(), and isTransparentContext().

Referenced by clang::Sema::ActOnEnumConstant(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ActOnTag(), clang::Sema::ActOnTypedefNameDecl(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckCompleteVariableDeclaration(), clang::Sema::CheckDependentFunctionTemplateSpecialization(), CheckExplicitInstantiationScope(), clang::Sema::CheckFunctionTemplateSpecialization(), clang::Sema::CheckObjCDeclScope(), CheckOperatorNewDeleteDeclarationScope(), CheckTemplateSpecializationScope(), clang::Sema::CheckUsingDeclRedeclaration(), clang::ASTReader::CompleteRedeclChain(), computeLVForDecl(), createFriendTagNNSFixIt(), clang::NamedDecl::declarationReplaces(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::FinalizeDeclaration(), getContextForScopeMatching(), clang::FunctionDecl::getCorrespondingUnsizedGlobalDeallocationFunction(), getFunctionStorageClass(), getLookupParent(), getLVForClosure(), getLVForNamespaceScopeDecl(), getRedeclContext(), handleWeakRefAttr(), clang::NamedDecl::isCXXClassMember(), clang::IdentifierResolver::isDeclInScope(), clang::VarDecl::isFunctionOrMethodVarDecl(), clang::FunctionDecl::isMain(), clang::FunctionDecl::isMSVCRTEntryPoint(), isOutOfScopePreviousDeclaration(), clang::FunctionDecl::isReplaceableGlobalAllocationFunction(), clang::FunctionDecl::isReservedGlobalPlacementOperator(), isSameEntity(), isStdNamespace(), clang::Sema::LookupName(), clang::Sema::MergeFunctionDecl(), clang::Sema::PushOnScopeChains(), clang::Sema::RegisterLocallyScopedExternCDecl(), shouldConsiderLinkage(), clang::Sema::ShouldEnterDeclaratorScope(), clang::IdentifierResolver::tryAddTopLevelDecl(), and clang::ASTDeclWriter::VisitNamespaceDecl().

Definition at line 1232 of file DeclBase.h.

References getRedeclContext().

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

Definition at line 1624 of file DeclBase.h.

Referenced by decls_begin(), decls_empty(), clang::ASTContext::getASTRecordLayout(), localUncachedLookup(), and clang::ASTNodeImporter::VisitRecordDecl().

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

Definition at line 1634 of file DeclBase.h.

Referenced by clang::ASTReader::completeVisibleDeclsMap(), clang::ASTReader::FindExternalVisibleDeclsByName(), localUncachedLookup(), lookup(), lookups(), and noload_lookup().

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 1455 of file DeclBase.cpp.

References Equals(), getParent(), isFileContext(), and clang::NamespaceDecl::isInline().

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::CheckDependentFunctionTemplateSpecialization(), CheckExplicitInstantiationScope(), CheckTemplateSpecializationScope(), clang::IdentifierResolver::isDeclInScope(), and clang::Sema::isStdInitializerList().

bool clang::DeclContext::isClosure ( ) const [inline]

Definition at line 1123 of file DeclBase.h.

Referenced by clang::FormatASTNodeDiagnosticArgument().

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

Definition at line 1646 of file DeclBase.h.

References FirstDecl, LastDecl, and clang::Decl::NextInContextAndBits.

Determines whether this context is dependent on a template parameter.

Definition at line 824 of file DeclBase.cpp.

References getLexicalParent(), getParent(), isDependentContext(), isFileContext(), and Record.

Referenced by clang::Sema::ActOnBlockStmtExpr(), clang::Sema::ActOnCXXEnterDeclaratorScope(), clang::Sema::ActOnCXXMemberDeclarator(), clang::Sema::ActOnDependentTemplateName(), clang::Sema::ActOnFinishFunctionBody(), clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnOpenMPAtomicDirective(), clang::Sema::ActOnOpenMPForDirective(), clang::Sema::ActOnOpenMPParallelForDirective(), clang::Sema::ActOnOpenMPSimdDirective(), clang::Sema::ActOnVariableDeclarator(), AddOrdinaryNameResults(), clang::CXXMethodDecl::addOverriddenMethod(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::BuildBaseInitializer(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::Sema::BuildDelegatingInitializer(), clang::Sema::BuildMemberReferenceExpr(), clang::Sema::buildOverloadedCallSet(), clang::Sema::BuildVariableInstantiation(), CanDeclareSpecialMemberFunction(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckCompleteVariableDeclaration(), CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(), checkMoveAssignmentForRepeatedMove(), CheckOpenMPIterationSpace(), CheckOpenMPLoop(), clang::Sema::CheckParmsForFunctionDef(), clang::Sema::CheckPureMethod(), clang::Sema::CheckTemplateArgument(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CodeCompleteMemberReferenceExpr(), computeDeclRefDependence(), ddiags(), clang::Sema::DeclareInheritingConstructors(), clang::ASTContext::DeclMustBeEmitted(), clang::Sema::DeduceFunctionTypeFromReturnExpr(), DiagnoseBaseOrMemInitializerOrder(), clang::Sema::DiagnoseEmptyLookup(), clang::CodeGen::CodeGenModule::EmitTopLevelDecl(), clang::Sema::FinalizeVarWithDestructor(), clang::Sema::FindInstantiatedDecl(), clang::CXXRecordDecl::forallBases(), getCurrentInstantiationOf(), clang::Sema::getDestructorName(), getStackIndexOfNearestEnclosingCaptureReadyLambda(), clang::Sema::getTypeName(), clang::Sema::HandleDeclarator(), clang::CXXRecordDecl::hasAnyDependentBases(), clang::CXXRecordDecl::isCurrentInstantiation(), clang::TemplateArgument::isDependent(), isDependentContext(), IsDerivedFromInclusive(), clang::TemplateArgument::isInstantiationDependent(), clang::Sema::isNonTypeNestedNameSpecifier(), clang::Expr::isPotentialConstantExpr(), IsPotentiallyEvaluatedContext(), clang::Sema::LookupParsedName(), clang::Sema::LookupQualifiedName(), clang::Sema::MarkBaseAndMemberDestructorsReferenced(), clang::Sema::MarkVTableUsed(), clang::CXXRecordDecl::mayBeAbstract(), clang::Sema::MaybeBindToTemporary(), clang::Sema::MergeCXXFunctionDecl(), MightInstantiateTo(), clang::Sema::RequireCompleteDeclContext(), clang::Sema::SetCtorInitializers(), clang::Sema::ShouldWarnIfUnusedFileScopedDecl(), and clang::Sema::startLambdaDefinition().

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

Definition at line 871 of file DeclBase.cpp.

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

Referenced by clang::Sema::ActOnFields(), clang::Sema::CheckTemplateDeclScope(), clang::VarDecl::isInExternCContext(), clang::FunctionDecl::isInExternCContext(), and clang::RecordDecl::mayInsertExtraPadding().

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

Definition at line 875 of file DeclBase.cpp.

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

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

Definition at line 1139 of file DeclBase.h.

Referenced by clang::Sema::ActOnStartOfLambdaDefinition(), clang::Sema::ActOnTag(), clang::Sema::ActOnVariableDeclarator(), clang::CodeCompletionBuilder::addParentContext(), clang::Sema::adjustContextForLocalExternDecl(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::Sema::BuildDeclRefExpr(), clang::Sema::BuildUsingDeclaration(), clang::Sema::BuildVariableInstantiation(), CheckTemplateSpecializationScope(), computeCachedProperties(), computeLVForDecl(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createLambdaClosureType(), diagnoseUncapturableValueReference(), DoMarkVarDeclReferenced(), clang::Sema::FindInstantiatedDecl(), getContextForScopeMatching(), getFunctionStorageClass(), clang::CodeCompletionTUInfo::getParentName(), clang::TemplateDeclInstantiator::InstantiateEnumDefinition(), clang::IdentifierResolver::isDeclInScope(), isDeclWithinFunction(), clang::VarDecl::isFunctionOrMethodVarDecl(), isOutOfScopePreviousDeclaration(), LookupVisibleDecls(), clang::Sema::MergeFunctionDecl(), mergeTypeWithPrevious(), clang::Sema::ParsedFreeStandingDeclSpec(), clang::NamedDecl::printQualifiedName(), clang::Sema::PushOnScopeChains(), clang::Sema::PushUsingDirective(), shouldConsiderLinkage(), ShouldDiagnoseUnusedDecl(), clang::Sema::UseArgumentDependentLookup(), clang::ASTNodeImporter::VisitClassTemplateDecl(), clang::ASTNodeImporter::VisitEnumConstantDecl(), clang::ASTNodeImporter::VisitEnumDecl(), clang::ASTNodeImporter::VisitFunctionDecl(), clang::TemplateDeclInstantiator::VisitFunctionDecl(), clang::ASTNodeImporter::VisitRecordDecl(), clang::ASTNodeImporter::VisitTypedefNameDecl(), clang::ASTDeclReader::VisitVarDeclImpl(), clang::ASTNodeImporter::VisitVarTemplateDecl(), and warnAboutAmbiguousFunction().

Definition at line 803 of file DeclBase.cpp.

References isNamespace().

Referenced by CollectEnclosingNamespace(), and IsFunctionStdAbs().

bool clang::DeclContext::isRecord ( ) const [inline]

Definition at line 1158 of file DeclBase.h.

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnTag(), clang::Sema::ActOnVariableDeclarator(), clang::Sema::AddInitializerToDecl(), clang::Sema::BuildAnonymousStructOrUnion(), clang::Sema::BuildCXXNestedNameSpecifier(), clang::Sema::BuildUsingDeclaration(), clang::Sema::CheckAddressOfOperand(), clang::Sema::CheckClassTemplate(), clang::comments::Sema::checkDeprecatedCommand(), CheckExplicitInstantiationScope(), clang::Sema::CheckQualifiedMemberReference(), clang::Sema::CheckShadow(), CheckTemplateSpecializationScope(), clang::Sema::CheckUsingDeclQualifier(), clang::Sema::CheckUsingDeclRedeclaration(), clang::Sema::CheckUsingShadowDecl(), ClassifyMemberExpr(), CollectEnclosingNamespace(), computeLVForDecl(), clang::Sema::CreateCapturedStmtRecordDecl(), clang::Sema::createLambdaClosureType(), CreateNewFunctionDecl(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::diagnoseQualifiedDeclaration(), getDeclLanguageLinkage(), GetFullTypeForDeclarator(), getLookupParent(), getOuterLexicalRecordContext(), clang::Sema::HandleDeclarator(), haveIncompatibleLanguageLinkages(), clang::Sema::InstantiateVariableDefinition(), clang::NamedDecl::isCXXClassMember(), isDeclExternC(), isDeclWithinFunction(), clang::RecordDecl::isInjectedClassName(), isOutOfScopePreviousDeclaration(), mapCodeCompletionContext(), clang::Sema::MergeCXXFunctionDecl(), clang::Sema::MergeVarDecl(), shouldConsiderLinkage(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().

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 852 of file DeclBase.cpp.

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnTag(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckQualifiedMemberReference(), CollectEnclosingNamespace(), clang::Sema::getNonFieldDeclScope(), getRedeclContext(), clang::ento::CheckerContext::isCLibraryFunction(), clang::IdentifierResolver::isDeclInScope(), clang::Sema::LookupName(), and clang::Sema::PushOnScopeChains().

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

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 1297 of file DeclBase.cpp.

References buildLookup(), clang::ExternalASTSource::FindExternalVisibleDeclsByName(), clang::ASTContext::getExternalSource(), getParentASTContext(), getPrimaryContext(), hasExternalVisibleStorage(), and lookup().

Referenced by clang::Sema::ActOnProperty(), clang::Sema::ActOnStartNamespaceDef(), clang::Sema::ArgumentDependentLookup(), clang::Sema::BuildBlockForLambdaConversion(), clang::Sema::BuildCXXDefaultInitExpr(), clang::Sema::BuildMemInitializer(), clang::Sema::CheckCompletedCXXClass(), checkGlobalOrExternCConflict(), CheckPropertyAgainstProtocol(), ClassImplementsAllMethodsAndProperties(), clang::ASTReader::CompleteRedeclChain(), clang::Sema::DeclareGlobalAllocationFunction(), clang::CodeGen::CodeGenFunction::EmitBuiltinNewDeleteCall(), FindHiddenVirtualMethod(), clang::Sema::FindHiddenVirtualMethods(), clang::Sema::FindInstantiatedDecl(), clang::CXXRecordDecl::FindNestedNameSpecifierMember(), clang::CXXRecordDecl::FindOrdinaryMember(), FindOverriddenMethod(), clang::ObjCPropertyDecl::findPropertyDecl(), clang::CXXRecordDecl::FindTagMember(), clang::CXXMethodDecl::getCorrespondingMethodInClass(), clang::FunctionDecl::getCorrespondingUnsizedGlobalDeallocationFunction(), clang::CXXRecordDecl::getDestructor(), clang::ObjCContainerDecl::getIvarDecl(), clang::CXXRecordDecl::getLambdaCallOperator(), clang::CXXRecordDecl::getLambdaStaticInvoker(), clang::ObjCContainerDecl::getMethod(), hasMember(), clang::ObjCContainerDecl::HasUserDeclaredSetterMethod(), clang::Sema::InstantiateClassMembers(), clang::CXXMethodDecl::isUsualDeallocationFunction(), localUncachedLookup(), lookup(), LookupAnyMember(), clang::Sema::LookupConstructors(), LookupDirect(), clang::Sema::LookupSpecialMember(), noload_lookup(), clang::TreeTransform< Derived >::RebuildShuffleVectorExpr(), threadSafetyCheckIsSmartPointer(), using_directives(), clang::ASTDeclReader::VisitDecl(), and visitLocalLookupResults().

Definition at line 1540 of file DeclBase.h.

References lookup().

Iterators over all possible lookups within this context.

Definition at line 81 of file DeclLookups.h.

References lookups().

Definition at line 85 of file DeclLookups.h.

References lookups().

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 1473 of file DeclBase.cpp.

References clang::Decl::getDeclContext(), and getPrimaryContext().

Referenced by clang::Sema::ActOnFriendFunctionDecl(), clang::Sema::ActOnPropertyImplDecl(), clang::Sema::ActOnTag(), clang::Sema::BuildVariableInstantiation(), clang::Sema::CheckClassTemplate(), clang::Sema::CheckImplementationIvars(), DiagnoseNamespaceInlineMismatch(), clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::TemplateDeclInstantiator::VisitFunctionDecl().

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 1332 of file DeclBase.h.

References noload_decls_begin(), and noload_decls_end().

Referenced by findAnonymousStructOrUnionIndex(), and getFieldIndex().

Definition at line 1335 of file DeclBase.h.

References FirstDecl.

Referenced by noload_decls(), and noload_lookup().

Definition at line 1336 of file DeclBase.h.

Referenced by noload_decls(), and noload_lookup().

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 1355 of file DeclBase.cpp.

References collectAllContexts(), Contexts, getPrimaryContext(), hasExternalVisibleStorage(), lookup(), noload_decls_begin(), noload_decls_end(), and noload_lookup().

Referenced by noload_lookup().

Definition at line 89 of file DeclLookups.h.

References getLookupPtr(), and getPrimaryContext().

Referenced by noload_lookups_begin(), and noload_lookups_end().

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

Definition at line 98 of file DeclLookups.h.

References noload_lookups().

Definition at line 103 of file DeclLookups.h.

References noload_lookups().

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

Definition at line 1628 of file DeclBase.h.

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

Definition at line 1638 of file DeclBase.h.

Mark the lookup table as needing to be built. This should be used only if setHasExternalLexicalStorage() has been called on any decl context for which this is the primary context.

Definition at line 1611 of file DeclBase.h.

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

Definition at line 1575 of file DeclBase.cpp.

References lookup().

Referenced by LookupQualifiedNameInUsingDirectives(), and LookupVisibleDecls().


Friends And Related Function Documentation

friend class ASTDeclReader [friend]
friend class ASTWriter [friend]

Reimplemented in clang::CXXRecordDecl.

Definition at line 1067 of file DeclBase.h.

friend class DependentDiagnostic [friend]

Definition at line 1670 of file DeclBase.h.

friend class ExternalASTSource [friend]

Definition at line 1065 of file DeclBase.h.


Member Data Documentation

Decl* clang::DeclContext::FirstDecl [mutable, protected]

FirstDecl - The first declaration stored within this declaration context.

Definition at line 1057 of file DeclBase.h.

Referenced by addHiddenDecl(), decls_begin(), decls_empty(), isDeclInLexicalTraversal(), localUncachedLookup(), noload_decls_begin(), and removeDecl().

Decl* clang::DeclContext::LastDecl [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 1063 of file DeclBase.h.

Referenced by addHiddenDecl(), containsDecl(), isDeclInLexicalTraversal(), and removeDecl().


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