Skip to content

[5.7] Add support for the new -index-ignore-clang-modules flag #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ extension Driver {
if !parsedOptions.contains(.indexIgnoreSystemModules) {
commandLine.appendFlag(.indexSystemModules)
}
try commandLine.appendLast(.indexIgnoreClangModules, from: &parsedOptions)
}

if parsedOptions.contains(.debugInfoStoreInvocation) ||
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftOptions/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ extension Option {
public static let indentWidth: Option = Option("-indent-width", .separate, attributes: [.noInteractive, .noBatch, .indent], metaVar: "<n>", helpText: "Number of characters to indent.", group: .codeFormatting)
public static let indexFilePath: Option = Option("-index-file-path", .separate, attributes: [.noInteractive, .doesNotAffectIncrementalBuild, .argumentIsPath], metaVar: "<path>", helpText: "Produce index data for file <path>")
public static let indexFile: Option = Option("-index-file", .flag, attributes: [.noInteractive, .doesNotAffectIncrementalBuild], helpText: "Produce index data for a source file", group: .modes)
public static let indexIgnoreClangModules: Option = Option("-index-ignore-clang-modules", .flag, attributes: [.frontend], helpText: "Avoid indexing clang modules (pcms)")
public static let indexIgnoreStdlib: Option = Option("-index-ignore-stdlib", .flag, attributes: [.helpHidden, .frontend, .noDriver], helpText: "Avoid emitting index data for the standard library.")
public static let indexIgnoreSystemModules: Option = Option("-index-ignore-system-modules", .flag, attributes: [.noInteractive], helpText: "Avoid indexing system modules")
public static let indexStorePath: Option = Option("-index-store-path", .separate, attributes: [.frontend, .argumentIsPath], metaVar: "<path>", helpText: "Store indexing data to <path>")
Expand Down Expand Up @@ -1079,6 +1080,7 @@ extension Option {
Option.indentWidth,
Option.indexFilePath,
Option.indexFile,
Option.indexIgnoreClangModules,
Option.indexIgnoreStdlib,
Option.indexIgnoreSystemModules,
Option.indexStorePath,
Expand Down
16 changes: 16 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,22 @@ final class SwiftDriverTests: XCTestCase {
}
}

func testIndexIgnoreClangModules() throws {
// Make sure `-index-ignore-clang-modules` isn't passed by default, only when explicitly given.
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-index-store-path", "/tmp/idx") { driver in
let jobs = try driver.planBuild()
let commandLine = jobs[0].commandLine
XCTAssertTrue(commandLine.contains(.flag("-index-store-path")))
XCTAssertFalse(commandLine.contains(.flag("-index-ignore-clang-modules")))
}
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-index-store-path", "/tmp/idx", "-index-ignore-clang-modules") { driver in
let jobs = try driver.planBuild()
let commandLine = jobs[0].commandLine
XCTAssertTrue(commandLine.contains(.flag("-index-store-path")))
XCTAssertTrue(commandLine.contains(.flag("-index-ignore-clang-modules")))
}
}

func testMultiThreadingOutputs() throws {
try assertDriverDiagnostics(args: "swiftc", "-c", "foo.swift", "bar.swift", "-o", "bar.ll", "-o", "foo.ll", "-num-threads", "2", "-whole-module-optimization") {
$1.expect(.error("cannot specify -o when generating multiple output files"))
Expand Down