Skip to content

Commit 252b5c3

Browse files
authored
Merge pull request #78139 from cachemeifyoucan/eng/PR-141284501-release-6.1
[6.1][ClangImporter] Share CASOptions when cloning CompilerInstance
2 parents 17ec817 + e0a7f44 commit 252b5c3

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,6 +2007,9 @@ ClangImporter::cloneCompilerInstanceForPrecompiling() {
20072007
if (FrontendOpts.CASIncludeTreeID.empty())
20082008
FrontendOpts.Inputs.clear();
20092009

2010+
// Share the CASOption and the underlying CAS.
2011+
invocation->setCASOption(Impl.Invocation->getCASOptsPtr());
2012+
20102013
auto clonedInstance = std::make_unique<clang::CompilerInstance>(
20112014
Impl.Instance->getPCHContainerOperations(),
20122015
&Impl.Instance->getModuleCache());

test/CAS/cached_diagnostics_pcm.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O -I %t \
5+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
6+
// RUN: %t/test.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas -module-load-mode prefer-serialized
7+
8+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
9+
// RUN: %swift_frontend_plain @%t/shim.cmd
10+
11+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/A.cmd
12+
// RUN: %swift_frontend_plain @%t/A.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CACHE-MISS
13+
14+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:A > %t/A.cmd
15+
// RUN: %swift_frontend_plain @%t/A.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CACHE-HIT
16+
17+
// CACHE-MISS: remark: cache miss for input
18+
// CHECK: <module-includes>:1
19+
// CHECK-SAME: note: in file included from <module-includes>:1:
20+
// CHECK: warning: warning a.h
21+
// CACHE-HIT: remark: replay output file
22+
23+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
24+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
25+
26+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
27+
// RUN: echo "\"-disable-implicit-string-processing-module-import\"" >> %t/MyApp.cmd
28+
// RUN: echo "\"-disable-implicit-concurrency-module-import\"" >> %t/MyApp.cmd
29+
// RUN: echo "\"-disable-implicit-swift-modules\"" >> %t/MyApp.cmd
30+
// RUN: echo "\"-explicit-swift-module-map-file\"" >> %t/MyApp.cmd
31+
// RUN: echo "\"@%t/map.casid\"" >> %t/MyApp.cmd
32+
33+
// RUN: %target-swift-frontend -cache-compile-job -module-name Test -O -cas-path %t/cas @%t/MyApp.cmd %t/test.swift \
34+
// RUN: -emit-module -o %t/test.swiftmodule
35+
36+
//--- module.modulemap
37+
module A {
38+
header "a.h"
39+
export *
40+
}
41+
42+
//--- a.h
43+
#warning warning a.h
44+
45+
//--- test.swift
46+
import A

0 commit comments

Comments
 (0)