Go to the documentation of this file.
13 #ifndef LLVM_CLANG_AST_DECLBASE_H
14 #define LLVM_CLANG_AST_DECLBASE_H
23 #include "llvm/ADT/ArrayRef.h"
24 #include "llvm/ADT/PointerIntPair.h"
25 #include "llvm/ADT/PointerUnion.h"
26 #include "llvm/ADT/iterator.h"
27 #include "llvm/ADT/iterator_range.h"
28 #include "llvm/Support/Casting.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/PrettyStackTrace.h"
31 #include "llvm/Support/VersionTuple.h"
37 #include <type_traits>
43 class ASTMutationListener;
47 class ExternalSourceSymbolAttr;
52 class LinkageSpecDecl;
55 class ObjCContainerDecl;
57 struct PrintingPolicy;
63 class TemplateParameterList;
64 class TranslationUnitDecl;
65 class UsingDirectiveDecl;
87 #define DECL(DERIVED, BASE) DERIVED,
88 #define ABSTRACT_DECL(DECL)
89 #define DECL_RANGE(BASE, START, END) \
90 first##BASE = START, last##BASE = END,
91 #define LAST_DECL_RANGE(BASE, START, END) \
92 first##BASE = START, last##BASE = END
93 #include "clang/AST/DeclNodes.inc"
262 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
264 bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
265 bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
267 MultipleDC *getMultipleDC()
const {
268 return DeclCtx.get<MultipleDC*>();
279 unsigned DeclKind : 7;
282 unsigned InvalidDecl : 1;
285 unsigned HasAttrs : 1;
289 unsigned Implicit : 1;
299 unsigned Referenced : 1;
304 unsigned TopLevelDeclInObjCContainer : 1;
307 static bool StatisticsEnabled;
350 bool AccessDeclContextCheck()
const;
356 auto *D = cast<Decl>(DC);
357 auto MOK = D->getModuleOwnershipKind();
359 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
377 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(
false), HasAttrs(
false),
382 if (StatisticsEnabled)
add(DK);
391 if (StatisticsEnabled)
add(DK);
436 return getSemanticDC();
437 return getMultipleDC()->SemanticDC;
470 assert(AccessDeclContextCheck());
474 assert(AccessDeclContextCheck());
512 template <
typename T>
514 if (!HasAttrs)
return;
517 llvm::erase_if(Vec, [](
Attr *A) {
return isa<T>(A); });
523 template <
typename T>
525 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
528 template <
typename T>
533 template <
typename T>
567 bool isUsed(
bool CheckUsedAttr =
true)
const;
594 return TopLevelDeclInObjCContainer;
598 TopLevelDeclInObjCContainer =
V;
654 assert(
isFromASTFile() &&
"Only works on a deserialized declaration");
655 *((
unsigned*)
this - 2) =
ID;
678 VersionTuple EnclosingVersion = VersionTuple(),
679 StringRef *RealizedPlatform =
nullptr)
const;
731 return *((
const unsigned*)
this - 1);
739 return *((
const unsigned*)
this - 2);
744 Module *getOwningModuleSlow()
const;
756 return getOwningModuleSlow();
766 "owned local decl but no local module storage");
767 return reinterpret_cast<Module *
const *
>(
this)[-1];
772 "should not have a cached owning module");
773 reinterpret_cast<Module **
>(
this)[-1] = M;
819 "no storage available for owning module for this declaration");
854 return getSemanticDC();
855 return getMultipleDC()->LexicalDC;
937 Decl *Current =
nullptr;
954 assert(Current &&
"Advancing while iterator has reached end");
956 Decl *Next = Current->getNextRedeclarationImpl();
957 assert(Next &&
"Should return next redeclaration or itself, never null!");
958 Current = (Next != Starter) ? Next :
nullptr;
969 return x.Current == y.Current;
973 return x.Current != y.Current;
1052 return (DeclKind >= Decl::firstFunction &&
1053 DeclKind <= Decl::lastFunction) ||
1054 DeclKind == FunctionTemplate;
1091 "namespace is not ordinary");
1117 "namespace includes neither ordinary nor tag");
1121 "namespace includes other than ordinary or tag");
1128 if (PerformFriendInjection ||
1136 if (PerformFriendInjection ||
1164 "visible non-member operators should be in ordinary namespace");
1172 void print(raw_ostream &Out,
unsigned Indentation = 0,
1173 bool PrintInstantiation =
false)
const;
1175 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1178 unsigned Indentation = 0);
1186 void dump(raw_ostream &Out,
bool Deserialize =
false,
1220 const Decl *TheDecl;
1223 const char *Message;
1228 : TheDecl(theDecl), Loc(L),
SM(sm), Message(Msg) {}
1230 void print(raw_ostream &OS)
const override;
1242 static constexpr
int NumLowBitsAvailable = 3;
1252 using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>;
1269 assert(Ptr &&
"dereferencing end() iterator");
1278 assert(!Ptr.isNull() &&
"Advancing empty iterator");
1281 Ptr = CurNode->Rest;
1296 Decls Rest =
nullptr;
1322 bool empty()
const {
return Result.isNull(); }
1331 for (
auto *D : *
this)
1332 if (T *
Decl = dyn_cast<T>(D))
1374 class DeclContextBitfields {
1382 mutable uint64_t ExternalLexicalStorage : 1;
1387 mutable uint64_t ExternalVisibleStorage : 1;
1393 mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1397 mutable uint64_t HasLazyLocalLexicalLookups : 1;
1401 mutable uint64_t HasLazyExternalLexicalLookups : 1;
1406 mutable uint64_t UseQualifiedLookup : 1;
1410 enum { NumDeclContextBits = 13 };
1415 class TagDeclBitfields {
1416 friend class TagDecl;
1433 uint64_t IsEmbeddedInDeclarator : 1;
1446 uint64_t IsCompleteDefinitionRequired : 1;
1450 uint64_t IsThisDeclarationADemotedDefinition : 1;
1454 enum { NumTagDeclBits = 10 };
1459 class EnumDeclBitfields {
1460 friend class EnumDecl;
1482 uint64_t IsScopedUsingClassTag : 1;
1493 enum { NumEnumDeclBits = 20 };
1498 class RecordDeclBitfields {
1499 friend class RecordDecl;
1508 uint64_t HasFlexibleArrayMember : 1;
1511 uint64_t AnonymousStructOrUnion : 1;
1525 mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1528 uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1529 uint64_t NonTrivialToPrimitiveCopy : 1;
1530 uint64_t NonTrivialToPrimitiveDestroy : 1;
1535 uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
1536 uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
1537 uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
1540 uint64_t ParamDestroyedInCallee : 1;
1543 uint64_t ArgPassingRestrictions : 2;
1550 enum { NumRecordDeclBits = 15 };
1555 class OMPDeclareReductionDeclBitfields {
1556 friend class OMPDeclareReductionDecl;
1566 enum { NumOMPDeclareReductionDeclBits = 2 };
1572 class FunctionDeclBitfields {
1573 friend class FunctionDecl;
1575 friend class CXXDeductionGuideDecl;
1585 uint64_t HasInheritedPrototype : 1;
1597 uint64_t IsExplicitlyDefaulted : 1;
1598 uint64_t HasDefaultedFunctionInfo : 1;
1603 uint64_t IsIneligibleOrNotSelected : 1;
1605 uint64_t HasImplicitReturnZero : 1;
1610 uint64_t InstantiationIsPending : 1;
1630 uint64_t IsCopyDeductionCandidate : 1;
1640 enum { NumFunctionDeclBits = 28 };
1645 class CXXConstructorDeclBitfields {
1646 friend class CXXConstructorDecl;
1658 uint64_t IsInheritingConstructor : 1;
1661 uint64_t HasTrailingExplicitSpecifier : 1;
1669 NumCXXConstructorDeclBits = 64 - NumDeclContextBits - NumFunctionDeclBits
1675 class ObjCMethodDeclBitfields {
1676 friend class ObjCMethodDecl;
1694 uint64_t IsSynthesizedAccessorStub : 1;
1703 mutable uint64_t HasRedeclaration : 1;
1732 enum { NumObjCMethodDeclBits = 24 };
1737 class ObjCContainerDeclBitfields {
1738 friend class ObjCContainerDecl;
1740 uint32_t : NumDeclContextBits;
1744 SourceLocation AtStart;
1750 enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1755 class LinkageSpecDeclBitfields {
1756 friend class LinkageSpecDecl;
1772 enum { NumLinkageSpecDeclBits = 4 };
1777 class BlockDeclBitfields {
1778 friend class BlockDecl;
1784 uint64_t BlockMissingReturnType : 1;
1785 uint64_t IsConversionFromLambda : 1;
1798 enum { NumBlockDeclBits = 5 };
1806 mutable StoredDeclsMap *LookupPtr =
nullptr;
1830 static_assert(
sizeof(DeclContextBitfields) <= 8,
1831 "DeclContextBitfields is larger than 8 bytes!");
1832 static_assert(
sizeof(TagDeclBitfields) <= 8,
1833 "TagDeclBitfields is larger than 8 bytes!");
1834 static_assert(
sizeof(EnumDeclBitfields) <= 8,
1835 "EnumDeclBitfields is larger than 8 bytes!");
1836 static_assert(
sizeof(RecordDeclBitfields) <= 8,
1837 "RecordDeclBitfields is larger than 8 bytes!");
1838 static_assert(
sizeof(OMPDeclareReductionDeclBitfields) <= 8,
1839 "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
1840 static_assert(
sizeof(FunctionDeclBitfields) <= 8,
1841 "FunctionDeclBitfields is larger than 8 bytes!");
1842 static_assert(
sizeof(CXXConstructorDeclBitfields) <= 8,
1843 "CXXConstructorDeclBitfields is larger than 8 bytes!");
1844 static_assert(
sizeof(ObjCMethodDeclBitfields) <= 8,
1845 "ObjCMethodDeclBitfields is larger than 8 bytes!");
1846 static_assert(
sizeof(ObjCContainerDeclBitfields) <= 8,
1847 "ObjCContainerDeclBitfields is larger than 8 bytes!");
1848 static_assert(
sizeof(LinkageSpecDeclBitfields) <= 8,
1849 "LinkageSpecDeclBitfields is larger than 8 bytes!");
1850 static_assert(
sizeof(BlockDeclBitfields) <= 8,
1851 "BlockDeclBitfields is larger than 8 bytes!");
1867 static std::pair<Decl *, Decl *>
1883 return cast<Decl>(
this)->getDeclContext();
1899 return cast<Decl>(
this)->getLexicalDeclContext();
1912 return cast<Decl>(
this)->getASTContext();
1923 case Decl::ObjCCategory:
1924 case Decl::ObjCCategoryImpl:
1925 case Decl::ObjCImplementation:
1926 case Decl::ObjCInterface:
1927 case Decl::ObjCProtocol:
1937 case Decl::Captured:
1938 case Decl::ObjCMethod:
2096 Decl *Current =
nullptr;
2114 Current = Current->getNextDeclInContext();
2125 return x.Current == y.Current;
2129 return x.Current != y.Current;
2156 template<
typename SpecificDecl>
2166 void SkipToNextDecl() {
2167 while (*Current && !isa<SpecificDecl>(*Current))
2178 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2214 return x.Current == y.Current;
2219 return x.Current != y.Current;
2232 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
2242 void SkipToNextDecl() {
2244 (!isa<SpecificDecl>(*Current) ||
2245 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2256 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2290 return x.Current == y.Current;
2295 return x.Current != y.Current;
2425 using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2439 "should only be called on primary context");
2472 if (ES && LookupPtr)
2498 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false,
2499 bool Deserialize =
false)
const;
2506 bool hasNeedToReconcileExternalVisibleStorage()
const {
2514 void setNeedToReconcileExternalVisibleStorage(
bool Need =
true)
const {
2520 bool hasLazyLocalLexicalLookups()
const {
2526 void setHasLazyLocalLexicalLookups(
bool HasLLLL =
true)
const {
2532 bool hasLazyExternalLexicalLookups()
const {
2538 void setHasLazyExternalLexicalLookups(
bool HasLELL =
true)
const {
2542 void reconcileExternalVisibleStorage()
const;
2543 bool LoadLexicalDeclsFromExternalStorage()
const;
2551 void makeDeclVisibleInContextInternal(NamedDecl *D);
2553 StoredDeclsMap *CreateStoredDeclsMap(ASTContext &
C)
const;
2555 void loadLazyLocalLexicalLookups();
2556 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
2557 void makeDeclVisibleInContextWithFlags(NamedDecl *D,
bool Internal,
2558 bool Rediscoverable);
2559 void makeDeclVisibleInContextImpl(NamedDecl *D,
bool Internal);
2563 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
2564 getKind() == TemplateTemplateParm;
2568 template <
class ToTy,
2569 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2581 template <
class ToTy>
2584 return static_cast<const ToTy*
>(Val);
2588 return static_cast<ToTy*
>(Val);
2597 template <
typename To>
2599 static bool doit(const ::clang::DeclContext &Val) {
2600 return To::classofKind(Val.getDeclKind());
2605 template<
class ToTy>
2606 struct cast_convert_val<ToTy,
2608 static const ToTy &
doit(const ::clang::DeclContext &Val) {
2613 template<
class ToTy>
2620 template<
class ToTy>
2621 struct cast_convert_val<ToTy,
2623 static const ToTy *
doit(const ::clang::DeclContext *Val) {
2624 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2628 template<
class ToTy>
2631 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2636 template<
class FromTy>
2638 static ::clang::DeclContext &
doit(
const FromTy &Val) {
2639 return *FromTy::castToDeclContext(&Val);
2643 template<
class FromTy>
2645 static ::clang::DeclContext *
doit(
const FromTy *Val) {
2646 return FromTy::castToDeclContext(Val);
2650 template<
class FromTy>
2652 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
2653 return *FromTy::castToDeclContext(&Val);
2657 template<
class FromTy>
2659 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
2660 return FromTy::castToDeclContext(Val);
2666 #endif // LLVM_CLANG_AST_DECLBASE_H
void setLexicalDeclContext(DeclContext *DC)
decl_iterator noload_decls_end() const
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
DeclContextLookupResult(Decls Result)
const Decl * getNonClosureContext() const
ASTContext & getASTContext() const LLVM_READONLY
decl_iterator decls_end() const
void removeDecl(Decl *D)
Removes a declaration from this context.
@ IDNS_Type
Types, declared with 'struct foo', typedefs, etc.
specific_attr_iterator< T > specific_attr_end() const
YAML serialization mapping.
specific_decl_iterator()=default
SourceLocation getBeginLoc() const LLVM_READONLY
ASTContext & getParentASTContext() const
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
bool hasCachedLinkage() const
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
const_iterator end() const
const Decl * getNonClosureAncestor() const
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
SourceLocation getEndLoc() const LLVM_READONLY
Represents a linkage specification.
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
bool isTemplateDecl() const
returns true if this declaration is a template
A trivial tuple used to represent a source range.
ObjCContainerDeclBitfields ObjCContainerDeclBits
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
bool operator!=(const iterator &X) const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static const ToTy * doit(const DeclContext *Val)
redecl_iterator & operator++()
OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
Provides common interface for the Decls that can be redeclared.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
static ToTy & doit(::clang::DeclContext &Val)
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
reference operator*() const
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
const DeclContext * getParent() const
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
Represents C++ using-directive.
BlockDeclBitfields BlockDeclBits
ASTMutationListener * getASTMutationListener() const
Encodes a location in the source.
redecl_iterator redecls_begin() const
This represents a decl that may have a name.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
@ ModulePrivate
This declaration has an owning module, but is only visible to lookups that occur within that module.
SourceLocation getBegin() const
bool isSingleResult() const
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
@ IDNS_Using
This declaration is a using declaration.
Linkage getCachedLinkage() const
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
const_iterator begin() const
value_type operator->() const
llvm::iterator_range< redecl_iterator > redecl_range
Decl * getNextDeclInContext()
static const ToTy & doit(const ::clang::DeclContext &Val)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
const DeclContext * getLexicalDeclContext() const
unsigned getIdentifierNamespace() const
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setTopLevelDeclInObjCContainer(bool V=true)
std::ptrdiff_t difference_type
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context.
void dumpDeclContext() const
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
const LangOptions & getLangOpts() const LLVM_READONLY
Helper to get the language options from the ASTContext.
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
filtered_decl_iterator operator++(int)
Describes how types, statements, expressions, and declarations should be printed.
bool isInlineNamespace() const
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
const DeclContext * getLookupParent() const
ObjCMethodDeclBitfields ObjCMethodDeclBits
static bool classof(const Decl *D)
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc....
static inline ::clang::NamedDecl * getFromVoidPointer(void *P)
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
::clang::DeclContext & doit(const FromTy &Val)
The name of a declaration.
bool isReferenced() const
Whether any declaration of this entity was referenced.
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
std::forward_iterator_tag iterator_category
reference operator*() const
bool hasTagIdentifierNamespace() const
This class handles loading and caching of source files into memory.
decl_iterator & operator++()
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
static const ToTy * doit(const ::clang::DeclContext *Val)
@ IDNS_TagFriend
This declaration is a friend class.
attr_iterator attr_end() const
DeclContext * getNonTransparentContext()
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
ModuleOwnershipKind
The kind of ownership a declaration has, for visibility purposes.
bool InEnclosingNamespaceSetOf(const DeclContext *NS) const
Test if this context is part of the enclosing namespace set of the context NS, as defined in C++0x [n...
value_type operator->() const
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
llvm::iterator_range< all_lookups_iterator > lookups_range
reference operator*() const
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
bool setUseQualifiedLookup(bool use=true) const
::clang::DeclContext * doit(const FromTy *Val)
The top declaration context.
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Kind
Lists the kind of concrete classes of Decl.
static unsigned getIdentifierNamespaceForKind(Kind DK)
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
friend bool operator==(decl_iterator x, decl_iterator y)
specific_decl_iterator(DeclContext::decl_iterator C)
specific_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
all_lookups_iterator noload_lookups_begin() const
Iterators over all possible lookups within this context that are currently loaded; don't attempt to r...
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
Describes a module or submodule.
bool isObjCContainer() const
lookups_range lookups() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
AccessSpecifier getAccess() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Represents a block literal declaration, which is like an unnamed FunctionDecl.
const Decl * getNextDeclInContext() const
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
@ VisibleWhenImported
This declaration has an owning module, and is visible when that module is imported.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void setAccess(AccessSpecifier AS)
llvm::PointerIntPair< Decl *, 2, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
specific_decl_iterator operator++(int)
Decl::Kind getDeclKind() const
@ FOK_None
Not a friend object.
bool isInStdNamespace() const
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
SourceLocation getEnd() const
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
std::forward_iterator_tag iterator_category
void setAttrs(const AttrVec &Attrs)
filtered_decl_iterator()=default
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
ptrdiff_t difference_type
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
friend bool operator!=(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
@ FOK_Undeclared
A friend of a previously-undeclared entity.
An array of decls optimized for the common case of only containing one entry.
all_lookups_iterator lookups_end() const
bool isLookupContext() const
Test whether the context supports looking up names.
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
ASTDumpOutputFormat
Used to specify the format for printing AST dump information.
const Attr * getDefiningAttr() const
Return this declaration's defining attribute if it has one.
static ToTy * doit(::clang::DeclContext *Val)
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context,...
bool isInvalidDecl() const
ddiag_range ddiags() const
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
DeclContextLookupResult()=default
bool shouldUseQualifiedLookup() const
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
specific_decl_iterator & operator++()
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Decl & operator=(const Decl &)=delete
static void EnableStatistics()
redecl_iterator operator++(int)
decl_iterator - Iterates through the declarations stored within this context.
bool operator==(const iterator &X) const
bool isTranslationUnit() const
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined.
std::forward_iterator_tag iterator_category
bool isStdNamespace() const
friend bool operator==(const specific_decl_iterator &x, const specific_decl_iterator &y)
friend bool operator==(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
lookups_range noload_lookups(bool PreserveInternalState) const
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
Stores a list of template parameters for a TemplateDecl and its derived classes.
llvm::PointerUnion< NamedDecl *, DeclListNode * > Decls
Iterates through all the redeclarations of the same decl.
llvm::iterator_range< DeclContext::ddiag_iterator > ddiag_range
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static ToTy * doit(DeclContext *Val)
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
const RecordDecl * getOuterLexicalRecordContext() const
friend bool operator!=(decl_iterator x, decl_iterator y)
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
Writes an AST file containing the contents of a translation unit.
const Decl * getMostRecentDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
void setImplicit(bool I=true)
const Decl * getCanonicalDecl() const
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
IRgen optimization opportunities The common pattern of short x
static DeclContext * castToDeclContext(const Decl *)
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
@ IDNS_Member
Members, declared with object declarations within tag definitions.
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
@ IDNS_OMPMapper
This declaration is an OpenMP user defined mapper.
@ IDNS_Ordinary
Ordinary names.
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity,...
value_type operator*() const
const TranslationUnitDecl * getTranslationUnitDecl() const
@ Visible
This declaration has an owning module, but is globally visible (typically because its owning module i...
static Decl * castFromDeclContext(const DeclContext *)
TranslationUnitDecl * getTranslationUnitDecl()
value_type operator->() const
@ ObjCMethodFamilyBitWidth
static const ::clang::DeclContext * doit(const FromTy *Val)
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
filtered_decl_iterator & operator++()
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
SpecificDecl * value_type
bool isInIdentifierNamespace(unsigned NS) const
DeclContext(Decl::Kind K)
void setLocation(SourceLocation L)
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
unsigned CacheValidAndLinkage
If 0, we have not computed the linkage of this declaration.
DeclContextBitfields DeclContextBits
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
const DeclContext * getPrimaryContext() const
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
LinkageSpecDeclBitfields LinkageSpecDeclBits
lookup_result::iterator lookup_iterator
Language
The language for the input, used to select and validate the language standard and possible actions.
const char * getDeclKindName() const
std::forward_iterator_tag iterator_category
@ IDNS_Label
Labels, declared with 'x:' and referenced with 'goto x'.
llvm::iterator_range< decl_iterator > decl_range
UsingDirectiveDecl * operator*() const
void addDecl(Decl *D)
Add the declaration D into this context.
unsigned Access
Access - Used by C++ decls for the access specifier.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
@ IDNS_OMPReduction
This declaration is an OpenMP user defined reduction construction.
The base class of all kinds of template declarations (e.g., class, function, etc.).
attr_iterator attr_begin() const
Decl(Kind DK, DeclContext *DC, SourceLocation L)
Decl - This represents one declaration (or definition), e.g.
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
unsigned getTemplateDepth() const
Determine the number of levels of template parameter surrounding this declaration.
decl_iterator operator++(int)
friend bool operator!=(const specific_decl_iterator &x, const specific_decl_iterator &y)
redecl_iterator()=default
@ IDNS_ObjCProtocol
Objective C @protocol.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
@ FOK_Declared
A friend of a previously-declared entity.
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
unsigned IdentifierNamespace
IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
ExternalSourceSymbolAttr * getExternalSourceSymbolAttr() const
Looks on this and related declarations for an applicable external source symbol attribute.
friend bool operator!=(redecl_iterator x, redecl_iterator y)
value_type operator*() const
Decl(Kind DK, EmptyShell Empty)
const Decl * getPreviousDecl() const
Retrieve the previous declaration that declares the same entity as this declaration,...
void setCachedLinkage(Linkage L) const
static ToTy * doit(DeclContext *Val)
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
AttrVec::const_iterator attr_iterator
Iterates over a filtered subrange of declarations stored in a DeclContext.
bool isFileContext() const
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
One of these records is kept for each identifier that is lexed.
all_lookups_iterator noload_lookups_end() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
std::ptrdiff_t difference_type
const BlockDecl * getInnermostBlockDecl() const
Return this DeclContext if it is a BlockDecl.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
Reads an AST files chain containing the contents of a translation unit.
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
std::forward_iterator_tag iterator_category
static bool doit(const ::clang::DeclContext &Val)
bool hasOwningModule() const
Is this declaration owned by some module?
An iterator over the dependent diagnostics in a dependent context.
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
void print(raw_ostream &OS) const override
void setOwningModuleID(unsigned ID)
Set the owning module ID.
static bool classof(const DeclContext *D)
A dependently-generated diagnostic.
bool isParameterPack() const
Whether this declaration is a parameter pack.
A list storing NamedDecls in the lookup tables.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
const DeclContext * getDeclContext() const
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
static bool isTagIdentifierNamespace(unsigned NS)
SpecificDecl * value_type
value_type operator->() const
PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg)
Stmt - This represents one statement.
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
AvailabilityResult
Captures the result of checking the availability of a declaration.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
AccessSpecifier getAccessUnsafe() const
Retrieve the access specifier for this declaration, even though it may not yet have been properly set...
decl_iterator noload_decls_begin() const
@ Unowned
This declaration is not owned by a module.
CXXConstructorDeclBitfields CXXConstructorDeclBits
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
Attr - This represents one attribute.
llvm::iterator_range< udir_iterator > udir_range
all_lookups_iterator lookups_begin() const
Iterators over all possible lookups within this context.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
specific_attr_iterator< T > specific_attr_begin() const
void setFromASTFile()
Set the FromASTFile flag.
bool hasLocalOwningModuleStorage() const
friend class CXXClassMemberWrapper
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
static const ToTy * doit(const DeclContext *Val)
The results of name lookup within a DeclContext.
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
Module * getLocalOwningModule() const
Get the local owning module, if known.
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
const TemplateParameterList * getDescribedTemplateParams() const
If this is a declaration that describes some template or partial specialization, this returns the cor...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
EnumDeclBitfields EnumDeclBits
friend bool operator==(redecl_iterator x, redecl_iterator y)
filtered_decl_iterator(DeclContext::decl_iterator C)
filtered_decl_iterator - Construct a new iterator over a subset of the declarations the range [C,...
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
llvm::iterator_range< attr_iterator > attr_range
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
udir_iterator(lookup_iterator I)
const DeclContext * getEnclosingNamespaceContext() const
RecordDeclBitfields RecordDeclBits
Abstract interface for external sources of AST nodes.
const DeclContext * getLexicalParent() const
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration.
bool isFunctionOrMethod() const
bool isInLocalScopeForInstantiation() const
Determine whether a substitution into this declaration would occur as part of a substitution into a d...
static void * getAsVoidPointer(::clang::NamedDecl *P)
SourceLocation getLocation() const
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl,...
void setReferenced(bool R=true)
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Represents a function declaration or definition.
DeclContext * getParentFunctionOrMethod()
Represents a struct/union/class.
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
@ IDNS_LocalExtern
This declaration is a function-local extern declaration of a variable or function.
static bool classofKind(Kind K)
void setLocalOwningModule(Module *M)
FunctionDeclBitfields FunctionDeclBits
const DeclContext * getRedeclContext() const
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
static const ::clang::DeclContext & doit(const FromTy &Val)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
const char * getDeclKindName() const
TagDeclBitfields TagDeclBits
bool isInAnonymousNamespace() const
DeclListNode::iterator iterator
const DeclContext * getNonTransparentContext() const
DeclContext * getDeclContext()
redecl_iterator redecls_end() const
decl_iterator decls_begin() const