14 #ifndef LLVM_CLANG_AST_DECLBASE_H
15 #define LLVM_CLANG_AST_DECLBASE_H
20 #include "llvm/ADT/PointerUnion.h"
21 #include "llvm/ADT/iterator.h"
22 #include "llvm/ADT/iterator_range.h"
23 #include "llvm/Support/Compiler.h"
24 #include "llvm/Support/PrettyStackTrace.h"
27 class ASTMutationListener;
32 class DeclarationName;
33 class DependentDiagnostic;
38 class LinkageComputer;
39 class LinkageSpecDecl;
43 class ObjCCategoryDecl;
44 class ObjCCategoryImplDecl;
45 class ObjCContainerDecl;
47 class ObjCImplementationDecl;
48 class ObjCInterfaceDecl;
50 class ObjCProtocolDecl;
51 struct PrintingPolicy;
55 class TranslationUnitDecl;
56 class UsingDirectiveDecl;
84 #define DECL(DERIVED, BASE) DERIVED,
85 #define ABSTRACT_DECL(DECL)
86 #define DECL_RANGE(BASE, START, END) \
87 first##BASE = START, last##BASE = END,
88 #define LAST_DECL_RANGE(BASE, START, END) \
89 first##BASE = START, last##BASE = END
90 #include "clang/AST/DeclNodes.inc"
244 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
246 inline bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
247 inline bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
248 inline MultipleDC *getMultipleDC()
const {
249 return DeclCtx.get<MultipleDC*>();
259 unsigned DeclKind : 8;
262 unsigned InvalidDecl : 1;
265 unsigned HasAttrs : 1;
269 unsigned Implicit : 1;
279 unsigned Referenced : 1;
282 static bool StatisticsEnabled;
329 bool AccessDeclContextSanity()
const;
335 Loc(L), DeclKind(DK), InvalidDecl(0),
341 if (StatisticsEnabled)
add(DK);
351 if (StatisticsEnabled)
add(DK);
395 return getSemanticDC();
396 return getMultipleDC()->SemanticDC;
425 assert(AccessDeclContextSanity());
429 assert(AccessDeclContextSanity());
470 template <
typename T>
472 if (!HasAttrs)
return;
475 Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end());
481 template <
typename T>
483 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
486 template <
typename T>
490 template <
typename T>
523 bool isUsed(
bool CheckUsedAttr =
true)
const;
581 assert(
isFromASTFile() &&
"Only works on a deserialized declaration");
582 *((
unsigned*)
this - 2) =
ID;
641 return *((
const unsigned*)
this - 1);
649 return *((
const unsigned*)
this - 2);
655 Module *getOwningModuleSlow()
const;
666 return getOwningModuleSlow();
674 return reinterpret_cast<Module *
const *
>(
this)[-1];
678 "should not have a cached owning module");
679 reinterpret_cast<Module **
>(
this)[-1] = M;
710 return getSemanticDC();
711 return getMultipleDC()->LexicalDC;
797 assert(Current &&
"Advancing while iterator has reached end");
800 assert(Next &&
"Should return next redeclaration or itself, never null!");
801 Current = (Next != Starter) ? Next :
nullptr;
812 return x.Current == y.Current;
815 return x.Current != y.Current;
893 return (DeclKind >= Decl::firstFunction &&
894 DeclKind <= Decl::lastFunction) ||
895 DeclKind == FunctionTemplate;
915 "namespace is not ordinary");
944 "namespace includes neither ordinary nor tag");
948 "namespace includes other than ordinary or tag");
955 if (PerformFriendInjection ||
962 if (PerformFriendInjection ||
990 "visible non-member operators should be in ordinary namespace");
998 void print(raw_ostream &Out,
unsigned Indentation = 0,
999 bool PrintInstantiation =
false)
const;
1001 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1004 unsigned Indentation = 0);
1009 void dump(raw_ostream &Out)
const;
1039 const Decl *TheDecl;
1042 const char *Message;
1046 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1048 void print(raw_ostream &OS)
const override;
1061 static NamedDecl *
const SingleElementDummyList;
1066 : Result(Result), Single() {}
1068 : Result(SingleElementDummyList), Single(Single) {}
1072 std::random_access_iterator_tag,
1075 value_type SingleElement;
1093 bool empty()
const {
return Result.empty(); }
1095 size_t size()
const {
return Single ? 1 : Result.size(); }
1103 Sliced.Single = Single;
1123 unsigned DeclKind : 8;
1128 mutable bool ExternalLexicalStorage : 1;
1133 mutable bool ExternalVisibleStorage : 1;
1139 mutable bool NeedToReconcileExternalVisibleStorage : 1;
1143 mutable bool HasLazyLocalLexicalLookups : 1;
1147 mutable bool HasLazyExternalLexicalLookups : 1;
1152 mutable bool UseQualifiedLookup : 1;
1180 static std::pair<Decl *, Decl *>
1184 : DeclKind(K), ExternalLexicalStorage(
false),
1185 ExternalVisibleStorage(
false),
1186 NeedToReconcileExternalVisibleStorage(
false),
1187 HasLazyLocalLexicalLookups(
false), HasLazyExternalLexicalLookups(
false),
1188 UseQualifiedLookup(
false),
1201 return cast<Decl>(
this)->getDeclContext();
1217 return cast<Decl>(
this)->getLexicalDeclContext();
1230 return cast<Decl>(
this)->getASTContext();
1234 return DeclKind == Decl::Block;
1239 case Decl::ObjCCategory:
1240 case Decl::ObjCCategoryImpl:
1241 case Decl::ObjCImplementation:
1242 case Decl::ObjCInterface:
1243 case Decl::ObjCProtocol:
1252 case Decl::Captured:
1253 case Decl::ObjCMethod:
1256 return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction;
1266 return DeclKind == Decl::TranslationUnit || DeclKind == Decl::Namespace;
1270 return DeclKind == Decl::TranslationUnit;
1274 return DeclKind >= Decl::firstRecord && DeclKind <= Decl::lastRecord;
1278 return DeclKind == Decl::Namespace;
1428 return x.Current == y.Current;
1431 return x.Current != y.Current;
1458 template<
typename SpecificDecl>
1468 void SkipToNextDecl() {
1469 while (*Current && !isa<SpecificDecl>(*Current))
1479 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1515 return x.Current == y.Current;
1520 return x.Current != y.Current;
1533 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
1543 void SkipToNextDecl() {
1545 (!isa<SpecificDecl>(*Current) ||
1546 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
1556 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1591 return x.Current == y.Current;
1596 return x.Current != y.Current;
1685 typedef llvm::iterator_range<all_lookups_iterator>
lookups_range;
1702 std::random_access_iterator_tag,
1715 typedef llvm::iterator_range<DeclContext::ddiag_iterator>
ddiag_range;
1729 "should only be called on primary context");
1730 HasLazyExternalLexicalLookups =
true;
1747 ExternalLexicalStorage = ES;
1757 ExternalVisibleStorage = ES;
1758 if (ES && LookupPtr)
1759 NeedToReconcileExternalVisibleStorage =
true;
1770 bool old_value = UseQualifiedLookup;
1771 UseQualifiedLookup = use;
1776 return UseQualifiedLookup;
1784 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false)
const;
1787 void reconcileExternalVisibleStorage()
const;
1788 bool LoadLexicalDeclsFromExternalStorage()
const;
1796 void makeDeclVisibleInContextInternal(
NamedDecl *D);
1801 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
1802 void makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
1803 bool Rediscoverable);
1804 void makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal);
1808 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
1809 getKind() == TemplateTemplateParm;
1813 template <
class ToTy,
1814 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
1826 template <
class ToTy>
1829 return static_cast<const ToTy*
>(Val);
1833 return static_cast<ToTy*
>(Val);
1843 template <
typename To>
1845 static bool doit(const ::clang::DeclContext &Val) {
1846 return To::classofKind(Val.getDeclKind());
1851 template<
class ToTy>
1852 struct cast_convert_val<ToTy,
1854 static const ToTy &
doit(const ::clang::DeclContext &Val) {
1858 template<
class ToTy>
1864 template<
class ToTy>
1865 struct cast_convert_val<ToTy,
1867 static const ToTy *
doit(const ::clang::DeclContext *Val) {
1868 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1871 template<
class ToTy>
1874 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1879 template<
class FromTy>
1881 static ::clang::DeclContext &
doit(
const FromTy &Val) {
1882 return *FromTy::castToDeclContext(&Val);
1886 template<
class FromTy>
1888 static ::clang::DeclContext *
doit(
const FromTy *Val) {
1889 return FromTy::castToDeclContext(Val);
1893 template<
class FromTy>
1895 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
1896 return *FromTy::castToDeclContext(&Val);
1900 template<
class FromTy>
1902 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
1903 return FromTy::castToDeclContext(Val);
decl_iterator noload_decls_end() const
SourceLocation getEnd() const
const value_type * pointer
const DeclContext * getLookupParent() const
ddiag_range ddiags() const
specific_decl_iterator & operator++()
void setImplicit(bool I=true)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
redecl_iterator operator++(int)
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
static DeclContext * castToDeclContext(const Decl *)
UsingDirectiveDecl * operator*() const
bool isObjCContainer() const
llvm::iterator_range< redecl_iterator > redecl_range
specific_attr_iterator< T > specific_attr_begin() const
std::forward_iterator_tag iterator_category
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
static Decl * castFromDeclContext(const DeclContext *)
void setAttrs(const AttrVec &Attrs)
redecl_iterator redecls_end() const
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
FunctionType - C99 6.7.5.3 - Function Declarators.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
unsigned CacheValidAndLinkage
If 0, we have not computed the linkage of this declaration.
std::forward_iterator_tag iterator_category
Decl - This represents one declaration (or definition), e.g.
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
friend bool operator==(const specific_decl_iterator &x, const specific_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...
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool isInStdNamespace() const
bool isStdNamespace() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
static void printGroup(Decl **Begin, unsigned NumDecls, raw_ostream &Out, const PrintingPolicy &Policy, unsigned Indentation=0)
static ToTy * doit(DeclContext *Val)
SourceLocation getLocEnd() const LLVM_READONLY
Iterates over a filtered subrange of declarations stored in a DeclContext.
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
unsigned Access
Access - Used by C++ decls for the access specifier.
redecl_iterator & operator++()
llvm::iterator_adaptor_base< iterator, ResultTy::iterator, std::random_access_iterator_tag, NamedDecl *const > IteratorBase
AccessSpecifier getAccess() const
Whether this declaration is a top-level declaration (function, global variable, etc.) that is lexically inside an objc container definition.
const Decl * getNextDeclInContext() const
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
std::ptrdiff_t difference_type
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
const RecordDecl * getOuterLexicalRecordContext() const
friend bool operator!=(const specific_decl_iterator &x, const specific_decl_iterator &y)
Describes how types, statements, expressions, and declarations should be printed. ...
decl_iterator decls_end() const
static const ToTy * doit(const ::clang::DeclContext *Val)
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Decl(Kind DK, EmptyShell Empty)
const value_type * pointer
void setHasExternalVisibleStorage(bool ES=true)
State whether this DeclContext has external storage for declarations visible in this context...
void removeDecl(Decl *D)
Removes a declaration from this context.
Types, declared with 'struct foo', typedefs, etc.
RecordDecl - Represents a struct/union/class.
ASTMutationListener * getASTMutationListener() const
Provides common interface for the Decls that can be redeclared.
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl, 0 if there are none.
One of these records is kept for each identifier that is lexed.
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
llvm::iterator_range< decl_iterator > decl_range
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
specific_decl_iterator operator++(int)
bool isInIdentifierNamespace(unsigned NS) const
This declaration is a friend function.
bool isReferenced() const
Whether any declaration of this entity was referenced.
all_lookups_iterator lookups_end() const
unsigned getIdentifierNamespace() const
bool isTranslationUnit() const
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setOwningModuleID(unsigned ID)
Set the owning module ID.
bool isInlineNamespace() const
SmallVector< Attr *, 2 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
SpecificDecl * value_type
Describes a module or submodule.
friend bool operator!=(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
iterator(pointer Pos, value_type Single=nullptr)
lookups_range noload_lookups() const
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
Namespaces, declared with 'namespace foo {}'.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
filtered_decl_iterator(DeclContext::decl_iterator C)
filtered_decl_iterator - Construct a new iterator over a subset of the declarations the range [C...
A friend of a previously-undeclared entity.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
value_type operator->() const
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const Decl * getMostRecentDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
bool hasLocalOwningModuleStorage() const
Labels, declared with 'x:' and referenced with 'goto x'.
void setLocalOwningModule(Module *M)
Module * getLocalOwningModule() const
Get the local owning module, if known.
value_type operator*() const
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
::clang::DeclContext * doit(const FromTy *Val)
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.
iterator::reference reference
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
AvailabilityResult
Captures the result of checking the availability of a declaration.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
specific_attr_iterator< T > specific_attr_end() const
Decl * getNextDeclInContext()
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
This declaration is a C++ operator declared in a non-class context.
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
ID
Defines the set of possible language-specific address spaces.
lookups_range lookups() const
This declaration is a friend class.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
const char * getDeclKindName() const
bool isLookupContext() const
Test whether the context supports looking up names.
static bool classofKind(Kind K)
static unsigned getIdentifierNamespaceForKind(Kind DK)
llvm::iterator_range< udir_iterator > udir_range
bool isTemplateDecl() const
returns true if this declaration is a template
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
ASTContext & getParentASTContext() const
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc.) that is lexically inside an objc container definition.
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
value_type operator->() const
bool isInAnonymousNamespace() const
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
DeclContext * getDeclContext()
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
const char * getDeclKindName() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
std::forward_iterator_tag iterator_category
static ToTy * doit(::clang::DeclContext *Val)
llvm::iterator_range< all_lookups_iterator > lookups_range
redecl_iterator redecls_begin() const
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
const Decl * getNonClosureContext() const
value_type operator->() const
DeclContextLookupResult slice(size_t N) const
void setLocation(SourceLocation L)
all_lookups_iterator lookups_begin() const
Iterators over all possible lookups within this context.
const Decl * getNonClosureAncestor() const
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
static bool isTagIdentifierNamespace(unsigned NS)
filtered_decl_iterator & operator++()
const value_type & reference
static const ToTy & doit(const ::clang::DeclContext &Val)
static const ::clang::DeclContext * doit(const FromTy *Val)
Abstract interface for external sources of AST nodes.
SourceLocation getLocStart() const LLVM_READONLY
reference operator*() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool hasTagIdentifierNamespace() const
Iterates through all the redeclarations of the same decl.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
llvm::iterator_adaptor_base< udir_iterator, lookup_iterator, std::random_access_iterator_tag, UsingDirectiveDecl * > udir_iterator_base
Encodes a location in the source.
void setTopLevelDeclInObjCContainer(bool V=true)
Members, declared with object declarations within tag definitions.
SpecificDecl * value_type
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
const TemplateArgument * iterator
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...
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
reference operator*() const
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
ASTContext & getASTContext() const LLVM_READONLY
decl_iterator noload_decls_begin() const
void setReferenced(bool R=true)
static bool classof(const DeclContext *D)
const DeclContext * getEnclosingNamespaceContext() const
udir_iterator(lookup_iterator I)
iterator::pointer pointer
all_lookups_iterator noload_lookups_end() const
A friend of a previously-declared entity.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
void print(raw_ostream &OS) const override
all_lookups_iterator noload_lookups_begin() const
Iterators over all possible lookups within this context that are currently loaded; don't attempt to r...
DeclContextLookupResult(NamedDecl *Single)
::clang::DeclContext & doit(const FromTy &Val)
void setCachedLinkage(Linkage L) const
Linkage getCachedLinkage() const
SourceLocation getBegin() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
friend bool operator==(redecl_iterator x, redecl_iterator y)
bool isFileContext() const
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
DeclContextLookupResult lookup_result
bool hasCachedLinkage() const
static ToTy * doit(DeclContext *Val)
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Defines various enumerations that describe declaration and type specifiers.
std::ptrdiff_t difference_type
decl_iterator - Iterates through the declarations stored within this context.
reference operator*() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static bool doit(const ::clang::DeclContext &Val)
static const ToTy * doit(const DeclContext *Val)
llvm::iterator_range< attr_iterator > attr_range
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
llvm::iterator_range< DeclContext::ddiag_iterator > ddiag_range
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
bool shouldUseQualifiedLookup() const
bool isInvalidDecl() const
friend bool operator!=(redecl_iterator x, redecl_iterator y)
Reads an AST files chain containing the contents of a translation unit.
const Decl * getPreviousDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
DeclarationName - The name of a declaration.
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks, lambdas, etc.
U cast(CodeGen::Address addr)
decl_iterator operator++(int)
lookup_result::iterator lookup_iterator
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
Whether this declaration is private to the module in which it was defined.
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
attr_iterator attr_end() const
void setHasExternalLexicalStorage(bool ES=true)
State whether this DeclContext has external storage for declarations lexically in this context...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
SmallVector< Context, 8 > Contexts
A dependently-generated diagnostic.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
const DeclContext * getLexicalDeclContext() const
std::forward_iterator_tag iterator_category
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
const TranslationUnitDecl * getTranslationUnitDecl() const
Decl::Kind getDeclKind() const
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
filtered_decl_iterator operator++(int)
static __inline__ uint32_t uint32_t y
An iterator over the dependent diagnostics in a dependent context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
static ToTy & doit(::clang::DeclContext &Val)
void addDecl(Decl *D)
Add the declaration D into this context.
AccessSpecifier getAccessUnsafe() const
Retrieve the access specifier for this declaration, even though it may not yet have been properly set...
reference operator[](size_t N) const
bool isLexicallyWithinFunctionOrMethod() const
Returns true if this declaration lexically is inside a function.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
__PTRDIFF_TYPE__ ptrdiff_t
const DeclContext * getLexicalParent() const
unsigned Hidden
Whether this declaration is hidden from normal name lookup, e.g., because it is was loaded from an AS...
const value_type & reference
const Decl * getCanonicalDecl() const
llvm::PointerIntPair< Decl *, 2, unsigned > NextInContextAndBits
The next declaration within the same lexical DeclContext.
static const ::clang::DeclContext & doit(const FromTy &Val)
friend bool operator==(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
decl_iterator & operator++()
PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
const DeclContext * getDeclContext() const
Decl(Kind DK, DeclContext *DC, SourceLocation L)
virtual Decl * getPreviousDeclImpl()
Implementation of getPreviousDecl(), to be overridden by any subclass that has a redeclaration chain...
void dumpDeclContext() const
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.
static const ToTy * doit(const DeclContext *Val)
static bool classof(const Decl *D)
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
friend class CXXClassMemberWrapper
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
Kind
Lists the kind of concrete classes of Decl.
TranslationUnitDecl - The top declaration context.
This declaration is a function-local extern declaration of a variable or function.
const DeclContext * getParent() const
value_type operator*() const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
static void EnableStatistics()
friend bool operator==(decl_iterator x, decl_iterator y)
attr_iterator attr_begin() const
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where in the...
DeclContextLookupResult(ArrayRef< NamedDecl * > Result)
bool setUseQualifiedLookup(bool use=true)
bool isParameterPack() const
Whether this declaration is a parameter pack.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
NamedDecl - This represents a decl with a name.
void setAccess(AccessSpecifier AS)
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context...
Represents C++ using-directive.
TranslationUnitDecl * getTranslationUnitDecl()
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 DeclContext * getPrimaryContext() const
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
This class handles loading and caching of source files into memory.
const DeclContext * getRedeclContext() const
DeclContextLookupResult()
AttrVec::const_iterator attr_iterator
value_type operator->() const
Attr - This represents one attribute.
friend bool operator!=(decl_iterator x, decl_iterator y)
DeclContext(Decl::Kind K)
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
This declaration is a using declaration.
DeclContext * getParentFunctionOrMethod()
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...