Skip to content

Commit 45ac397

Browse files
committed
[cxx-interop] Add driver support for -emit-clang-header-min-access
This is a counterpart to swiftlang/swift#84816. rdar://159211965
1 parent e7e3390 commit 45ac397

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ extension Driver {
378378
try commandLine.appendLast(.clangBuildSessionFile, from: &parsedOptions)
379379
}
380380

381+
try commandLine.appendLast(.emitClangHeaderMinAccess, from: &parsedOptions)
382+
381383
if isFrontendArgSupported(.enableBuiltinModule) {
382384
try commandLine.appendLast(.enableBuiltinModule, from: &parsedOptions)
383385
}

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ extension Option {
341341
public static let emitBc: Option = Option("-emit-bc", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Emit LLVM BC file(s)", group: .modes)
342342
public static let emitClangHeaderNonmodularIncludes: Option = Option("-emit-clang-header-nonmodular-includes", .flag, attributes: [.frontend, .noInteractive, .supplementaryOutput], helpText: "Augment emitted Objective-C header with textual imports for every included modular import")
343343
public static let emitClangHeaderPath: Option = Option("-emit-clang-header-path", .separate, alias: Option.emitObjcHeaderPath, attributes: [.frontend, .noInteractive, .argumentIsPath, .supplementaryOutput, .cacheInvariant], helpText: "Emit an Objective-C and C++ header file to <path>")
344+
public static let emitClangHeaderMinAccess: Option = Option("-emit-clang-header-min-access", .separate, attributes: [.frontend, .noInteractive, .cacheInvariant], metaVar: "<access-level>", helpText: "The minimum access level of declarations to include in the emitted header")
344345
public static let emitConstValuesPath: Option = Option("-emit-const-values-path", .separate, attributes: [.frontend, .noInteractive, .argumentIsPath, .supplementaryOutput, .cacheInvariant], metaVar: "<path>", helpText: "Emit the extracted compile-time known values to <path>")
345346
public static let emitConstValues: Option = Option("-emit-const-values", .flag, attributes: [.noInteractive, .supplementaryOutput])
346347
public static let emitDependenciesPath: Option = Option("-emit-dependencies-path", .separate, attributes: [.frontend, .noDriver, .cacheInvariant], metaVar: "<path>", helpText: "Output basic Make-compatible dependencies file to <path>")
@@ -1311,6 +1312,7 @@ extension Option {
13111312
Option.emitBc,
13121313
Option.emitClangHeaderNonmodularIncludes,
13131314
Option.emitClangHeaderPath,
1315+
Option.emitClangHeaderMinAccess,
13141316
Option.emitConstValuesPath,
13151317
Option.emitConstValues,
13161318
Option.emitDependenciesPath,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7639,6 +7639,16 @@ final class SwiftDriverTests: XCTestCase {
76397639
try XCTAssertJobInvocationMatches(jobs[0], .flag("-emit-objc-header-path"), toPathOption("path/to/header"))
76407640
}
76417641

7642+
func testEmitClangHeaderMinAccess() throws {
7643+
VirtualPath.resetTemporaryFileStore()
7644+
var driver = try Driver(args: [
7645+
"swiftc", "-emit-clang-header-path", "path/to/header", "-emit-clang-header-min-access", "public", "-typecheck", "test.swift"
7646+
])
7647+
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
7648+
XCTAssertEqual(jobs.count, 2)
7649+
try XCTAssertJobInvocationMatches(jobs[0], .flag("-emit-clang-header-min-access"), .flag("public"))
7650+
}
7651+
76427652
func testGccToolchainFlags() throws {
76437653
VirtualPath.resetTemporaryFileStore()
76447654
var driver = try Driver(args: [

0 commit comments

Comments
 (0)