31 #include "llvm/ADT/DenseMap.h"
32 #include "llvm/Support/raw_ostream.h"
34 using namespace clang;
40 #define DECL(DERIVED, BASE) static int n##DERIVED##s = 0;
41 #define ABSTRACT_DECL(DECL)
42 #include "clang/AST/DeclNodes.inc"
53 void *
Result = (
char*)Start + 8;
55 unsigned *PrefixPtr = (
unsigned *)Result - 2;
68 assert(!Parent || &Parent->getParentASTContext() == &Ctx);
71 if (Ctx.getLangOpts().ModulesLocalVisibility) {
72 void *Buffer = ::operator
new(
sizeof(
Module *) + Size + Extra, Ctx);
73 return new (Buffer)
Module*(
nullptr) + 1;
75 return ::operator
new(Size + Extra, Ctx);
78 Module *Decl::getOwningModuleSlow()
const {
89 default: llvm_unreachable(
"Declaration not in DeclNodes.inc!");
90 #define DECL(DERIVED, BASE) case DERIVED: return #DERIVED;
91 #define ABSTRACT_DECL(DECL)
92 #include "clang/AST/DeclNodes.inc"
97 InvalidDecl = Invalid;
98 assert(!isa<TagDecl>(
this) || !cast<TagDecl>(
this)->isCompleteDefinition());
99 if (Invalid && !isa<ParmVarDecl>(
this)) {
109 default: llvm_unreachable(
"Declaration context not in DeclNodes.inc!");
110 #define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED;
111 #define ABSTRACT_DECL(DECL)
112 #include "clang/AST/DeclNodes.inc"
116 bool Decl::StatisticsEnabled =
false;
118 StatisticsEnabled =
true;
122 llvm::errs() <<
"\n*** Decl Stats:\n";
125 #define DECL(DERIVED, BASE) totalDecls += n##DERIVED##s;
126 #define ABSTRACT_DECL(DECL)
127 #include "clang/AST/DeclNodes.inc"
128 llvm::errs() <<
" " << totalDecls <<
" decls total.\n";
131 #define DECL(DERIVED, BASE) \
132 if (n##DERIVED##s > 0) { \
133 totalBytes += (int)(n##DERIVED##s * sizeof(DERIVED##Decl)); \
134 llvm::errs() << " " << n##DERIVED##s << " " #DERIVED " decls, " \
135 << sizeof(DERIVED##Decl) << " each (" \
136 << n##DERIVED##s * sizeof(DERIVED##Decl) \
139 #define ABSTRACT_DECL(DECL)
140 #include "clang/AST/DeclNodes.inc"
142 llvm::errs() <<
"Total bytes = " << totalBytes <<
"\n";
147 #define DECL(DERIVED, BASE) case DERIVED: ++n##DERIVED##s; break;
148 #define ABSTRACT_DECL(DECL)
149 #include "clang/AST/DeclNodes.inc"
155 return TTP->isParameterPack();
157 = dyn_cast<NonTypeTemplateParmDecl>(
this))
158 return NTTP->isParameterPack();
160 = dyn_cast<TemplateTemplateParmDecl>(
this))
161 return TTP->isParameterPack();
166 if (
const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(
this))
167 return Parm->isParameterPack();
176 return FTD->getTemplatedDecl();
181 return isa<TemplateDecl>(
this);
187 DC = DC->getParent())
188 if (DC->isFunctionOrMethod())
205 TheLoc.
print(OS, SM);
211 if (
const NamedDecl *DN = dyn_cast_or_null<NamedDecl>(TheDecl)) {
213 DN->printQualifiedName(OS);
237 getMultipleDC()->LexicalDC = DC;
244 if (SemaDC == LexicalDC) {
247 Decl::MultipleDC *MDC =
new (Ctx) Decl::MultipleDC();
248 MDC->SemanticDC = SemaDC;
249 MDC->LexicalDC = LexicalDC;
258 if (ND->isAnonymousNamespace())
274 assert(DC &&
"This decl is not contained in a translation unit!");
278 assert(DC &&
"This decl is not contained in a translation unit!");
281 return cast<TranslationUnitDecl>(DC);
301 Align = std::max(Align, I->getAlignment(Ctx));
310 if (CheckUsedAttr && hasAttr<UsedAttr>())
348 const AvailabilityAttr *A,
349 std::string *Message) {
353 if (TargetMinVersion.
empty())
358 StringRef ActualPlatform = A->getPlatform()->getName();
359 StringRef RealizedPlatform = ActualPlatform;
361 size_t suffix = RealizedPlatform.rfind(
"_app_extension");
362 if (suffix != StringRef::npos)
363 RealizedPlatform = RealizedPlatform.slice(0, suffix);
369 if (RealizedPlatform != TargetPlatform)
372 StringRef PrettyPlatformName
373 = AvailabilityAttr::getPrettyPlatformName(ActualPlatform);
375 if (PrettyPlatformName.empty())
376 PrettyPlatformName = ActualPlatform;
378 std::string HintMessage;
379 if (!A->getMessage().empty()) {
381 HintMessage += A->getMessage();
385 if (A->getUnavailable()) {
388 llvm::raw_string_ostream Out(*Message);
389 Out <<
"not available on " << PrettyPlatformName
397 if (!A->getIntroduced().empty() &&
398 TargetMinVersion < A->getIntroduced()) {
401 llvm::raw_string_ostream Out(*Message);
404 Out <<
"introduced in " << PrettyPlatformName <<
' '
405 << VTI << HintMessage;
412 if (!A->getObsoleted().empty() && TargetMinVersion >= A->getObsoleted()) {
415 llvm::raw_string_ostream Out(*Message);
418 Out <<
"obsoleted in " << PrettyPlatformName <<
' '
419 << VTO << HintMessage;
426 if (!A->getDeprecated().empty() && TargetMinVersion >= A->getDeprecated()) {
429 llvm::raw_string_ostream Out(*Message);
432 Out <<
"first deprecated in " << PrettyPlatformName <<
' '
433 << VTD << HintMessage;
444 std::string ResultMessage;
446 for (
const auto *A :
attrs()) {
447 if (
const auto *Deprecated = dyn_cast<DeprecatedAttr>(A)) {
452 ResultMessage = Deprecated->getMessage();
458 if (
const auto *Unavailable = dyn_cast<UnavailableAttr>(A)) {
460 *Message = Unavailable->getMessage();
464 if (
const auto *Availability = dyn_cast<AvailabilityAttr>(A)) {
474 ResultMessage.swap(*Message);
481 Message->swap(ResultMessage);
486 IsDefinition =
false;
489 if (
const VarDecl *Var = dyn_cast<VarDecl>(
this)) {
490 if (Var->isThisDeclarationADefinition()) {
497 }
else if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(
this)) {
505 }
else if (isa<ObjCInterfaceDecl>(
this) &&
520 for (
const auto *A :
attrs()) {
521 if (isa<WeakImportAttr>(A))
524 if (
const auto *Availability = dyn_cast<AvailabilityAttr>(A)) {
545 case NonTypeTemplateParm:
555 case ObjCCompatibleAlias:
561 case TypeAliasTemplate:
562 case UnresolvedUsingTypename:
563 case TemplateTypeParm:
570 case UnresolvedUsingValue:
580 case ObjCAtDefsField:
593 case FunctionTemplate:
598 case TemplateTemplateParm:
608 case ObjCPropertyImpl:
611 case TranslationUnit:
615 case ClassTemplateSpecialization:
616 case ClassTemplatePartialSpecialization:
617 case ClassScopeFunctionSpecialization:
618 case VarTemplateSpecialization:
619 case VarTemplatePartialSpecialization:
620 case ObjCImplementation:
622 case ObjCCategoryImpl:
624 case OMPThreadPrivate:
630 llvm_unreachable(
"Invalid DeclKind!");
634 assert(!HasAttrs &&
"Decl already contains attrs.");
637 assert(AttrBlank.empty() &&
"HasAttrs was wrong?");
644 if (!HasAttrs)
return;
651 assert(HasAttrs &&
"No attrs to get!");
658 #define DECL(NAME, BASE)
659 #define DECL_CONTEXT(NAME) \
661 return static_cast<NAME##Decl*>(const_cast<DeclContext*>(D));
662 #define DECL_CONTEXT_BASE(NAME)
663 #include "clang/AST/DeclNodes.inc"
665 #define DECL(NAME, BASE)
666 #define DECL_CONTEXT_BASE(NAME) \
667 if (DK >= first##NAME && DK <= last##NAME) \
668 return static_cast<NAME##Decl*>(const_cast<DeclContext*>(D));
669 #include "clang/AST/DeclNodes.inc"
670 llvm_unreachable(
"a decl that inherits DeclContext isn't handled");
677 #define DECL(NAME, BASE)
678 #define DECL_CONTEXT(NAME) \
680 return static_cast<NAME##Decl*>(const_cast<Decl*>(D));
681 #define DECL_CONTEXT_BASE(NAME)
682 #include "clang/AST/DeclNodes.inc"
684 #define DECL(NAME, BASE)
685 #define DECL_CONTEXT_BASE(NAME) \
686 if (DK >= first##NAME && DK <= last##NAME) \
687 return static_cast<NAME##Decl*>(const_cast<Decl*>(D));
688 #include "clang/AST/DeclNodes.inc"
689 llvm_unreachable(
"a decl that inherits DeclContext isn't handled");
696 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(
this)) {
698 if (FD->hasBody(Definition))
704 return Body->getSourceRange().getEnd();
709 bool Decl::AccessDeclContextSanity()
const {
718 if (isa<TranslationUnitDecl>(
this) ||
719 isa<TemplateTypeParmDecl>(
this) ||
720 isa<NonTypeTemplateParmDecl>(
this) ||
723 isa<StaticAssertDecl>(
this) ||
726 isa<ParmVarDecl>(
this) ||
729 isa<CXXRecordDecl>(
this) ||
730 isa<ClassScopeFunctionSpecializationDecl>(
this))
734 "Access specifier is AS_none inside a record decl");
744 if (
const ValueDecl *D = dyn_cast<ValueDecl>(
this))
747 Ty = D->getUnderlyingType();
763 if (
getKind(D) == Decl::CXXMethod) {
769 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
773 }
else if (
BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
775 }
else if (
CapturedDecl *CD = dyn_cast<CapturedDecl>(D)) {
796 #define DECL(NAME, BASE)
797 #define DECL_CONTEXT(NAME) case Decl::NAME:
798 #define DECL_CONTEXT_BASE(NAME)
799 #include "clang/AST/DeclNodes.inc"
802 #define DECL(NAME, BASE)
803 #define DECL_CONTEXT_BASE(NAME) \
804 if (D->getKind() >= Decl::first##NAME && \
805 D->getKind() <= Decl::last##NAME) \
807 #include "clang/AST/DeclNodes.inc"
822 if (isa<FunctionDecl>(
this))
832 cast<NamespaceDecl>(
this)->isInline();
848 return II && II->
isStr(
"std");
855 if (isa<ClassTemplatePartialSpecializationDecl>(
this))
858 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(
this)) {
859 if (Record->getDescribedClassTemplate())
862 if (Record->isDependentLambda())
866 if (
const FunctionDecl *Function = dyn_cast<FunctionDecl>(
this)) {
867 if (Function->getDescribedFunctionTemplate())
872 if (cast<Decl>(
this)->getFriendObjectKind())
884 if (DeclKind == Decl::Enum)
885 return !cast<EnumDecl>(
this)->isScoped();
886 else if (DeclKind == Decl::LinkageSpec)
894 while (DC->
getDeclKind() != Decl::TranslationUnit) {
896 return cast<LinkageSpecDecl>(DC)->getLanguage() ==
ID;
922 case Decl::TranslationUnit:
923 case Decl::ExternCContext:
924 case Decl::LinkageSpec:
930 case Decl::Namespace:
932 return static_cast<NamespaceDecl*
>(
this)->getOriginalNamespace();
934 case Decl::ObjCMethod:
937 case Decl::ObjCInterface:
943 case Decl::ObjCProtocol:
949 case Decl::ObjCCategory:
952 case Decl::ObjCImplementation:
953 case Decl::ObjCCategoryImpl:
957 if (DeclKind >= Decl::firstTag && DeclKind <= Decl::lastTag) {
960 TagDecl *Tag = cast<TagDecl>(
this);
967 TagDecl *PossiblePartialDef = TagTy->getDecl();
969 return PossiblePartialDef;
977 assert(DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction &&
978 "Unknown DeclContext kind");
987 if (DeclKind != Decl::Namespace) {
988 Contexts.push_back(
this);
995 Contexts.push_back(N);
997 std::reverse(Contexts.begin(), Contexts.end());
1000 std::pair<Decl *, Decl *>
1002 bool FieldsAlreadyLoaded) {
1004 Decl *FirstNewDecl =
nullptr;
1005 Decl *PrevDecl =
nullptr;
1006 for (
unsigned I = 0, N = Decls.size(); I != N; ++I) {
1007 if (FieldsAlreadyLoaded && isa<FieldDecl>(Decls[I]))
1019 return std::make_pair(FirstNewDecl, PrevDecl);
1025 void DeclContext::reconcileExternalVisibleStorage()
const {
1026 assert(NeedToReconcileExternalVisibleStorage && LookupPtr);
1027 NeedToReconcileExternalVisibleStorage =
false;
1029 for (
auto &Lookup : *LookupPtr)
1030 Lookup.second.setHasExternalDecls();
1037 DeclContext::LoadLexicalDeclsFromExternalStorage()
const {
1046 ExternalLexicalStorage =
false;
1061 bool FieldsAlreadyLoaded =
false;
1062 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(
this))
1063 FieldsAlreadyLoaded = RD->LoadedFieldsFromExternalStorage;
1067 Decl *ExternalFirst, *ExternalLast;
1068 std::tie(ExternalFirst, ExternalLast) =
1070 ExternalLast->NextInContextAndBits.setPointer(
FirstDecl);
1082 if (!(Map = DC->LookupPtr))
1083 Map = DC->CreateStoredDeclsMap(Context);
1084 if (DC->NeedToReconcileExternalVisibleStorage)
1085 DC->reconcileExternalVisibleStorage();
1087 (*Map)[Name].removeExternalDecls();
1098 if (!(Map = DC->LookupPtr))
1099 Map = DC->CreateStoredDeclsMap(Context);
1100 if (DC->NeedToReconcileExternalVisibleStorage)
1101 DC->reconcileExternalVisibleStorage();
1114 for (
unsigned I = 0, N = Decls.size(); I != N; ++I)
1117 Skip.push_back(Decls.size());
1120 unsigned SkipPos = 0;
1121 for (
unsigned I = 0, N = Decls.size(); I != N; ++I) {
1122 if (I == Skip[SkipPos])
1130 I = Decls.begin(), E = Decls.end(); I != E; ++I) {
1143 LoadLexicalDeclsFromExternalStorage();
1149 LoadLexicalDeclsFromExternalStorage();
1161 "decl being removed from non-lexical context");
1163 "decl is not in decls list");
1173 assert(I &&
"decl not found in linked list");
1174 if (I->NextInContextAndBits.getPointer() == D) {
1186 if (isa<NamedDecl>(D)) {
1195 StoredDeclsMap::iterator Pos = Map->find(ND->
getDeclName());
1196 assert(Pos != Map->end() &&
"no lookup entry for decl");
1197 if (Pos->second.getAsVector() || Pos->second.getAsDecl() == ND)
1198 Pos->second.remove(ND);
1204 "Decl inserted into wrong lexical context");
1206 "Decl already inserted into a DeclContext");
1218 Record->addedMember(D);
1223 if (
ImportDecl *Import = dyn_cast<ImportDecl>(D))
1231 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
1232 ND->getDeclContext()->getPrimaryContext()->
1233 makeDeclVisibleInContextWithFlags(ND,
false,
true);
1239 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
1240 ND->getDeclContext()->getPrimaryContext()->
1241 makeDeclVisibleInContextWithFlags(ND,
true,
true);
1261 if (isa<ClassTemplateSpecializationDecl>(D))
1264 if (FD->isFunctionTemplateSpecialization())
1280 if (!HasLazyLocalLexicalLookups && !HasLazyExternalLexicalLookups)
1286 if (HasLazyExternalLexicalLookups) {
1287 HasLazyExternalLexicalLookups =
false;
1288 for (
auto *DC : Contexts) {
1289 if (DC->hasExternalLexicalStorage())
1290 HasLazyLocalLexicalLookups |=
1291 DC->LoadLexicalDeclsFromExternalStorage();
1294 if (!HasLazyLocalLexicalLookups)
1298 for (
auto *DC : Contexts)
1302 HasLazyLocalLexicalLookups =
false;
1310 void DeclContext::buildLookupImpl(
DeclContext *DCtx,
bool Internal) {
1320 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
1322 (!ND->isFromASTFile() ||
1325 makeDeclVisibleInContextImpl(ND, Internal);
1330 if (
DeclContext *InnerCtx = dyn_cast<DeclContext>(D))
1331 if (InnerCtx->isTransparentContext() || InnerCtx->isInlineNamespace())
1332 buildLookupImpl(InnerCtx, Internal);
1336 NamedDecl *
const DeclContextLookupResult::SingleElementDummyList =
nullptr;
1340 assert(DeclKind != Decl::LinkageSpec &&
1341 "Should not perform lookups into linkage specs!");
1344 if (PrimaryContext !=
this)
1345 return PrimaryContext->
lookup(Name);
1352 (void)cast<Decl>(
this)->getMostRecentDecl();
1355 assert(Source &&
"external visible storage but no external source?");
1357 if (NeedToReconcileExternalVisibleStorage)
1358 reconcileExternalVisibleStorage();
1362 if (HasLazyLocalLexicalLookups || HasLazyExternalLexicalLookups)
1370 std::pair<StoredDeclsMap::iterator, bool> R =
1372 if (!R.second && !R.first->second.hasExternalDecls())
1373 return R.first->second.getLookupResult();
1377 StoredDeclsMap::iterator I = Map->find(Name);
1378 if (I != Map->end())
1379 return I->second.getLookupResult();
1387 if (HasLazyLocalLexicalLookups || HasLazyExternalLexicalLookups)
1393 StoredDeclsMap::iterator I = Map->find(Name);
1394 if (I == Map->end())
1397 return I->second.getLookupResult();
1402 assert(DeclKind != Decl::LinkageSpec &&
1403 "Should not perform lookups into linkage specs!");
1406 if (PrimaryContext !=
this)
1412 if (HasLazyLocalLexicalLookups) {
1415 for (
unsigned I = 0, N = Contexts.size(); I != N; ++I)
1417 HasLazyLocalLexicalLookups =
false;
1424 StoredDeclsMap::iterator I = Map->find(Name);
1425 return I != Map->end() ? I->second.getLookupResult()
1437 Results.insert(Results.end(), LookupResults.
begin(), LookupResults.
end());
1443 if (Name && !HasLazyLocalLexicalLookups && !HasLazyExternalLexicalLookups) {
1445 StoredDeclsMap::iterator Pos =
Map->find(Name);
1446 if (Pos !=
Map->end()) {
1447 Results.insert(Results.end(),
1448 Pos->second.getLookupResult().begin(),
1449 Pos->second.getLookupResult().end());
1460 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
1461 if (ND->getDeclName() == Name)
1462 Results.push_back(ND);
1487 OutermostRD = cast<RecordDecl>(DC);
1516 PrimaryDC->makeDeclVisibleInContextWithFlags(D,
false, PrimaryDC == DeclDC);
1519 void DeclContext::makeDeclVisibleInContextWithFlags(
NamedDecl *D,
bool Internal,
1547 makeDeclVisibleInContextImpl(D, Internal);
1549 HasLazyLocalLexicalLookups =
true;
1556 makeDeclVisibleInContextWithFlags(D, Internal, Recoverable);
1558 Decl *DCAsDecl = cast<Decl>(
this);
1560 if (!(isa<TagDecl>(DCAsDecl) && cast<TagDecl>(DCAsDecl)->isBeingDefined()))
1562 L->AddedVisibleDecl(
this, D);
1565 void DeclContext::makeDeclVisibleInContextImpl(
NamedDecl *D,
bool Internal) {
1570 Map = CreateStoredDeclsMap(*C);
1596 if (DeclNameEntries.
isNull()) {
1612 return cast<UsingDirectiveDecl>(*I);
1629 assert(!LookupPtr &&
"context already has a decls map");
1631 "creating decls map on non-primary context");
1639 M->Previous = C.LastSDM;
1640 C.LastSDM = llvm::PointerIntPair<StoredDeclsMap*,1>(M, Dependent);
1645 void ASTContext::ReleaseDeclContextMaps() {
1655 llvm::PointerIntPair<StoredDeclsMap*,1>
Next = Map->Previous;
1662 Map = Next.getPointer();
1663 Dependent = Next.getInt();
1671 &&
"cannot iterate dependent diagnostics of non-dependent context");
1673 if (!Parent->LookupPtr)
1674 Parent->CreateStoredDeclsMap(C);
1688 DD->NextDiagnostic = Map->FirstDiagnostic;
1689 Map->FirstDiagnostic = DD;
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
void setHasExternalDecls()
AttrVec & getDeclAttrs(const Decl *D)
Retrieve the attributes for the given declaration.
bool isTransparentContext() const
bool isTemplateParameter() const
void updateOutOfDate(IdentifierInfo &II) const
Update a potentially out-of-date declaration.
static DeclContext * castToDeclContext(const Decl *)
static bool shouldBeHidden(NamedDecl *D)
UsingDirectiveDecl * operator*() const
Represents a version number in the form major[.minor[.subminor[.build]]].
void AddSubsequentDecl(NamedDecl *D)
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
static Decl * castFromDeclContext(const DeclContext *)
IdentifierInfo * getIdentifier() const
static bool isLinkageSpecContext(const DeclContext *DC, LinkageSpecDecl::LanguageIDs ID)
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
Defines the C++ template declaration subclasses.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool isInStdNamespace() const
static DeclContextLookupResult SetExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl * > Decls)
bool isStdNamespace() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
NamespaceDecl - Represent a C++ namespace.
bool isWeakImported() const
Determine whether this is a weak-imported symbol.
bool isBlockPointerType() const
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)
unsigned Access
Access - Used by C++ decls for the access specifier.
bool HandleRedeclaration(NamedDecl *D, bool IsKnownNewer)
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
udir_range using_directives() const
ParmVarDecl - Represents a parameter to a function.
void removeDecl(Decl *D)
Removes a declaration from this context.
ASTMutationListener * getASTMutationListener() const
unsigned getMaxAlignment() const
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. This is either a single result (with no stable stora...
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isReferenced() const
Whether any declaration of this entity was referenced.
unsigned getIdentifierNamespace() const
bool isTranslationUnit() const
bool isInlineNamespace() const
static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)
Build up a chain of declarations.
Describes a module or submodule.
virtual void updateOutOfDateIdentifier(IdentifierInfo &II)
Update an out-of-date identifier.
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
const TargetInfo & getTargetInfo() const
virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name)
Find all declarations with the given name in the given context, and add them to the context by callin...
const LangOptions & getLangOpts() const
bool isInline() const
Returns true if this is an inline namespace declaration.
StoredDeclsMap * buildLookup()
Ensure the lookup structure is fully-built and return it.
const CXXRecordDecl * getParent() const
static DeclContextLookupResult SetNoExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name)
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, bool(*isKindWeWant)(Decl::Kind), SmallVectorImpl< Decl * > &Result)
Finds all declarations lexically contained within the given DeclContext, after applying an optional f...
void eraseDeclAttrs(const Decl *D)
Erase the attributes corresponding to the given declaration.
Represents an Objective-C protocol declaration.
DeclContext * getLexicalDeclContext()
bool hasLocalOwningModuleStorage() const
Labels, declared with 'x:' and referenced with 'goto x'.
This represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
decl_iterator decls_begin() const
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
AvailabilityResult
Captures the result of checking the availability of a declaration.
bool isTemplateParameterPack() const
Decl * getNextDeclInContext()
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
decl_range noload_decls() const
bool hasWeakClassImport() const
Does this runtime support weakly importing classes?
unsigned getOwningModuleID() const
Retrieve the global ID of the module that owns this particular declaration.
SourceLocation getBodyRBrace() const
ID
Defines the set of possible language-specific address spaces.
bool isFunctionPointerType() const
void removeExternalDecls()
Remove any declarations which were imported from an external AST source.
DeclContext * getLexicalParent()
const char * getDeclKindName() const
const Type * getTypeForDecl() const
QualType getPointeeType() const
static unsigned getIdentifierNamespaceForKind(Kind DK)
llvm::iterator_range< udir_iterator > udir_range
Declaration of a template type parameter.
bool isTemplateDecl() const
returns true if this declaration is a template
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
ASTContext & getParentASTContext() const
Loading the external information has succeeded.
void setInvalidDecl(bool Invalid=true)
The external information has already been loaded, and therefore no additional processing is required...
bool isInAnonymousNamespace() const
DeclContext * getDeclContext()
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e. the innermost semantic parent of this con...
const char * getDeclKindName() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
friend class DependentDiagnostic
bool isFunctionOrMethod() const
clang::ObjCRuntime ObjCRuntime
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
DeclarationName getDeclName() const
TagDecl * getDefinition() const
The result type of a method or function.
void setDeclContext(DeclContext *DC)
virtual void DeclarationMarkedUsed(const Decl *D)
A declaration is marked used which was not previously marked used.
Abstract interface for external sources of AST nodes.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContext::lookup_result getLookupResult()
void print(raw_ostream &OS, const SourceManager &SM) const
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
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...
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const LLVM_READONLY
Represents a static or instance method of a struct/union/class.
This file defines OpenMP nodes for declarative directives.
virtual Stmt * getBody() const
void print(raw_ostream &OS) const override
ASTContext & getASTContext() const
lookup_result lookup(DeclarationName Name) const
bool isFileContext() const
DeclContextLookupResult lookup_result
An array of decls optimized for the common case of only containing one entry.
bool isExternCXXContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
Describes a module import declaration, which makes the contents of the named module visible in the cu...
QualType getPointeeType() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Base class for declarations which introduce a typedef-name.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
virtual Module * getModule(unsigned ID)
Retrieve the module that corresponds to the given module ID.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
bool isInvalidDecl() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
Decl * getNonClosureContext()
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. Will return null if...
static AvailabilityResult CheckAvailability(ASTContext &Context, const AvailabilityAttr *A, std::string *Message)
Determine the availability of the given declaration based on the target platform. ...
bool isLambda() const
Determine whether this class describes a lambda function object.
SmallVector< Context, 8 > Contexts
A dependently-generated diagnostic.
static DependentDiagnostic * Create(ASTContext &Context, DeclContext *Parent, AccessNonce _, SourceLocation Loc, bool IsMemberAccess, AccessSpecifier AS, NamedDecl *TargetDecl, CXXRecordDecl *NamingClass, QualType BaseObjectType, const PartialDiagnostic &PDiag)
Decl::Kind getDeclKind() const
LanguageIDs
Represents the language in a linkage specification.
void setOnlyValue(NamedDecl *ND)
DeclContext * getRedeclContext()
void addDecl(Decl *D)
Add the declaration D into this context.
ASTMutationListener * getASTMutationListener() const
Retrieve a pointer to the AST mutation listener associated with this AST context, if any...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
unsigned Hidden
Whether this declaration is hidden from normal name lookup, e.g., because it is was loaded from an AS...
llvm::PointerIntPair< Decl *, 2, unsigned > NextInContextAndBits
The next declaration within the same lexical DeclContext. These pointers form the linked list that is...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Represents a C++ struct/union/class.
void addHiddenDecl(Decl *D)
Add the declaration D to this context without modifying any lookup tables.
void * Allocate(size_t Size, unsigned Align=8) const
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
static bool classof(const Decl *D)
Defines the clang::TargetInfo interface.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Kind
Lists the kind of concrete classes of Decl.
static Decl::Kind getKind(const Decl *D)
TranslationUnitDecl - The top declaration context.
Loading the external information has failed.
static void DestroyAll(StoredDeclsMap *Map, bool Dependent)
NamedDecl * getMostRecentDecl()
DeclContext * getPrimaryContext()
static void EnableStatistics()
bool isParameterPack() const
Whether this declaration is a parameter pack.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
void setAccess(AccessSpecifier AS)
void collectAllContexts(SmallVectorImpl< DeclContext * > &Contexts)
Collects all of the declaration contexts that are semantically connected to this declaration context...
Represents C++ using-directive.
void addedLocalImportDecl(ImportDecl *Import)
Notify the AST context that a new import declaration has been parsed or implicitly created within thi...
TranslationUnitDecl * getTranslationUnitDecl()
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
Declaration of a template function.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
OverloadedOperatorKind getOverloadedOperator() const