Skip to content

Commit b5fdd40

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 b5fdd40

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

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

381+
if isFrontendArgSupported(.emitClangHeaderMinAccess) {
382+
try commandLine.appendLast(.emitClangHeaderMinAccess, from: &parsedOptions)
383+
}
384+
381385
if isFrontendArgSupported(.enableBuiltinModule) {
382386
try commandLine.appendLast(.enableBuiltinModule, from: &parsedOptions)
383387
}

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ extension Option {
339339
public static let emitAssembly: Option = Option("-emit-assembly", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Emit assembly file(s) (-S)", group: .modes)
340340
public static let emitAst: Option = Option("-emit-ast", .flag, alias: Option.dumpAst, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild])
341341
public static let emitBc: Option = Option("-emit-bc", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Emit LLVM BC file(s)", group: .modes)
342+
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")
342343
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")
343344
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>")
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>")
@@ -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)