13 #ifndef LLVM_CLANG_AST_DECLBASE_H 14 #define LLVM_CLANG_AST_DECLBASE_H 23 #include "llvm/ADT/ArrayRef.h" 24 #include "llvm/ADT/PointerIntPair.h" 25 #include "llvm/ADT/PointerUnion.h" 26 #include "llvm/ADT/iterator.h" 27 #include "llvm/ADT/iterator_range.h" 28 #include "llvm/Support/Casting.h" 29 #include "llvm/Support/Compiler.h" 30 #include "llvm/Support/PrettyStackTrace.h" 31 #include "llvm/Support/VersionTuple.h" 37 #include <type_traits> 43 class ASTMutationListener;
47 class ExternalSourceSymbolAttr;
52 class LinkageSpecDecl;
55 class ObjCCategoryDecl;
56 class ObjCCategoryImplDecl;
57 class ObjCContainerDecl;
59 class ObjCImplementationDecl;
60 class ObjCInterfaceDecl;
62 class ObjCProtocolDecl;
63 struct PrintingPolicy;
69 class TranslationUnitDecl;
70 class UsingDirectiveDecl;
92 #define DECL(DERIVED, BASE) DERIVED, 93 #define ABSTRACT_DECL(DECL) 94 #define DECL_RANGE(BASE, START, END) \ 95 first##BASE = START, last##BASE = END, 96 #define LAST_DECL_RANGE(BASE, START, END) \ 97 first##BASE = START, last##BASE = END 98 #include "clang/AST/DeclNodes.inc" 267 llvm::PointerUnion<DeclContext*, MultipleDC*> DeclCtx;
269 bool isInSemaDC()
const {
return DeclCtx.is<
DeclContext*>(); }
270 bool isOutOfSemaDC()
const {
return DeclCtx.is<MultipleDC*>(); }
272 MultipleDC *getMultipleDC()
const {
273 return DeclCtx.get<MultipleDC*>();
284 unsigned DeclKind : 7;
287 unsigned InvalidDecl : 1;
290 unsigned HasAttrs : 1;
294 unsigned Implicit : 1;
304 unsigned Referenced : 1;
309 unsigned TopLevelDeclInObjCContainer : 1;
312 static bool StatisticsEnabled;
354 bool AccessDeclContextSanity()
const;
360 auto *D = cast<Decl>(DC);
361 auto MOK = D->getModuleOwnershipKind();
363 (!D->isFromASTFile() || D->hasLocalOwningModuleStorage()))
380 : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
381 DeclCtx(DC), Loc(L), DeclKind(DK), InvalidDecl(
false), HasAttrs(
false),
386 if (StatisticsEnabled)
add(DK);
395 if (StatisticsEnabled)
add(DK);
440 return getSemanticDC();
441 return getMultipleDC()->SemanticDC;
470 assert(AccessDeclContextSanity());
474 assert(AccessDeclContextSanity());
512 template <
typename T>
514 if (!HasAttrs)
return;
517 Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end());
523 template <
typename T>
525 return llvm::make_range(specific_attr_begin<T>(), specific_attr_end<T>());
528 template <
typename T>
533 template <
typename T>
567 bool isUsed(
bool CheckUsedAttr =
true)
const;
594 return TopLevelDeclInObjCContainer;
598 TopLevelDeclInObjCContainer =
V;
631 assert(
isFromASTFile() &&
"Only works on a deserialized declaration");
632 *((
unsigned*)
this - 2) =
ID;
655 VersionTuple EnclosingVersion = VersionTuple(),
656 StringRef *RealizedPlatform =
nullptr)
const;
708 return *((
const unsigned*)
this - 1);
716 return *((
const unsigned*)
this - 2);
721 Module *getOwningModuleSlow()
const;
733 return getOwningModuleSlow();
743 "owned local decl but no local module storage");
744 return reinterpret_cast<Module *
const *
>(
this)[-1];
749 "should not have a cached owning module");
750 reinterpret_cast<Module **
>(
this)[-1] = M;
787 return NextInContextAndBits.getInt();
795 "no storage available for owning module for this declaration");
796 NextInContextAndBits.setInt(MOK);
830 return getSemanticDC();
831 return getMultipleDC()->LexicalDC;
904 Decl *Current =
nullptr;
921 assert(Current &&
"Advancing while iterator has reached end");
924 assert(Next &&
"Should return next redeclaration or itself, never null!");
925 Current = (Next != Starter) ? Next :
nullptr;
936 return x.Current == y.Current;
940 return x.Current != y.Current;
1019 return (DeclKind >= Decl::firstFunction &&
1020 DeclKind <= Decl::lastFunction) ||
1021 DeclKind == FunctionTemplate;
1050 "namespace is not ordinary");
1076 "namespace includes neither ordinary nor tag");
1080 "namespace includes other than ordinary or tag");
1087 if (PerformFriendInjection ||
1095 if (PerformFriendInjection ||
1123 "visible non-member operators should be in ordinary namespace");
1131 void print(raw_ostream &Out,
unsigned Indentation = 0,
1132 bool PrintInstantiation =
false)
const;
1134 unsigned Indentation = 0,
bool PrintInstantiation =
false)
const;
1137 unsigned Indentation = 0);
1145 void dump(raw_ostream &Out,
bool Deserialize =
false,
1149 int64_t
getID()
const;
1179 const Decl *TheDecl;
1182 const char *Message;
1187 : TheDecl(theDecl), Loc(L), SM(sm), Message(Msg) {}
1189 void print(raw_ostream &OS)
const override;
1204 static NamedDecl *
const SingleElementDummyList;
1211 : Result(SingleElementDummyList), Single(Single) {}
1216 llvm::iterator_adaptor_base<
iterator, ResultTy::iterator,
1217 std::random_access_iterator_tag,
1221 value_type SingleElement;
1237 iterator
end()
const {
return iterator(Result.end(),
Single); }
1239 bool empty()
const {
return Result.empty(); }
1241 size_t size()
const {
return Single ? 1 : Result.size(); }
1289 class DeclContextBitfields {
1292 uint64_t DeclKind : 7;
1297 mutable uint64_t ExternalLexicalStorage : 1;
1302 mutable uint64_t ExternalVisibleStorage : 1;
1308 mutable uint64_t NeedToReconcileExternalVisibleStorage : 1;
1312 mutable uint64_t HasLazyLocalLexicalLookups : 1;
1316 mutable uint64_t HasLazyExternalLexicalLookups : 1;
1321 mutable uint64_t UseQualifiedLookup : 1;
1325 enum { NumDeclContextBits = 13 };
1330 class TagDeclBitfields {
1333 uint64_t : NumDeclContextBits;
1336 uint64_t TagDeclKind : 3;
1341 uint64_t IsCompleteDefinition : 1;
1344 uint64_t IsBeingDefined : 1;
1348 uint64_t IsEmbeddedInDeclarator : 1;
1351 uint64_t IsFreeStanding : 1;
1357 uint64_t MayHaveOutOfDateDef : 1;
1361 uint64_t IsCompleteDefinitionRequired : 1;
1365 enum { NumTagDeclBits = 9 };
1370 class EnumDeclBitfields {
1373 uint64_t : NumDeclContextBits;
1375 uint64_t : NumTagDeclBits;
1379 uint64_t NumPositiveBits : 8;
1383 uint64_t NumNegativeBits : 8;
1387 uint64_t IsScoped : 1;
1393 uint64_t IsScopedUsingClassTag : 1;
1397 uint64_t IsFixed : 1;
1400 uint64_t HasODRHash : 1;
1404 enum { NumEnumDeclBits = 20 };
1409 class RecordDeclBitfields {
1412 uint64_t : NumDeclContextBits;
1414 uint64_t : NumTagDeclBits;
1419 uint64_t HasFlexibleArrayMember : 1;
1422 uint64_t AnonymousStructOrUnion : 1;
1426 uint64_t HasObjectMember : 1;
1430 uint64_t HasVolatileMember : 1;
1436 mutable uint64_t LoadedFieldsFromExternalStorage : 1;
1439 uint64_t NonTrivialToPrimitiveDefaultInitialize : 1;
1440 uint64_t NonTrivialToPrimitiveCopy : 1;
1441 uint64_t NonTrivialToPrimitiveDestroy : 1;
1446 uint64_t HasNonTrivialToPrimitiveDefaultInitializeCUnion : 1;
1447 uint64_t HasNonTrivialToPrimitiveDestructCUnion : 1;
1448 uint64_t HasNonTrivialToPrimitiveCopyCUnion : 1;
1451 uint64_t ParamDestroyedInCallee : 1;
1454 uint64_t ArgPassingRestrictions : 2;
1458 enum { NumRecordDeclBits = 14 };
1463 class OMPDeclareReductionDeclBitfields {
1466 uint64_t : NumDeclContextBits;
1470 uint64_t InitializerKind : 2;
1474 enum { NumOMPDeclareReductionDeclBits = 2 };
1480 class FunctionDeclBitfields {
1485 uint64_t : NumDeclContextBits;
1487 uint64_t SClass : 3;
1488 uint64_t IsInline : 1;
1489 uint64_t IsInlineSpecified : 1;
1491 uint64_t IsVirtualAsWritten : 1;
1492 uint64_t IsPure : 1;
1493 uint64_t HasInheritedPrototype : 1;
1494 uint64_t HasWrittenPrototype : 1;
1495 uint64_t IsDeleted : 1;
1497 uint64_t IsTrivial : 1;
1502 uint64_t IsTrivialForCall : 1;
1504 uint64_t IsDefaulted : 1;
1505 uint64_t IsExplicitlyDefaulted : 1;
1506 uint64_t HasDefaultedFunctionInfo : 1;
1507 uint64_t HasImplicitReturnZero : 1;
1508 uint64_t IsLateTemplateParsed : 1;
1511 uint64_t ConstexprKind : 2;
1512 uint64_t InstantiationIsPending : 1;
1515 uint64_t UsesSEHTry : 1;
1519 uint64_t HasSkippedBody : 1;
1523 uint64_t WillHaveBody : 1;
1527 uint64_t IsMultiVersion : 1;
1532 uint64_t IsCopyDeductionCandidate : 1;
1535 uint64_t HasODRHash : 1;
1538 uint64_t UsesFPIntrin : 1;
1542 enum { NumFunctionDeclBits = 27 };
1547 class CXXConstructorDeclBitfields {
1550 uint64_t : NumDeclContextBits;
1552 uint64_t : NumFunctionDeclBits;
1559 uint64_t NumCtorInitializers : 21;
1560 uint64_t IsInheritingConstructor : 1;
1563 uint64_t HasTrailingExplicitSpecifier : 1;
1566 uint64_t IsSimpleExplicit : 1;
1571 NumCXXConstructorDeclBits = 64 - NumDeclContextBits - NumFunctionDeclBits
1577 class ObjCMethodDeclBitfields {
1581 uint64_t : NumDeclContextBits;
1589 uint64_t IsInstance : 1;
1590 uint64_t IsVariadic : 1;
1593 uint64_t IsPropertyAccessor : 1;
1596 uint64_t IsSynthesizedAccessorStub : 1;
1599 uint64_t IsDefined : 1;
1602 uint64_t IsRedeclaration : 1;
1605 mutable uint64_t HasRedeclaration : 1;
1608 uint64_t DeclImplementation : 2;
1611 uint64_t objcDeclQualifier : 7;
1614 uint64_t RelatedResultType : 1;
1618 uint64_t SelLocsKind : 2;
1627 uint64_t IsOverriding : 1;
1630 uint64_t HasSkippedBody : 1;
1634 enum { NumObjCMethodDeclBits = 24 };
1639 class ObjCContainerDeclBitfields {
1642 uint32_t : NumDeclContextBits;
1652 enum { NumObjCContainerDeclBits = 64 - NumDeclContextBits };
1657 class LinkageSpecDeclBitfields {
1660 uint64_t : NumDeclContextBits;
1670 uint64_t HasBraces : 1;
1674 enum { NumLinkageSpecDeclBits = 4 };
1679 class BlockDeclBitfields {
1682 uint64_t : NumDeclContextBits;
1684 uint64_t IsVariadic : 1;
1685 uint64_t CapturesCXXThis : 1;
1686 uint64_t BlockMissingReturnType : 1;
1687 uint64_t IsConversionFromLambda : 1;
1691 uint64_t DoesNotEscape : 1;
1696 uint64_t CanAvoidCopyToHeap : 1;
1700 enum { NumBlockDeclBits = 5 };
1732 static_assert(
sizeof(DeclContextBitfields) <= 8,
1733 "DeclContextBitfields is larger than 8 bytes!");
1734 static_assert(
sizeof(TagDeclBitfields) <= 8,
1735 "TagDeclBitfields is larger than 8 bytes!");
1736 static_assert(
sizeof(EnumDeclBitfields) <= 8,
1737 "EnumDeclBitfields is larger than 8 bytes!");
1738 static_assert(
sizeof(RecordDeclBitfields) <= 8,
1739 "RecordDeclBitfields is larger than 8 bytes!");
1740 static_assert(
sizeof(OMPDeclareReductionDeclBitfields) <= 8,
1741 "OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
1742 static_assert(
sizeof(FunctionDeclBitfields) <= 8,
1743 "FunctionDeclBitfields is larger than 8 bytes!");
1744 static_assert(
sizeof(CXXConstructorDeclBitfields) <= 8,
1745 "CXXConstructorDeclBitfields is larger than 8 bytes!");
1746 static_assert(
sizeof(ObjCMethodDeclBitfields) <= 8,
1747 "ObjCMethodDeclBitfields is larger than 8 bytes!");
1748 static_assert(
sizeof(ObjCContainerDeclBitfields) <= 8,
1749 "ObjCContainerDeclBitfields is larger than 8 bytes!");
1750 static_assert(
sizeof(LinkageSpecDeclBitfields) <= 8,
1751 "LinkageSpecDeclBitfields is larger than 8 bytes!");
1752 static_assert(
sizeof(BlockDeclBitfields) <= 8,
1753 "BlockDeclBitfields is larger than 8 bytes!");
1769 static std::pair<Decl *, Decl *>
1778 return static_cast<Decl::Kind>(DeclContextBits.DeclKind);
1788 return const_cast<DeclContext*
>(
this)->getParent();
1804 return const_cast<DeclContext*
>(
this)->getLexicalParent();
1810 return const_cast<DeclContext*
>(
this)->getLookupParent();
1817 bool isClosure()
const {
return getDeclKind() == Decl::Block; }
1821 const BlockDecl *getInnermostBlockDecl()
const;
1824 switch (getDeclKind()) {
1825 case Decl::ObjCCategory:
1826 case Decl::ObjCCategoryImpl:
1827 case Decl::ObjCImplementation:
1828 case Decl::ObjCInterface:
1829 case Decl::ObjCProtocol:
1837 switch (getDeclKind()) {
1839 case Decl::Captured:
1840 case Decl::ObjCMethod:
1843 return getDeclKind() >= Decl::firstFunction &&
1844 getDeclKind() <= Decl::lastFunction;
1851 getDeclKind() != Decl::Export;
1855 return getDeclKind() == Decl::TranslationUnit ||
1856 getDeclKind() == Decl::Namespace;
1860 return getDeclKind() == Decl::TranslationUnit;
1864 return getDeclKind() >= Decl::firstRecord &&
1865 getDeclKind() <= Decl::lastRecord;
1872 bool isInlineNamespace()
const;
1876 bool isDependentContext()
const;
1893 bool isTransparentContext()
const;
1897 bool isExternCContext()
const;
1904 bool isExternCXXContext()
const;
1919 Decl *getNonClosureAncestor();
1921 return const_cast<DeclContext*
>(
this)->getNonClosureAncestor();
1932 return const_cast<DeclContext*
>(
this)->getPrimaryContext();
1940 return const_cast<DeclContext *
>(
this)->getRedeclContext();
1946 return const_cast<DeclContext *
>(
this)->getEnclosingNamespaceContext();
1952 return const_cast<DeclContext *
>(
this)->getOuterLexicalRecordContext();
1961 bool InEnclosingNamespaceSetOf(
const DeclContext *NS)
const;
1992 Decl *Current =
nullptr;
2021 return x.Current == y.Current;
2025 return x.Current != y.Current;
2036 bool decls_empty()
const;
2042 return decl_range(noload_decls_begin(), noload_decls_end());
2052 template<
typename SpecificDecl>
2062 void SkipToNextDecl() {
2063 while (*Current && !isa<SpecificDecl>(*Current))
2074 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2110 return x.Current == y.Current;
2115 return x.Current != y.Current;
2128 template<
typename SpecificDecl,
bool (SpecificDecl::*Acceptable)() const>
2138 void SkipToNextDecl() {
2140 (!isa<SpecificDecl>(*Current) ||
2141 (Acceptable && !(cast<SpecificDecl>(*Current)->*Acceptable)())))
2152 std::iterator_traits<DeclContext::decl_iterator>::difference_type;
2186 return x.Current == y.Current;
2191 return x.Current != y.Current;
2207 void addDecl(
Decl *D);
2217 void addDeclInternal(
Decl *D);
2225 void addHiddenDecl(
Decl *D);
2228 void removeDecl(
Decl *D);
2231 bool containsDecl(
Decl *D)
const;
2235 bool containsDeclAndLoad(
Decl *D)
const;
2278 void makeDeclVisibleInContext(
NamedDecl *D);
2289 lookups_range noload_lookups(
bool PreserveInternalState)
const;
2305 std::random_access_iterator_tag,
2321 using ddiag_range = llvm::iterator_range<DeclContext::ddiag_iterator>;
2334 assert(
this == getPrimaryContext() &&
2335 "should only be called on primary context");
2336 DeclContextBits.HasLazyExternalLexicalLookups =
true;
2349 return DeclContextBits.ExternalLexicalStorage;
2355 DeclContextBits.ExternalLexicalStorage = ES;
2361 return DeclContextBits.ExternalVisibleStorage;
2367 DeclContextBits.ExternalVisibleStorage = ES;
2368 if (ES && LookupPtr)
2369 DeclContextBits.NeedToReconcileExternalVisibleStorage =
true;
2380 bool old_value = DeclContextBits.UseQualifiedLookup;
2381 DeclContextBits.UseQualifiedLookup = use;
2386 return DeclContextBits.UseQualifiedLookup;
2392 void dumpDeclContext()
const;
2393 void dumpLookups()
const;
2394 void dumpLookups(llvm::raw_ostream &OS,
bool DumpDecls =
false,
2395 bool Deserialize =
false)
const;
2402 bool hasNeedToReconcileExternalVisibleStorage()
const {
2403 return DeclContextBits.NeedToReconcileExternalVisibleStorage;
2410 void setNeedToReconcileExternalVisibleStorage(
bool Need =
true)
const {
2411 DeclContextBits.NeedToReconcileExternalVisibleStorage = Need;
2416 bool hasLazyLocalLexicalLookups()
const {
2417 return DeclContextBits.HasLazyLocalLexicalLookups;
2422 void setHasLazyLocalLexicalLookups(
bool HasLLLL =
true)
const {
2423 DeclContextBits.HasLazyLocalLexicalLookups = HasLLLL;
2428 bool hasLazyExternalLexicalLookups()
const {
2429 return DeclContextBits.HasLazyExternalLexicalLookups;
2434 void setHasLazyExternalLexicalLookups(
bool HasLELL =
true)
const {
2435 DeclContextBits.HasLazyExternalLexicalLookups = HasLELL;
2438 void reconcileExternalVisibleStorage()
const;
2439 bool LoadLexicalDeclsFromExternalStorage()
const;
2447 void makeDeclVisibleInContextInternal(
NamedDecl *D);
2451 void loadLazyLocalLexicalLookups();
2452 void buildLookupImpl(
DeclContext *DCtx,
bool Internal);
2453 void makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
2454 bool Rediscoverable);
2455 void makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal);
2459 return getKind() == TemplateTypeParm ||
getKind() == NonTypeTemplateParm ||
2460 getKind() == TemplateTemplateParm;
2464 template <
class ToTy,
2465 bool IsKnownSubtype = ::std::is_base_of<DeclContext, ToTy>::value>
2477 template <
class ToTy>
2480 return static_cast<const ToTy*
>(Val);
2484 return static_cast<ToTy*
>(Val);
2493 template <
typename To>
2495 static bool doit(const ::clang::DeclContext &Val) {
2496 return To::classofKind(Val.getDeclKind());
2501 template<
class ToTy>
2502 struct cast_convert_val<ToTy,
2504 static const ToTy &
doit(const ::clang::DeclContext &Val) {
2509 template<
class ToTy>
2516 template<
class ToTy>
2517 struct cast_convert_val<ToTy,
2519 static const ToTy *
doit(const ::clang::DeclContext *Val) {
2520 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2524 template<
class ToTy>
2527 return ::clang::cast_convert_decl_context<ToTy>::doit(Val);
2532 template<
class FromTy>
2534 static ::clang::DeclContext &
doit(
const FromTy &Val) {
2535 return *FromTy::castToDeclContext(&Val);
2539 template<
class FromTy>
2541 static ::clang::DeclContext *
doit(
const FromTy *Val) {
2542 return FromTy::castToDeclContext(Val);
2546 template<
class FromTy>
2548 static const ::clang::DeclContext &
doit(
const FromTy &Val) {
2549 return *FromTy::castToDeclContext(&Val);
2553 template<
class FromTy>
2555 static const ::clang::DeclContext *
doit(
const FromTy *Val) {
2556 return FromTy::castToDeclContext(Val);
2562 #endif // LLVM_CLANG_AST_DECLBASE_H
const Decl * getPreviousDecl() const
Retrieve the previous 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.
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)
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
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.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
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)
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.
Decl & operator=(const Decl &)=delete
Language
The language for the input, used to select and validate the language standard and possible actions...
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.
Represents 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.
ASTDumpOutputFormat
Used to specify the format for printing AST dump information.
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...
This declaration is an OpenMP user defined mapper.
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
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)
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
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...