Skip to content

Commit 9b8f7c3

Browse files
committed
[ClangImporter] Probe for a PCH when the header is missing
The default for `ProbePrecompiled` was changed in rebranch. Set it back to `true` to avoid breaking existing clients. Resolves rdar://106966024.
1 parent cd52979 commit 9b8f7c3

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,7 @@ std::unique_ptr<clang::CompilerInvocation> ClangImporter::createClangInvocation(
10511051
CIOpts.Diags = clangDiags;
10521052
CIOpts.RecoverOnError = false;
10531053
CIOpts.CC1Args = CC1Args;
1054+
CIOpts.ProbePrecompiled = true;
10541055
CI = clang::createInvocation(invocationArgs, std::move(CIOpts));
10551056
}
10561057

lib/IDETool/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ bool ide::initInvocationByClangArguments(ArrayRef<const char *> ArgList,
280280
// Create a new Clang compiler invocation.
281281
clang::CreateInvocationOptions CIOpts;
282282
CIOpts.Diags = ClangDiags;
283+
CIOpts.ProbePrecompiled = true;
283284
std::unique_ptr<clang::CompilerInvocation> ClangInvok =
284285
clang::createInvocation(ClangArgList, std::move(CIOpts));
285286
if (!ClangInvok || ClangDiags->hasErrorOccurred()) {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// REQUIRES: objc_interop
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %empty-directory(%t/pch)
5+
// RUN: split-file %s %t
6+
7+
// Precompile a header into a separate directory and check that it can be
8+
// loaded via its original header name, even if the header isn't adjacent
9+
// to the PCH. This used to be the default, but was changed in clang 16
10+
// (see `CreateInvocationOptions::ProbePrecompiled`).
11+
12+
// RUN: %target-swift-frontend -emit-pch %t/header.h -o %t/pch/header.h.pch
13+
// RUN: %target-swift-frontend -verify -typecheck %t/use.swift -Xcc -include -Xcc %t/pch/header.h -import-objc-header %t/empty.h
14+
15+
//--- empty.h
16+
17+
//--- header.h
18+
void headerFunc();
19+
20+
//--- use.swift
21+
func useHeaderFunc() {
22+
headerFunc()
23+
}

0 commit comments

Comments
 (0)