diff --git a/lib/vast/Dialect/Core/Linkage.cpp b/lib/vast/Dialect/Core/Linkage.cpp index c6926b3a5f..b968c2454a 100644 --- a/lib/vast/Dialect/Core/Linkage.cpp +++ b/lib/vast/Dialect/Core/Linkage.cpp @@ -162,6 +162,17 @@ namespace vast::core { return GlobalLinkageKind::InternalLinkage; } + if (const auto *fn = decl->getAsFunction()) { + if (fn->isMultiVersion() && linkage == clang::GVA_AvailableExternally) { + return GlobalLinkageKind::LinkOnceAnyLinkage; + } + if (!fn->isThisDeclarationADefinition() + && decl->hasAttr< clang::WeakAttr >()) + { + return GlobalLinkageKind::ExternalWeakLinkage; + } + } + if (decl->hasAttr< clang::WeakAttr >()) { if (is_constant) return GlobalLinkageKind::WeakODRLinkage; @@ -169,12 +180,6 @@ namespace vast::core { return GlobalLinkageKind::WeakAnyLinkage; } - if (const auto *fn = decl->getAsFunction()) { - if (fn->isMultiVersion() && linkage == clang::GVA_AvailableExternally) { - return GlobalLinkageKind::LinkOnceAnyLinkage; - } - } - // We are guaranteed to have a strong definition somewhere else, // so we can use available_externally linkage. if (linkage == clang::GVA_AvailableExternally) {