;
39 if(!PrevMemberDecl) {
49diag::err_class_redeclared_with_different_access)
50<< MemberDecl << LexicalAS;
51 Diag(PrevMemberDecl->
getLocation(), diag::note_previous_access_declaration)
52<< PrevMemberDecl << PrevMemberDecl->
getAccess();
67 if(isa<EnumDecl>(DC))
68DC = cast<EnumDecl>(DC)->getDeclContext();
72DeclaringClass = cast<CXXRecordDecl>(DeclaringClass->
getDeclContext());
73 returnDeclaringClass;
77structEffectiveContext {
87 if(
auto*DGD = dyn_cast<CXXDeductionGuideDecl>(DC)) {
88 if(DGD->isImplicit()) {
89DC = DGD->getCorrespondingConstructor();
93DC = cast<DeclContext>(DGD->getDeducedTemplate()->getTemplatedDecl());
117 if(isa<CXXRecordDecl>(DC)) {
120DC =
Record->getDeclContext();
121}
else if(isa<FunctionDecl>(DC)) {
123Functions.push_back(
Function->getCanonicalDecl());
124 if(
Function->getFriendObjectKind())
125DC =
Function->getLexicalDeclContext();
136 boolisDependent()
const{
return Dependent; }
140 returnllvm::is_contained(
Records, R);
171FoundDecl, BaseObjectType) {
185 boolisInstanceMember()
const{
186 return(isMemberAccess() && getTargetDecl()->isCXXInstanceMember());
189 boolhasInstanceContext()
const{
190 returnHasInstanceContext;
193 classSavedInstanceContext {
195SavedInstanceContext(SavedInstanceContext &&S)
202SavedInstanceContext &operator=(SavedInstanceContext &&) =
delete;
206SavedInstanceContext(
constSavedInstanceContext &) =
delete;
207SavedInstanceContext &operator=(
constSavedInstanceContext &) =
delete;
209~SavedInstanceContext() {
211 Target->HasInstanceContext = Has;
215 friend structAccessTarget;
216 explicitSavedInstanceContext(AccessTarget &
Target)
222SavedInstanceContext saveInstanceContext() {
223 returnSavedInstanceContext(*
this);
226 voidsuppressInstanceContext() {
227HasInstanceContext =
false;
231assert(HasInstanceContext);
232 if(CalculatedInstanceContext)
233 returnInstanceContext;
235CalculatedInstanceContext =
true;
237InstanceContext = (IC ? cast<CXXRecordDecl>(IC)->getCanonicalDecl()
239 returnInstanceContext;
243 returnDeclaringClass;
251namingClass = cast<CXXRecordDecl>(namingClass->
getParent());
257HasInstanceContext = (isMemberAccess() &&
258!getBaseObjectType().isNull() &&
259getTargetDecl()->isCXXInstanceMember());
260CalculatedInstanceContext =
false;
261InstanceContext =
nullptr;
263 if(isMemberAccess())
266DeclaringClass = getBaseClass();
267DeclaringClass = DeclaringClass->getCanonicalDecl();
270 boolHasInstanceContext : 1;
271 mutable boolCalculatedInstanceContext : 1;
287 if(FromDC == ToDC)
return true;
318 for(
const auto&I : Derived->
bases()) {
323RD = cast<CXXRecordDecl>(RT->getDecl());
341 if(Queue.empty())
break;
343Derived = Queue.pop_back_val();
355assert(!
Friend->isDependentContext() &&
356 "can't handle friends with dependent contexts here");
358 if(!Context->isDependentContext())
361 if(
Friend->isFileContext())
374 if(!
Friend->isDependentType() && !Context->isDependentType())
384 if(Context->getDeclName() !=
Friend->getDeclName())
388Context->getDeclContext(),
389 Friend->getDeclContext()))
397->getAs<FunctionProtoType>();
404 if(FriendTy->getNumParams() != ContextTy->getNumParams())
408FriendTy->getReturnType()))
411 for(
unsignedI = 0,
E= FriendTy->getNumParams(); I !=
E; ++I)
413FriendTy->getParamType(I)))
423Context->getTemplatedDecl(),
424 Friend->getTemplatedDecl());
428 constEffectiveContext &EC,
430 if(EC.includesClass(
Friend))
433 if(EC.isDependent()) {
444 constEffectiveContext &EC,
447 return MatchesFriend(S, EC, cast<CXXRecordDecl>(RT->getDecl()));
450 if(
Friend->isDependentType())
459 constEffectiveContext &EC,
466I = EC.Records.begin(),
E= EC.Records.end(); I !=
E; ++I) {
473 if(isa<ClassTemplateSpecializationDecl>(
Record)) {
474CTD = cast<ClassTemplateSpecializationDecl>(
Record)
475->getSpecializedTemplate();
479CTD =
Record->getDescribedClassTemplate();
488 if(!EC.isDependent())
499 Friend->getDeclContext()))
512 constEffectiveContext &EC,
517I = EC.Functions.begin(),
E= EC.Functions.end(); I !=
E; ++I) {
531 constEffectiveContext &EC,
538I = EC.Functions.begin(),
E= EC.Functions.end(); I !=
E; ++I) {
542FTD = (*I)->getDescribedFunctionTemplate();
561 constEffectiveContext &EC,
576 if(isa<ClassTemplateDecl>(
Friend))
579 if(isa<FunctionTemplateDecl>(
Friend))
582 if(isa<CXXRecordDecl>(
Friend))
585assert(isa<FunctionDecl>(
Friend) &&
"unknown friend decl kind");
590 constEffectiveContext &EC,
617structProtectedFriendContext {
619 constEffectiveContext &EC;
627ProtectedFriendContext(
Sema&S,
constEffectiveContext &EC,
630: S(S), EC(EC), NamingClass(NamingClass),
631CheckDependent(InstanceContext->isDependentContext() ||
632NamingClass->isDependentContext()),
633EverDependent(
false) {}
637 boolcheckFriendshipAlongPath(
unsignedI) {
638assert(I < CurPath.size());
639 for(
unsigned E= CurPath.size(); I !=
E; ++I) {
654 boolfindFriendship(
const CXXRecordDecl*Cur,
unsignedPrivateDepth) {
658 if(Cur == NamingClass)
659 returncheckFriendshipAlongPath(PrivateDepth);
662EverDependent =
true;
665 for(
const auto&I : Cur->
bases()) {
668 unsignedBasePrivateDepth = PrivateDepth;
670BasePrivateDepth = CurPath.size() - 1;
676RD = cast<CXXRecordDecl>(RT->getDecl());
682EverDependent =
true;
687CurPath.push_back(RD);
697assert(CurPath.empty());
698CurPath.push_back(Cur);
699 returnfindFriendship(Cur, 0);
733assert(InstanceContext ==
nullptr||
740 if(!InstanceContext)
return GetFriendKind(S, EC, NamingClass);
742ProtectedFriendContext PRC(S, EC, InstanceContext, NamingClass);
743 if(PRC.findFriendship(InstanceContext))
return AR_accessible;
749 constEffectiveContext &EC,
752 constAccessTarget &
Target) {
754 "declaration should be canonicalized before being passed here");
761 for(EffectiveContext::record_iterator
762I = EC.Records.begin(),
E= EC.Records.end(); I !=
E; ++I) {
769 if(ECRecord == NamingClass)
801 if(!
Target.hasInstanceContext()) {
812 if(S.
getLangOpts().MSVCCompat && !EC.Functions.empty())
813 if(
CXXMethodDecl* MD = dyn_cast<CXXMethodDecl>(EC.Functions.front()))
838assert(
Target.isInstanceMember());
841 if(!InstanceContext) {
867 if(
Target.hasInstanceContext()) {
868InstanceContext =
Target.resolveInstanceContext(S);
877llvm_unreachable(
"impossible friendship kind");
887llvm_unreachable(
"impossible friendship kind");
947 constEffectiveContext &EC,
958assert(isDerived &&
"derived class not actually derived from base");
963assert(FinalAccess !=
AS_none&&
"forbidden access after declaring class");
965 boolAnyDependent =
false;
970AccessTarget::SavedInstanceContext _ =
Target.saveInstanceContext();
974CXXBasePath::iterator I = PI->end(),
E= PI->begin();
978assert(PathAccess !=
AS_none);
991PathAccess = std::max(PathAccess, BaseAccess);
1000 Target.suppressInstanceContext();
1003AnyDependent =
true;
1010 if(BestPath ==
nullptr|| PathAccess < BestPath->Access) {
1012BestPath->
Access= PathAccess;
1023 "fell out of loop with public path");
1039AccessTarget &
Target) {
1041 if(!
Target.isInstanceMember())
1044assert(
Target.isMemberAccess());
1048 for(EffectiveContext::record_iterator
1049I = EC.Records.begin(),
E= EC.Records.end(); I !=
E; ++I) {
1069 if(!
Target.hasInstanceContext()) {
1071 if(NamingClass == ECRecord)
continue;
1075S.
Diag(
D->
getLocation(), diag::note_access_protected_restricted_noobject)
1081assert(InstanceContext &&
"diagnosing dependent access");
1093 if(isa<CXXConstructorDecl>(
D) || isa<CXXDestructorDecl>(
D) ||
1094(isa<FunctionTemplateDecl>(
D) &&
1095isa<CXXConstructorDecl>(
1096cast<FunctionTemplateDecl>(
D)->getTemplatedDecl()))) {
1098diag::note_access_protected_restricted_ctordtor)
1104diag::note_access_protected_restricted_object)
1114 constEffectiveContext &EC,
1115AccessTarget &entity) {
1116assert(entity.isMemberAccess());
1126 if(
VarDecl*VD = dyn_cast<VarDecl>(
D))
1132 else if(
TagDecl*TD = dyn_cast<TagDecl>(
D)) {
1133 if(isa<RecordDecl>(
D) && cast<RecordDecl>(
D)->isInjectedClassName())
1137 if(!PrevDecl)
break;
1142 Decl*ImmediateChild;
1144ImmediateChild =
D;
1147 while(DC->
getParent() != DeclaringClass)
1149ImmediateChild = cast<Decl>(DC);
1154 boolisImplicit =
true;
1155 for(
const auto*I : DeclaringClass->
decls()) {
1156 if(I == ImmediateChild)
break;
1157 if(isa<AccessSpecDecl>(I)) {
1158isImplicit =
false;
1171 constEffectiveContext &EC,
1172AccessTarget &entity) {
1174AccessTarget::SavedInstanceContext _ = entity.saveInstanceContext();
1183 if(entity.isMemberAccess()) {
1186 const CXXRecordDecl*declaringClass = entity.getDeclaringClass();
1188 switch(
HasAccess(S, EC, declaringClass, accessSoFar, entity)) {
1193entity.suppressInstanceContext();
1198declaringClass == entity.getEffectiveNamingClass())
1203llvm_unreachable(
"cannot diagnose dependent access");
1211CXXBasePath::iterator i = path.end(), e = path.begin();
1212CXXBasePath::iterator constrainingBase = i;
1226 if(baseAccess > accessSoFar) {
1227constrainingBase = i;
1228accessSoFar = baseAccess;
1231 switch(
HasAccess(S, EC, derivingClass, accessSoFar, entity)) {
1235entity.suppressInstanceContext();
1236constrainingBase =
nullptr;
1239llvm_unreachable(
"cannot diagnose dependent access");
1246assert(constrainingBase == i);
1253 if(constrainingBase == path.end())
1259 unsigneddiagnostic;
1260 if(entity.isMemberAccess() ||
1261constrainingBase + 1 != path.end()) {
1262diagnostic = diag::note_access_constrained_by_path;
1264diagnostic = diag::note_access_natural;
1274 if(entity.isMemberAccess())
1275S.
Diag(entity.getTargetDecl()->getLocation(),
1276diag::note_member_declared_at);
1280 constEffectiveContext &EC,
1281AccessTarget &Entity) {
1283 const CXXRecordDecl*DeclaringClass = Entity.getDeclaringClass();
1284 NamedDecl*
D= (Entity.isMemberAccess() ? Entity.getTargetDecl() :
nullptr);
1286S.
Diag(
Loc, Entity.getDiag())
1316AccessTarget &Entity) {
1318dyn_cast<UsingShadowDecl>(Entity.getTargetDecl()))
1319 if(
UsingDecl*UD = dyn_cast<UsingDecl>(Shadow->getIntroducer())) {
1321 if(Entity.getTargetDecl()->getAccess() ==
AS_private&&
1324S.
Diag(AccessLoc, diag::ext_ms_using_declaration_inaccessible)
1325<< UD->getQualifiedNameAsString()
1336 constEffectiveContext &EC,
1337AccessTarget &Entity) {
1339 const CXXRecordDecl*NamingClass = Entity.getEffectiveNamingClass();
1342assert(UnprivilegedAccess !=
AS_public&&
"public access not weeded out");
1348 if(UnprivilegedAccess !=
AS_none) {
1349 switch(
HasAccess(S, EC, NamingClass, UnprivilegedAccess, Entity)) {
1365AccessTarget::SavedInstanceContext _ = Entity.saveInstanceContext();
1371 if(Entity.isMemberAccess()) {
1375 const CXXRecordDecl*DeclaringClass = Entity.getDeclaringClass();
1378 switch(
HasAccess(S, EC, DeclaringClass, FinalAccess, Entity)) {
1386Entity.suppressInstanceContext();
1392 if(DeclaringClass == NamingClass)
1398assert(Entity.getDeclaringClass() != NamingClass);
1406assert(
Path->Access <= UnprivilegedAccess &&
1407 "access along best path worse than direct?");
1414 constEffectiveContext &EC,
1416 constAccessTarget &Entity) {
1417assert(EC.isDependent() &&
"delaying non-dependent access");
1422Entity.isMemberAccess(),
1424Entity.getTargetDecl(),
1425Entity.getNamingClass(),
1426Entity.getBaseObjectType(),
1432 constEffectiveContext &EC,
1434AccessTarget &Entity) {
1435assert(Entity.getAccess() !=
AS_public&&
"called for public access!");
1446 if(!Entity.isQuiet())
1455llvm_unreachable(
"invalid access result");
1459AccessTarget &Entity) {
1489 boolIsFriendDeclaration =
false;
1490 while(TS && !IsFriendDeclaration) {
1494 if(!IsFriendDeclaration) {
1506llvm_unreachable(
"invalid access result");
1518}
else if(
FunctionDecl*FN = dyn_cast<FunctionDecl>(
D)) {
1520}
else if(
TemplateDecl*TD = dyn_cast<TemplateDecl>(
D)) {
1521 if(isa<DeclContext>(TD->getTemplatedDecl()))
1522DC = cast<DeclContext>(TD->getTemplatedDecl());
1523}
else if(
auto*RD = dyn_cast<RequiresExprBodyDecl>(
D)) {
1527EffectiveContext EC(DC);
1542 if(!NamingD)
return;
1545 if(!TargetD)
return;
1549 NamedDecl*TargetDecl = cast<NamedDecl>(TargetD);
1551 if(!BaseObjectType.
isNull()) {
1552BaseObjectType =
SubstType(BaseObjectType, TemplateArgs,
Loc,
1554 if(BaseObjectType.
isNull())
return;
1557AccessTarget Entity(
Context,
1558AccessTarget::Member,
1565AccessTarget Entity(
Context,
1567cast<CXXRecordDecl>(TargetD),
1568cast<CXXRecordDecl>(NamingD),
1578!
E->getNamingClass() ||
1582AccessTarget Entity(
Context, AccessTarget::Member,
E->getNamingClass(),
1586 return CheckAccess(*
this,
E->getNameLoc(), Entity);
1599AccessTarget Entity(
Context, AccessTarget::Member,
E->getNamingClass(),
1603 return CheckAccess(*
this,
E->getMemberLoc(), Entity);
1615AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
Found,
1619Entity.setDiag(
Diag);
1624 case AR_dependent: llvm_unreachable(
"dependent for =delete computation");
1625 case AR_delayed: llvm_unreachable(
"cannot delay =delete computation");
1627llvm_unreachable(
"bad access result");
1645AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
1648Entity.setDiag(
PDiag);
1657 boolIsCopyBindingRefToTemp) {
1664PD =
PDiag(IsCopyBindingRefToTemp
1665? diag::ext_rvalue_to_reference_access_ctor
1666: diag::err_access_ctor);
1671PD =
PDiag(diag::err_access_base_ctor);
1680PD =
PDiag(diag::err_access_field_ctor);
1681PD << Field->getType()
1688PD =
PDiag(diag::err_access_lambda_capture);
1689PD << VarName << Entity.
getType()
1722}
else if(
auto*Shadow =
1723dyn_cast<ConstructorUsingShadowDecl>(
Found.getDecl())) {
1728ObjectClass = NamingClass;
1731AccessTarget AccessEntity(
1732 Context, AccessTarget::Member, NamingClass,
1735AccessEntity.setDiag(PD);
1737 return CheckAccess(*
this, UseLoc, AccessEntity);
1750AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
Found,
1753Entity.setDiag(diag::err_access)
1767AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
1781AccessTarget Entity(
Context, AccessTarget::Member, DecomposedClass, Field,
1783Entity.setDiag(diag::err_decomp_decl_inaccessible_field);
1798AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
Found,
1819 if(!ArgExprs.empty()) {
1821ArgExprs.back()->getEndLoc());
1839AccessTarget entity(
Context, AccessTarget::Member,
1843entity.setDiag(diag::err_access_friend_function)
1855llvm_unreachable(
"invalid access result");
1868AccessTarget Entity(
Context, AccessTarget::Member, NamingClass,
Found,
1870Entity.setDiag(diag::err_access)
1882 boolForceUnprivileged) {
1883 if(!ForceCheck && !
getLangOpts().AccessControl)
1893AccessTarget Entity(
Context, AccessTarget::Base, BaseD, DerivedD,
1896Entity.setDiag(DiagID) << Derived <<
Base;
1898 if(ForceUnprivileged) {
1900AccessLoc, Entity)) {
1905llvm_unreachable(
"unexpected result from CheckEffectiveAccess");
1912&&
"performing access check without access control");
1913assert(R.
getNamingClass() &&
"performing access check without naming class");
1920Entity.setDiag(diag::err_access);
1929 if(
Target->isCXXClassMember() && NamingClass) {
1952ClassOfMethodDecl = MD->getClassInterface();
1955= dyn_cast<ObjCImplDecl>(FD->getLexicalDeclContext())) {
1957= dyn_cast<ObjCImplementationDecl>(Impl))
1958ClassOfMethodDecl = IMPD->getClassInterface();
1960= dyn_cast<ObjCCategoryImplDecl>(Impl))
1961ClassOfMethodDecl = CatImplClass->getClassInterface();
1966 if(!ClassOfMethodDecl)
1977 returnIvar->getContainingInterface()->
isSuperClassOf(ClassOfMethodDecl);
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Records Records
llvm::MachO::Record Record
static void DiagnoseBadAccess(Sema &S, SourceLocation Loc, const EffectiveContext &EC, AccessTarget &Entity)
AccessResult
A copy of Sema's enum without AR_delayed.
static bool TryDiagnoseProtectedAccess(Sema &S, const EffectiveContext &EC, AccessTarget &Target)
Given that an entity has protected natural access, check whether access might be denied because of th...
static AccessResult IsDerivedFromInclusive(const CXXRecordDecl *Derived, const CXXRecordDecl *Target)
Checks whether one class is derived from another, inclusively.
static void diagnoseBadDirectAccess(Sema &S, const EffectiveContext &EC, AccessTarget &entity)
We are unable to access a given declaration due to its direct access control; diagnose that.
static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc, AccessTarget &Entity)
static AccessResult GetFriendKind(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *Class)
static AccessResult MatchesFriend(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *Friend)
static AccessResult GetProtectedFriendKind(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *InstanceContext, const CXXRecordDecl *NamingClass)
Search for a class P that EC is a friend of, under the constraint InstanceContext <= P if InstanceCon...
static bool IsMicrosoftUsingDeclarationAccessBug(Sema &S, SourceLocation AccessLoc, AccessTarget &Entity)
MSVC has a bug where if during an using declaration name lookup, the declaration found is unaccessibl...
static CXXBasePath * FindBestPath(Sema &S, const EffectiveContext &EC, AccessTarget &Target, AccessSpecifier FinalAccess, CXXBasePaths &Paths)
Finds the best path from the naming class to the declaring class, taking friend declarations into acc...
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
static AccessResult HasAccess(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *NamingClass, AccessSpecifier Access, const AccessTarget &Target)
static bool MightInstantiateTo(const CXXRecordDecl *From, const CXXRecordDecl *To)
Checks whether one class might instantiate to the other.
static void DiagnoseAccessPath(Sema &S, const EffectiveContext &EC, AccessTarget &entity)
Diagnose the path which caused the given declaration or base class to become inaccessible.
static CXXRecordDecl * FindDeclaringClass(NamedDecl *D)
static AccessResult CheckEffectiveAccess(Sema &S, const EffectiveContext &EC, SourceLocation Loc, AccessTarget &Entity)
Checks access to an entity from the given effective context.
static void DelayDependentAccess(Sema &S, const EffectiveContext &EC, SourceLocation Loc, const AccessTarget &Entity)
Defines various enumerations that describe declaration and type specifiers.
static QualType getPointeeType(const MemRegion *R)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getRecordType(const RecordDecl *Decl) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
std::list< CXXBasePath >::iterator paths_iterator
Represents a base class of a C++ class.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
QualType getType() const
Retrieves the type of the base class.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a C++ struct/union/class.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasDefinition() const
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
Declaration of a class template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
bool isLocalExternDecl() const
Determine whether this is a block-scope declaration with linkage.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
A dependently-generated diagnostic.
NamedDecl * getAccessNamingClass() const
QualType getAccessBaseObjectType() const
bool isAccessToMember() const
NamedDecl * getAccessTarget() const
SourceLocation getAccessLoc() const
const PartialDiagnostic & getDiagnostic() const
static DependentDiagnostic * Create(ASTContext &Context, DeclContext *Parent, AccessNonce _, SourceLocation Loc, bool IsMemberAccess, AccessSpecifier AS, NamedDecl *TargetDecl, CXXRecordDecl *NamingClass, QualType BaseObjectType, const PartialDiagnostic &PDiag)
AccessSpecifier getAccess() const
This represents one expression.
Represents a member of a struct/union/class.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Represents a function declaration or definition.
DeclarationNameInfo getNameInfo() const
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Describes an entity that is being initialized.
EntityKind getKind() const
Determine the kind of initialization.
QualType getType() const
Retrieve type being initialized.
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
bool isInheritedVirtualBase() const
Return whether the base is an inherited virtual base.
@ EK_Member
The entity being initialized is a non-static data member subobject.
@ EK_Base
The entity being initialized is a base member subobject.
@ EK_ParenAggInitMember
The entity being initialized is a non-static data member subobject of an object initialized via paren...
@ EK_Delegating
The initialization is being done by a delegating constructor.
@ EK_LambdaCapture
The entity being initialized is the field that captures a variable in a lambda.
StringRef getCapturedVarName() const
For a lambda capture, return the capture's name.
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
The injected class name of a C++ class template or class template partial specialization.
Represents the results of name lookup.
SourceLocation getNameLoc() const
Gets the location of the identifier.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
QualType getBaseObjectType() const
Returns the base object type associated with this lookup; important for [class.protected].
Data structure that captures multiple levels of template argument lists for use in template instantia...
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getQualifiedNameAsString() const
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
SourceLocation getNameLoc() const
Gets the location of the name.
CXXRecordDecl * getNamingClass()
Gets the naming class of this lookup, if any.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Scope - A scope is a transient data structure that is used while parsing the program.
bool isFriendScope() const
Determine whether this scope is a friend scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
Sema - This implements semantic analysis and AST building for C.
Scope * getCurScope() const
Retrieve the parser's current scope.
CXXSpecialMemberKind getSpecialMember(const CXXMethodDecl *MD)
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
NamedDecl * FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, const MultiLevelTemplateArgumentList &TemplateArgs, bool FindingInstantiatedContext=false)
Find the instantiation of the given declaration within the current instantiation.
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
TypeSourceInfo * SubstType(TypeSourceInfo *T, const MultiLevelTemplateArgumentList &TemplateArgs, SourceLocation Loc, DeclarationName Entity, bool AllowDeducedTST=false)
Perform substitution on the type T with a given set of template arguments.
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, const SourceRange &, DeclAccessPair FoundDecl)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
const LangOptions & getLangOpts() const
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, QualType BaseType)
Checks access to Target from the given class.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void CheckLookupAccess(const LookupResult &R)
Checks access to all the declarations in the given result set.
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
@ Diagnose
Diagnose issues that are non-constant or that are extensions.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Represents the declaration of a struct/union/class/enum.
The base class of all kinds of template declarations (e.g., class, function, etc.).
A container of type source information.
CanQualType getCanonicalTypeUnqualified() const
const T * castAs() const
Member-template castAs<specific type>.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const T * getAs() const
Member-template getAs<specific type>'.
Base class for declarations which introduce a typedef-name.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
The iterator over UnresolvedSets.
Represents a C++ using-declaration.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represents a variable declaration or definition.
A declaration being accessed, together with information about how it was accessed.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
AccessedEntity & getAccessData()
static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity)
The JSON file list parser is used to communicate input to InstallAPI.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
OverloadExpr * Expression
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4