Skip to content

Commit

Permalink
clang::Linkage values lost their Linkage suffixes in clang 18
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Nov 20, 2023
1 parent 975a5de commit 77a7af2
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions subdoc/lib/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,28 @@ bool path_contains_namespace(clang::Decl* decl, Namespace n) noexcept {
}

bool path_is_private(clang::NamedDecl* decl) noexcept {
// clang::Linkage members were renamed in 18.
#if CLANG_VERSION_MAJOR >= 18
auto ModuleLinkage = clang::Linkage::Module;
auto ExternalLinkage = clang::Linkage::External;
auto NoneLinkage = clang::Linkage::None;
#else
auto ModuleLinkage = clang::Linkage::ModuleLinkage;
auto ExternalLinkage = clang::Linkage::ExternalLinkage;
auto NoneLinkage = clang::Linkage::NoLinkage;
#endif

clang::Linkage linkage = decl->getLinkageInternal();
if (linkage != clang::Linkage::ModuleLinkage &&
linkage != clang::Linkage::ExternalLinkage) {
// NoLinkage describes itself as "can only be referred to from within its
// scope".
if (linkage != ModuleLinkage &&
linkage != ExternalLinkage) {
// Linkage::None describes itself as "can only be referred to from within
// its scope".
//
// However `namespace a { using b::S; }` brings S into `a` in a way that is
// usable publicly from other scopes. So we accept `NoLinkage` for
// usable publicly from other scopes. So we accept `Linkage::None` for
// `UsingDecl` and `UsingEnumDecl` (aka `BaseUsingDecl`). Similar for
// type aliases.
if (!(linkage == clang::Linkage::NoLinkage &&
if (!(linkage == NoneLinkage &&
(clang::isa<clang::BaseUsingDecl>(decl) ||
clang::isa<clang::TypedefNameDecl>(decl)))) {
return true;
Expand Down

0 comments on commit 77a7af2

Please sign in to comment.