diff options
author | Erik Verbruggen <erikjv@me.com> | 2011-10-06 07:27:49 +0000 |
---|---|---|
committer | Erik Verbruggen <erikjv@me.com> | 2011-10-06 07:27:49 +0000 |
commit | d12059673dcef32bc2b6bae5321654d33863afe6 (patch) | |
tree | ab758c88fd4c47be76385950000fcd057c541c2f /lib/Sema/SemaAccess.cpp | |
parent | aed123ec3cc37e457fe20a6158fdadf8849ad916 (diff) |
Added CXAvailability_NotAccessible to indicate that a declaration is available, but not accessible from the current code completion context.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaAccess.cpp')
-rw-r--r-- | lib/Sema/SemaAccess.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Sema/SemaAccess.cpp b/lib/Sema/SemaAccess.cpp index a2d078b12c..14c8ebafe7 100644 --- a/lib/Sema/SemaAccess.cpp +++ b/lib/Sema/SemaAccess.cpp @@ -1641,6 +1641,27 @@ void Sema::CheckLookupAccess(const LookupResult &R) { } } +/// Checks access to Decl from the given class. The check will take access +/// specifiers into account, but no member access expressions and such. +/// +/// \param Decl the declaration to check if it can be accessed +/// \param Class the class/context from which to start the search +/// \return true if the Decl is accessible from the Class, false otherwise. +bool Sema::IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *Class) { + if (!Class) + return true; + + QualType qType = Class->getTypeForDecl()->getCanonicalTypeInternal(); + AccessTarget Entity(Context, AccessedEntity::Member, Class, + DeclAccessPair::make(Decl, Decl->getAccess()), + qType); + if (Entity.getAccess() == AS_public) + return true; + + EffectiveContext EC(CurContext); + return ::IsAccessible(*this, EC, Entity) != ::AR_inaccessible; +} + void Sema::ActOnStartSuppressingAccessChecks() { assert(!SuppressAccessChecking && "Tried to start access check suppression when already started."); |