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"
269 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
271 bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
272 bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
274 MultipleDC *getMultipleDC()
const {
275 return DeclCtx.get<MultipleDC*>();
286 unsigned DeclKind : 7;
289 unsigned InvalidDecl : 1;
292 unsigned HasAttrs : 1;
296 unsigned Implicit : 1;
306 unsigned Referenced : 1;
311 unsigned TopLevelDeclInObjCContainer : 1;
314 static bool StatisticsEnabled;
357 bool AccessDeclContextCheck()
const;
363 auto *D = cast<Decl>(DC);
364 auto MOK = D->getModuleOwnershipKind();
366 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
384 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(
false), HasAttrs(
false),
389 if (StatisticsEnabled)
add(DK);
398 if (StatisticsEnabled)
add(DK);
443 return getSemanticDC();
444 return getMultipleDC()->SemanticDC;
488 assert(AccessDeclContextCheck());
492 assert(AccessDeclContextCheck());
530 template <
typename T>
532 if (!HasAttrs)
return;
535 llvm::erase_if(Vec, [](
Attr *A) {
return isa<T>(A); });
541 template <
typename T>
543 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
546 template <
typename T>
551 template <
typename T>
585 bool isUsed(
bool CheckUsedAttr =
true)
const;
612 return TopLevelDeclInObjCContainer;
616 TopLevelDeclInObjCContainer =
V;
680 assert(
isFromASTFile() &&
"Only works on a deserialized declaration");
681 *((
unsigned*)
this - 2) =
ID;
704 VersionTuple EnclosingVersion = VersionTuple(),
705 StringRef *RealizedPlatform =
nullptr)
const;
757 return *((
const unsigned*)
this - 1);
765 return *((
const unsigned*)
this - 2);
770 Module *getOwningModuleSlow()
const;
782 return getOwningModuleSlow();
792 "owned local decl but no local module storage");
793 return reinterpret_cast<Module *
const *
>(
this)[-1];
798 "should not have a cached owning module");
799 reinterpret_cast<Module **
>(
this)[-1] = M;
850 "no storage available for owning module for this declaration");
885 return getSemanticDC();
886 return getMultipleDC()->LexicalDC;
970 Decl *Current =
nullptr;
987 assert(Current &&
"Advancing while iterator has reached end");
989 Decl *Next = Current->getNextRedeclarationImpl();
990 assert(Next &&
"Should return next redeclaration or itself, never null!");
991 Current = (Next != Starter) ? Next :
nullptr;
1002 return x.Current == y.Current;
1006 return x.Current != y.Current;
1085 return (DeclKind >= Decl::firstFunction &&
1086 DeclKind <= Decl::lastFunction) ||
1087 DeclKind == FunctionTemplate;
1124 "namespace is not ordinary");
1150 "namespace includes neither ordinary nor tag");
1154 "namespace includes other than ordinary or tag");
1161 if (PerformFriendInjection ||
1169 if (PerformFriendInjection ||
1197 "visible non-member operators should be in ordinary namespace");
1205 void print(raw_ostream &Out,
unsigned Indentation = 0,
1206 bool PrintInstantiation =
false)
const;
1208 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1211 unsigned Indentation = 0);
1219 void dump(raw_ostream &Out,
bool Deserialize =
false,
1253 const Decl *TheDecl;
1256 const char *Message;
1261 : TheDecl(theDecl), Loc(L),
SM(sm), Message(Msg) {}
1263 void print(raw_ostream &OS)
const override;
1275 static constexpr
int NumLowBitsAvailable = 3;
1285 using Decls = llvm::PointerUnion<NamedDecl*, DeclListNode*>;
1302 assert(Ptr &&
"dereferencing end() iterator");
1311 assert(!Ptr.isNull() &&
"Advancing empty iterator");
1314 Ptr = CurNode->Rest;
1329 Decls Rest =
nullptr;
1355 bool empty()
const {
return Result.isNull(); }
1364 for (
auto *D : *
this)
1365 if (T *
Decl = dyn_cast<T>(D))
1407 class DeclContextBitfields {
1415 mutable uint64_t ExternalLexicalStorage : 1;
1420 mutable uint64_t ExternalVisibleStorage : 1;
1426 mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1430 mutable uint64_t HasLazyLocalLexicalLookups : 1;
1434 mutable uint64_t HasLazyExternalLexicalLookups : 1;
1439 mutable uint64_t UseQualifiedLookup : 1;
1443 enum { NumDeclContextBits = 13 };
1448 class TagDeclBitfields {
1449 friend class TagDecl;
1466 uint64_t IsEmbeddedInDeclarator : 1;
1479 uint64_t IsCompleteDefinitionRequired : 1;
1483 uint64_t IsThisDeclarationADemotedDefinition : 1;
1487 enum { NumTagDeclBits = 10 };
1492 class EnumDeclBitfields {
1493 friend class EnumDecl;
1515 uint64_t IsScopedUsingClassTag : 1;
1526 enum { NumEnumDeclBits = 20 };
1531 class RecordDeclBitfields {
1532 friend class RecordDecl;
1541 uint64_t HasFlexibleArrayMember : 1;
1544 uint64_t AnonymousStructOrUnion : 1;
1558 mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1561 uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1562 uint64_t NonTrivialToPrimitiveCopy : 1;
1563 uint64_t NonTrivialToPrimitiveDestroy : 1;
1568 uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
1569 uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
1570 uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
1573 uint64_t ParamDestroyedInCallee : 1;
1576 uint64_t ArgPassingRestrictions : 2;
1587 enum { NumRecordDeclBits = 41 };
1592 class OMPDeclareReductionDeclBitfields {
1593 friend class OMPDeclareReductionDecl;
1603 enum { NumOMPDeclareReductionDeclBits = 2 };
1609 class FunctionDeclBitfields {
1610 friend class FunctionDecl;
1612 friend class CXXDeductionGuideDecl;
1622 uint64_t HasInheritedPrototype : 1;
1634 uint64_t IsExplicitlyDefaulted : 1;
1635 uint64_t HasDefaultedFunctionInfo : 1;
1640 uint64_t IsIneligibleOrNotSelected : 1;
1642 uint64_t HasImplicitReturnZero : 1;
1647 uint64_t InstantiationIsPending : 1;
1667 uint64_t IsCopyDeductionCandidate : 1;
1677 uint64_t FriendConstraintRefersToEnclosingTemplate : 1;
1681 enum { NumFunctionDeclBits = 29 };
1686 class CXXConstructorDeclBitfields {
1687 friend class CXXConstructorDecl;
1699 uint64_t IsInheritingConstructor : 1;
1702 uint64_t HasTrailingExplicitSpecifier : 1;
1710 NumCXXConstructorDeclBits = 64 - NumDeclContextBits - NumFunctionDeclBits
1716 class ObjCMethodDeclBitfields {
1717 friend class ObjCMethodDecl;
1735 uint64_t IsSynthesizedAccessorStub : 1;
1744 mutable uint64_t HasRedeclaration : 1;
1773 enum { NumObjCMethodDeclBits = 24 };
1778 class ObjCContainerDeclBitfields {
1779 friend class ObjCContainerDecl;
1781 uint32_t : NumDeclContextBits;
1785 SourceLocation AtStart;
1791 enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1796 class LinkageSpecDeclBitfields {
1797 friend class LinkageSpecDecl;
1813 enum { NumLinkageSpecDeclBits = 4 };
1818 class BlockDeclBitfields {
1819 friend class BlockDecl;
1825 uint64_t BlockMissingReturnType : 1;
1826 uint64_t IsConversionFromLambda : 1;
1839 enum { NumBlockDeclBits = 5 };
1847 mutable StoredDeclsMap *LookupPtr =
nullptr;
1871 static_assert(
sizeof(DeclContextBitfields) <= 8,
1872 "DeclContextBitfields is larger than 8 bytes!");
1873 static_assert(
sizeof(TagDeclBitfields) <= 8,
1874 "TagDeclBitfields is larger than 8 bytes!");
1875 static_assert(
sizeof(EnumDeclBitfields) <= 8,
1876 "EnumDeclBitfields is larger than 8 bytes!");
1877 static_assert(
sizeof(RecordDeclBitfields) <= 8,
1878 "RecordDeclBitfields is larger than 8 bytes!");
1879 static_assert(
sizeof(OMPDeclareReductionDeclBitfields) <= 8,
1880 "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
1881 static_assert(
sizeof(FunctionDeclBitfields) <= 8,
1882 "FunctionDeclBitfields is larger than 8 bytes!");
1883 static_assert(
sizeof(CXXConstructorDeclBitfields) <= 8,
1884 "CXXConstructorDeclBitfields is larger than 8 bytes!");
1885 static_assert(
sizeof(ObjCMethodDeclBitfields) <= 8,
1886 "ObjCMethodDeclBitfields is larger than 8 bytes!");
1887 static_assert(
sizeof(ObjCContainerDeclBitfields) <= 8,
1888 "ObjCContainerDeclBitfields is larger than 8 bytes!");
1889 static_assert(
sizeof(LinkageSpecDeclBitfields) <= 8,
1890 "LinkageSpecDeclBitfields is larger than 8 bytes!");
1891 static_assert(
sizeof(BlockDeclBitfields) <= 8,
1892 "BlockDeclBitfields is larger than 8 bytes!");
1908 static std::pair<Decl *, Decl *>
1928 return cast<Decl>(
this)->getDeclContext();
1944 return cast<Decl>(
this)->getLexicalDeclContext();
1957 return cast<Decl>(
this)->getASTContext();
1968 case Decl::ObjCCategory:
1969 case Decl::ObjCCategoryImpl:
1970 case Decl::ObjCImplementation:
1971 case Decl::ObjCInterface:
1972 case Decl::ObjCProtocol:
1982 case Decl::Captured:
1983 case Decl::ObjCMethod:
2141 Decl *Current =
nullptr;
2159 Current = Current->getNextDeclInContext();
2170 return x.Current == y.Current;
2174 return x.Current != y.Current;
2201 template<
typename SpecificDecl>
2211 void SkipToNextDecl() {
2212 while (*Current && !isa<SpecificDecl>(*Current))
2223 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2259 return x.Current == y.Current;
2264 return x.Current != y.Current;
2277 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
2287 void SkipToNextDecl() {
2289 (!isa<SpecificDecl>(*Current) ||
2290 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2301 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2335 return x.Current == y.Current;
2340 return x.Current != y.Current;
2470 using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2484 "should only be called on primary context");
2517 if (ES && LookupPtr)
2545 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false,
2546 bool Deserialize =
false)
const;
2553 bool hasNeedToReconcileExternalVisibleStorage()
const {
2561 void setNeedToReconcileExternalVisibleStorage(
bool Need =
true)
const {
2567 bool hasLazyLocalLexicalLookups()
const {
2573 void setHasLazyLocalLexicalLookups(
bool HasLLLL =
true)
const {
2579 bool hasLazyExternalLexicalLookups()
const {
2585 void setHasLazyExternalLexicalLookups(
bool HasLELL =
true)
const {
2589 void reconcileExternalVisibleStorage()
const;
2590 bool LoadLexicalDeclsFromExternalStorage()
const;
2598 void makeDeclVisibleInContextInternal(NamedDecl *D);
2600 StoredDeclsMap *CreateStoredDeclsMap(ASTContext &
C)
const;
2602 void loadLazyLocalLexicalLookups();
2603 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
2604 void makeDeclVisibleInContextWithFlags(NamedDecl *D,
bool Internal,
2605 bool Rediscoverable);
2606 void makeDeclVisibleInContextImpl(NamedDecl *D,
bool Internal);
2610 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
2611 getKind() == TemplateTemplateParm;
2615 template <
class ToTy,
2616 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2628 template <
class ToTy>
2631 return static_cast<const ToTy*
>(Val);
2635 return static_cast<ToTy*
>(Val);
2644 template <
typename To>
2646 static bool doit(const ::clang::DeclContext &Val) {
2647 return To::classofKind(Val.getDeclKind());
2652 template<
class ToTy>
2653 struct cast_convert_val<ToTy,
2655 static const ToTy &
doit(const ::clang::DeclContext &Val) {
2660 template<
class ToTy>
2667 template<
class ToTy>
2668 struct cast_convert_val<ToTy,
2670 static const ToTy *
doit(const ::clang::DeclContext *Val) {
2671 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2675 template<
class ToTy>
2678 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2683 template<
class FromTy>
2685 static ::clang::DeclContext &
doit(
const FromTy &Val) {
2686 return *FromTy::castToDeclContext(&Val);
2690 template<
class FromTy>
2692 static ::clang::DeclContext *
doit(
const FromTy *Val) {
2693 return FromTy::castToDeclContext(Val);
2697 template<
class FromTy>
2699 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
2700 return *FromTy::castToDeclContext(&Val);
2704 template<
class FromTy>
2706 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
2707 return FromTy::castToDeclContext(Val);
2713 #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.
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
bool isDiscardedInGlobalModuleFragment() const
FIXME: Implement discarding declarations actually in global module fragment.
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
llvm::PointerIntPair< Decl *, 3, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
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 DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
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.
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
bool isFileContextDecl() const
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)
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
@ ReachableWhenImported
This declaration has an owning module, and is visible to lookups that occurs within that module.
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.
DeclContext * getNonTransparentDeclContext()
Return the non transparent context.
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 ...
bool hasValidDeclKind() const
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)
const DeclContext * getNonTransparentDeclContext() const
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)
bool isInvisibleOutsideTheOwningModule() const
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.
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
DeclContext * getParentFunctionOrMethod(bool LexicalParent=false)
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