Lines Matching +full:class +full:- +full:d
1 //===---- SemaAccess.cpp - C++ Access Control -------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
42 MemberDecl->setAccess(LexicalAS); in SetMemberAccessSpecifier()
46 // C++ [class.access.spec]p3: When a member is redeclared its access in SetMemberAccessSpecifier()
48 if (LexicalAS != AS_none && LexicalAS != PrevMemberDecl->getAccess()) { in SetMemberAccessSpecifier()
49 Diag(MemberDecl->getLocation(), in SetMemberAccessSpecifier()
52 Diag(PrevMemberDecl->getLocation(), diag::note_previous_access_declaration) in SetMemberAccessSpecifier()
53 << PrevMemberDecl << PrevMemberDecl->getAccess(); in SetMemberAccessSpecifier()
55 MemberDecl->setAccess(LexicalAS); in SetMemberAccessSpecifier()
59 MemberDecl->setAccess(PrevMemberDecl->getAccess()); in SetMemberAccessSpecifier()
63 static CXXRecordDecl *FindDeclaringClass(NamedDecl *D) { in FindDeclaringClass() argument
64 DeclContext *DC = D->getDeclContext(); in FindDeclaringClass()
69 DC = cast<EnumDecl>(DC)->getDeclContext(); in FindDeclaringClass()
72 while (DeclaringClass->isAnonymousStructOrUnion()) in FindDeclaringClass()
73 DeclaringClass = cast<CXXRecordDecl>(DeclaringClass->getDeclContext()); in FindDeclaringClass()
83 Dependent(DC->isDependentContext()) { in EffectiveContext()
86 // class template, but for access purposes behaves like the constructor in EffectiveContext()
89 if (DGD->isImplicit()) { in EffectiveContext()
90 DC = DGD->getCorrespondingConstructor(); in EffectiveContext()
94 DC = cast<DeclContext>(DGD->getDeducedTemplate()->getTemplatedDecl()); in EffectiveContext()
99 // C++11 [class.access.nest]p1: in EffectiveContext()
100 // A nested class is a member and as such has the same access in EffectiveContext()
102 // C++11 [class.access]p2: in EffectiveContext()
103 // A member of a class can also access all the names to which in EffectiveContext()
104 // the class has access. A local class of a member function in EffectiveContext()
108 // Technically it says nothing about the local classes of non-member in EffectiveContext()
120 Records.push_back(Record->getCanonicalDecl()); in EffectiveContext()
121 DC = Record->getDeclContext(); in EffectiveContext()
124 Functions.push_back(Function->getCanonicalDecl()); in EffectiveContext()
125 if (Function->getFriendObjectKind()) in EffectiveContext()
126 DC = Function->getLexicalDeclContext(); in EffectiveContext()
128 DC = Function->getDeclContext(); in EffectiveContext()
129 } else if (DC->isFileContext()) { in EffectiveContext()
132 DC = DC->getParent(); in EffectiveContext()
140 R = R->getCanonicalDecl(); in includesClass()
145 /// doing access-control without privileges.
187 return (isMemberAccess() && getTargetDecl()->isCXXInstanceMember()); in isInstanceMember()
194 class SavedInstanceContext {
212 Target->HasInstanceContext = Has; in ~SavedInstanceContext()
238 InstanceContext = (IC ? cast<CXXRecordDecl>(IC)->getCanonicalDecl() in resolveInstanceContext()
247 /// The "effective" naming class is the canonical non-anonymous
248 /// class containing the actual naming class.
251 while (namingClass->isAnonymousStructOrUnion()) in getEffectiveNamingClass()
252 namingClass = cast<CXXRecordDecl>(namingClass->getParent()); in getEffectiveNamingClass()
253 return namingClass->getCanonicalDecl(); in getEffectiveNamingClass()
260 getTargetDecl()->isCXXInstanceMember()); in initialize()
268 DeclaringClass = DeclaringClass->getCanonicalDecl(); in initialize()
279 /// Checks whether one class might instantiate to the other.
283 if (From->getDeclName() != To->getDeclName()) in MightInstantiateTo()
286 const DeclContext *FromDC = From->getDeclContext()->getPrimaryContext(); in MightInstantiateTo()
287 const DeclContext *ToDC = To->getDeclContext()->getPrimaryContext(); in MightInstantiateTo()
289 if (FromDC->isFileContext() || ToDC->isFileContext()) return false; in MightInstantiateTo()
295 /// Checks whether one class is derived from another, inclusively.
302 assert(Derived->getCanonicalDecl() == Derived); in IsDerivedFromInclusive()
303 assert(Target->getCanonicalDecl() == Target); in IsDerivedFromInclusive()
307 bool CheckDependent = Derived->isDependentContext(); in IsDerivedFromInclusive()
315 if (Derived->isDependentContext() && !Derived->hasDefinition() && in IsDerivedFromInclusive()
316 !Derived->isLambda()) in IsDerivedFromInclusive()
319 for (const auto &I : Derived->bases()) { in IsDerivedFromInclusive()
323 if (const RecordType *RT = T->getAs<RecordType>()) { in IsDerivedFromInclusive()
324 RD = cast<CXXRecordDecl>(RT->getDecl()); in IsDerivedFromInclusive()
326 = T->getAs<InjectedClassNameType>()) { in IsDerivedFromInclusive()
327 RD = IT->getDecl(); in IsDerivedFromInclusive()
329 assert(T->isDependentType() && "non-dependent base wasn't a record?"); in IsDerivedFromInclusive()
334 RD = RD->getCanonicalDecl(); in IsDerivedFromInclusive()
356 assert(!Friend->isDependentContext() && in MightInstantiateTo()
359 if (!Context->isDependentContext()) in MightInstantiateTo()
362 if (Friend->isFileContext()) in MightInstantiateTo()
375 if (!Friend->isDependentType() && !Context->isDependentType()) in MightInstantiateTo()
385 if (Context->getDeclName() != Friend->getDeclName()) in MightInstantiateTo()
389 Context->getDeclContext(), in MightInstantiateTo()
390 Friend->getDeclContext())) in MightInstantiateTo()
394 = S.Context.getCanonicalType(Friend->getType()) in MightInstantiateTo()
395 ->getAs<FunctionProtoType>(); in MightInstantiateTo()
397 = S.Context.getCanonicalType(Context->getType()) in MightInstantiateTo()
398 ->getAs<FunctionProtoType>(); in MightInstantiateTo()
405 if (FriendTy->getNumParams() != ContextTy->getNumParams()) in MightInstantiateTo()
408 if (!MightInstantiateTo(S, ContextTy->getReturnType(), in MightInstantiateTo()
409 FriendTy->getReturnType())) in MightInstantiateTo()
412 for (unsigned I = 0, E = FriendTy->getNumParams(); I != E; ++I) in MightInstantiateTo()
413 if (!MightInstantiateTo(S, ContextTy->getParamType(I), in MightInstantiateTo()
414 FriendTy->getParamType(I))) in MightInstantiateTo()
424 Context->getTemplatedDecl(), in MightInstantiateTo()
425 Friend->getTemplatedDecl()); in MightInstantiateTo()
447 if (const RecordType *RT = Friend->getAs<RecordType>()) in MatchesFriend()
448 return MatchesFriend(S, EC, cast<CXXRecordDecl>(RT->getDecl())); in MatchesFriend()
451 if (Friend->isDependentType()) in MatchesFriend()
457 /// Determines whether the given friend class template matches
464 // Check whether the friend is the template of a class in the in MatchesFriend()
470 // Figure out whether the current class has a template: in MatchesFriend()
476 ->getSpecializedTemplate(); in MatchesFriend()
480 CTD = Record->getDescribedClassTemplate(); in MatchesFriend()
485 if (Friend == CTD->getCanonicalDecl()) in MatchesFriend()
494 if (CTD->getDeclName() != Friend->getDeclName()) in MatchesFriend()
497 // If the class's context can't instantiate to the friend's in MatchesFriend()
499 if (!MightInstantiateTo(S, CTD->getDeclContext(), in MatchesFriend()
500 Friend->getDeclContext())) in MatchesFriend()
541 FunctionTemplateDecl *FTD = (*I)->getPrimaryTemplate(); in MatchesFriend()
543 FTD = (*I)->getDescribedFunctionTemplate(); in MatchesFriend()
547 FTD = FTD->getCanonicalDecl(); in MatchesFriend()
566 if (FriendD->isInvalidDecl() || FriendD->isUnsupportedFriend()) in MatchesFriend()
569 if (TypeSourceInfo *T = FriendD->getFriendType()) in MatchesFriend()
570 return MatchesFriend(S, EC, T->getType()->getCanonicalTypeUnqualified()); in MatchesFriend()
573 = cast<NamedDecl>(FriendD->getFriendDecl()->getCanonicalDecl()); in MatchesFriend()
592 const CXXRecordDecl *Class) { in GetFriendKind() argument
596 for (auto *Friend : Class->friends()) { in GetFriendKind()
616 /// A helper class for checking for a friend which will grant access
625 /// The path down to the current base class.
632 CheckDependent(InstanceContext->isDependentContext() || in ProtectedFriendContext()
633 NamingClass->isDependentContext()), in ProtectedFriendContext()
650 /// Perform a search starting at the given class.
652 /// PrivateDepth is the index of the last (least derived) class
654 /// the final class in the path would have access in that class.
656 // If we ever reach the naming class, check the current path for in findFriendship()
658 // won't find the naming class there again. in findFriendship()
666 for (const auto &I : Cur->bases()) { in findFriendship()
671 BasePrivateDepth = CurPath.size() - 1; in findFriendship()
676 if (const RecordType *RT = T->getAs<RecordType>()) { in findFriendship()
677 RD = cast<CXXRecordDecl>(RT->getDecl()); in findFriendship()
679 = T->getAs<InjectedClassNameType>()) { in findFriendship()
680 RD = IT->getDecl(); in findFriendship()
682 assert(T->isDependentType() && "non-dependent base wasn't a record?"); in findFriendship()
689 if (findFriendship(RD->getCanonicalDecl(), BasePrivateDepth)) in findFriendship()
705 /// Search for a class P that EC is a friend of, under the constraint
721 /// - Most importantly, it breaks encapsulation because you can
722 /// access a forbidden base class's members by directly subclassing
724 /// - It also makes access substantially harder to compute because it
725 /// breaks the hill-climbing algorithm: knowing that the target is
726 /// accessible in some base class would no longer let you change
727 /// the question solely to whether the base class is accessible,
735 InstanceContext->getCanonicalDecl() == InstanceContext); in GetProtectedFriendKind()
736 assert(NamingClass->getCanonicalDecl() == NamingClass); in GetProtectedFriendKind()
754 assert(NamingClass->getCanonicalDecl() == NamingClass && in HasAccess()
785 // C++ [class.protected]p1: in HasAccess()
787 // [class.access] is applied when a non-static data member or in HasAccess()
788 // non-static member function is a protected member of its naming in HasAccess()
789 // class. As described earlier, access to a protected member is in HasAccess()
791 // some class C. If the access is to form a pointer to member, in HasAccess()
792 // the nested-name-specifier shall name C or a class derived from in HasAccess()
794 // expression. In this case, the class of the object expression in HasAccess()
795 // shall be C or a class derived from C. in HasAccess()
799 // In this part of the code, 'C' is just our context class ECRecord. in HasAccess()
806 // If it's an instance member, use the pointer-to-member rule in HasAccess()
807 // that the naming class has to be derived from the effective in HasAccess()
810 // Emulate a MSVC bug where the creation of pointer-to-member in HasAccess()
811 // to protected member of base class is allowed but only from in HasAccess()
815 if (MD->isStatic()) return AR_accessible; in HasAccess()
819 // pointer-to-member expression nor in a member access: when in HasAccess()
822 // same naming-class restriction here. in HasAccess()
824 // protected-member restriction when we retroactively convert in HasAccess()
835 // Otherwise, this context class tells us nothing; on to the next. in HasAccess()
856 // access if the access occurs in a friend or member of some class P in HasAccess()
859 // would necessarily be one of the effective-context records, and we in HasAccess()
862 // *unless* the [class.protected] restriction applies. If it does, in HasAccess()
863 // however, we should ignore whether the naming class is a friend, in HasAccess()
891 /// Finds the best path from the naming class to the declaring class,
894 /// C++0x [class.access.base]p5:
895 /// A member m is accessible at the point R when named in class N if
898 /// friend of class N, or
900 /// friend of class N, or in a member or friend of a class P
903 /// [M4] there exists a base class B of N that is accessible at R, and
904 /// m is accessible at R when named in class B.
906 /// C++0x [class.access.base]p4:
907 /// A base class B of N is accessible at R, if
909 /// [B2] R occurs in a member or friend of class N, and an invented public
911 /// [B3] R occurs in a member or friend of a class P derived from N, and an
914 /// [B4] there exists a class S such that B is a base class of S accessible
915 /// at R and S is a base class of N accessible at R.
920 /// First, we note that M1-4 are equivalent to B1-4 if the member is
921 /// treated as a notional base of its declaring class with inheritance
923 /// ask whether a class B is accessible from a class N in context R.
926 /// B_1 = N, B_n = B, and for all i, B_{i+1} is a direct base class of
957 bool isDerived = Derived->isDerivedFrom(const_cast<CXXRecordDecl*>(Base), in FindBestPath()
959 assert(isDerived && "derived class not actually derived from base"); in FindBestPath()
964 assert(FinalAccess != AS_none && "forbidden access after declaring class"); in FindBestPath()
968 // Derive the friend-modified access along each path. in FindBestPath()
975 CXXBasePath::iterator I = PI->end(), E = PI->begin(); in FindBestPath()
977 --I; in FindBestPath()
981 // If the declaration is a private member of a base class, there in FindBestPath()
989 const CXXRecordDecl *NC = I->Class->getCanonicalDecl(); in FindBestPath()
991 AccessSpecifier BaseAccess = I->Base->getAccessSpecifier(); in FindBestPath()
1010 // friend-modified access. in FindBestPath()
1011 if (BestPath == nullptr || PathAccess < BestPath->Access) { in FindBestPath()
1013 BestPath->Access = PathAccess; in FindBestPath()
1015 // Short-circuit if we found a public path. in FindBestPath()
1016 if (BestPath->Access == AS_public) in FindBestPath()
1023 assert((!BestPath || BestPath->Access != AS_public) && in FindBestPath()
1058 // The effective context is a subclass of the declaring class. in TryDiagnoseProtectedAccess()
1059 // Check whether the [class.protected] restriction is limiting in TryDiagnoseProtectedAccess()
1066 NamedDecl *D = Target.getTargetDecl(); in TryDiagnoseProtectedAccess() local
1068 // If we don't have an instance context, [class.protected] says the in TryDiagnoseProtectedAccess()
1069 // naming class has to equal the context class. in TryDiagnoseProtectedAccess()
1076 S.Diag(D->getLocation(), diag::note_access_protected_restricted_noobject) in TryDiagnoseProtectedAccess()
1094 if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D) || in TryDiagnoseProtectedAccess()
1095 (isa<FunctionTemplateDecl>(D) && in TryDiagnoseProtectedAccess()
1097 cast<FunctionTemplateDecl>(D)->getTemplatedDecl()))) { in TryDiagnoseProtectedAccess()
1098 return S.Diag(D->getLocation(), in TryDiagnoseProtectedAccess()
1100 << isa<CXXDestructorDecl>(D->getAsFunction()); in TryDiagnoseProtectedAccess()
1104 return S.Diag(D->getLocation(), in TryDiagnoseProtectedAccess()
1118 NamedDecl *D = entity.getTargetDecl(); in diagnoseBadDirectAccess() local
1120 if (D->getAccess() == AS_protected && in diagnoseBadDirectAccess()
1125 while (D->isOutOfLine()) { in diagnoseBadDirectAccess()
1127 if (VarDecl *VD = dyn_cast<VarDecl>(D)) in diagnoseBadDirectAccess()
1128 PrevDecl = VD->getPreviousDecl(); in diagnoseBadDirectAccess()
1129 else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) in diagnoseBadDirectAccess()
1130 PrevDecl = FD->getPreviousDecl(); in diagnoseBadDirectAccess()
1131 else if (TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(D)) in diagnoseBadDirectAccess()
1132 PrevDecl = TND->getPreviousDecl(); in diagnoseBadDirectAccess()
1133 else if (TagDecl *TD = dyn_cast<TagDecl>(D)) { in diagnoseBadDirectAccess()
1134 if (isa<RecordDecl>(D) && cast<RecordDecl>(D)->isInjectedClassName()) in diagnoseBadDirectAccess()
1136 PrevDecl = TD->getPreviousDecl(); in diagnoseBadDirectAccess()
1139 D = PrevDecl; in diagnoseBadDirectAccess()
1142 CXXRecordDecl *DeclaringClass = FindDeclaringClass(D); in diagnoseBadDirectAccess()
1144 if (D->getDeclContext() == DeclaringClass) in diagnoseBadDirectAccess()
1145 ImmediateChild = D; in diagnoseBadDirectAccess()
1147 DeclContext *DC = D->getDeclContext(); in diagnoseBadDirectAccess()
1148 while (DC->getParent() != DeclaringClass) in diagnoseBadDirectAccess()
1149 DC = DC->getParent(); in diagnoseBadDirectAccess()
1156 for (const auto *I : DeclaringClass->decls()) { in diagnoseBadDirectAccess()
1164 S.Diag(D->getLocation(), diag::note_access_natural) in diagnoseBadDirectAccess()
1165 << (unsigned) (D->getAccess() == AS_protected) in diagnoseBadDirectAccess()
1169 /// Diagnose the path which caused the given declaration or base class
1183 // Check whether we have special rights to the declaring class. in DiagnoseAccessPath()
1185 NamedDecl *D = entity.getTargetDecl(); in DiagnoseAccessPath() local
1186 accessSoFar = D->getAccess(); in DiagnoseAccessPath()
1191 // class, then we must be constrained by the path. in DiagnoseAccessPath()
1215 --i; in DiagnoseAccessPath()
1219 // Is the entity accessible when named in the deriving class, as in DiagnoseAccessPath()
1221 const CXXRecordDecl *derivingClass = i->Class->getCanonicalDecl(); in DiagnoseAccessPath()
1222 const CXXBaseSpecifier *base = i->Base; in DiagnoseAccessPath()
1226 AccessSpecifier baseAccess = base->getAccessSpecifier(); in DiagnoseAccessPath()
1244 // the deriving class, we're done. in DiagnoseAccessPath()
1268 const CXXBaseSpecifier *base = constrainingBase->Base; in DiagnoseAccessPath()
1270 S.Diag(base->getSourceRange().getBegin(), diagnostic) in DiagnoseAccessPath()
1271 << base->getSourceRange() in DiagnoseAccessPath()
1272 << (base->getAccessSpecifier() == AS_protected) in DiagnoseAccessPath()
1273 << (base->getAccessSpecifierAsWritten() == AS_none); in DiagnoseAccessPath()
1276 S.Diag(entity.getTargetDecl()->getLocation(), in DiagnoseAccessPath()
1285 NamedDecl *D = (Entity.isMemberAccess() ? Entity.getTargetDecl() : nullptr); in DiagnoseBadAccess() local
1289 << (D ? D->getDeclName() : DeclarationName()) in DiagnoseBadAccess()
1300 /// class A {
1304 /// class B : public A {
1308 /// class C : public B {
1320 if (UsingDecl *UD = dyn_cast<UsingDecl>(Shadow->getIntroducer())) { in IsMicrosoftUsingDeclarationAccessBug()
1321 const NamedDecl *OrigDecl = Entity.getTargetDecl()->getUnderlyingDecl(); in IsMicrosoftUsingDeclarationAccessBug()
1322 if (Entity.getTargetDecl()->getAccess() == AS_private && in IsMicrosoftUsingDeclarationAccessBug()
1323 (OrigDecl->getAccess() == AS_public || in IsMicrosoftUsingDeclarationAccessBug()
1324 OrigDecl->getAccess() == AS_protected)) { in IsMicrosoftUsingDeclarationAccessBug()
1326 << UD->getQualifiedNameAsString() in IsMicrosoftUsingDeclarationAccessBug()
1327 << OrigDecl->getQualifiedNameAsString(); in IsMicrosoftUsingDeclarationAccessBug()
1339 // Determine the actual naming class. in IsAccessible()
1345 // Before we try to recalculate access paths, try to white-list in IsAccessible()
1355 // class will make the declaration accessible non-dependently. in IsAccessible()
1369 // member is a base class of its declaring class. in IsAccessible()
1374 // in its declaring class. in IsAccessible()
1378 FinalAccess = Target->getAccess(); in IsAccessible()
1381 // Target is accessible at EC when named in its declaring class. in IsAccessible()
1382 // We can now hill-climb and simply check whether the declaring in IsAccessible()
1383 // class is accessible as a base of the naming class. This is in IsAccessible()
1407 assert(Path->Access <= UnprivilegedAccess && in IsAccessible()
1409 if (Path->Access == AS_public) in IsAccessible()
1418 assert(EC.isDependent() && "delaying non-dependent access"); in DelayDependentAccess()
1420 assert(DC->isDependentContext() && "delaying non-dependent access"); in DelayDependentAccess()
1475 // class D { in CheckAccess()
1476 // class E{ in CheckAccess()
1477 // class F{}; in CheckAccess()
1478 // friend void foo(D::E::F& q); in CheckAccess()
1480 // friend void foo(D::E::F& q); in CheckAccess()
1483 // [class.friend]p9: in CheckAccess()
1485 // class containing the friend declaration. The meaning of the friend in CheckAccess()
1487 // private, protected, or public ([class.mem]) portion of the class in CheckAccess()
1488 // member-specification. in CheckAccess()
1492 IsFriendDeclaration = TS->isFriendScope(); in CheckAccess()
1493 TS = TS->getParent(); in CheckAccess()
1510 void Sema::HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *D) { in HandleDelayedAccessCheck() argument
1516 DeclContext *DC = D->getDeclContext(); in HandleDelayedAccessCheck()
1517 if (D->isLocalExternDecl()) { in HandleDelayedAccessCheck()
1518 DC = D->getLexicalDeclContext(); in HandleDelayedAccessCheck()
1519 } else if (FunctionDecl *FN = dyn_cast<FunctionDecl>(D)) { in HandleDelayedAccessCheck()
1521 } else if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D)) { in HandleDelayedAccessCheck()
1522 if (isa<DeclContext>(TD->getTemplatedDecl())) in HandleDelayedAccessCheck()
1523 DC = cast<DeclContext>(TD->getTemplatedDecl()); in HandleDelayedAccessCheck()
1524 } else if (auto *RD = dyn_cast<RequiresExprBodyDecl>(D)) { in HandleDelayedAccessCheck()
1579 !E->getNamingClass() || in CheckUnresolvedLookupAccess()
1583 AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(), in CheckUnresolvedLookupAccess()
1585 Entity.setDiag(diag::err_access) << E->getSourceRange(); in CheckUnresolvedLookupAccess()
1587 return CheckAccess(*this, E->getNameLoc(), Entity); in CheckUnresolvedLookupAccess()
1596 QualType BaseType = E->getBaseType(); in CheckUnresolvedMemberAccess()
1597 if (E->isArrow()) in CheckUnresolvedMemberAccess()
1598 BaseType = BaseType->castAs<PointerType>()->getPointeeType(); in CheckUnresolvedMemberAccess()
1600 AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(), in CheckUnresolvedMemberAccess()
1602 Entity.setDiag(diag::err_access) << E->getSourceRange(); in CheckUnresolvedMemberAccess()
1604 return CheckAccess(*this, E->getMemberLoc(), Entity); in CheckUnresolvedMemberAccess()
1639 AccessSpecifier Access = Dtor->getAccess(); in CheckDestructorAccess()
1643 CXXRecordDecl *NamingClass = Dtor->getParent(); in CheckDestructorAccess()
1674 << Entity.getBaseSpecifier()->getType() in CheckConstructorAccess()
1682 PD << Field->getType() in CheckConstructorAccess()
1709 CXXRecordDecl *NamingClass = Constructor->getParent(); in CheckConstructorAccess()
1711 // Initializing a base sub-object is an instance method call on an in CheckConstructorAccess()
1712 // object of the derived class. Otherwise, we have an instance method in CheckConstructorAccess()
1715 // FIXME: If we have a parent, we're initializing the base class subobject in CheckConstructorAccess()
1716 // in aggregate initialization. It's not clear whether the object class in CheckConstructorAccess()
1717 // should be the base class or the derived class in that case. in CheckConstructorAccess()
1722 ObjectClass = cast<CXXConstructorDecl>(CurContext)->getParent(); in CheckConstructorAccess()
1726 // the object class is the derived class, not the base class. in CheckConstructorAccess()
1727 ObjectClass = Shadow->getParent(); in CheckConstructorAccess()
1796 const RecordType *RT = ObjectExpr->getType()->castAs<RecordType>(); in CheckMemberOperatorAccess()
1797 CXXRecordDecl *NamingClass = cast<CXXRecordDecl>(RT->getDecl()); in CheckMemberOperatorAccess()
1800 ObjectExpr->getType()); in CheckMemberOperatorAccess()
1801 Entity.setDiag(diag::err_access) << ObjectExpr->getSourceRange() << Range; in CheckMemberOperatorAccess()
1811 OpLoc, ObjectExpr, ArgExpr ? ArgExpr->getSourceRange() : SourceRange(), in CheckMemberOperatorAccess()
1821 R = SourceRange(ArgExprs.front()->getBeginLoc(), in CheckMemberOperatorAccess()
1822 ArgExprs.back()->getEndLoc()); in CheckMemberOperatorAccess()
1829 assert(isa<CXXMethodDecl>(target->getAsFunction())); in CheckFriendAccess()
1833 AccessSpecifier access = target->getAccess(); in CheckFriendAccess()
1838 CXXMethodDecl *method = cast<CXXMethodDecl>(target->getAsFunction()); in CheckFriendAccess()
1841 cast<CXXRecordDecl>(target->getDeclContext()), in CheckFriendAccess()
1845 << (method->getQualifier() ? method->getQualifierLoc().getSourceRange() in CheckFriendAccess()
1846 : method->getNameInfo().getSourceRange()); in CheckFriendAccess()
1848 // We need to bypass delayed-diagnostics because we might be called in CheckFriendAccess()
1851 switch (CheckEffectiveAccess(*this, EC, target->getLocation(), entity)) { in CheckFriendAccess()
1867 CXXRecordDecl *NamingClass = Ovl->getNamingClass(); in CheckAddressOfMemberAccess()
1872 << Ovl->getSourceRange(); in CheckAddressOfMemberAccess()
1874 return CheckAccess(*this, Ovl->getNameLoc(), Entity); in CheckAddressOfMemberAccess()
1891 BaseD = cast<CXXRecordDecl>(Base->castAs<RecordType>()->getDecl()); in CheckBaseClassAccess()
1892 DerivedD = cast<CXXRecordDecl>(Derived->castAs<RecordType>()->getDecl()); in CheckBaseClassAccess()
1914 assert(R.getNamingClass() && "performing access check without naming class"); in CheckLookupAccess()
1930 if (Target->isCXXClassMember() && NamingClass) { in IsSimplyAccessible()
1936 // Decl->getAccess()) when calculating the access. in IsSimplyAccessible()
1945 if (Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Public || in IsSimplyAccessible()
1946 Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Package) in IsSimplyAccessible()
1949 // If we are inside a class or category implementation, determine the in IsSimplyAccessible()
1953 ClassOfMethodDecl = MD->getClassInterface(); in IsSimplyAccessible()
1956 = dyn_cast<ObjCImplDecl>(FD->getLexicalDeclContext())) { in IsSimplyAccessible()
1959 ClassOfMethodDecl = IMPD->getClassInterface(); in IsSimplyAccessible()
1962 ClassOfMethodDecl = CatImplClass->getClassInterface(); in IsSimplyAccessible()
1971 if (declaresSameEntity(ClassOfMethodDecl, Ivar->getContainingInterface())) in IsSimplyAccessible()
1975 if (Ivar->getCanonicalAccessControl() == ObjCIvarDecl::Private) in IsSimplyAccessible()
1978 return Ivar->getContainingInterface()->isSuperClassOf(ClassOfMethodDecl); in IsSimplyAccessible()