14 #ifndef LLVM_CLANG_AST_DECLBASE_H
15 #define LLVM_CLANG_AST_DECLBASE_H
21 #include "llvm/ADT/PointerUnion.h"
22 #include "llvm/ADT/iterator.h"
23 #include "llvm/ADT/iterator_range.h"
24 #include "llvm/Support/Compiler.h"
25 #include "llvm/Support/PrettyStackTrace.h"
28 class ASTMutationListener;
33 class DeclarationName;
34 class DependentDiagnostic;
37 class ExternalSourceSymbolAttr;
41 class LinkageComputer;
42 class LinkageSpecDecl;
46 class ObjCCategoryDecl;
47 class ObjCCategoryImplDecl;
48 class ObjCContainerDecl;
50 class ObjCImplementationDecl;
51 class ObjCInterfaceDecl;
53 class ObjCProtocolDecl;
54 struct PrintingPolicy;
59 class TranslationUnitDecl;
60 class UsingDirectiveDecl;
81 class LLVM_ALIGNAS( 8)
Decl {
85 #define DECL(DERIVED, BASE) DERIVED,
86 #define ABSTRACT_DECL(DECL)
87 #define DECL_RANGE(BASE, START, END) \
88 first##BASE = START, last##BASE = END,
89 #define LAST_DECL_RANGE(BASE, START, END) \
90 first##BASE = START, last##BASE = END
91 #include "clang/AST/DeclNodes.inc"
131 IDNS_Member = 0x0008,
135 IDNS_Namespace = 0x0010,
139 IDNS_Ordinary = 0x0020,
142 IDNS_ObjCProtocol = 0x0040,
147 IDNS_OrdinaryFriend = 0x0080,
152 IDNS_TagFriend = 0x0100,
163 IDNS_NonMemberOperator = 0x0400,
170 IDNS_LocalExtern = 0x0800,
173 IDNS_OMPReduction = 0x1000
195 OBJC_TQ_Bycopy = 0x8,
196 OBJC_TQ_Byref = 0x10,
197 OBJC_TQ_Oneway = 0x20,
202 OBJC_TQ_CSNullability = 0x40
255 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
257 inline bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
258 inline bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
259 inline MultipleDC *getMultipleDC()
const {
260 return DeclCtx.get<MultipleDC*>();
262 inline DeclContext *getSemanticDC()
const {
263 return DeclCtx.get<DeclContext*>();
270 unsigned DeclKind : 7;
273 unsigned InvalidDecl : 1;
276 unsigned HasAttrs : 1;
290 unsigned Referenced : 1;
295 unsigned TopLevelDeclInObjCContainer : 1;
298 static bool StatisticsEnabled;
304 friend class CXXClassMemberWrapper;
307 unsigned FromASTFile : 1;
314 mutable unsigned CacheValidAndLinkage : 3;
340 bool AccessDeclContextSanity()
const;
346 auto *D = cast<Decl>(DC);
347 auto MOK = D->getModuleOwnershipKind();
348 if (MOK != ModuleOwnershipKind::Unowned &&
349 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
354 return ModuleOwnershipKind::Unowned;
359 : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
360 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(0), HasAttrs(
false),
362 TopLevelDeclInObjCContainer(
false), Access(
AS_none), FromASTFile(0),
364 CacheValidAndLinkage(0) {
365 if (StatisticsEnabled) add(DK);
369 : NextInContextAndBits(), DeclKind(DK), InvalidDecl(0), HasAttrs(
false),
371 TopLevelDeclInObjCContainer(
false), Access(
AS_none), FromASTFile(0),
373 CacheValidAndLinkage(0) {
374 if (StatisticsEnabled) add(DK);
383 return Linkage(CacheValidAndLinkage - 1);
387 CacheValidAndLinkage = L + 1;
391 return CacheValidAndLinkage;
411 const char *getDeclKindName()
const;
418 return getSemanticDC();
419 return getMultipleDC()->SemanticDC;
422 return const_cast<Decl*
>(
this)->getDeclContext();
437 return const_cast<Decl*
>(
this)->getTranslationUnitDecl();
440 bool isInAnonymousNamespace()
const;
442 bool isInStdNamespace()
const;
444 ASTContext &getASTContext() const LLVM_READONLY;
448 assert(AccessDeclContextSanity());
452 assert(AccessDeclContextSanity());
464 return setAttrsImpl(Attrs, getASTContext());
467 return const_cast<AttrVec&
>(
const_cast<const Decl*
>(
this)->getAttrs());
469 const AttrVec &getAttrs()
const;
474 getAttrs().push_back(A);
487 return hasAttrs() ? getAttrs().begin() :
nullptr;
490 return hasAttrs() ? getAttrs().end() :
nullptr;
493 template <
typename T>
495 if (!HasAttrs)
return;
498 Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end());
504 template <
typename T>
506 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
509 template <
typename T>
513 template <
typename T>
519 return hasAttrs() ? getSpecificAttr<T>(getAttrs()) :
nullptr;
522 return hasAttrs() && hasSpecificAttr<T>(getAttrs());
527 unsigned getMaxAlignment()
const;
531 void setInvalidDecl(
bool Invalid =
true);
546 bool isUsed(
bool CheckUsedAttr =
true)
const;
561 bool isReferenced()
const;
573 return TopLevelDeclInObjCContainer;
577 TopLevelDeclInObjCContainer = V;
582 ExternalSourceSymbolAttr *getExternalSourceSymbolAttr()
const;
587 return getModuleOwnershipKind() == ModuleOwnershipKind::ModulePrivate;
592 bool isExported()
const;
596 bool hasDefiningAttr()
const;
599 const Attr *getDefiningAttr()
const;
607 if (getModuleOwnershipKind() == ModuleOwnershipKind::Unowned)
609 setModuleOwnershipKind(ModuleOwnershipKind::ModulePrivate);
614 assert(isFromASTFile() &&
"Only works on a deserialized declaration");
615 *((
unsigned*)
this - 2) =
ID;
634 getAvailability(std::string *Message =
nullptr,
669 bool isWeakImported()
const;
677 bool canBeWeakImported(
bool &IsDefinition)
const;
687 return *((
const unsigned*)
this - 1);
695 return *((
const unsigned*)
this - 2);
700 Module *getOwningModuleSlow()
const;
702 bool hasLocalOwningModuleStorage()
const;
708 if (!isFromASTFile() || !hasOwningModule())
711 return getOwningModuleSlow();
717 if (isFromASTFile() || !hasOwningModule())
720 assert(hasLocalOwningModuleStorage() &&
721 "owned local decl but no local module storage");
722 return reinterpret_cast<Module *
const *
>(
this)[-1];
725 assert(!isFromASTFile() && hasOwningModule() &&
726 hasLocalOwningModuleStorage() &&
727 "should not have a cached owning module");
728 reinterpret_cast<Module **
>(
this)[-1] = M;
733 return getModuleOwnershipKind() != ModuleOwnershipKind::Unowned;
738 return isFromASTFile() ? getImportedOwningModule() : getLocalOwningModule();
746 return (
int)getModuleOwnershipKind() > (int)ModuleOwnershipKind::Visible;
753 setModuleOwnershipKind(ModuleOwnershipKind::Visible);
758 return NextInContextAndBits.getInt();
763 assert(!(getModuleOwnershipKind() == ModuleOwnershipKind::Unowned &&
764 MOK != ModuleOwnershipKind::Unowned && !isFromASTFile() &&
765 !hasLocalOwningModuleStorage()) &&
766 "no storage available for owning module for this declaration");
767 NextInContextAndBits.setInt(MOK);
774 return getIdentifierNamespace() & NS;
776 static unsigned getIdentifierNamespaceForKind(
Kind DK);
779 return isTagIdentifierNamespace(getIdentifierNamespace());
783 return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
798 return getSemanticDC();
799 return getMultipleDC()->LexicalDC;
802 return const_cast<Decl*
>(
this)->getLexicalDeclContext();
807 virtual bool isOutOfLine()
const;
820 return getParentFunctionOrMethod() ==
nullptr;
830 bool isLexicallyWithinFunctionOrMethod()
const;
834 const DeclContext *getParentFunctionOrMethod()
const;
837 const_cast<const Decl*
>(
this)->getParentFunctionOrMethod());
885 assert(
Current &&
"Advancing while iterator has reached end");
888 assert(Next &&
"Should return next redeclaration or itself, never null!");
889 Current = (Next != Starter) ? Next :
nullptr;
900 return x.Current == y.Current;
903 return x.Current != y.Current;
927 return const_cast<Decl *
>(
this)->getPreviousDeclImpl();
932 return getPreviousDecl() ==
nullptr;
942 return const_cast<Decl *
>(
this)->getMostRecentDeclImpl();
954 virtual bool hasBody()
const {
return getBody() !=
nullptr; }
961 static void add(
Kind k);
962 static void EnableStatistics();
963 static void PrintStats();
967 bool isTemplateParameter()
const;
971 bool isTemplateParameterPack()
const;
974 bool isParameterPack()
const;
977 bool isTemplateDecl()
const;
981 return (DeclKind >= Decl::firstFunction &&
982 DeclKind <= Decl::lastFunction) ||
983 DeclKind == FunctionTemplate;
995 return const_cast<Decl *
>(
this)->getAsFunction();
1007 "namespace is not ordinary");
1009 Decl *Prev = getPreviousDecl();
1033 assert((OldNS & (IDNS_Tag | IDNS_Ordinary |
1034 IDNS_TagFriend | IDNS_OrdinaryFriend |
1035 IDNS_LocalExtern)) &&
1036 "namespace includes neither ordinary nor tag");
1037 assert(!(OldNS & ~(IDNS_Tag | IDNS_Ordinary | IDNS_Type |
1038 IDNS_TagFriend | IDNS_OrdinaryFriend |
1039 IDNS_LocalExtern)) &&
1040 "namespace includes other than ordinary or tag");
1042 Decl *Prev = getPreviousDecl();
1045 if (OldNS & (IDNS_Tag | IDNS_TagFriend)) {
1047 if (PerformFriendInjection ||
1052 if (OldNS & (IDNS_Ordinary | IDNS_OrdinaryFriend | IDNS_LocalExtern)) {
1054 if (PerformFriendInjection ||
1073 if (!mask)
return FOK_None;
1082 "visible non-member operators should be in ordinary namespace");
1090 void print(raw_ostream &Out,
unsigned Indentation = 0,
1091 bool PrintInstantiation =
false)
const;
1093 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1094 static void printGroup(
Decl**
Begin,
unsigned NumDecls,
1096 unsigned Indentation = 0);
1100 void dumpColor()
const;
1101 void dump(raw_ostream &Out,
bool Deserialize =
false)
const;
1106 const FunctionType *getFunctionType(
bool BlocksToo =
true)
const;
1131 const Decl *TheDecl;
1134 const char *Message;
1138 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1140 void print(raw_ostream &OS)
const override;
1153 static NamedDecl *
const SingleElementDummyList;
1158 : Result(Result), Single() {}
1160 : Result(SingleElementDummyList), Single(Single) {}
1163 typedef llvm::iterator_adaptor_base<
iterator, ResultTy::iterator,
1164 std::random_access_iterator_tag,
1167 value_type SingleElement;
1185 bool empty()
const {
return Result.empty(); }
1187 size_t size()
const {
return Single ? 1 : Result.size(); }
1195 Sliced.Single = Single;
1217 unsigned DeclKind : 8;
1222 mutable bool ExternalLexicalStorage : 1;
1227 mutable bool ExternalVisibleStorage : 1;
1233 mutable bool NeedToReconcileExternalVisibleStorage : 1;
1237 mutable bool HasLazyLocalLexicalLookups : 1;
1241 mutable bool HasLazyExternalLexicalLookups : 1;
1246 mutable bool UseQualifiedLookup : 1;
1274 static std::pair<Decl *, Decl *>
1278 : DeclKind(K), ExternalLexicalStorage(
false),
1279 ExternalVisibleStorage(
false),
1280 NeedToReconcileExternalVisibleStorage(
false),
1281 HasLazyLocalLexicalLookups(
false), HasLazyExternalLexicalLookups(
false),
1282 UseQualifiedLookup(
false),
1295 return cast<Decl>(
this)->getDeclContext();
1311 return cast<Decl>(
this)->getLexicalDeclContext();
1324 return cast<Decl>(
this)->getASTContext();
1328 return DeclKind == Decl::Block;
1333 case Decl::ObjCCategory:
1334 case Decl::ObjCCategoryImpl:
1335 case Decl::ObjCImplementation:
1336 case Decl::ObjCInterface:
1337 case Decl::ObjCProtocol:
1346 case Decl::Captured:
1347 case Decl::ObjCMethod:
1350 return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction;
1357 DeclKind != Decl::Export;
1361 return DeclKind == Decl::TranslationUnit || DeclKind == Decl::Namespace;
1365 return DeclKind == Decl::TranslationUnit;
1369 return DeclKind >= Decl::firstRecord && DeclKind <= Decl::lastRecord;
1373 return DeclKind == Decl::Namespace;
1526 return x.Current == y.Current;
1529 return x.Current != y.Current;
1556 template<
typename SpecificDecl>
1566 void SkipToNextDecl() {
1567 while (*Current && !isa<SpecificDecl>(*Current))
1577 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1613 return x.Current == y.Current;
1618 return x.Current != y.Current;
1631 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
1641 void SkipToNextDecl() {
1643 (!isa<SpecificDecl>(*Current) ||
1644 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
1654 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1689 return x.Current == y.Current;
1694 return x.Current != y.Current;
1783 typedef llvm::iterator_range<all_lookups_iterator>
lookups_range;
1800 std::random_access_iterator_tag,
1813 typedef llvm::iterator_range<DeclContext::ddiag_iterator>
ddiag_range;
1827 "should only be called on primary context");
1828 HasLazyExternalLexicalLookups =
true;
1845 ExternalLexicalStorage = ES;
1855 ExternalVisibleStorage = ES;
1856 if (ES && LookupPtr)
1857 NeedToReconcileExternalVisibleStorage =
true;
1868 bool old_value = UseQualifiedLookup;
1869 UseQualifiedLookup = use;
1874 return UseQualifiedLookup;
1882 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false,
1883 bool Deserialize =
false)
const;
1886 void reconcileExternalVisibleStorage()
const;
1887 bool LoadLexicalDeclsFromExternalStorage()
const;
1895 void makeDeclVisibleInContextInternal(
NamedDecl *D);
1900 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
1901 void makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
1902 bool Rediscoverable);
1903 void makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal);
1907 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
1908 getKind() == TemplateTemplateParm;
1912 template <
class ToTy,
1913 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
1925 template <
class ToTy>
1928 return static_cast<const ToTy*
>(Val);
1932 return static_cast<ToTy*
>(Val);
1942 template <
typename To>
1944 static bool doit(const ::clang::DeclContext &Val) {
1945 return To::classofKind(Val.getDeclKind());
1950 template<
class ToTy>
1951 struct cast_convert_val<ToTy,
1953 static const ToTy &
doit(const ::clang::DeclContext &Val) {
1957 template<
class ToTy>
1963 template<
class ToTy>
1964 struct cast_convert_val<ToTy,
1966 static const ToTy *
doit(const ::clang::DeclContext *Val) {
1967 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1970 template<
class ToTy>
1973 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1978 template<
class FromTy>
1980 static ::clang::DeclContext &
doit(
const FromTy &Val) {
1981 return *FromTy::castToDeclContext(&Val);
1985 template<
class FromTy>
1987 static ::clang::DeclContext *
doit(
const FromTy *Val) {
1988 return FromTy::castToDeclContext(Val);
1992 template<
class FromTy>
1994 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
1995 return *FromTy::castToDeclContext(&Val);
1999 template<
class FromTy>
2001 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
2002 return FromTy::castToDeclContext(Val);
decl_iterator noload_decls_end() const
bool hasOwningModule() const
Is this declaration owned by some module?
SourceLocation getEnd() const
const value_type * pointer
const DeclContext * getLookupParent() const
ddiag_range ddiags() const
specific_decl_iterator & operator++()
static const Decl * getCanonicalDecl(const Decl *D)
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.
UsingDirectiveDecl * operator*() const
bool isObjCContainer() const
llvm::iterator_range< redecl_iterator > redecl_range
llvm::PointerIntPair< Decl *, 2, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
Represents a version number in the form major[.minor[.subminor[.build]]].
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'.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static Decl * castFromDeclContext(const DeclContext *)
void setAttrs(const AttrVec &Attrs)
redecl_iterator redecls_end() const
Stmt - This represents one statement.
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.
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)
static TemplateDecl * getDescribedTemplate(Decl *Templated)
specific_decl_iterator(DeclContext::decl_iterator C)
specific_decl_iterator - Construct a new iterator over a subset of the declarations the range [C...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
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...
static Decl * getNonClosureContext(T *D)
Starting at a given context (a Decl or DeclContext), look for a code context that is not a closure (a...
redecl_iterator & operator++()
ModuleOwnershipKind
The kind of ownership a declaration has, for visibility purposes.
llvm::iterator_adaptor_base< iterator, ResultTy::iterator, std::random_access_iterator_tag, NamedDecl *const > IteratorBase
AccessSpecifier getAccess() const
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
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
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.
RecordDecl - Represents a struct/union/class.
Provides common interface for the Decls that can be redeclared.
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...
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
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
all_lookups_iterator lookups_end() const
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
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
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.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
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...
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)...
void setLocalOwningModule(Module *M)
Module * getLocalOwningModule() const
Get the local owning module, if known.
value_type operator*() const
Represents a linkage specification.
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.
specific_attr_iterator< T > specific_attr_end() const
Decl * getNextDeclInContext()
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
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.
lookups_range lookups() const
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)
llvm::iterator_range< udir_iterator > udir_range
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
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.
value_type operator->() 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.
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
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
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
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.
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)
SpecificDecl * value_type
all_lookups_iterator - An iterator that provides a view over the results of looking up every possible...
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
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
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...
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
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
The base class of all kinds of template declarations (e.g., class, function, etc.).
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.
decl_iterator operator++(int)
lookup_result::iterator lookup_iterator
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
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.
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)
Module * getOwningModule() const
Get the module that owns this declaration.
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
const DeclContext * getLexicalParent() const
const value_type & reference
const Decl * getCanonicalDecl() const
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
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
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
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.
static Decl::Kind getKind(const Decl *D)
TranslationUnitDecl - The top declaration context.
const DeclContext * getParent() const
value_type operator*() const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
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 this Decl ...
DeclContextLookupResult(ArrayRef< NamedDecl * > Result)
bool setUseQualifiedLookup(bool use=true)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
NamedDecl - This represents a decl with a name.
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.
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'.
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 ...