Skip to content
Prev Previous commit
Next Next commit
Fix access specifiers for some declarations
  • Loading branch information
Endilll committed Feb 22, 2024
commit 90df977a1d938df1f310af58bf3d9f787da6d6b9
41 changes: 21 additions & 20 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ class Sema final {
/// CurContext - This is the current declaration context of parsing.
DeclContext *CurContext;

protected:
friend class Parser;
friend class InitializationSequence;
friend class ASTReader;
Expand Down Expand Up @@ -3524,8 +3525,6 @@ class Sema final {
bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old);
bool IsRedefinitionInModule(const NamedDecl *New, const NamedDecl *Old) const;

static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);

bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const;

/// If it's a file scoped decl that must warn if not used, keep track
Expand Down Expand Up @@ -3674,6 +3673,8 @@ class Sema final {
/// it looks like the user is trying to modify the shadowing declaration.
llvm::DenseMap<const NamedDecl *, const NamedDecl *> ShadowingDecls;

static bool mightHaveNonExternalLinkage(const DeclaratorDecl *FD);

///@}

//
Expand Down Expand Up @@ -7796,24 +7797,6 @@ class Sema final {

bool isModuleVisible(const Module *M, bool ModulePrivate = false);

/// Determine whether two declarations should be linked together, given that
/// the old declaration might not be visible and the new declaration might
/// not have external linkage.
bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
const NamedDecl *New) {
if (isVisible(Old))
return true;
// See comment in below overload for why it's safe to compute the linkage
// of the new declaration here.
if (New->isExternallyDeclarable()) {
assert(Old->isExternallyDeclarable() &&
"should not have found a non-externally-declarable previous decl");
return true;
}
return false;
}
bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);

/// Determine whether any declaration of an entity is visible.
bool
hasVisibleDeclaration(const NamedDecl *D,
Expand Down Expand Up @@ -7971,6 +7954,24 @@ class Sema final {

bool isAcceptableSlow(const NamedDecl *D, AcceptableKind Kind);

/// Determine whether two declarations should be linked together, given that
/// the old declaration might not be visible and the new declaration might
/// not have external linkage.
bool shouldLinkPossiblyHiddenDecl(const NamedDecl *Old,
const NamedDecl *New) {
if (isVisible(Old))
return true;
// See comment in below overload for why it's safe to compute the linkage
// of the new declaration here.
if (New->isExternallyDeclarable()) {
assert(Old->isExternallyDeclarable() &&
"should not have found a non-externally-declarable previous decl");
return true;
}
return false;
}
bool shouldLinkPossiblyHiddenDecl(LookupResult &Old, const NamedDecl *New);

///@}

//
Expand Down