mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- Add CompilerInvocation::getPCHHash
This will be used when creating a unique filename for a persistent
precompiled bridging header.
- Automatically generate and use a precompiled briding header
When we're given both -import-objc-header and -pch-output-dir
arguments, we will try to:
- Validate what we think the PCH filename should be for the bridging
header, based on the Swift PCH hash and the clang module hash.
- If we're successful, we'll just use it.
- If it's out of date or something else is wrong, we'll try to
emit it.
- This gives us a single filename which we can `stat` to check for the
validity of our code completion cache, which is keyed off of module
name, module filename, and module file age.
- Cache code completion results from imported modules
If we just have a single .PCH file imported, we can use that file as
part of the key used to cache declarations in a module. Because
multiple files can contribute to the __ObjC module, we've always given
it the phony filename "<imports>", which never exists, so `stat`-ing it
always fails and we never cache declarations in it.
This is extremely problematic for projects with huge bridging headers.
In the case where we have a single PCH import, this can bring warm code
completion times down to about 500ms from over 2-3s, so it can provide a
nice performance win for IDEs.
- Add a new test that performs two code-completion requests with a bridging header.
- Add some -pch-output-dir flags to existing SourceKit tests that import a bridging
header.
rdar://problem/31198982
22 lines
928 B
Swift
22 lines
928 B
Swift
|
|
func test(_ b : BaseInHead) {
|
|
b.doIt(0);
|
|
}
|
|
|
|
// REQUIRES: objc_interop
|
|
// RUN: %swift -typecheck %s %mcp_opt -module-name Mixed -import-objc-header %S/Inputs/header.h 2> %t.diags
|
|
// RUN: %FileCheck -input-file %t.diags %s -check-prefix=DIAG
|
|
// DIAG: warning: using the result of an assignment
|
|
|
|
// RUN: %sourcekitd-test -req=cursor -pos=3:7 %s -- %s %mcp_opt -module-name Mixed -import-objc-header %S/Inputs/header.h | %FileCheck %s
|
|
|
|
// RUN: rm -rf %t && mkdir -p %t
|
|
// RUN: %sourcekitd-test -req=cursor -pos=3:7 %s -- %s %mcp_opt -module-name Mixed -pch-output-dir %t -import-objc-header %S/Inputs/header.h | %FileCheck %s
|
|
// RUN: stat %t/*.pch
|
|
|
|
// CHECK: source.lang.swift.ref.function.method.instance ({{.*}}Inputs/header.h:4:9-4:23)
|
|
// CHECK: doIt(_:)
|
|
// CHECK: c:objc(cs)BaseInHead(im)doIt:
|
|
// CHECK: (BaseInHead) -> (Int32) -> ()
|
|
// CHECK: <Declaration>func doIt(_ arg: <Type usr="s:s5Int32V">Int32</Type>)</Declaration>
|