Skip to content

Commit 049f381

Browse files
committed
FineModuleTracing: being blocklisted in collecting fine trace shouldn't change that the promised file is being emitted
1 parent c8fa52b commit 049f381

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lib/FrontendTool/LoadedModuleTrace.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,17 @@ static void createFineModuleTraceFile(CompilerInstance &instance,
876876
return;
877877
}
878878
ObjcMethodReferenceCollector collector(MD);
879-
instance.forEachFileToTypeCheck([&](SourceFile& SF) {
880-
collector.setFileBeforeVisiting(&SF);
881-
collector.walk(SF);
882-
return false;
883-
});
879+
880+
auto blocklisted = ctx.blockListConfig.hasBlockListAction(MD->getNameStr(),
881+
BlockListKeyKind::ModuleName, BlockListAction::SkipEmittingFineModuleTrace);
882+
883+
if (!blocklisted) {
884+
instance.forEachFileToTypeCheck([&](SourceFile& SF) {
885+
collector.setFileBeforeVisiting(&SF);
886+
collector.walk(SF);
887+
return false;
888+
});
889+
}
884890

885891
// print this json line.
886892
std::string stringBuffer;
@@ -903,9 +909,6 @@ bool swift::emitFineModuleTraceIfNeeded(CompilerInstance &Instance,
903909
const FrontendOptions &opts) {
904910
ModuleDecl *mainModule = Instance.getMainModule();
905911
ASTContext &ctxt = mainModule->getASTContext();
906-
if (ctxt.blockListConfig.hasBlockListAction(mainModule->getNameStr(),
907-
BlockListKeyKind::ModuleName, BlockListAction::SkipEmittingFineModuleTrace))
908-
return false;
909912
assert(!ctxt.hadError() &&
910913
"We should've already exited earlier if there was an error.");
911914

test/IDE/objc_send_collector_1.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// RUN: echo " - FooBar" >> %t/blocklist.yml
1818

1919
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_3.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name FooBar -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -blocklist-file %t/blocklist.yml
20-
// RUN: not ls %t/given_trace_3.json
20+
// RUN: cat %t/given_trace_3.json | %{python} -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' | %FileCheck %s --check-prefix=CHECK-BLOCKED
2121

2222
// RUN: SWIFT_COMPILER_FINE_GRAINED_TRACE_PATH=%t/given_trace_4.json %target-swift-frontend -I %t/lib/swift -typecheck %s %S/Inputs/objc_send_collector_2.swift -module-name FooBar -swift-version 5 -F %S/Inputs/mock-sdk -emit-loaded-module-trace-path %t/.MODULE_TRACE -disable-fine-module-tracing
2323
// RUN: not ls %t/given_trace_4.json
@@ -45,3 +45,5 @@ public func testProperties(_ x: FooClassBase, _ y: FooProtocolBase) {
4545
// CHECK-DAG: "file_path": "SOURCE_DIR/test/IDE/objc_send_collector_1.swift"
4646
// CHECK-DAG: "file_path": "SOURCE_DIR/test/IDE/Inputs/objc_send_collector_2.swift"
4747
// CHECK-DAG: "swift-compiler-version":
48+
49+
// CHECK-BLOCKED-NOT: "FooClassBase"

0 commit comments

Comments
 (0)