Lines Matching defs:Access
1 //===---- SemaAccess.cpp - C++ Access Control -------------------*- C++ -*-===//
9 // This file provides Sema routines for C++ access control semantics.
36 /// SetMemberAccessSpecifier - Set the access specifier of a member.
37 /// Returns true on error (when the previous member decl access specifier
38 /// is different from the new member decl access specifier).
43 // Use the lexical access specifier.
48 // C++ [class.access.spec]p3: When a member is redeclared its access
88 // class template, but for access purposes behaves like the constructor
101 // C++11 [class.access.nest]p1:
102 // A nested class is a member and as such has the same access
104 // C++11 [class.access]p2:
105 // A member of a class can also access all the names to which
106 // the class has access. A local class of a member function
107 // may access the same names that the member function itself
108 // may access.
147 /// doing access-control without privileges.
182 AccessSpecifier Access)
184 Access) {
608 /// A helper class for checking for a friend which will grant access
646 /// the final class in the path would have access in that class.
660 // base will not have any access in classes derived from Cur.
702 /// NamingClass would have some natural access in P, which implicitly
707 /// would have to have some natural access in P, it says the actual
708 /// target has to have some natural access in P, which opens up the
714 /// access a forbidden base class's members by directly subclassing
716 /// - It also makes access substantially harder to compute because it
744 AccessSpecifier Access,
749 if (Access == AS_public) return AR_accessible;
750 assert(Access == AS_private || Access == AS_protected);
761 if (Access == AS_private) {
770 assert(Access == AS_protected);
778 // An additional access check beyond those described earlier in
779 // [class.access] is applied when a non-static data member or
781 // class. As described earlier, access to a protected member is
783 // some class C. If the access is to form a pointer to member,
811 // pointer-to-member expression nor in a member access: when
848 // access if the access occurs in a friend or member of some class P
850 // access in P. The 'member' aspect is easy to handle because P
857 if (Access == AS_protected && Target.isInstanceMember()) {
886 /// C++0x [class.access.base]p5:
898 /// C++0x [class.access.base]p4:
914 /// access equivalent to the member's access. Therefore we need only
919 /// B_i). For i in 1..n, we will calculate ACAB(i), the access to the
921 /// Access(a, b) = (* access on the base specifier from a to b *)
931 /// let AccessToBase = Merge(Access(B_i, B_{i+1}), ACAB(i+1)) in
936 /// \param FinalAccess the access of the "final step", or AS_public if
956 assert(FinalAccess != AS_none && "forbidden access after declaring class");
960 // Derive the friend-modified access along each path.
1001 // Note that we modify the path's Access field to the
1002 // friend-modified access.
1003 if (BestPath == nullptr || PathAccess < BestPath->Access) {
1005 BestPath->Access = PathAccess;
1008 if (BestPath->Access == AS_public)
1015 assert((!BestPath || BestPath->Access != AS_public) &&
1026 /// Given that an entity has protected natural access, check whether
1027 /// access might be denied because of the protected member access
1052 // access.
1056 // access here would grant us access overall.
1074 assert(InstanceContext && "diagnosing dependent access");
1104 /// We are unable to access a given declaration due to its direct
1105 /// access control; diagnose that.
1172 // The natural access so far.
1196 llvm_unreachable("cannot diagnose dependent access");
1202 assert(path.Access != AS_public);
1216 // If the access to this base is worse than the access we have to
1232 llvm_unreachable("cannot diagnose dependent access");
1235 // If this was private inheritance, but we don't have access to
1244 // If we don't have a constraining base, the access failure must be
1334 assert(UnprivilegedAccess != AS_public && "public access not weeded out");
1336 // Before we try to recalculate access paths, try to white-list
1339 // common forms of privileged access.
1344 // *have* to delay immediately here: we can do the full access
1349 // access.
1375 // equivalent to checking the access of a notional public
1392 // Append the declaration's access if applicable.
1398 assert(Path->Access <= UnprivilegedAccess &&
1399 "access along best path worse than direct?");
1400 if (Path->Access == AS_public)
1409 assert(EC.isDependent() && "delaying non-dependent access");
1411 assert(DC->isDependentContext() && "delaying non-dependent access");
1412 DependentDiagnostic::Create(S.Context, DC, DependentDiagnostic::Access,
1422 /// Checks access to an entity from the given effective context.
1427 assert(Entity.getAccess() != AS_public && "called for public access!");
1447 llvm_unreachable("invalid access result");
1452 // If the access path is public, it's accessible everywhere.
1457 // access control checking, because our effective context might be
1478 llvm_unreachable("invalid access result");
1482 // Access control for names used in the declarations of functions
1508 AccessSpecifier Access = DD.getAccess();
1530 DeclAccessPair::make(TargetDecl, Access),
1539 Access);
1559 /// Perform access-control checking on a previously-unresolved member
1560 /// access which has now been resolved to a member.
1601 llvm_unreachable("bad access result");
1611 // There's never a path involved when checking implicit destructor access.
1612 AccessSpecifier Access = Dtor->getAccess();
1613 if (Access == AS_public)
1620 DeclAccessPair::make(Dtor, Access),
1627 /// Checks access to a constructor.
1670 /// Checks access to a constructor.
1712 /// Checks access to an overloaded operator new or delete.
1732 /// Checks access to a member.
1747 /// Checks implicit access to a member in a structured binding.
1763 /// Checks access to an overloaded member operator, including
1785 /// Checks access to the target of a friend declaration.
1790 // inheritance path modifying access.
1791 AccessSpecifier access = target->getAccess();
1793 if (!getLangOpts().AccessControl || access == AS_public)
1800 DeclAccessPair::make(target, access),
1814 llvm_unreachable("invalid access result");
1835 /// Checks access for a hierarchy conversion.
1837 /// \param ForceCheck true if this check should be performed even if access
1851 if (Path.Access == AS_public)
1859 Path.Access);
1875 /// Checks access to all the declarations in the given result set.
1878 && "performing access check without access control");
1879 assert(R.getNamingClass() && "performing access check without naming class");
1892 /// Checks access to Target from the given class. The check will take access
1893 /// specifiers into account, but no member access expressions and such.
1897 /// \param BaseType type of the left side of member access expression.
1898 /// \p BaseType and \p NamingClass are used for C++ access control.
1900 /// - lhs.target (member access without a qualifier):
1902 /// - lhs.X::target (member access with a qualifier):
1904 /// - X::target (qualified lookup without member access):
1915 // The unprivileged access is AS_none as we don't know how the member was
1916 // accessed, which is described by the access in DeclAccessPair.
1917 // `IsAccessible` will examine the actual access of Target (i.e.
1918 // Decl->getAccess()) when calculating the access.