mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ClangImporter: don't import clang SPI attributes by default
This commit is contained in:
@@ -740,6 +740,9 @@ namespace swift {
|
|||||||
/// When set, don't look for or load overlays.
|
/// When set, don't look for or load overlays.
|
||||||
bool DisableOverlayModules = false;
|
bool DisableOverlayModules = false;
|
||||||
|
|
||||||
|
/// When set, import SPI_AVAILABLE symbols with Swift SPI attribtues.
|
||||||
|
bool EnableClangSPI = false;
|
||||||
|
|
||||||
/// When set, don't enforce warnings with -Werror.
|
/// When set, don't enforce warnings with -Werror.
|
||||||
bool DebuggerSupport = false;
|
bool DebuggerSupport = false;
|
||||||
|
|
||||||
@@ -767,7 +770,8 @@ namespace swift {
|
|||||||
DetailedPreprocessingRecord,
|
DetailedPreprocessingRecord,
|
||||||
ImportForwardDeclarations,
|
ImportForwardDeclarations,
|
||||||
DisableSwiftBridgeAttr,
|
DisableSwiftBridgeAttr,
|
||||||
DisableOverlayModules);
|
DisableOverlayModules,
|
||||||
|
EnableClangSPI);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,10 @@ def disable_testable_attr_requires_testable_module :
|
|||||||
Flag<["-"], "disable-testable-attr-requires-testable-module">,
|
Flag<["-"], "disable-testable-attr-requires-testable-module">,
|
||||||
HelpText<"Disable checking of @testable">;
|
HelpText<"Disable checking of @testable">;
|
||||||
|
|
||||||
|
def enable_clang_spi :
|
||||||
|
Flag<["-"], "enable-clang-spi">,
|
||||||
|
HelpText<"Import Clang SPIs as Swift SPIs">;
|
||||||
|
|
||||||
def enable_target_os_checking :
|
def enable_target_os_checking :
|
||||||
Flag<["-"], "enable-target-os-checking">,
|
Flag<["-"], "enable-target-os-checking">,
|
||||||
HelpText<"Enable checking the target OS of serialized modules">;
|
HelpText<"Enable checking the target OS of serialized modules">;
|
||||||
|
|||||||
@@ -2197,6 +2197,7 @@ ClangImporter::Implementation::Implementation(
|
|||||||
DisableSwiftBridgeAttr(ctx.ClangImporterOpts.DisableSwiftBridgeAttr),
|
DisableSwiftBridgeAttr(ctx.ClangImporterOpts.DisableSwiftBridgeAttr),
|
||||||
BridgingHeaderExplicitlyRequested(!ctx.ClangImporterOpts.BridgingHeader.empty()),
|
BridgingHeaderExplicitlyRequested(!ctx.ClangImporterOpts.BridgingHeader.empty()),
|
||||||
DisableOverlayModules(ctx.ClangImporterOpts.DisableOverlayModules),
|
DisableOverlayModules(ctx.ClangImporterOpts.DisableOverlayModules),
|
||||||
|
EnableClangSPI(ctx.ClangImporterOpts.EnableClangSPI),
|
||||||
IsReadingBridgingPCH(false),
|
IsReadingBridgingPCH(false),
|
||||||
CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
|
CurrentVersion(ImportNameVersion::fromOptions(ctx.LangOpts)),
|
||||||
BridgingHeaderLookupTable(new SwiftLookupTable(nullptr)),
|
BridgingHeaderLookupTable(new SwiftLookupTable(nullptr)),
|
||||||
|
|||||||
@@ -8711,15 +8711,17 @@ void ClangImporter::Implementation::importAttributes(
|
|||||||
AnyUnavailable = true;
|
AnyUnavailable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isUsingMacroName(getClangASTContext().getSourceManager(),
|
if (EnableClangSPI) {
|
||||||
avail->getLoc(), "SPI_AVAILABLE") ||
|
if (isUsingMacroName(getClangASTContext().getSourceManager(),
|
||||||
isUsingMacroName(getClangASTContext().getSourceManager(),
|
avail->getLoc(), "SPI_AVAILABLE") ||
|
||||||
avail->getLoc(), "__SPI_AVAILABLE")) {
|
isUsingMacroName(getClangASTContext().getSourceManager(),
|
||||||
// The decl has been marked as SPI in the header by using the SPI macro,
|
avail->getLoc(), "__SPI_AVAILABLE")) {
|
||||||
// thus we add the SPI attribute to it with a default group name.
|
// The decl has been marked as SPI in the header by using the SPI macro,
|
||||||
MappedDecl->getAttrs().add(SPIAccessControlAttr::create(SwiftContext,
|
// thus we add the SPI attribute to it with a default group name.
|
||||||
SourceLoc(), SourceRange(),
|
MappedDecl->getAttrs().add(SPIAccessControlAttr::create(SwiftContext,
|
||||||
SwiftContext.getIdentifier(CLANG_MODULE_DEFUALT_SPI_GROUP_NAME)));
|
SourceLoc(), SourceRange(),
|
||||||
|
SwiftContext.getIdentifier(CLANG_MODULE_DEFUALT_SPI_GROUP_NAME)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef message = avail->getMessage();
|
StringRef message = avail->getMessage();
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ public:
|
|||||||
const bool DisableSwiftBridgeAttr;
|
const bool DisableSwiftBridgeAttr;
|
||||||
const bool BridgingHeaderExplicitlyRequested;
|
const bool BridgingHeaderExplicitlyRequested;
|
||||||
const bool DisableOverlayModules;
|
const bool DisableOverlayModules;
|
||||||
|
const bool EnableClangSPI;
|
||||||
|
|
||||||
bool IsReadingBridgingPCH;
|
bool IsReadingBridgingPCH;
|
||||||
llvm::SmallVector<clang::serialization::SubmoduleID, 2> PCHImportedSubmodules;
|
llvm::SmallVector<clang::serialization::SubmoduleID, 2> PCHImportedSubmodules;
|
||||||
|
|||||||
@@ -1052,6 +1052,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
|
|||||||
|
|
||||||
Opts.DisableOverlayModules |= Args.hasArg(OPT_emit_imported_modules);
|
Opts.DisableOverlayModules |= Args.hasArg(OPT_emit_imported_modules);
|
||||||
|
|
||||||
|
Opts.EnableClangSPI |= Args.hasArg(OPT_enable_clang_spi);
|
||||||
|
|
||||||
Opts.ExtraArgsOnly |= Args.hasArg(OPT_extra_clang_options_only);
|
Opts.ExtraArgsOnly |= Args.hasArg(OPT_extra_clang_options_only);
|
||||||
|
|
||||||
if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) {
|
if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// REQUIRES: OS=macosx
|
// REQUIRES: OS=macosx
|
||||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -verify -DNOT_UNDERLYING
|
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -enable-clang-spi -verify -DNOT_UNDERLYING
|
||||||
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -verify
|
// RUN: %target-swift-frontend -typecheck %s -F %S/Inputs/frameworks -module-name SPIContainer -import-underlying-module -enable-clang-spi -verify
|
||||||
|
|
||||||
#if NOT_UNDERLYING
|
#if NOT_UNDERLYING
|
||||||
import SPIContainer
|
import SPIContainer
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// REQUIRES: OS=macosx
|
// REQUIRES: OS=macosx
|
||||||
// RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/frameworks/SPIContainer.framework/Headers/SPIContainer.h -verify
|
// RUN: %target-swift-frontend -typecheck %s -import-objc-header %S/Inputs/frameworks/SPIContainer.framework/Headers/SPIContainer.h -enable-clang-spi -verify
|
||||||
|
|
||||||
|
|
||||||
@_spi(a) public let a: SPIInterface1
|
@_spi(a) public let a: SPIInterface1
|
||||||
|
|||||||
Reference in New Issue
Block a user