Skip to content

Commit a1a6799

Browse files
[Caching] Fix -access-note-path when using caching
Make sure to capture access-note when building with swift caching. rdar://161835182
1 parent 4b2cbef commit a1a6799

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

lib/DependencyScan/ModuleDependencyScanner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ SwiftDependencyTracker::SwiftDependencyTracker(
471471
// Add blocklist file.
472472
for (auto &File: CI.getFrontendOptions().BlocklistConfigFilePaths)
473473
addCommonFile(File);
474+
475+
// Add access notes.
476+
StringRef AccessNotePath = CI.getLangOptions().AccessNotesPath;
477+
if (!AccessNotePath.empty())
478+
addCommonFile(AccessNotePath);
474479
}
475480

476481
void SwiftDependencyTracker::startTracking(bool includeCommonDeps) {

test/CAS/access-notes.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// REQUIRES: objc_interop
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: split-file %s %t
5+
6+
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -module-cache-path %t/clang-module-cache -O \
7+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
8+
// RUN: %t/main.swift -o %t/deps.json -swift-version 5 -cache-compile-job -cas-path %t/cas -access-notes-path %t/extra.accessnotes
9+
10+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
11+
// RUN: %swift_frontend_plain @%t/shim.cmd
12+
13+
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
14+
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
15+
16+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/MyApp.cmd
17+
18+
// RUN: %target-swift-frontend \
19+
// RUN: -typecheck -cache-compile-job -cas-path %t/cas \
20+
// RUN: -swift-version 5 -disable-implicit-swift-modules \
21+
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
22+
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
23+
// RUN: %t/main.swift @%t/MyApp.cmd -access-notes-path %t/extra.accessnotes -Raccess-note=all 2>&1 | %FileCheck %s
24+
25+
//--- main.swift
26+
class Extant {
27+
func good(_: Int) {} // expected-remark * {{}} expected-note * {{}}
28+
// CHECK-DAG: main.swift:2:{{[0-9]+}}: remark: implicitly added '@objc' to this instance method, as specified by access note for Access notes containing future, unknown syntax
29+
// CHECK-DAG: note: add '@objc' explicitly to silence this warning
30+
31+
func bad(_: Int?) {} // expected-remark * {{}}
32+
// CHECK-DAG: main.swift:6:{{[0-9]+}}: remark: ignored access note: instance method cannot be marked '@objc' by an access note because the type of the parameter cannot be represented in Objective-C; did not implicitly add '@objc' to this instance method, even though it was specified by access note for Access notes containing future, unknown syntax
33+
}
34+
35+
//--- extra.accessnotes
36+
Reason: Access notes containing future, unknown syntax
37+
Notes:
38+
- Name: 'Extant.good(_:)'
39+
ObjC: true
40+
- Name: 'Extant.bad(_:)'
41+
ObjC: true

0 commit comments

Comments
 (0)