Skip to content

Commit 22f048e

Browse files
committed
[SourceKit] Save clang module validation time
Pass '-fbuild-session-timestamp' and '-fmodules-validate-once-per-build-sessio' to ClangImporter so that module validation happens only once for the SourceKit lifetime. rdar://problem/59567281
1 parent 8f30626 commit 22f048e

File tree

21 files changed

+294
-1
lines changed

21 files changed

+294
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import Foo
2+
3+
func test() {
4+
5+
}
6+
7+
// -----------------------------------------------------------------------------
8+
// Test that modifications for frameworks in '-Fsystem' doesn't affect the result.
9+
10+
// RUN: %empty-directory(%t/ModuleCache)
11+
// RUN: %empty-directory(%t/System/Frameworks)
12+
// RUN: cp -R %S/../Inputs/build_session/Frameworks/Foo.framework %t/System/Frameworks/
13+
// RUN: cp -R %S/../Inputs/build_session/Frameworks/FooHelper.framework %t/System/Frameworks/
14+
// RUN: %sourcekitd-test \
15+
// RUN: -shell -- echo '## ONE' == \
16+
// RUN: -req=complete -pos=4:1 %s -- %s -D ONE -Fsystem %t/System/Frameworks -module-cache-path %t/ModuleCache == \
17+
// RUN: -shell -- cp -R %S/../Inputs/build_session/Frameworks_modified/Foo.framework %t/System/Frameworks/ == \
18+
// RUN: -shell -- cp -R %S/../Inputs/build_session/Frameworks_modified/FooHelper.framework %t/System/Frameworks/ == \
19+
// RUN: -shell -- echo '## TWO' == \
20+
// RUN: -req=complete -pos=4:1 %s -- %s -D TWO -Fsystem %t/System/Frameworks -module-cache-path %t/ModuleCache \
21+
// RUN: | tee %t.response | %FileCheck %s --check-prefix=CHECK_SYSTEM
22+
// RUN: sleep 2
23+
// RUN: %sourcekitd-test \
24+
// RUN: -shell -- echo '## THREE' == \
25+
// RUN: -req=complete -pos=4:1 %s -- %s -D TWO -Fsystem %t/System/Frameworks -module-cache-path %t/ModuleCache \
26+
// RUN: | %FileCheck %s --check-prefix=CHECK_SYSTEM_2
27+
28+
// CHECK_SYSTEM-LABEL: ## ONE
29+
// CHECK_SYSTEM-DAG: key.description: "fooFunc(arg: Int32)"
30+
// CHECK_SYSTEM-DAG: key.description: "fooSubFunc(arg: Int32)"
31+
// CHECK_SYSTEM-DAG: key.description: "fooHelperFunc(arg: Int32)"
32+
// CHECK_SYSTEM-DAG: key.description: "fooHelperSubFunc(arg: Int32)"
33+
34+
// CHECK_SYSTEM-LABEL: ## TWO
35+
// CHECK_SYSTEM-DAG: key.description: "fooFunc(arg: Int32)"
36+
// CHECK_SYSTEM-DAG: key.description: "fooSubFunc(arg: Int32)"
37+
// CHECK_SYSTEM-DAG: key.description: "fooHelperFunc(arg: Int32)"
38+
// CHECK_SYSTEM-DAG: key.description: "fooHelperSubFunc(arg: Int32)"
39+
40+
// CHECK_SYSTEM_2-LABEL: ## THREE
41+
// CHECK_SYSTEM_2-NOT: fooFunc(
42+
// CHECK_SYSTEM_2-NOT: fooSubFunc(
43+
// CHECK_SYSTEM_2-NOT: fooHelperFunc(
44+
// CHECK_SYSTEM_2-NOT: fooHelperSubFunc(
45+
// CHECK_SYSTEM_2-DAG: key.description: "fooFunc_mod(arg: Int32)"
46+
// CHECK_SYSTEM_2-DAG: key.description: "fooSubFunc_mod(arg: Int32)"
47+
// CHECK_SYSTEM_2-DAG: key.description: "fooHelperFunc_mod(arg: Int32)"
48+
// CHECK_SYSTEM_2-DAG: key.description: "fooHelperSubFunc_mod(arg: Int32)"
49+
// CHECK_SYSTEM_2-NOT: fooFunc(
50+
// CHECK_SYSTEM_2-NOT: fooSubFunc(
51+
// CHECK_SYSTEM_2-NOT: fooHelperFunc(
52+
// CHECK_SYSTEM_2-NOT: fooHelperSubFunc(
53+
54+
// -----------------------------------------------------------------------------
55+
// Test that modifications for frameworks in '-F' are immidiately propagated
56+
// while modifications for frameworks in '-Fsystem' are not.
57+
58+
// RUN: %empty-directory(%t/ModuleCache)
59+
// RUN: %empty-directory(%t/Frameworks)
60+
// RUN: %empty-directory(%t/System/Frameworks)
61+
// RUN: cp -R %S/../Inputs/build_session/Frameworks/Foo.framework %t/Frameworks/
62+
// RUN: cp -R %S/../Inputs/build_session/Frameworks/FooHelper.framework %t/System/Frameworks/
63+
// RUN: %sourcekitd-test \
64+
// RUN: -shell -- echo '## ONE' == \
65+
// RUN: -req=complete -pos=4:1 %s -- %s -D ONE -F %t/Frameworks -Fsystem %t/System/Frameworks -module-cache-path %t/ModuleCache == \
66+
// RUN: -shell -- cp -R %S/../Inputs/build_session/Frameworks_modified/Foo.framework %t/Frameworks/ == \
67+
// RUN: -shell -- cp -R %S/../Inputs/build_session/Frameworks_modified/FooHelper.framework %t/System/Frameworks/ == \
68+
// RUN: -shell -- echo '## TWO' == \
69+
// RUN: -req=complete -pos=4:1 %s -- %s -D TWO -F %t/Frameworks -Fsystem %t/System/Frameworks -module-cache-path %t/ModuleCache \
70+
// RUN: | %FileCheck %s --check-prefix=CHECK_USER
71+
72+
// CHECK_USER-LABEL: ## ONE
73+
// CHECK_USER-DAG: key.description: "fooFunc(arg: Int32)"
74+
// CHECK_USER-DAG: key.description: "fooSubFunc(arg: Int32)"
75+
// CHECK_USER-DAG: key.description: "fooHelperFunc(arg: Int32)"
76+
// CHECK_USER-DAG: key.description: "fooHelperSubFunc(arg: Int32)"
77+
78+
// CHECK_USER-LABEL: ## TWO
79+
// CHECK_USER-NOT: fooFunc(
80+
// CHECK_USER-NOT: fooSubFunc(
81+
// CHECK_USER-DAG: key.description: "fooFunc_mod(arg: Int32)"
82+
// CHECK_USER-DAG: key.description: "fooSubFunc_mod(arg: Int32)"
83+
// CHECK_USER-DAG: key.description: "fooHelperFunc(arg: Int32)"
84+
// CHECK_USER-DAG: key.description: "fooHelperSubFunc(arg: Int32)"
85+
// CHECK_USER-NOT: fooFunc(
86+
// CHECK_USER-NOT: fooSubFunc(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#if !defined(__FOOSUB_H__)
2+
#define __FOOSUB_H__ 1
3+
4+
int fooSubFunc(int arg);
5+
6+
#endif /* ! __FOOSUB_H__ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* Foo.h
2+
Copyright (c) 1815, Napoleon Bonaparte. All rights reserved.
3+
*/
4+
#if !defined(__FOO_H__)
5+
#define __FOO_H__ 1
6+
7+
#import <FooSub/FooSub.h>
8+
#import <FooHelper/FooHelper.h>
9+
10+
int fooFunc(int arg);
11+
12+
#endif /* ! __FOO_H__ */
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
framework module Foo {
2+
umbrella header "Foo.h"
3+
export *
4+
framework module FooSub {
5+
umbrella header "FooSub.h"
6+
export *
7+
}
8+
}
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int fooHelperSubFunc(int arg);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#import <FooHelperSub/FooHelperSub.h>
2+
3+
int fooHelperFunc(int arg);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int fooHelperExplicitFunc(int a);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
framework module FooHelper {
2+
umbrella header "FooHelper.h"
3+
4+
framework module FooHelperSub {
5+
umbrella header "FooHelperSub.h"
6+
}
7+
8+
explicit module FooHelperExplicit {
9+
header "FooHelperExplicit.h"
10+
}
11+
}
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#if !defined(__FOOSUB_H__)
2+
#define __FOOSUB_H__ 1
3+
4+
int fooSubFunc_mod(int arg);
5+
6+
#endif /* ! __FOOSUB_H__ */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* Foo.h
2+
Copyright (c) 1815, Napoleon Bonaparte. All rights reserved.
3+
*/
4+
#if !defined(__FOO_H__)
5+
#define __FOO_H__ 1
6+
7+
#import <FooSub/FooSub.h>
8+
#import <FooHelper/FooHelper.h>
9+
10+
int fooFunc_mod(int arg);
11+
12+
#endif /* ! __FOO_H__ */

0 commit comments

Comments
 (0)