Skip to content

Commit 1e4a388

Browse files
committed
Modify clang declaration weakly-imported query to use Swift's code-gen target triple
Similarly to how #70564 configures 'ClangImporter's 'CodeGenerator' using Swift's compilation target triple, we must use the versioned version of the 'isWeakImported' query to determine linkage for imported Clang symbols.
1 parent ee6decc commit 1e4a388

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

include/swift/AST/ClangModuleLoader.h

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class ClangModuleLoader : public ModuleLoader {
140140
/// (The implementing `ClangImporter` class maintains separate Target info
141141
/// for use by IRGen/CodeGen clients)
142142
virtual clang::TargetInfo &getModuleAvailabilityTarget() const = 0;
143+
virtual clang::TargetInfo &getTargetInfo() const = 0;
143144

144145
virtual clang::ASTContext &getClangASTContext() const = 0;
145146
virtual clang::Preprocessor &getClangPreprocessor() const = 0;

include/swift/ClangImporter/ClangImporter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ class ClangImporter final : public ClangModuleLoader {
570570
/// instead. To distinguish IRGen clients from module loading clients,
571571
/// `getModuleAvailabilityTarget` should be used instead by module-loading
572572
/// clients.
573-
clang::TargetInfo &getTargetInfo() const;
573+
clang::TargetInfo &getTargetInfo() const override;
574574
clang::CodeGenOptions &getCodeGenOpts() const;
575575

576576
std::string getClangModuleHash() const;

lib/AST/Decl.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575

7676
#include "clang/Basic/CharInfo.h"
7777
#include "clang/Basic/Module.h"
78+
#include "clang/Basic/TargetInfo.h"
7879
#include "clang/AST/Attr.h"
7980
#include "clang/AST/DeclObjC.h"
8081

@@ -1468,9 +1469,9 @@ AvailabilityRange Decl::getAvailabilityForLinkage() const {
14681469

14691470
bool Decl::isAlwaysWeakImported() const {
14701471
// For a Clang declaration, trust Clang.
1471-
if (auto clangDecl = getClangDecl()) {
1472-
return clangDecl->isWeakImported();
1473-
}
1472+
if (auto clangDecl = getClangDecl())
1473+
return clangDecl->isWeakImported(
1474+
getASTContext().LangOpts.getMinPlatformVersion());
14741475

14751476
if (getAttrs().hasAttribute<WeakLinkedAttr>())
14761477
return true;

lib/SIL/IR/SILFunction.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,8 @@ bool SILFunction::isWeakImported(ModuleDecl *module) const {
618618

619619
// For imported functions check the Clang declaration.
620620
if (ClangNodeOwner)
621-
return ClangNodeOwner->getClangDecl()->isWeakImported();
621+
return ClangNodeOwner->getClangDecl()->isWeakImported(
622+
getASTContext().LangOpts.getMinPlatformVersion());
622623

623624
// For native functions check a flag on the SILFunction
624625
// itself.

0 commit comments

Comments
 (0)