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;
56 class TranslationUnitDecl;
57 class UsingDirectiveDecl;
82 #define DECL(DERIVED, BASE) DERIVED,
83 #define ABSTRACT_DECL(DECL)
84 #define DECL_RANGE(BASE, START, END) \
85 first##BASE = START, last##BASE = END,
86 #define LAST_DECL_RANGE(BASE, START, END) \
87 first##BASE = START, last##BASE = END
88 #include "clang/AST/DeclNodes.inc"
94 struct EmptyShell { };
107 enum IdentifierNamespace {
128 IDNS_Member = 0x0008,
132 IDNS_Namespace = 0x0010,
136 IDNS_Ordinary = 0x0020,
139 IDNS_ObjCProtocol = 0x0040,
144 IDNS_OrdinaryFriend = 0x0080,
149 IDNS_TagFriend = 0x0100,
160 IDNS_NonMemberOperator = 0x0400,
167 IDNS_LocalExtern = 0x0800,
170 IDNS_OMPReduction = 0x1000
187 enum ObjCDeclQualifier {
192 OBJC_TQ_Bycopy = 0x8,
193 OBJC_TQ_Byref = 0x10,
194 OBJC_TQ_Oneway = 0x20,
199 OBJC_TQ_CSNullability = 0x40
208 TopLevelDeclInObjCContainerFlag = 0x01,
212 ModulePrivateFlag = 0x02
221 llvm::PointerIntPair<Decl *, 2, unsigned> NextInContextAndBits;
245 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
247 inline bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
248 inline bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
249 inline MultipleDC *getMultipleDC()
const {
250 return DeclCtx.get<MultipleDC*>();
260 unsigned DeclKind : 7;
263 unsigned InvalidDecl : 1;
266 unsigned HasAttrs : 1;
270 unsigned Implicit : 1;
280 unsigned Referenced : 1;
283 static bool StatisticsEnabled;
289 friend class CXXClassMemberWrapper;
292 unsigned FromASTFile : 1;
300 unsigned IdentifierNamespace : 13;
304 mutable unsigned CacheValidAndLinkage : 3;
330 bool AccessDeclContextSanity()
const;
335 : NextInContextAndBits(), DeclCtx(DC),
336 Loc(L), DeclKind(DK), InvalidDecl(0),
337 HasAttrs(
false), Implicit(
false),
Used(
false), Referenced(
false),
338 Access(
AS_none), FromASTFile(0), Hidden(DC && cast<Decl>(DC)->Hidden),
339 IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
340 CacheValidAndLinkage(0)
342 if (StatisticsEnabled) add(DK);
346 : NextInContextAndBits(), DeclKind(DK), InvalidDecl(0),
347 HasAttrs(
false), Implicit(
false),
Used(
false), Referenced(
false),
348 Access(
AS_none), FromASTFile(0), Hidden(0),
349 IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
350 CacheValidAndLinkage(0)
352 if (StatisticsEnabled) add(DK);
360 Linkage getCachedLinkage()
const {
361 return Linkage(CacheValidAndLinkage - 1);
364 void setCachedLinkage(
Linkage L)
const {
365 CacheValidAndLinkage = L + 1;
368 bool hasCachedLinkage()
const {
369 return CacheValidAndLinkage;
389 const char *getDeclKindName()
const;
391 Decl *getNextDeclInContext() {
return NextInContextAndBits.getPointer(); }
392 const Decl *getNextDeclInContext()
const {
return NextInContextAndBits.getPointer();}
396 return getSemanticDC();
397 return getMultipleDC()->SemanticDC;
400 return const_cast<Decl*
>(
this)->getDeclContext();
415 return const_cast<Decl*
>(
this)->getTranslationUnitDecl();
418 bool isInAnonymousNamespace()
const;
420 bool isInStdNamespace()
const;
422 ASTContext &getASTContext()
const LLVM_READONLY;
426 assert(AccessDeclContextSanity());
430 assert(AccessDeclContextSanity());
440 bool hasAttrs()
const {
return HasAttrs; }
441 void setAttrs(
const AttrVec& Attrs) {
442 return setAttrsImpl(Attrs, getASTContext());
445 return const_cast<AttrVec&
>(
const_cast<const Decl*
>(
this)->getAttrs());
447 const AttrVec &getAttrs()
const;
450 void addAttr(
Attr *A) {
452 getAttrs().push_back(A);
457 typedef AttrVec::const_iterator attr_iterator;
458 typedef llvm::iterator_range<attr_iterator> attr_range;
460 attr_range attrs()
const {
461 return attr_range(attr_begin(), attr_end());
464 attr_iterator attr_begin()
const {
465 return hasAttrs() ? getAttrs().begin() :
nullptr;
467 attr_iterator attr_end()
const {
468 return hasAttrs() ? getAttrs().end() :
nullptr;
471 template <
typename T>
473 if (!HasAttrs)
return;
476 Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end());
482 template <
typename T>
483 llvm::iterator_range<specific_attr_iterator<T>> specific_attrs()
const {
484 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
487 template <
typename T>
491 template <
typename T>
496 template<
typename T> T *getAttr()
const {
497 return hasAttrs() ? getSpecificAttr<T>(getAttrs()) :
nullptr;
499 template<
typename T>
bool hasAttr()
const {
500 return hasAttrs() && hasSpecificAttr<T>(getAttrs());
505 unsigned getMaxAlignment()
const;
509 void setInvalidDecl(
bool Invalid =
true);
510 bool isInvalidDecl()
const {
return (
bool) InvalidDecl; }
515 bool isImplicit()
const {
return Implicit; }
516 void setImplicit(
bool I =
true) { Implicit =
I; }
524 bool isUsed(
bool CheckUsedAttr =
true)
const;
539 bool isReferenced()
const;
543 bool isThisDeclarationReferenced()
const {
return Referenced; }
545 void setReferenced(
bool R =
true) { Referenced = R; }
550 bool isTopLevelDeclInObjCContainer()
const {
551 return NextInContextAndBits.getInt() & TopLevelDeclInObjCContainerFlag;
554 void setTopLevelDeclInObjCContainer(
bool V =
true) {
555 unsigned Bits = NextInContextAndBits.getInt();
557 Bits |= TopLevelDeclInObjCContainerFlag;
559 Bits &= ~TopLevelDeclInObjCContainerFlag;
560 NextInContextAndBits.setInt(Bits);
565 bool isModulePrivate()
const {
566 return NextInContextAndBits.getInt() & ModulePrivateFlag;
571 bool hasDefiningAttr()
const;
574 const Attr *getDefiningAttr()
const;
579 void setModulePrivate(
bool MP =
true) {
580 unsigned Bits = NextInContextAndBits.getInt();
582 Bits |= ModulePrivateFlag;
584 Bits &= ~ModulePrivateFlag;
585 NextInContextAndBits.setInt(Bits);
589 void setOwningModuleID(
unsigned ID) {
590 assert(isFromASTFile() &&
"Only works on a deserialized declaration");
591 *((
unsigned*)
this - 2) =
ID;
613 bool isDeprecated(std::string *Message =
nullptr)
const {
622 bool isUnavailable(std::string *Message =
nullptr)
const {
632 bool isWeakImported()
const;
640 bool canBeWeakImported(
bool &IsDefinition)
const;
644 bool isFromASTFile()
const {
return FromASTFile; }
648 unsigned getGlobalID()
const {
650 return *((
const unsigned*)
this - 1);
656 unsigned getOwningModuleID()
const {
658 return *((
const unsigned*)
this - 2);
664 Module *getOwningModuleSlow()
const;
666 bool hasLocalOwningModuleStorage()
const;
671 Module *getImportedOwningModule()
const {
672 if (!isFromASTFile())
675 return getOwningModuleSlow();
680 Module *getLocalOwningModule()
const {
681 if (isFromASTFile() || !Hidden)
683 return reinterpret_cast<Module *
const *
>(
this)[-1];
685 void setLocalOwningModule(
Module *M) {
686 assert(!isFromASTFile() && Hidden && hasLocalOwningModuleStorage() &&
687 "should not have a cached owning module");
688 reinterpret_cast<Module **
>(
this)[-1] = M;
691 unsigned getIdentifierNamespace()
const {
692 return IdentifierNamespace;
694 bool isInIdentifierNamespace(
unsigned NS)
const {
695 return getIdentifierNamespace() & NS;
697 static unsigned getIdentifierNamespaceForKind(
Kind DK);
699 bool hasTagIdentifierNamespace()
const {
700 return isTagIdentifierNamespace(getIdentifierNamespace());
702 static bool isTagIdentifierNamespace(
unsigned NS) {
704 return (NS & ~IDNS_TagFriend) == (IDNS_Tag | IDNS_Type);
719 return getSemanticDC();
720 return getMultipleDC()->LexicalDC;
723 return const_cast<Decl*
>(
this)->getLexicalDeclContext();
728 virtual bool isOutOfLine()
const;
740 bool isDefinedOutsideFunctionOrMethod()
const {
741 return getParentFunctionOrMethod() ==
nullptr;
751 bool isLexicallyWithinFunctionOrMethod()
const;
755 const DeclContext *getParentFunctionOrMethod()
const;
758 const_cast<const Decl*
>(
this)->getParentFunctionOrMethod());
775 virtual Decl *getNextRedeclarationImpl() {
return this; }
779 virtual Decl *getPreviousDeclImpl() {
return nullptr; }
783 virtual Decl *getMostRecentDeclImpl() {
return this; }
787 class redecl_iterator {
793 typedef Decl *value_type;
794 typedef const value_type &reference;
795 typedef const value_type *pointer;
796 typedef std::forward_iterator_tag iterator_category;
799 redecl_iterator() :
Current(
nullptr) { }
800 explicit redecl_iterator(
Decl *C) :
Current(C), Starter(C) { }
803 value_type operator->()
const {
return Current; }
805 redecl_iterator& operator++() {
806 assert(
Current &&
"Advancing while iterator has reached end");
809 assert(Next &&
"Should return next redeclaration or itself, never null!");
810 Current = (Next != Starter) ? Next :
nullptr;
814 redecl_iterator operator++(
int) {
815 redecl_iterator tmp(*
this);
820 friend bool operator==(redecl_iterator x, redecl_iterator y) {
821 return x.Current == y.Current;
823 friend bool operator!=(redecl_iterator x, redecl_iterator y) {
824 return x.Current != y.Current;
828 typedef llvm::iterator_range<redecl_iterator> redecl_range;
832 redecl_range redecls()
const {
833 return redecl_range(redecls_begin(), redecls_end());
836 redecl_iterator redecls_begin()
const {
837 return redecl_iterator(const_cast<Decl *>(
this));
839 redecl_iterator redecls_end()
const {
return redecl_iterator(); }
843 Decl *getPreviousDecl() {
return getPreviousDeclImpl(); }
847 const Decl *getPreviousDecl()
const {
848 return const_cast<Decl *
>(
this)->getPreviousDeclImpl();
852 bool isFirstDecl()
const {
853 return getPreviousDecl() ==
nullptr;
858 Decl *getMostRecentDecl() {
return getMostRecentDeclImpl(); }
862 const Decl *getMostRecentDecl()
const {
863 return const_cast<Decl *
>(
this)->getMostRecentDeclImpl();
869 virtual Stmt* getBody()
const {
return nullptr; }
875 virtual bool hasBody()
const {
return getBody() !=
nullptr; }
882 static void add(
Kind k);
883 static void EnableStatistics();
884 static void PrintStats();
888 bool isTemplateParameter()
const;
892 bool isTemplateParameterPack()
const;
895 bool isParameterPack()
const;
898 bool isTemplateDecl()
const;
901 bool isFunctionOrFunctionTemplate()
const {
902 return (DeclKind >= Decl::firstFunction &&
903 DeclKind <= Decl::lastFunction) ||
904 DeclKind == FunctionTemplate;
916 return const_cast<Decl *
>(
this)->getAsFunction();
925 void setLocalExternDecl() {
926 assert((IdentifierNamespace == IDNS_Ordinary ||
927 IdentifierNamespace == IDNS_OrdinaryFriend) &&
928 "namespace is not ordinary");
930 Decl *Prev = getPreviousDecl();
931 IdentifierNamespace &= ~IDNS_Ordinary;
933 IdentifierNamespace |= IDNS_LocalExtern;
934 if (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary)
935 IdentifierNamespace |= IDNS_Ordinary;
941 bool isLocalExternDecl() {
942 return IdentifierNamespace & IDNS_LocalExtern;
952 void setObjectOfFriendDecl(
bool PerformFriendInjection =
false) {
953 unsigned OldNS = IdentifierNamespace;
954 assert((OldNS & (IDNS_Tag | IDNS_Ordinary |
955 IDNS_TagFriend | IDNS_OrdinaryFriend |
956 IDNS_LocalExtern)) &&
957 "namespace includes neither ordinary nor tag");
958 assert(!(OldNS & ~(IDNS_Tag | IDNS_Ordinary | IDNS_Type |
959 IDNS_TagFriend | IDNS_OrdinaryFriend |
960 IDNS_LocalExtern)) &&
961 "namespace includes other than ordinary or tag");
963 Decl *Prev = getPreviousDecl();
964 IdentifierNamespace &= ~(IDNS_Ordinary | IDNS_Tag | IDNS_Type);
966 if (OldNS & (IDNS_Tag | IDNS_TagFriend)) {
967 IdentifierNamespace |= IDNS_TagFriend;
968 if (PerformFriendInjection ||
969 (Prev && Prev->getIdentifierNamespace() & IDNS_Tag))
970 IdentifierNamespace |= IDNS_Tag | IDNS_Type;
973 if (OldNS & (IDNS_Ordinary | IDNS_OrdinaryFriend | IDNS_LocalExtern)) {
974 IdentifierNamespace |= IDNS_OrdinaryFriend;
975 if (PerformFriendInjection ||
976 (Prev && Prev->getIdentifierNamespace() & IDNS_Ordinary))
977 IdentifierNamespace |= IDNS_Ordinary;
981 enum FriendObjectKind {
991 FriendObjectKind getFriendObjectKind()
const {
993 (IdentifierNamespace & (IDNS_TagFriend | IDNS_OrdinaryFriend));
994 if (!mask)
return FOK_None;
995 return (IdentifierNamespace & (IDNS_Tag | IDNS_Ordinary) ? FOK_Declared
1000 void setNonMemberOperator() {
1002 assert((IdentifierNamespace & IDNS_Ordinary) &&
1003 "visible non-member operators should be in ordinary namespace");
1004 IdentifierNamespace |= IDNS_NonMemberOperator;
1007 static bool classofKind(
Kind K) {
return true; }
1011 void print(raw_ostream &Out,
unsigned Indentation = 0,
1012 bool PrintInstantiation =
false)
const;
1014 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1015 static void printGroup(
Decl** Begin,
unsigned NumDecls,
1017 unsigned Indentation = 0);
1021 void dumpColor()
const;
1022 void dump(raw_ostream &Out)
const;
1027 const FunctionType *getFunctionType(
bool BlocksToo =
true)
const;
1046 return D1->getCanonicalDecl() == D2->getCanonicalDecl();
1052 const Decl *TheDecl;
1055 const char *Message;
1059 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1061 void print(raw_ostream &OS)
const override;
1074 static NamedDecl *
const SingleElementDummyList;
1079 : Result(Result), Single() {}
1081 : Result(SingleElementDummyList), Single(Single) {}
1085 std::random_access_iterator_tag,
1088 value_type SingleElement;
1106 bool empty()
const {
return Result.empty(); }
1108 size_t size()
const {
return Single ? 1 : Result.size(); }
1116 Sliced.Single = Single;
1137 unsigned DeclKind : 8;
1142 mutable bool ExternalLexicalStorage : 1;
1147 mutable bool ExternalVisibleStorage : 1;
1153 mutable bool NeedToReconcileExternalVisibleStorage : 1;
1157 mutable bool HasLazyLocalLexicalLookups : 1;
1161 mutable bool HasLazyExternalLexicalLookups : 1;
1166 mutable bool UseQualifiedLookup : 1;
1194 static std::pair<Decl *, Decl *>
1198 : DeclKind(K), ExternalLexicalStorage(
false),
1199 ExternalVisibleStorage(
false),
1200 NeedToReconcileExternalVisibleStorage(
false),
1201 HasLazyLocalLexicalLookups(
false), HasLazyExternalLexicalLookups(
false),
1202 UseQualifiedLookup(
false),
1215 return cast<Decl>(
this)->getDeclContext();
1231 return cast<Decl>(
this)->getLexicalDeclContext();
1244 return cast<Decl>(
this)->getASTContext();
1248 return DeclKind == Decl::Block;
1253 case Decl::ObjCCategory:
1254 case Decl::ObjCCategoryImpl:
1255 case Decl::ObjCImplementation:
1256 case Decl::ObjCInterface:
1257 case Decl::ObjCProtocol:
1266 case Decl::Captured:
1267 case Decl::ObjCMethod:
1270 return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction;
1280 return DeclKind == Decl::TranslationUnit || DeclKind == Decl::Namespace;
1284 return DeclKind == Decl::TranslationUnit;
1288 return DeclKind >= Decl::firstRecord && DeclKind <= Decl::lastRecord;
1292 return DeclKind == Decl::Namespace;
1431 Current = Current->getNextDeclInContext();
1442 return x.Current == y.Current;
1445 return x.Current != y.Current;
1472 template<
typename SpecificDecl>
1482 void SkipToNextDecl() {
1483 while (*Current && !isa<SpecificDecl>(*Current))
1493 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1529 return x.Current == y.Current;
1534 return x.Current != y.Current;
1547 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
1557 void SkipToNextDecl() {
1559 (!isa<SpecificDecl>(*Current) ||
1560 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
1570 typedef std::iterator_traits<DeclContext::decl_iterator>::difference_type
1605 return x.Current == y.Current;
1610 return x.Current != y.Current;
1699 typedef llvm::iterator_range<all_lookups_iterator>
lookups_range;
1716 std::random_access_iterator_tag,
1729 typedef llvm::iterator_range<DeclContext::ddiag_iterator>
ddiag_range;
1743 "should only be called on primary context");
1744 HasLazyExternalLexicalLookups =
true;
1761 ExternalLexicalStorage = ES;
1771 ExternalVisibleStorage = ES;
1772 if (ES && LookupPtr)
1773 NeedToReconcileExternalVisibleStorage =
true;
1779 return D && (D->NextInContextAndBits.getPointer() || D ==
FirstDecl ||
1784 bool old_value = UseQualifiedLookup;
1785 UseQualifiedLookup = use;
1790 return UseQualifiedLookup;
1798 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false)
const;
1801 void reconcileExternalVisibleStorage()
const;
1802 bool LoadLexicalDeclsFromExternalStorage()
const;
1810 void makeDeclVisibleInContextInternal(
NamedDecl *D);
1815 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
1816 void makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
1817 bool Rediscoverable);
1818 void makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal);
1821 inline bool Decl::isTemplateParameter()
const {
1822 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
1823 getKind() == TemplateTemplateParm;
1827 template <
class ToTy,
1828 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
1831 return static_cast<const ToTy*
>(Decl::castFromDeclContext(Val));
1835 return static_cast<ToTy*
>(Decl::castFromDeclContext(Val));
1840 template <
class ToTy>
1843 return static_cast<const ToTy*
>(Val);
1847 return static_cast<ToTy*
>(Val);
1857 template <
typename To>
1859 static bool doit(const ::clang::DeclContext &Val) {
1860 return To::classofKind(Val.getDeclKind());
1865 template<
class ToTy>
1866 struct cast_convert_val<ToTy,
1868 static const ToTy &
doit(const ::clang::DeclContext &Val) {
1872 template<
class ToTy>
1878 template<
class ToTy>
1879 struct cast_convert_val<ToTy,
1881 static const ToTy *
doit(const ::clang::DeclContext *Val) {
1882 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1885 template<
class ToTy>
1888 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
1893 template<
class FromTy>
1895 static ::clang::DeclContext &
doit(
const FromTy &Val) {
1896 return *FromTy::castToDeclContext(&Val);
1900 template<
class FromTy>
1902 static ::clang::DeclContext *
doit(
const FromTy *Val) {
1903 return FromTy::castToDeclContext(Val);
1907 template<
class FromTy>
1909 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
1910 return *FromTy::castToDeclContext(&Val);
1914 template<
class FromTy>
1916 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
1917 return FromTy::castToDeclContext(Val);
decl_iterator noload_decls_end() const
class LLVM_ALIGNAS(8) Decl
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEnd() const
const DeclContext * getLookupParent() const
ddiag_range ddiags() const
specific_decl_iterator & operator++()
static const Decl * getCanonicalDecl(const Decl *D)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
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.
UsingDirectiveDecl * operator*() const
bool isObjCContainer() const
std::forward_iterator_tag iterator_category
bool operator==(CanQual< T > x, CanQual< U > y)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
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.
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...
bool isStdNamespace() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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)
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...
llvm::iterator_adaptor_base< iterator, ResultTy::iterator, std::random_access_iterator_tag, NamedDecl *const > IteratorBase
Decl * FirstDecl
FirstDecl - The first declaration stored within this declaration context.
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...
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...
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)
all_lookups_iterator lookups_end() const
bool isTranslationUnit() const
bool isInlineNamespace() const
SmallVector< Attr *, 2 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
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.
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.
value_type operator*() const
decl_iterator decls_begin() const
detail::InMemoryDirectory::const_iterator I
::clang::DeclContext * doit(const FromTy *Val)
iterator::reference reference
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.
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
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.
llvm::iterator_range< udir_iterator > udir_range
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
ASTContext & getParentASTContext() const
Decl * LastDecl
LastDecl - The last declaration stored within this declaration context.
value_type operator->() 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...
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
bool isFunctionOrMethod() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContextLookupResult slice(size_t N) const
all_lookups_iterator lookups_begin() const
Iterators over all possible lookups within this context.
const Decl * getNonClosureAncestor() const
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.
reference operator*() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
llvm::iterator_adaptor_base< udir_iterator, lookup_iterator, std::random_access_iterator_tag, UsingDirectiveDecl * > udir_iterator_base
specific_attr_iterator< SpecificAttr, Container > specific_attr_begin(const Container &container)
Encodes a location in the source.
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
decl_iterator noload_decls_begin() const
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
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)
SourceLocation getBegin() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isFileContext() const
DeclContextLookupResult lookup_result
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
static bool doit(const ::clang::DeclContext &Val)
static const ToTy * doit(const DeclContext *Val)
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 shouldUseQualifiedLookup() const
Reads an AST files chain containing the contents of a translation unit.
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
DeclarationName - The name of a declaration.
decl_iterator operator++(int)
lookup_result::iterator lookup_iterator
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).
SmallVector< Context, 8 > Contexts
A dependently-generated diagnostic.
std::forward_iterator_tag iterator_category
Decl::Kind getDeclKind() const
filtered_decl_iterator operator++(int)
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 ...
static ToTy & doit(::clang::DeclContext &Val)
void addDecl(Decl *D)
Add the declaration D into this context.
reference operator[](size_t N) const
const DeclContext * getLexicalParent() const
static const ::clang::DeclContext & doit(const FromTy &Val)
specific_attr_iterator< SpecificAttr, Container > specific_attr_end(const Container &container)
friend bool operator==(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
decl_iterator & operator++()
PrettyStackTraceDecl(const Decl *theDecl, SourceLocation L, SourceManager &sm, const char *Msg)
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
bool operator!=(CanQual< T > x, CanQual< U > y)
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
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
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)
DeclContextLookupResult(ArrayRef< NamedDecl * > Result)
bool setUseQualifiedLookup(bool use=true)
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context...
Represents C++ using-directive.
const DeclContext * getPrimaryContext() const
This class handles loading and caching of source files into memory.
const DeclContext * getRedeclContext() const
DeclContextLookupResult()
value_type operator->() const
Attr - This represents one attribute.
friend bool operator!=(decl_iterator x, decl_iterator y)
DeclContext(Decl::Kind K)
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 ...