27 using namespace clang;
43 if (!PrevMemberDecl) {
53 diag::err_class_redeclared_with_different_access)
54 << MemberDecl << LexicalAS;
55 Diag(PrevMemberDecl->
getLocation(), diag::note_previous_access_declaration)
56 << PrevMemberDecl << PrevMemberDecl->
getAccess();
71 if (isa<EnumDecl>(DC))
72 DC = cast<EnumDecl>(DC)->getDeclContext();
76 DeclaringClass = cast<CXXRecordDecl>(DeclaringClass->
getDeclContext());
77 return DeclaringClass;
81 struct EffectiveContext {
82 EffectiveContext() : Inner(
nullptr), Dependent(
false) {}
107 if (isa<CXXRecordDecl>(DC)) {
111 }
else if (isa<FunctionDecl>(DC)) {
126 bool isDependent()
const {
return Dependent; }
130 return std::find(Records.begin(), Records.end(), R)
162 FoundDecl, BaseObjectType) {
176 bool isInstanceMember()
const {
177 return (isMemberAccess() && getTargetDecl()->isCXXInstanceMember());
180 bool hasInstanceContext()
const {
181 return HasInstanceContext;
184 class SavedInstanceContext {
186 SavedInstanceContext(SavedInstanceContext &&S)
187 :
Target(S.Target), Has(S.Has) {
190 ~SavedInstanceContext() {
192 Target->HasInstanceContext = Has;
196 friend struct AccessTarget;
197 explicit SavedInstanceContext(AccessTarget &
Target)
198 :
Target(&Target), Has(Target.HasInstanceContext) {}
203 SavedInstanceContext saveInstanceContext() {
204 return SavedInstanceContext(*
this);
207 void suppressInstanceContext() {
208 HasInstanceContext =
false;
212 assert(HasInstanceContext);
213 if (CalculatedInstanceContext)
214 return InstanceContext;
216 CalculatedInstanceContext =
true;
220 return InstanceContext;
224 return DeclaringClass;
232 namingClass = cast<CXXRecordDecl>(namingClass->
getParent());
238 HasInstanceContext = (isMemberAccess() &&
239 !getBaseObjectType().isNull() &&
240 getTargetDecl()->isCXXInstanceMember());
241 CalculatedInstanceContext =
false;
242 InstanceContext =
nullptr;
244 if (isMemberAccess())
247 DeclaringClass = getBaseClass();
248 DeclaringClass = DeclaringClass->getCanonicalDecl();
251 bool HasInstanceContext : 1;
252 mutable bool CalculatedInstanceContext : 1;
268 if (FromDC == ToDC)
return true;
299 for (
const auto &I : Derived->
bases()) {
304 RD = cast<CXXRecordDecl>(RT->getDecl());
322 if (Queue.empty())
break;
324 Derived = Queue.pop_back_val();
333 if (Friend == Context)
337 "can't handle friends with dependent contexts here");
352 if (Friend == Context)
355 if (!Friend->isDependentType() && !Context->isDependentType())
375 ->getAs<FunctionProtoType>();
378 ->getAs<FunctionProtoType>();
385 if (FriendTy->getNumParams() != ContextTy->getNumParams())
389 FriendTy->getReturnType()))
392 for (
unsigned I = 0, E = FriendTy->getNumParams(); I != E; ++I)
394 FriendTy->getParamType(I)))
409 const EffectiveContext &EC,
411 if (EC.includesClass(Friend))
414 if (EC.isDependent()) {
425 const EffectiveContext &EC,
428 return MatchesFriend(S, EC, cast<CXXRecordDecl>(RT->getDecl()));
431 if (Friend->isDependentType())
440 const EffectiveContext &EC,
447 I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
454 if (isa<ClassTemplateSpecializationDecl>(Record)) {
455 CTD = cast<ClassTemplateSpecializationDecl>(Record)
456 ->getSpecializedTemplate();
469 if (!EC.isDependent())
493 const EffectiveContext &EC,
498 I = EC.Functions.begin(), E = EC.Functions.end(); I != E; ++I) {
512 const EffectiveContext &EC,
519 I = EC.Functions.begin(), E = EC.Functions.end(); I != E; ++I) {
523 FTD = (*I)->getDescribedFunctionTemplate();
542 const EffectiveContext &EC,
550 return MatchesFriend(S, EC, T->getType()->getCanonicalTypeUnqualified());
557 if (isa<ClassTemplateDecl>(Friend))
558 return MatchesFriend(S, EC, cast<ClassTemplateDecl>(Friend));
560 if (isa<FunctionTemplateDecl>(Friend))
561 return MatchesFriend(S, EC, cast<FunctionTemplateDecl>(Friend));
563 if (isa<CXXRecordDecl>(Friend))
566 assert(isa<FunctionDecl>(Friend) &&
"unknown friend decl kind");
571 const EffectiveContext &EC,
576 for (
auto *Friend : Class->
friends()) {
598 struct ProtectedFriendContext {
600 const EffectiveContext &EC;
608 ProtectedFriendContext(
Sema &S,
const EffectiveContext &EC,
611 : S(S), EC(EC), NamingClass(NamingClass),
614 EverDependent(
false) {}
618 bool checkFriendshipAlongPath(
unsigned I) {
619 assert(I < CurPath.size());
620 for (
unsigned E = CurPath.size(); I != E; ++I) {
635 bool findFriendship(
const CXXRecordDecl *Cur,
unsigned PrivateDepth) {
639 if (Cur == NamingClass)
640 return checkFriendshipAlongPath(PrivateDepth);
643 EverDependent =
true;
646 for (
const auto &I : Cur->
bases()) {
649 unsigned BasePrivateDepth = PrivateDepth;
651 BasePrivateDepth = CurPath.size() - 1;
657 RD = cast<CXXRecordDecl>(RT->getDecl());
663 EverDependent =
true;
668 CurPath.push_back(RD);
678 assert(CurPath.empty());
679 CurPath.push_back(Cur);
680 return findFriendship(Cur, 0);
714 assert(InstanceContext ==
nullptr ||
721 if (!InstanceContext)
return GetFriendKind(S, EC, NamingClass);
723 ProtectedFriendContext PRC(S, EC, InstanceContext, NamingClass);
724 if (PRC.findFriendship(InstanceContext))
return AR_accessible;
730 const EffectiveContext &EC,
733 const AccessTarget &
Target) {
735 "declaration should be canonicalized before being passed here");
742 for (EffectiveContext::record_iterator
743 I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
750 if (ECRecord == NamingClass)
782 if (!Target.hasInstanceContext()) {
793 if (S.
getLangOpts().MSVCCompat && !EC.Functions.empty())
794 if (
CXXMethodDecl* MD = dyn_cast<CXXMethodDecl>(EC.Functions.front()))
819 assert(Target.isInstanceMember());
821 const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
822 if (!InstanceContext) {
845 if (Access ==
AS_protected && Target.isInstanceMember()) {
848 if (Target.hasInstanceContext()) {
849 InstanceContext = Target.resolveInstanceContext(S);
858 llvm_unreachable(
"impossible friendship kind");
868 llvm_unreachable(
"impossible friendship kind");
928 const EffectiveContext &EC,
937 bool isDerived = Derived->
isDerivedFrom(const_cast<CXXRecordDecl*>(Base),
939 assert(isDerived &&
"derived class not actually derived from base");
944 assert(FinalAccess !=
AS_none &&
"forbidden access after declaring class");
946 bool AnyDependent =
false;
951 AccessTarget::SavedInstanceContext _ = Target.saveInstanceContext();
955 CXXBasePath::iterator I = PI->end(), E = PI->begin();
972 PathAccess =
std::max(PathAccess, BaseAccess);
974 switch (
HasAccess(S, EC, NC, PathAccess, Target)) {
981 Target.suppressInstanceContext();
991 if (BestPath ==
nullptr || PathAccess < BestPath->Access) {
993 BestPath->
Access = PathAccess;
1004 "fell out of loop with public path");
1022 if (!Target.isInstanceMember())
1025 assert(Target.isMemberAccess());
1027 const CXXRecordDecl *NamingClass = Target.getEffectiveNamingClass();
1029 for (EffectiveContext::record_iterator
1030 I = EC.Records.begin(), E = EC.Records.end(); I != E; ++I) {
1050 if (!Target.hasInstanceContext()) {
1052 if (NamingClass == ECRecord)
continue;
1056 S.
Diag(D->
getLocation(), diag::note_access_protected_restricted_noobject)
1061 const CXXRecordDecl *InstanceContext = Target.resolveInstanceContext(S);
1062 assert(InstanceContext &&
"diagnosing dependent access");
1074 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D) ||
1075 (isa<FunctionTemplateDecl>(D) &&
1076 isa<CXXConstructorDecl>(
1077 cast<FunctionTemplateDecl>(D)->getTemplatedDecl()))) {
1079 diag::note_access_protected_restricted_ctordtor)
1085 diag::note_access_protected_restricted_object)
1095 const EffectiveContext &EC,
1096 AccessTarget &entity) {
1097 assert(entity.isMemberAccess());
1105 while (D->isOutOfLine()) {
1107 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
1113 else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
1114 if (isa<RecordDecl>(D) && cast<RecordDecl>(D)->isInjectedClassName())
1118 if (!PrevDecl)
break;
1123 Decl *ImmediateChild;
1124 if (D->getDeclContext() == DeclaringClass)
1128 while (DC->
getParent() != DeclaringClass)
1130 ImmediateChild = cast<Decl>(DC);
1135 bool isImplicit =
true;
1136 for (
const auto *I : DeclaringClass->
decls()) {
1137 if (I == ImmediateChild)
break;
1138 if (isa<AccessSpecDecl>(I)) {
1144 S.
Diag(D->getLocation(), diag::note_access_natural)
1152 const EffectiveContext &EC,
1153 AccessTarget &entity) {
1155 AccessTarget::SavedInstanceContext _ = entity.saveInstanceContext();
1164 if (entity.isMemberAccess()) {
1167 const CXXRecordDecl *declaringClass = entity.getDeclaringClass();
1169 switch (
HasAccess(S, EC, declaringClass, accessSoFar, entity)) {
1174 entity.suppressInstanceContext();
1179 declaringClass == entity.getEffectiveNamingClass())
1184 llvm_unreachable(
"cannot diagnose dependent access");
1192 CXXBasePath::iterator i = path.end(), e = path.begin();
1193 CXXBasePath::iterator constrainingBase = i;
1207 if (baseAccess > accessSoFar) {
1208 constrainingBase = i;
1209 accessSoFar = baseAccess;
1212 switch (
HasAccess(S, EC, derivingClass, accessSoFar, entity)) {
1216 entity.suppressInstanceContext();
1217 constrainingBase =
nullptr;
1220 llvm_unreachable(
"cannot diagnose dependent access");
1227 assert(constrainingBase == i);
1234 if (constrainingBase == path.end())
1240 unsigned diagnostic;
1241 if (entity.isMemberAccess() ||
1242 constrainingBase + 1 != path.end()) {
1243 diagnostic = diag::note_access_constrained_by_path;
1245 diagnostic = diag::note_access_natural;
1255 if (entity.isMemberAccess())
1256 S.
Diag(entity.getTargetDecl()->getLocation(),
1257 diag::note_member_declared_at);
1261 const EffectiveContext &EC,
1262 AccessTarget &Entity) {
1264 const CXXRecordDecl *DeclaringClass = Entity.getDeclaringClass();
1265 NamedDecl *D = (Entity.isMemberAccess() ? Entity.getTargetDecl() :
nullptr);
1267 S.
Diag(Loc, Entity.getDiag())
1297 AccessTarget &Entity) {
1299 dyn_cast<UsingShadowDecl>(Entity.getTargetDecl())) {
1300 const NamedDecl *OrigDecl = Entity.getTargetDecl()->getUnderlyingDecl();
1301 if (Entity.getTargetDecl()->getAccess() ==
AS_private &&
1304 S.
Diag(AccessLoc, diag::ext_ms_using_declaration_inaccessible)
1305 << Shadow->getUsingDecl()->getQualifiedNameAsString()
1316 const EffectiveContext &EC,
1317 AccessTarget &Entity) {
1319 const CXXRecordDecl *NamingClass = Entity.getEffectiveNamingClass();
1322 assert(UnprivilegedAccess !=
AS_public &&
"public access not weeded out");
1328 if (UnprivilegedAccess !=
AS_none) {
1329 switch (
HasAccess(S, EC, NamingClass, UnprivilegedAccess, Entity)) {
1345 AccessTarget::SavedInstanceContext _ = Entity.saveInstanceContext();
1351 if (Entity.isMemberAccess()) {
1355 const CXXRecordDecl *DeclaringClass = Entity.getDeclaringClass();
1358 switch (
HasAccess(S, EC, DeclaringClass, FinalAccess, Entity)) {
1366 Entity.suppressInstanceContext();
1372 if (DeclaringClass == NamingClass)
1378 assert(Entity.getDeclaringClass() != NamingClass);
1386 assert(Path->
Access <= UnprivilegedAccess &&
1387 "access along best path worse than direct?");
1394 const EffectiveContext &EC,
1396 const AccessTarget &Entity) {
1397 assert(EC.isDependent() &&
"delaying non-dependent access");
1399 assert(DC->isDependentContext() &&
"delaying non-dependent access");
1402 Entity.isMemberAccess(),
1404 Entity.getTargetDecl(),
1405 Entity.getNamingClass(),
1406 Entity.getBaseObjectType(),
1412 const EffectiveContext &EC,
1414 AccessTarget &Entity) {
1415 assert(Entity.getAccess() !=
AS_public &&
"called for public access!");
1426 if (!Entity.isQuiet())
1435 llvm_unreachable(
"invalid access result");
1439 AccessTarget &Entity) {
1466 llvm_unreachable(
"invalid access result");
1478 }
else if (
FunctionDecl *FN = dyn_cast<FunctionDecl>(D)) {
1480 }
else if (
TemplateDecl *TD = dyn_cast<TemplateDecl>(D)) {
1481 DC = cast<DeclContext>(TD->getTemplatedDecl());
1484 EffectiveContext EC(DC);
1499 if (!NamingD)
return;
1502 if (!TargetD)
return;
1506 NamedDecl *TargetDecl = cast<NamedDecl>(TargetD);
1508 if (!BaseObjectType.isNull()) {
1509 BaseObjectType = SubstType(BaseObjectType, TemplateArgs, Loc,
1511 if (BaseObjectType.isNull())
return;
1514 AccessTarget Entity(Context,
1515 AccessTarget::Member,
1522 AccessTarget Entity(Context,
1524 cast<CXXRecordDecl>(TargetD),
1525 cast<CXXRecordDecl>(NamingD),
1534 if (!getLangOpts().AccessControl ||
1539 AccessTarget Entity(Context, AccessTarget::Member, E->
getNamingClass(),
1550 if (!getLangOpts().AccessControl ||
1558 AccessTarget Entity(Context, AccessTarget::Member, E->
getNamingClass(),
1571 if (access ==
AS_public || !getLangOpts().AccessControl)
return true;
1573 AccessTarget entity(Context, AccessTarget::Member, decl->
getParent(),
1577 entity.setDiag(PDiag());
1582 case AR_dependent: llvm_unreachable(
"dependent for =delete computation");
1583 case AR_delayed: llvm_unreachable(
"cannot delay =delete computation");
1585 llvm_unreachable(
"bad access result");
1592 if (!getLangOpts().AccessControl)
1603 AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
1606 Entity.setDiag(PDiag);
1616 bool IsCopyBindingRefToTemp) {
1623 PD = PDiag(IsCopyBindingRefToTemp
1624 ? diag::ext_rvalue_to_reference_access_ctor
1625 : diag::err_access_ctor);
1630 PD = PDiag(diag::err_access_base_ctor);
1637 PD = PDiag(diag::err_access_field_ctor);
1638 PD << Field->
getType() << getSpecialMember(Constructor);
1644 PD = PDiag(diag::err_access_lambda_capture);
1645 PD << VarName << Entity.
getType() << getSpecialMember(Constructor);
1651 return CheckConstructorAccess(UseLoc, Constructor, Found, Entity, PD);
1660 if (!getLangOpts().AccessControl ||
1677 ObjectClass = cast<CXXConstructorDecl>(CurContext)->getParent();
1678 }
else if (
auto *Shadow =
1679 dyn_cast<ConstructorUsingShadowDecl>(Found.
getDecl())) {
1684 ObjectClass = NamingClass;
1687 AccessTarget AccessEntity(
1688 Context, AccessTarget::Member, NamingClass,
1691 AccessEntity.setDiag(PD);
1702 if (!getLangOpts().AccessControl ||
1707 AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
1710 Entity.setDiag(diag::err_access)
1720 if (!getLangOpts().AccessControl ||
1725 AccessTarget Entity(Context, AccessTarget::Member, NamingClass,
1737 if (!getLangOpts().AccessControl ||
1744 AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
1746 Entity.setDiag(diag::err_access)
1761 if (!getLangOpts().AccessControl || access ==
AS_public)
1766 AccessTarget entity(Context, AccessTarget::Member,
1770 entity.setDiag(diag::err_access_friend_function)
1776 EffectiveContext EC(CurContext);
1782 llvm_unreachable(
"invalid access result");
1787 if (!getLangOpts().AccessControl ||
1795 AccessTarget Entity(Context, AccessTarget::Member, NamingClass, Found,
1797 Entity.setDiag(diag::err_access)
1815 bool ForceUnprivileged) {
1816 if (!ForceCheck && !getLangOpts().AccessControl)
1824 DerivedD = cast<CXXRecordDecl>(Derived->
getAs<
RecordType>()->getDecl());
1826 AccessTarget Entity(Context, AccessTarget::Base, BaseD, DerivedD,
1829 Entity.setDiag(DiagID) << Derived << Base;
1831 if (ForceUnprivileged) {
1833 AccessLoc, Entity)) {
1838 llvm_unreachable(
"unexpected result from CheckEffectiveAccess");
1845 assert(getLangOpts().AccessControl
1846 &&
"performing access check without access control");
1847 assert(R.
getNamingClass() &&
"performing access check without naming class");
1854 Entity.setDiag(diag::err_access);
1873 QualType qType = Class->getTypeForDecl()->getCanonicalTypeInternal();
1880 EffectiveContext EC(CurContext);
1884 if (
ObjCIvarDecl *Ivar = dyn_cast<ObjCIvarDecl>(Target)) {
1894 ClassOfMethodDecl = MD->getClassInterface();
1897 = dyn_cast<ObjCImplDecl>(FD->getLexicalDeclContext())) {
1899 = dyn_cast<ObjCImplementationDecl>(Impl))
1900 ClassOfMethodDecl = IMPD->getClassInterface();
1902 = dyn_cast<ObjCCategoryImplDecl>(Impl))
1903 ClassOfMethodDecl = CatImplClass->getClassInterface();
1908 if (!ClassOfMethodDecl)
1919 return Ivar->getContainingInterface()->
isSuperClassOf(ClassOfMethodDecl);
CXXRecordDecl * getNamingClass() const
Retrieve the naming class of this lookup.
Defines the clang::ASTContext interface.
static const Decl * getCanonicalDecl(const Decl *D)
Represents a function declaration or definition.
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
AccessSpecifier getAccess() const
static void DelayDependentAccess(Sema &S, const EffectiveContext &EC, SourceLocation Loc, const AccessTarget &Entity)
static AccessResult MatchesFriend(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *Friend)
QualType getBaseObjectType() const
Returns the base object type associated with this lookup; important for [class.protected].
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
NamedDecl * getDecl() const
SourceLocation getAccessLoc() const
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
A container of type source information.
The entity being initialized is a base member subobject.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
Represents a C++ constructor within a class.
std::list< CXXBasePath >::iterator paths_iterator
const PartialDiagnostic & getDiagnostic() const
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
void HandleDependentAccessCheck(const DependentDiagnostic &DD, const MultiLevelTemplateArgumentList &TemplateArgs)
Represents a variable declaration or definition.
const T * getAs() const
Member-template getAs<specific type>'.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
void CheckLookupAccess(const LookupResult &R)
Checks access to all the declarations in the given result set.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isInvalidDecl() const
EntityKind getKind() const
Determine the kind of initialization.
bool hasDefinition() const
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
Defines the clang::Expr interface and subclasses for C++ expressions.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
AccessResult CheckFriendAccess(NamedDecl *D)
Checks access to the target of a friend declaration.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
static AccessResult IsAccessible(Sema &S, const EffectiveContext &EC, AccessTarget &Entity)
Determines whether the accessed entity is accessible.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool isInheritedVirtualBase() const
Return whether the base is an inherited virtual base.
Represents a member of a struct/union/class.
AccessedEntity & getAccessData()
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
The iterator over UnresolvedSets.
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
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 GetFriendKind(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *Class)
static AccessResult IsDerivedFromInclusive(const CXXRecordDecl *Derived, const CXXRecordDecl *Target)
Checks whether one class is derived from another, inclusively.
StringRef getCapturedVarName() const
For a lambda capture, return the capture's name.
FunctionTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
Represents the results of name lookup.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
bool isSpecialMemberAccessibleForDeletion(CXXMethodDecl *decl, AccessSpecifier access, QualType objectType)
Is the given special member function accessible for the purposes of deciding whether to define a spec...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
The entity being initialized is a non-static data member subobject.
bool isLambda() const
Determine whether this class describes a lambda function object.
AccessResult
A copy of Sema's enum without AR_delayed.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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)...
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, DeclAccessPair FoundDecl, const InitializedEntity &Entity, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
const LangOptions & getLangOpts() const
Represents an ObjC class declaration.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getMemberLoc() const
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, DeclAccessPair FoundDecl)
Perform access-control checking on a previously-unresolved member access which has now been resolved ...
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
Sema - This implements semantic analysis and AST building for C.
CXXRecordDecl * getNamingClass() const
Gets the naming class of this lookup, if any.
Expr - This represents one expression.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '...
A declaration being accessed, together with information about how it was accessed.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ destructor within a class.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
bool isFileContext() const
DeclContext * getDeclContext()
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
PartialDiagnostic::StorageAllocator & getDiagAllocator()
DeclContext * getParent()
getParent - Returns the containing DeclContext.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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 bool MightInstantiateTo(const CXXRecordDecl *From, const CXXRecordDecl *To)
Checks whether one class might instantiate to the other.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
RecordDecl * getDecl() const
static AccessResult CheckEffectiveAccess(Sema &S, const EffectiveContext &EC, SourceLocation Loc, AccessTarget &Entity)
Checks access to an entity from the given effective context.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
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...
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SourceLocation getNameLoc() const
Gets the location of the name.
Encodes a location in the source.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isAccessToMember() const
Represents the declaration of a struct/union/class/enum.
bool IsSimplyAccessible(NamedDecl *decl, DeclContext *Ctx)
Checks access to Target from the given class.
Represents a static or instance method of a struct/union/class.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
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...
NamedDecl * getAccessNamingClass() const
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, NamedDecl *PrevMemberDecl, AccessSpecifier LexicalAS)
SetMemberAccessSpecifier - Set the access specifier of a member.
AccessSpecifier getAccess() const
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
DeclarationNameInfo getNameInfo() const
The injected class name of a C++ class template or class template partial specialization.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed...
Defines various enumerations that describe declaration and type specifiers.
A POD class for pairing a NamedDecl* with an access specifier.
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
Base class for declarations which introduce a typedef-name.
static CXXRecordDecl * FindDeclaringClass(NamedDecl *D)
QualType getType() const
Retrieve type being initialized.
Dataflow Directional Tag Classes.
static Sema::AccessResult CheckAccess(Sema &S, SourceLocation Loc, AccessTarget &Entity)
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.).
static void DiagnoseBadAccess(Sema &S, SourceLocation Loc, const EffectiveContext &EC, AccessTarget &Entity)
AccessSpecifier getAccess() const
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
DeclarationName - The name of a declaration.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
OverloadExpr * Expression
QualType getAccessBaseObjectType() const
friend_range friends() const
CXXRecordDecl * getNamingClass() const
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
A dependently-generated diagnostic.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static DependentDiagnostic * Create(ASTContext &Context, DeclContext *Parent, AccessNonce _, SourceLocation Loc, bool IsMemberAccess, AccessSpecifier AS, NamedDecl *TargetDecl, CXXRecordDecl *NamingClass, QualType BaseObjectType, const PartialDiagnostic &PDiag)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this template.
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
Represents a base class of a C++ class.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
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.
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
ObjCIvarDecl - Represents an ObjC instance variable.
NamedDecl * getAccessTarget() const
The entity being initialized is the field that captures a variable in a lambda.
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, DeclAccessPair FoundDecl)
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 CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Declaration of a class template.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
AccessSpecifier Access
The access along this inheritance path.
static void DiagnoseAccessPath(Sema &S, const EffectiveContext &EC, AccessTarget &entity)
Diagnose the path which caused the given declaration or base class to become inaccessible.
std::string getQualifiedNameAsString() const
__DEVICE__ int max(int __a, int __b)
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...
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
The initialization is being done by a delegating constructor.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, DeclAccessPair FoundDecl)
A trivial tuple used to represent a source range.
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
This represents a decl that may have a name.
void setAccess(AccessSpecifier AS)
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
SourceLocation getNameLoc() const
Gets the location of the identifier.
Describes an entity that is being initialized.
SourceLocation getBegin() const
static AccessResult HasAccess(Sema &S, const EffectiveContext &EC, const CXXRecordDecl *NamingClass, AccessSpecifier Access, const AccessTarget &Target)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool isUnsupportedFriend() const
Determines if this friend kind is unsupported.
QualType getBaseType() const
Declaration of a template function.
static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity)
SourceLocation getLocation() const
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
QualType getType() const
Retrieves the type of the base class.