Skip to content

Commit 051e803

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 09dadbf commit 051e803

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

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

388+
if isFrontendArgSupported(.emitClangHeaderMinAccess) {
389+
try commandLine.appendLast(.emitClangHeaderMinAccess, from: &parsedOptions)
390+
}
391+
388392
if isFrontendArgSupported(.enableBuiltinModule) {
389393
try commandLine.appendLast(.enableBuiltinModule, from: &parsedOptions)
390394
}

Sources/SwiftOptions/Options.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ extension Option {
349349
public static let emitAssembly: Option = Option("-emit-assembly", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Emit assembly file(s) (-S)", group: .modes)
350350
public static let emitAst: Option = Option("-emit-ast", .flag, alias: Option.dumpAst, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild])
351351
public static let emitBc: Option = Option("-emit-bc", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Emit LLVM BC file(s)", group: .modes)
352-
public static let emitClangHeaderMinAccess: Option = Option("-emit-clang-header-min-access", .separate, attributes: [.frontend, .noInteractive, .argumentIsPath, .cacheInvariant], metaVar: "<access-level>", helpText: "The minimum access level of declarations to include in the emitted header.>")
352+
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")
353353
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")
354354
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>")
355355
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>")

Tests/SwiftDriverTests/SwiftDriverTests.swift

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

7986+
func testEmitClangHeaderMinAccess() throws {
7987+
VirtualPath.resetTemporaryFileStore()
7988+
var driver = try Driver(args: [
7989+
"swiftc", "-emit-clang-header-path", "path/to/header", "-emit-clang-header-min-access", "public", "-typecheck", "test.swift"
7990+
])
7991+
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
7992+
XCTAssertEqual(jobs.count, 2)
7993+
try XCTAssertJobInvocationMatches(jobs[0], .flag("-emit-clang-header-min-access"), .flag("public"))
7994+
}
7995+
79867996
func testGccToolchainFlags() throws {
79877997
VirtualPath.resetTemporaryFileStore()
79887998
var driver = try Driver(args: [

0 commit comments

Comments
 (0)