Skip to content

[Frontend] Avoid doing whole-module work under primary-file typecheck #27153

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
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
10 changes: 6 additions & 4 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,12 @@ static bool performCompile(CompilerInstance &Instance,
if (Action == FrontendOptions::ActionType::Typecheck) {
if (emitIndexData(Invocation, Instance))
return true;
if (emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance,
Invocation,
moduleIsPublic)) {
return true;
if (opts.InputsAndOutputs.isWholeModule()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to explain why this test is here in a comment.

if (emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance,
Invocation,
moduleIsPublic)) {
return true;
}
}
return false;
}
Expand Down
35 changes: 35 additions & 0 deletions test/Index/Store/driver-index-with-auxiliary-outputs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: %empty-directory(%t)

// This test is very deliberately *not* indexing the current file; we need to
// make sure the frontend job doesn't try to emit the auxiliary outputs based
// on the non-indexed files. (This is how Xcode currently constructs -index-file
// invocations: take a normal build command and add extra arguments to it.)
// RUN: %target-build-swift -index-file -index-file-path %S/Inputs/SwiftModuleA.swift %S/Inputs/SwiftModuleA.swift %s -index-store-path %t/idx -module-name driver_index -emit-objc-header-path %t/out.h -emit-module-interface-path %t/out.swiftinterface

// RUN: test ! -f %t/out.h
// RUN: test ! -f %t/out.swiftinterface
// RUN: c-index-test core -print-unit %t/idx | %FileCheck %s

// CHECK-LABEL: module-name: driver_index
// CHECK: DEPEND START
// CHECK-NOT: Record |
// CHECK: Record | user | {{.+}}SwiftModuleA.swift
// CHECK-NOT: Record |
// CHECK: DEPEND END

#if _runtime(_ObjC)

// Do a stronger test here involving checking @objc
import ObjectiveC

public class PossiblyObjC: NSObject {
@objc public init(x: Int) {}
}

#else // _runtime(_ObjC)

public class Boring {
init()
}

#endif // _runtime(_ObjC)