-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[clang] Introduce SemaAccess
#92674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Endilll
wants to merge
6
commits into
llvm:main
Choose a base branch
from
Endilll:semaaccess
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[clang] Introduce SemaAccess
#92674
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6c33316
[clang] Introduce `SemaAccess`
Endilll 55757c3
Run clang-format
Endilll cb11cc6
Fix table of contents in `Sema`
Endilll b769ff3
Merge remote-tracking branch 'upstream/main' into semaaccess
Endilll 314c196
Add missing newline at the end of `SemaAccess.h`
Endilll 8acff4c
Merge remote-tracking branch 'upstream/main' into semaaccess
Endilll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
//===----- SemaAccess.h --------- C++ Access Control ----------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// \file | ||
/// This file declares routines for C++ access control semantics. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_SEMA_SEMAACCESS_H | ||
#define LLVM_CLANG_SEMA_SEMAACCESS_H | ||
|
||
#include "clang/AST/CXXInheritance.h" | ||
#include "clang/AST/Decl.h" | ||
#include "clang/AST/DeclAccessPair.h" | ||
#include "clang/AST/DeclCXX.h" | ||
#include "clang/AST/DependentDiagnostic.h" | ||
#include "clang/AST/Expr.h" | ||
#include "clang/AST/ExprCXX.h" | ||
#include "clang/AST/Type.h" | ||
#include "clang/Basic/LLVM.h" | ||
#include "clang/Basic/PartialDiagnostic.h" | ||
#include "clang/Basic/SourceLocation.h" | ||
#include "clang/Basic/Specifiers.h" | ||
#include "clang/Sema/DelayedDiagnostic.h" | ||
#include "clang/Sema/Initialization.h" | ||
#include "clang/Sema/SemaBase.h" | ||
|
||
namespace clang { | ||
class LookupResult; | ||
class MultiLevelTemplateArgumentList; | ||
|
||
class SemaAccess : public SemaBase { | ||
public: | ||
SemaAccess(Sema &S); | ||
|
||
enum AccessResult { | ||
AR_accessible, | ||
AR_inaccessible, | ||
AR_dependent, | ||
AR_delayed | ||
}; | ||
|
||
bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, | ||
NamedDecl *PrevMemberDecl, | ||
AccessSpecifier LexicalAS); | ||
|
||
AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, | ||
SourceRange PlacementRange, | ||
CXXRecordDecl *NamingClass, | ||
DeclAccessPair FoundDecl, | ||
bool Diagnose = true); | ||
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, | ||
DeclAccessPair FoundDecl, | ||
const InitializedEntity &Entity, | ||
bool IsCopyBindingRefToTemp = false); | ||
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, | ||
DeclAccessPair FoundDecl, | ||
const InitializedEntity &Entity, | ||
const PartialDiagnostic &PDiag); | ||
AccessResult CheckDestructorAccess(SourceLocation Loc, | ||
CXXDestructorDecl *Dtor, | ||
const PartialDiagnostic &PDiag, | ||
QualType objectType = QualType()); | ||
AccessResult CheckFriendAccess(NamedDecl *D); | ||
AccessResult CheckMemberAccess(SourceLocation UseLoc, | ||
CXXRecordDecl *NamingClass, | ||
DeclAccessPair Found); | ||
AccessResult | ||
CheckStructuredBindingMemberAccess(SourceLocation UseLoc, | ||
CXXRecordDecl *DecomposedClass, | ||
DeclAccessPair Field); | ||
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, | ||
const SourceRange &, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, | ||
Expr *ArgExpr, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, | ||
ArrayRef<Expr *> ArgExprs, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, | ||
DeclAccessPair FoundDecl); | ||
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, | ||
QualType Derived, const CXXBasePath &Path, | ||
unsigned DiagID, bool ForceCheck = false, | ||
bool ForceUnprivileged = false); | ||
void CheckLookupAccess(const LookupResult &R); | ||
bool IsSimplyAccessible(NamedDecl *Decl, CXXRecordDecl *NamingClass, | ||
QualType BaseType); | ||
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, | ||
DeclAccessPair Found, QualType ObjectType, | ||
SourceLocation Loc, | ||
const PartialDiagnostic &Diag); | ||
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, | ||
DeclAccessPair Found, QualType ObjectType); | ||
|
||
void HandleDependentAccessCheck( | ||
const DependentDiagnostic &DD, | ||
const MultiLevelTemplateArgumentList &TemplateArgs); | ||
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); | ||
}; | ||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_SEMA_SEMAACCESS_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.