Lines Matching full:access

1 //===---- SemaAccess.cpp - C++ Access Control -------------------*- C++ -*-===//
9 // This file provides Sema routines for C++ access control semantics.
41 // Use the lexical access specifier.
46 // C++ [class.access.spec]p3: When a member is redeclared its access
86 // class template, but for access purposes behaves like the constructor
99 // C++11 [class.access.nest]p1:
100 // A nested class is a member and as such has the same access
102 // C++11 [class.access]p2:
103 // A member of a class can also access all the names to which
104 // the class has access. A local class of a member function
105 // may access the same names that the member function itself
106 // may access.
145 /// doing access-control without privileges.
180 AccessSpecifier Access)
182 Access) {
616 /// A helper class for checking for a friend which will grant access
654 /// the final class in the path would have access in that class.
668 // base will not have any access in classes derived from Cur.
710 /// NamingClass would have some natural access in P, which implicitly
715 /// would have to have some natural access in P, it says the actual
716 /// target has to have some natural access in P, which opens up the
722 /// access a forbidden base class's members by directly subclassing
724 /// - It also makes access substantially harder to compute because it
752 AccessSpecifier Access,
757 if (Access == AS_public) return AR_accessible;
758 assert(Access == AS_private || Access == AS_protected);
769 if (Access == AS_private) {
778 assert(Access == AS_protected);
786 // An additional access check beyond those described earlier in
787 // [class.access] is applied when a non-static data member or
789 // class. As described earlier, access to a protected member is
791 // some class C. If the access is to form a pointer to member,
819 // pointer-to-member expression nor in a member access: when
856 // access if the access occurs in a friend or member of some class P
858 // access in P. The 'member' aspect is easy to handle because P
865 if (Access == AS_protected && Target.isInstanceMember()) {
894 /// C++0x [class.access.base]p5:
906 /// C++0x [class.access.base]p4:
922 /// access equivalent to the member's access. Therefore we need only
927 /// B_i). For i in 1..n, we will calculate ACAB(i), the access to the
929 /// Access(a, b) = (* access on the base specifier from a to b *)
939 /// let AccessToBase = Merge(Access(B_i, B_{i+1}), ACAB(i+1)) in
944 /// \param FinalAccess the access of the "final step", or AS_public if
964 assert(FinalAccess != AS_none && "forbidden access after declaring class");
968 // Derive the friend-modified access along each path.
1009 // Note that we modify the path's Access field to the
1010 // friend-modified access.
1011 if (BestPath == nullptr || PathAccess < BestPath->Access) {
1013 BestPath->Access = PathAccess;
1016 if (BestPath->Access == AS_public)
1023 assert((!BestPath || BestPath->Access != AS_public) &&
1034 /// Given that an entity has protected natural access, check whether
1035 /// access might be denied because of the protected member access
1060 // access.
1064 // access here would grant us access overall.
1082 assert(InstanceContext && "diagnosing dependent access");
1112 /// We are unable to access a given declaration due to its direct
1113 /// access control; diagnose that.
1180 // The natural access so far.
1204 llvm_unreachable("cannot diagnose dependent access");
1210 assert(path.Access != AS_public);
1224 // If the access to this base is worse than the access we have to
1240 llvm_unreachable("cannot diagnose dependent access");
1243 // If this was private inheritance, but we don't have access to
1252 // If we don't have a constraining base, the access failure must be
1343 assert(UnprivilegedAccess != AS_public && "public access not weeded out");
1345 // Before we try to recalculate access paths, try to white-list
1348 // common forms of privileged access.
1353 // *have* to delay immediately here: we can do the full access
1358 // access.
1384 // equivalent to checking the access of a notional public
1401 // Append the declaration's access if applicable.
1407 assert(Path->Access <= UnprivilegedAccess &&
1408 "access along best path worse than direct?");
1409 if (Path->Access == AS_public)
1418 assert(EC.isDependent() && "delaying non-dependent access");
1420 assert(DC->isDependentContext() && "delaying non-dependent access");
1421 DependentDiagnostic::Create(S.Context, DC, DependentDiagnostic::Access,
1431 /// Checks access to an entity from the given effective context.
1436 assert(Entity.getAccess() != AS_public && "called for public access!");
1456 llvm_unreachable("invalid access result");
1461 // If the access path is public, it's accessible everywhere.
1466 // access control checking, because our effective context might be
1507 llvm_unreachable("invalid access result");
1511 // Access control for names used in the declarations of functions
1539 AccessSpecifier Access = DD.getAccess();
1561 DeclAccessPair::make(TargetDecl, Access),
1570 Access);
1628 llvm_unreachable("bad access result");
1638 // There's never a path involved when checking implicit destructor access.
1639 AccessSpecifier Access = Dtor->getAccess();
1640 if (Access == AS_public)
1647 DeclAccessPair::make(Dtor, Access),
1832 // inheritance path modifying access.
1833 AccessSpecifier access = target->getAccess();
1835 if (!getLangOpts().AccessControl || access == AS_public)
1842 DeclAccessPair::make(target, access),
1856 llvm_unreachable("invalid access result");
1887 if (Path.Access == AS_public)
1895 Path.Access);
1913 && "performing access check without access control");
1914 assert(R.getNamingClass() && "performing access check without naming class");
1933 // The unprivileged access is AS_none as we don't know how the member was
1934 // accessed, which is described by the access in DeclAccessPair.
1935 // `IsAccessible` will examine the actual access of Target (i.e.
1936 // Decl->getAccess()) when calculating the access.