14 #ifndef LLVM_CLANG_AST_DECLBASE_H 15 #define LLVM_CLANG_AST_DECLBASE_H 23 #include "llvm/ADT/ArrayRef.h" 24 #include "llvm/ADT/PointerIntPair.h" 25 #include "llvm/ADT/PointerUnion.h" 26 #include "llvm/ADT/iterator.h" 27 #include "llvm/ADT/iterator_range.h" 28 #include "llvm/Support/Casting.h" 29 #include "llvm/Support/Compiler.h" 30 #include "llvm/Support/PrettyStackTrace.h" 31 #include "llvm/Support/VersionTuple.h" 37 #include <type_traits> 43 class ASTMutationListener;
46 class ExternalSourceSymbolAttr;
51 class LinkageSpecDecl;
54 class ObjCCategoryDecl;
55 class ObjCCategoryImplDecl;
56 class ObjCContainerDecl;
58 class ObjCImplementationDecl;
59 class ObjCInterfaceDecl;
61 class ObjCProtocolDecl;
62 struct PrintingPolicy;
68 class TranslationUnitDecl;
69 class UsingDirectiveDecl;
91 #define DECL(DERIVED, BASE) DERIVED, 92 #define ABSTRACT_DECL(DECL) 93 #define DECL_RANGE(BASE, START, END) \ 94 first##BASE = START, last##BASE = END, 95 #define LAST_DECL_RANGE(BASE, START, END) \ 96 first##BASE = START, last##BASE = END 97 #include "clang/AST/DeclNodes.inc" 263 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
265 bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
266 bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
268 MultipleDC *getMultipleDC()
const {
269 return DeclCtx.get<MultipleDC*>();
280 unsigned DeclKind : 7;
283 unsigned InvalidDecl : 1;
286 unsigned HasAttrs : 1;
290 unsigned Implicit : 1;
300 unsigned Referenced : 1;
305 unsigned TopLevelDeclInObjCContainer : 1;
308 static bool StatisticsEnabled;
350 bool AccessDeclContextSanity()
const;
356 auto *D = cast<Decl>(DC);
357 auto MOK = D->getModuleOwnershipKind();
359 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
369 : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
370 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(
false), HasAttrs(
false),
375 if (StatisticsEnabled)
add(DK);
384 if (StatisticsEnabled)
add(DK);
429 return getSemanticDC();
430 return getMultipleDC()->SemanticDC;
459 assert(AccessDeclContextSanity());
463 assert(AccessDeclContextSanity());
501 template <
typename T>
503 if (!HasAttrs)
return;
506 Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end());
512 template <
typename T>
514 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
517 template <
typename T>
522 template <
typename T>
556 bool isUsed(
bool CheckUsedAttr =
true)
const;
583 return TopLevelDeclInObjCContainer;
587 TopLevelDeclInObjCContainer = V;
624 assert(
isFromASTFile() &&
"Only works on a deserialized declaration");
625 *((
unsigned*)
this - 2) =
ID;
648 VersionTuple EnclosingVersion = VersionTuple(),
649 StringRef *RealizedPlatform =
nullptr)
const;
701 return *((
const unsigned*)
this - 1);
709 return *((
const unsigned*)
this - 2);
714 Module *getOwningModuleSlow()
const;
726 return getOwningModuleSlow();
736 "owned local decl but no local module storage");
737 return reinterpret_cast<Module *
const *
>(
this)[-1];
742 "should not have a cached owning module");
743 reinterpret_cast<Module **
>(
this)[-1] = M;
780 return NextInContextAndBits.getInt();
788 "no storage available for owning module for this declaration");
789 NextInContextAndBits.setInt(MOK);
823 return getSemanticDC();
824 return getMultipleDC()->LexicalDC;
897 Decl *Current =
nullptr;
914 assert(Current &&
"Advancing while iterator has reached end");
917 assert(Next &&
"Should return next redeclaration or itself, never null!");
918 Current = (Next != Starter) ? Next :
nullptr;
929 return x.Current == y.Current;
933 return x.Current != y.Current;
1012 return (DeclKind >= Decl::firstFunction &&
1013 DeclKind <= Decl::lastFunction) ||
1014 DeclKind == FunctionTemplate;
1043 "namespace is not ordinary");
1069 "namespace includes neither ordinary nor tag");
1073 "namespace includes other than ordinary or tag");
1080 if (PerformFriendInjection ||
1088 if (PerformFriendInjection ||
1116 "visible non-member operators should be in ordinary namespace");
1124 void print(raw_ostream &Out,
unsigned Indentation = 0,
1125 bool PrintInstantiation =
false)
const;
1127 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1130 unsigned Indentation = 0);
1138 void dump(raw_ostream &Out,
bool Deserialize =
false)
const;
1141 int64_t
getID()
const;
1171 const Decl *TheDecl;
1174 const char *Message;
1179 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1181 void print(raw_ostream &OS)
const override;
1196 static NamedDecl *
const SingleElementDummyList;
1203 : Result(SingleElementDummyList), Single(Single) {}
1208 llvm::iterator_adaptor_base<
iterator, ResultTy::iterator,
1209 std::random_access_iterator_tag,
1213 value_type SingleElement;
1228 iterator
begin()
const {
return iterator(Result.begin(), Single); }
1229 iterator
end()
const {
return iterator(Result.end(), Single); }
1231 bool empty()
const {
return Result.empty(); }
1233 size_t size()
const {
return Single ? 1 : Result.size(); }
1241 Sliced.Single = Single;
1280 class DeclContextBitfields {
1283 uint64_t DeclKind : 7;
1288 mutable uint64_t ExternalLexicalStorage : 1;
1293 mutable uint64_t ExternalVisibleStorage : 1;
1299 mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1303 mutable uint64_t HasLazyLocalLexicalLookups : 1;
1307 mutable uint64_t HasLazyExternalLexicalLookups : 1;
1312 mutable uint64_t UseQualifiedLookup : 1;
1316 enum { NumDeclContextBits = 13 };
1321 class TagDeclBitfields {
1324 uint64_t : NumDeclContextBits;
1327 uint64_t TagDeclKind : 3;
1332 uint64_t IsCompleteDefinition : 1;
1335 uint64_t IsBeingDefined : 1;
1339 uint64_t IsEmbeddedInDeclarator : 1;
1342 uint64_t IsFreeStanding : 1;
1348 uint64_t MayHaveOutOfDateDef : 1;
1352 uint64_t IsCompleteDefinitionRequired : 1;
1356 enum { NumTagDeclBits = 9 };
1361 class EnumDeclBitfields {
1364 uint64_t : NumDeclContextBits;
1366 uint64_t : NumTagDeclBits;
1370 uint64_t NumPositiveBits : 8;
1374 uint64_t NumNegativeBits : 8;
1378 uint64_t IsScoped : 1;
1384 uint64_t IsScopedUsingClassTag : 1;
1388 uint64_t IsFixed : 1;
1391 uint64_t HasODRHash : 1;
1395 enum { NumEnumDeclBits = 20 };
1400 class RecordDeclBitfields {
1403 uint64_t : NumDeclContextBits;
1405 uint64_t : NumTagDeclBits;
1410 uint64_t HasFlexibleArrayMember : 1;
1413 uint64_t AnonymousStructOrUnion : 1;
1417 uint64_t HasObjectMember : 1;
1421 uint64_t HasVolatileMember : 1;
1427 mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1430 uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1431 uint64_t NonTrivialToPrimitiveCopy : 1;
1432 uint64_t NonTrivialToPrimitiveDestroy : 1;
1435 uint64_t ParamDestroyedInCallee : 1;
1438 uint64_t ArgPassingRestrictions : 2;
1442 enum { NumRecordDeclBits = 11 };
1447 class OMPDeclareReductionDeclBitfields {
1450 uint64_t : NumDeclContextBits;
1454 uint64_t InitializerKind : 2;
1458 enum { NumOMPDeclareReductionDeclBits = 2 };
1464 class FunctionDeclBitfields {
1469 uint64_t : NumDeclContextBits;
1471 uint64_t SClass : 3;
1472 uint64_t IsInline : 1;
1473 uint64_t IsInlineSpecified : 1;
1477 uint64_t IsExplicitSpecified : 1;
1479 uint64_t IsVirtualAsWritten : 1;
1480 uint64_t IsPure : 1;
1481 uint64_t HasInheritedPrototype : 1;
1482 uint64_t HasWrittenPrototype : 1;
1483 uint64_t IsDeleted : 1;
1485 uint64_t IsTrivial : 1;
1490 uint64_t IsTrivialForCall : 1;
1493 uint64_t IsDefaulted : 1;
1495 uint64_t IsExplicitlyDefaulted : 1;
1496 uint64_t HasImplicitReturnZero : 1;
1497 uint64_t IsLateTemplateParsed : 1;
1498 uint64_t IsConstexpr : 1;
1499 uint64_t InstantiationIsPending : 1;
1502 uint64_t UsesSEHTry : 1;
1506 uint64_t HasSkippedBody : 1;
1510 uint64_t WillHaveBody : 1;
1514 uint64_t IsMultiVersion : 1;
1519 uint64_t IsCopyDeductionCandidate : 1;
1522 uint64_t HasODRHash : 1;
1526 enum { NumFunctionDeclBits = 25 };
1531 class CXXConstructorDeclBitfields {
1534 uint64_t : NumDeclContextBits;
1536 uint64_t : NumFunctionDeclBits;
1543 uint64_t NumCtorInitializers : 25;
1544 uint64_t IsInheritingConstructor : 1;
1548 enum { NumCXXConstructorDeclBits = 26 };
1553 class ObjCMethodDeclBitfields {
1557 uint64_t : NumDeclContextBits;
1565 uint64_t IsInstance : 1;
1566 uint64_t IsVariadic : 1;
1569 uint64_t IsPropertyAccessor : 1;
1572 uint64_t IsDefined : 1;
1575 uint64_t IsRedeclaration : 1;
1578 mutable uint64_t HasRedeclaration : 1;
1581 uint64_t DeclImplementation : 2;
1584 uint64_t objcDeclQualifier : 7;
1587 uint64_t RelatedResultType : 1;
1591 uint64_t SelLocsKind : 2;
1600 uint64_t IsOverriding : 1;
1603 uint64_t HasSkippedBody : 1;
1607 enum { NumObjCMethodDeclBits = 24 };
1612 class ObjCContainerDeclBitfields {
1615 uint32_t : NumDeclContextBits;
1625 enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1630 class LinkageSpecDeclBitfields {
1633 uint64_t : NumDeclContextBits;
1637 uint64_t Language : 3;
1643 uint64_t HasBraces : 1;
1647 enum { NumLinkageSpecDeclBits = 4 };
1652 class BlockDeclBitfields {
1655 uint64_t : NumDeclContextBits;
1657 uint64_t IsVariadic : 1;
1658 uint64_t CapturesCXXThis : 1;
1659 uint64_t BlockMissingReturnType : 1;
1660 uint64_t IsConversionFromLambda : 1;
1664 uint64_t DoesNotEscape : 1;
1668 enum { NumBlockDeclBits = 5 };
1700 static_assert(
sizeof(DeclContextBitfields) <= 8,
1701 "DeclContextBitfields is larger than 8 bytes!");
1702 static_assert(
sizeof(TagDeclBitfields) <= 8,
1703 "TagDeclBitfields is larger than 8 bytes!");
1704 static_assert(
sizeof(EnumDeclBitfields) <= 8,
1705 "EnumDeclBitfields is larger than 8 bytes!");
1706 static_assert(
sizeof(RecordDeclBitfields) <= 8,
1707 "RecordDeclBitfields is larger than 8 bytes!");
1708 static_assert(
sizeof(OMPDeclareReductionDeclBitfields) <= 8,
1709 "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
1710 static_assert(
sizeof(FunctionDeclBitfields) <= 8,
1711 "FunctionDeclBitfields is larger than 8 bytes!");
1712 static_assert(
sizeof(CXXConstructorDeclBitfields) <= 8,
1713 "CXXConstructorDeclBitfields is larger than 8 bytes!");
1714 static_assert(
sizeof(ObjCMethodDeclBitfields) <= 8,
1715 "ObjCMethodDeclBitfields is larger than 8 bytes!");
1716 static_assert(
sizeof(ObjCContainerDeclBitfields) <= 8,
1717 "ObjCContainerDeclBitfields is larger than 8 bytes!");
1718 static_assert(
sizeof(LinkageSpecDeclBitfields) <= 8,
1719 "LinkageSpecDeclBitfields is larger than 8 bytes!");
1720 static_assert(
sizeof(BlockDeclBitfields) <= 8,
1721 "BlockDeclBitfields is larger than 8 bytes!");
1737 static std::pair<Decl *, Decl *>
1746 return static_cast<Decl::Kind>(DeclContextBits.DeclKind);
1756 return const_cast<DeclContext*
>(
this)->getParent();
1772 return const_cast<DeclContext*
>(
this)->getLexicalParent();
1778 return const_cast<DeclContext*
>(
this)->getLookupParent();
1785 bool isClosure()
const {
return getDeclKind() == Decl::Block; }
1788 switch (getDeclKind()) {
1789 case Decl::ObjCCategory:
1790 case Decl::ObjCCategoryImpl:
1791 case Decl::ObjCImplementation:
1792 case Decl::ObjCInterface:
1793 case Decl::ObjCProtocol:
1801 switch (getDeclKind()) {
1803 case Decl::Captured:
1804 case Decl::ObjCMethod:
1807 return getDeclKind() >= Decl::firstFunction &&
1808 getDeclKind() <= Decl::lastFunction;
1815 getDeclKind() != Decl::Export;
1819 return getDeclKind() == Decl::TranslationUnit ||
1820 getDeclKind() == Decl::Namespace;
1824 return getDeclKind() == Decl::TranslationUnit;
1828 return getDeclKind() >= Decl::firstRecord &&
1829 getDeclKind() <= Decl::lastRecord;
1836 bool isInlineNamespace()
const;
1840 bool isDependentContext()
const;
1857 bool isTransparentContext()
const;
1861 bool isExternCContext()
const;
1868 bool isExternCXXContext()
const;
1883 Decl *getNonClosureAncestor();
1885 return const_cast<DeclContext*
>(
this)->getNonClosureAncestor();
1896 return const_cast<DeclContext*
>(
this)->getPrimaryContext();
1904 return const_cast<DeclContext *
>(
this)->getRedeclContext();
1910 return const_cast<DeclContext *
>(
this)->getEnclosingNamespaceContext();
1916 return const_cast<DeclContext *
>(
this)->getOuterLexicalRecordContext();
1925 bool InEnclosingNamespaceSetOf(
const DeclContext *NS)
const;
1956 Decl *Current =
nullptr;
1985 return x.Current == y.Current;
1989 return x.Current != y.Current;
2000 bool decls_empty()
const;
2006 return decl_range(noload_decls_begin(), noload_decls_end());
2016 template<
typename SpecificDecl>
2026 void SkipToNextDecl() {
2027 while (*Current && !isa<SpecificDecl>(*Current))
2038 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2074 return x.Current == y.Current;
2079 return x.Current != y.Current;
2092 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
2102 void SkipToNextDecl() {
2104 (!isa<SpecificDecl>(*Current) ||
2105 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2116 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2150 return x.Current == y.Current;
2155 return x.Current != y.Current;
2171 void addDecl(
Decl *D);
2181 void addDeclInternal(
Decl *D);
2189 void addHiddenDecl(
Decl *D);
2192 void removeDecl(
Decl *D);
2195 bool containsDecl(
Decl *D)
const;
2199 bool containsDeclAndLoad(
Decl *D)
const;
2242 void makeDeclVisibleInContext(
NamedDecl *D);
2253 lookups_range noload_lookups(
bool PreserveInternalState)
const;
2269 std::random_access_iterator_tag,
2285 using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2298 assert(
this == getPrimaryContext() &&
2299 "should only be called on primary context");
2300 DeclContextBits.HasLazyExternalLexicalLookups =
true;
2313 return DeclContextBits.ExternalLexicalStorage;
2319 DeclContextBits.ExternalLexicalStorage = ES;
2325 return DeclContextBits.ExternalVisibleStorage;
2331 DeclContextBits.ExternalVisibleStorage = ES;
2332 if (ES && LookupPtr)
2333 DeclContextBits.NeedToReconcileExternalVisibleStorage =
true;
2344 bool old_value = DeclContextBits.UseQualifiedLookup;
2345 DeclContextBits.UseQualifiedLookup = use;
2350 return DeclContextBits.UseQualifiedLookup;
2356 void dumpDeclContext()
const;
2357 void dumpLookups()
const;
2358 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false,
2359 bool Deserialize =
false)
const;
2366 bool hasNeedToReconcileExternalVisibleStorage()
const {
2367 return DeclContextBits.NeedToReconcileExternalVisibleStorage;
2374 void setNeedToReconcileExternalVisibleStorage(
bool Need =
true)
const {
2375 DeclContextBits.NeedToReconcileExternalVisibleStorage = Need;
2380 bool hasLazyLocalLexicalLookups()
const {
2381 return DeclContextBits.HasLazyLocalLexicalLookups;
2386 void setHasLazyLocalLexicalLookups(
bool HasLLLL =
true)
const {
2387 DeclContextBits.HasLazyLocalLexicalLookups = HasLLLL;
2392 bool hasLazyExternalLexicalLookups()
const {
2393 return DeclContextBits.HasLazyExternalLexicalLookups;
2398 void setHasLazyExternalLexicalLookups(
bool HasLELL =
true)
const {
2399 DeclContextBits.HasLazyExternalLexicalLookups = HasLELL;
2402 void reconcileExternalVisibleStorage()
const;
2403 bool LoadLexicalDeclsFromExternalStorage()
const;
2411 void makeDeclVisibleInContextInternal(
NamedDecl *D);
2415 void loadLazyLocalLexicalLookups();
2416 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
2417 void makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
2418 bool Rediscoverable);
2419 void makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal);
2423 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
2424 getKind() == TemplateTemplateParm;
2428 template <
class ToTy,
2429 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2441 template <
class ToTy>
2444 return static_cast<const ToTy*
>(Val);
2448 return static_cast<ToTy*
>(Val);
2457 template <
typename To>
2459 static bool doit(const ::clang::DeclContext &Val) {
2460 return To::classofKind(Val.getDeclKind());
2465 template<
class ToTy>
2466 struct cast_convert_val<ToTy,
2468 static const ToTy &
doit(const ::clang::DeclContext &Val) {
2473 template<
class ToTy>
2480 template<
class ToTy>
2481 struct cast_convert_val<ToTy,
2483 static const ToTy *
doit(const ::clang::DeclContext *Val) {
2484 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2488 template<
class ToTy>
2491 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2496 template<
class FromTy>
2498 static ::clang::DeclContext &
doit(
const FromTy &Val) {
2499 return *FromTy::castToDeclContext(&Val);
2503 template<
class FromTy>
2505 static ::clang::DeclContext *
doit(
const FromTy *Val) {
2506 return FromTy::castToDeclContext(Val);
2510 template<
class FromTy>
2512 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
2513 return *FromTy::castToDeclContext(&Val);
2517 template<
class FromTy>
2519 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
2520 return FromTy::castToDeclContext(Val);
2526 #endif // LLVM_CLANG_AST_DECLBASE_H
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.
bool shouldUseQualifiedLookup() const
specific_decl_iterator & operator++()
void setImplicit(bool I=true)
Represents a function declaration or definition.
redecl_iterator operator++(int)
const Decl * getCanonicalDecl() const
decl_iterator noload_decls_begin() const
llvm::iterator_range< redecl_iterator > redecl_range
static DeclContext * castToDeclContext(const Decl *)
Module * getOwningModule() const
Get the module that owns this declaration (for visibility purposes).
const char * getDeclKindName() const
llvm::PointerIntPair< Decl *, 2, ModuleOwnershipKind > NextInContextAndBits
The next declaration within the same lexical DeclContext.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static Decl * castFromDeclContext(const DeclContext *)
value_type operator*() const
This declaration has an owning module, but is only visible to lookups that occur within that module...
bool isLookupContext() const
Test whether the context supports looking up names.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
void setAttrs(const AttrVec &Attrs)
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Module * getOwningModuleForLinkage(bool IgnoreLinkage=false) const
Get the module that owns this declaration for linkage purposes.
attr_iterator attr_begin() const
specific_attr_iterator< T > specific_attr_begin() const
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
unsigned CacheValidAndLinkage
If 0, we have not computed the linkage of this declaration.
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)
SourceLocation getBeginLoc() const LLVM_READONLY
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.
static ToTy & doit(::clang::DeclContext &Val)
static bool doit(const ::clang::DeclContext &Val)
bool isObjCContainer() const
SourceLocation getEndLoc() const LLVM_READONLY
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)
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
static ToTy * doit(DeclContext *Val)
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Iterates over a filtered subrange of declarations stored in a DeclContext.
unsigned getIdentifierNamespace() const
Represents a C++ constructor within a class.
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
unsigned Access
Access - Used by C++ decls for the access specifier.
redecl_iterator & operator++()
reference operator*() const
ModuleOwnershipKind
The kind of ownership a declaration has, for visibility purposes.
bool hasOwningModule() const
Is this declaration owned by some module?
ASTMutationListener * getASTMutationListener() const
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool hasLocalOwningModuleStorage() const
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
friend bool operator!=(const specific_decl_iterator &x, const specific_decl_iterator &y)
ExternalSourceSymbolAttr * getExternalSourceSymbolAttr() const
Looks on this and related declarations for an applicable external source symbol attribute.
Describes how types, statements, expressions, and declarations should be printed. ...
bool isParameterPack() const
Whether this declaration is a parameter pack.
static const ToTy * doit(const ::clang::DeclContext *Val)
BlockDeclBitfields BlockDeclBits
Module * getLocalOwningModule() const
Get the local owning module, if known.
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
Decl(Kind DK, EmptyShell Empty)
value_type operator->() const
Types, declared with 'struct foo', typedefs, etc.
bool isLexicallyWithinFunctionOrMethod() const
Returns true if this declaration lexically is inside a function.
Represents a struct/union/class.
CXXConstructorDeclBitfields CXXConstructorDeclBits
Provides common interface for the Decls that can be redeclared.
One of these records is kept for each identifier that is lexed.
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context...
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
bool isInAnonymousNamespace() const
LinkageSpecDeclBitfields LinkageSpecDeclBits
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.
attr_iterator attr_end() const
specific_decl_iterator operator++(int)
llvm::iterator_range< decl_iterator > decl_range
std::forward_iterator_tag iterator_category
This declaration is a friend function.
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
void setOwningModuleID(unsigned ID)
Set the owning module ID.
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
bool isInIdentifierNamespace(unsigned NS) const
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
unsigned FromASTFile
Whether this declaration was loaded from an AST file.
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
specific_attr_iterator< T > specific_attr_end() const
Describes a module or submodule.
value_type operator*() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
friend bool operator!=(const filtered_decl_iterator &x, const filtered_decl_iterator &y)
iterator(pointer Pos, value_type Single=nullptr)
ObjCContainerDecl - Represents a container for method declarations.
bool isReferenced() const
Whether any declaration of this entity was referenced.
Namespaces, declared with 'namespace foo {}'.
bool hasTagIdentifierNamespace() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
const DeclContext * getLexicalDeclContext() const
ModuleOwnershipKind getModuleOwnershipKind() const
Get the kind of module ownership for this declaration.
std::forward_iterator_tag iterator_category
filtered_decl_iterator(DeclContext::decl_iterator C)
filtered_decl_iterator - Construct a new iterator over a subset of the declarations the range [C...
static bool isStdNamespace(const DeclContext *DC)
A friend of a previously-undeclared entity.
std::forward_iterator_tag iterator_category
DeclContextLookupResult slice(size_t N) 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.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
std::ptrdiff_t difference_type
Labels, declared with 'x:' and referenced with 'goto x'.
void setLocalOwningModule(Module *M)
Represents a linkage specification.
::clang::DeclContext * doit(const FromTy *Val)
bool isExported() const
Whether this declaration is exported (by virtue of being lexically within an ExportDecl or by being a...
virtual Decl * getMostRecentDeclImpl()
Implementation of getMostRecentDecl(), to be overridden by any subclass that has a redeclaration chai...
void setCachedLinkage(Linkage L) const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
AvailabilityResult
Captures the result of checking the availability of a declaration.
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...
DeclContextBitfields DeclContextBits
A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
This declaration is a C++ operator declared in a non-class context.
static ToTy * doit(::clang::DeclContext *Val)
llvm::iterator_range< udir_iterator > udir_range
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
std::ptrdiff_t difference_type
const DeclContext * getLookupParent() const
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
This declaration is a friend class.
const Decl * getNonClosureContext() const
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
const Attr * getDefiningAttr() const
Return this declaration's defining attribute if it has one.
llvm::iterator_range< all_lookups_iterator > lookups_range
static bool classofKind(Kind K)
static unsigned getIdentifierNamespaceForKind(Kind DK)
StoredDeclsMap * getLookupPtr() const
Retrieve the internal representation of the lookup structure.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
This declaration is an OpenMP user defined reduction construction.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
DeclContextLookupResult(ArrayRef< NamedDecl *> Result)
const Decl * getNextDeclInContext() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
DeclContext * getDeclContext()
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
redecl_iterator redecls_end() const
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack...
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined...
llvm::iterator_range< attr_iterator > attr_range
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
const DeclContext * getParent() const
bool isFunctionOrMethod() const
reference operator[](size_t N) const
unsigned getMaxAlignment() const
getMaxAlignment - return the maximum alignment specified by attributes on this decl, 0 if there are none.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
SourceLocation getEnd() const
void setLocation(SourceLocation L)
const FunctionDecl * getAsFunction() const
Represents a C++ deduction guide declaration.
The result type of a method or function.
unsigned IdentifierNamespace
IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
FunctionDeclBitfields FunctionDeclBits
const DeclContext * getDeclContext() const
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
reference operator*() const
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
static bool isTagIdentifierNamespace(unsigned NS)
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context...
virtual bool hasBody() const
Returns true if this Decl represents a declaration for a body of code, such as a function or method d...
filtered_decl_iterator & operator++()
static const ToTy & doit(const ::clang::DeclContext &Val)
static const ::clang::DeclContext * doit(const FromTy *Val)
iterator::reference reference
Abstract interface for external sources of AST nodes.
bool isTemplateDecl() const
returns true if this declaration is a template
Decl::Kind getDeclKind() const
This declaration has an owning module, but is globally visible (typically because its owning module i...
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.
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
Encodes a location in the source.
SpecificDecl * value_type
void setTopLevelDeclInObjCContainer(bool V=true)
Members, declared with object declarations within tag definitions.
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.
This represents '#pragma omp declare reduction ...' directive.
value_type operator->() const
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
void setReferenced(bool R=true)
static bool classof(const DeclContext *D)
std::forward_iterator_tag iterator_category
udir_iterator(lookup_iterator I)
bool hasCachedLinkage() const
A friend of a previously-declared entity.
DeclContextLookupResult(NamedDecl *Single)
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
::clang::DeclContext & doit(const FromTy &Val)
Linkage getCachedLinkage() const
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
friend bool operator==(redecl_iterator x, redecl_iterator y)
llvm::iterator_range< DeclContext::ddiag_iterator > ddiag_range
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
value_type operator->() const
virtual Decl * getNextRedeclarationImpl()
Returns the next redeclaration or itself if this is the only decl.
static ToTy * doit(DeclContext *Val)
decl_iterator noload_decls_end() const
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
Defines various enumerations that describe declaration and type specifiers.
decl_iterator - Iterates through the declarations stored within this context.
bool isThisDeclarationReferenced() const
Whether this declaration was referenced.
redecl_iterator redecls_begin() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
static const ToTy * doit(const DeclContext *Val)
Dataflow Directional Tag Classes.
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
The base class of all kinds of template declarations (e.g., class, function, etc.).
bool isTopLevelDeclInObjCContainer() const
Whether this declaration is a top-level declaration (function, global variable, etc.) that is lexically inside an objc container definition.
const Decl * getMostRecentDecl() const
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
friend bool operator!=(redecl_iterator x, redecl_iterator y)
Reads an AST files chain containing the contents of a translation unit.
AttrVec::const_iterator attr_iterator
AccessSpecifier getAccess() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
The name of a declaration.
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks, lambdas, etc.
decl_iterator operator++(int)
const Decl * getNonClosureAncestor() const
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
EnumDeclBitfields EnumDeclBits
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
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).
This declaration is not owned by a module.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
A dependently-generated diagnostic.
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
const RecordDecl * getOuterLexicalRecordContext() const
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
static bool classof(const OMPClause *T)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
filtered_decl_iterator operator++(int)
const DeclContext * getLexicalParent() const
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
An iterator over the dependent diagnostics in a dependent context.
iterator::pointer pointer
SpecificDecl * value_type
ObjCMethodDeclBitfields ObjCMethodDeclBits
reference operator*() const
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static const ::clang::DeclContext & doit(const FromTy &Val)
Defines the clang::SourceLocation class and associated facilities.
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
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)
bool setUseQualifiedLookup(bool use=true) const
const DeclContext * getEnclosingNamespaceContext() const
value_type operator->() const
RecordDeclBitfields RecordDeclBits
const DeclContext * getPrimaryContext() 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...
Writes an AST file containing the contents of a translation unit.
static const ToTy * doit(const DeclContext *Val)
friend class CXXClassMemberWrapper
ASTContext & getParentASTContext() const
Kind
Lists the kind of concrete classes of Decl.
The top declaration context.
This declaration is a function-local extern declaration of a variable or function.
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)
ObjCContainerDeclBitfields ObjCContainerDeclBits
AccessSpecifier getAccessUnsafe() const
Retrieve the access specifier for this declaration, even though it may not yet have been properly set...
A trivial tuple used to represent a source range.
bool isModulePrivate() const
Whether this declaration was marked as being private to the module in which it was defined...
void setLexicalDeclContext(DeclContext *DC)
OMPDeclareReductionDeclBitfields OMPDeclareReductionDeclBits
This represents a decl that may have a name.
bool isTranslationUnit() const
void setAccess(AccessSpecifier AS)
const TranslationUnitDecl * getTranslationUnitDecl() const
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration...
Represents C++ using-directive.
bool hasDefiningAttr() const
Return true if this declaration has an attribute which acts as definition of the entity, such as 'alias' or 'ifunc'.
bool isInStdNamespace() const
SourceLocation getBegin() const
TranslationUnitDecl * getTranslationUnitDecl()
bool isTemplated() const
Determine whether this declaration is a templated entity (whether it is.
This class handles loading and caching of source files into memory.
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
Attr - This represents one attribute.
SourceLocation getLocation() const
TagDeclBitfields TagDeclBits
friend bool operator!=(decl_iterator x, decl_iterator y)
const DeclContext * getRedeclContext() const
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
decl_iterator decls_end() const
This declaration is a using declaration.
std::iterator_traits< DeclContext::decl_iterator >::difference_type difference_type
DeclContext * getParentFunctionOrMethod()
PrettyStackTraceDecl - If a crash occurs, indicate that it happened when doing something to a specifi...