Skip to content

Commit 82c9fdf

Browse files
[Blocklist] Make sure blocklist config is read through VFS
Make sure block-list file is read through VFS so CASFS can be used to read the configuration to ensure sound caching, and also the path of the blocklist can be canonicalized via path remapping.
1 parent cf81f05 commit 82c9fdf

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

include/swift/Basic/BlockList.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
namespace swift {
2525

26+
class SourceManager;
27+
2628
enum class BlockListAction: uint8_t {
2729
Undefined = 0,
2830
#define BLOCKLIST_ACTION(NAME) NAME,
@@ -41,7 +43,7 @@ class BlockListStore {
4143
void addConfigureFilePath(StringRef path);
4244
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
4345
BlockListAction action);
44-
BlockListStore();
46+
BlockListStore(SourceManager &SM);
4547
~BlockListStore();
4648
private:
4749
Implementation &Impl;

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "swift/AST/TypeCheckRequests.h"
5959
#include "swift/Basic/APIntMap.h"
6060
#include "swift/Basic/Assertions.h"
61+
#include "swift/Basic/BlockList.h"
6162
#include "swift/Basic/Compiler.h"
6263
#include "swift/Basic/SourceManager.h"
6364
#include "swift/Basic/Statistic.h"
@@ -779,6 +780,7 @@ ASTContext::ASTContext(
779780
evaluator(Diags, langOpts), TheBuiltinModule(createBuiltinModule(*this)),
780781
StdlibModuleName(getIdentifier(STDLIB_NAME)),
781782
SwiftShimsModuleName(getIdentifier(SWIFT_SHIMS_NAME)),
783+
blockListConfig(SourceMgr),
782784
TheErrorType(new (*this, AllocationArena::Permanent) ErrorType(
783785
*this, Type(), RecursiveTypeProperties::HasError)),
784786
TheUnresolvedType(new(*this, AllocationArena::Permanent)

lib/Basic/BlockList.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "swift/Basic/SourceManager.h"
2020

2121
struct swift::BlockListStore::Implementation {
22-
SourceManager SM;
22+
SourceManager &SM;
2323
llvm::StringMap<std::vector<BlockListAction>> ModuleActionDict;
2424
llvm::StringMap<std::vector<BlockListAction>> ProjectActionDict;
2525
void addConfigureFilePath(StringRef path);
@@ -44,9 +44,12 @@ struct swift::BlockListStore::Implementation {
4444
}
4545
return std::string();
4646
}
47+
48+
Implementation(SourceManager &SM) : SM(SM) {}
4749
};
4850

49-
swift::BlockListStore::BlockListStore(): Impl(*new Implementation()) {}
51+
swift::BlockListStore::BlockListStore(swift::SourceManager &SM)
52+
: Impl(*new Implementation(SM)) {}
5053

5154
swift::BlockListStore::~BlockListStore() { delete &Impl; }
5255

test/CAS/block-list.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O \
55
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
66
// RUN: -blocklist-file %t/blocklist.yml -blocklist-file %t/empty.yml \
7+
// RUN: -scanner-prefix-map %t=/^tmp \
78
// RUN: %t/main.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas
89

910
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json clang:SwiftShims > %t/shim.cmd
@@ -25,10 +26,11 @@
2526
// RUN: -swift-version 5 -disable-implicit-swift-modules \
2627
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
2728
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
28-
// RUN: -blocklist-file %t/blocklist.yml -blocklist-file %t/empty.yml \
29+
// RUN: -blocklist-file /^tmp/blocklist.yml -blocklist-file /^tmp/empty.yml \
2930
// RUN: -enable-layout-string-value-witnesses -enable-layout-string-value-witnesses-instantiation \
3031
// RUN: -enable-experimental-feature LayoutStringValueWitnesses -enable-experimental-feature LayoutStringValueWitnessesInstantiation \
31-
// RUN: %t/main.swift @%t/MyApp.cmd 2>&1 | %FileCheck %s --check-prefix CHECK-BLOCKED
32+
// RUN: -cache-replay-prefix-map /^tmp=%t \
33+
// RUN: /^tmp/main.swift @%t/MyApp.cmd 2>&1 | %FileCheck %s --check-prefix CHECK-BLOCKED
3234

3335
// CHECK-BLOCKED: note: Layout string value witnesses have been disabled for module 'Test' through block list entry
3436
// CHECK-BLOCKED-NOT: type_layout_string

unittests/Basic/BlocklistTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "swift/AST/SearchPathOptions.h"
1515
#include "swift/Basic/Defer.h"
1616
#include "swift/Basic/BlockList.h"
17+
#include "swift/Basic/SourceManager.h"
1718

1819
using namespace swift;
1920

@@ -46,7 +47,8 @@ TEST(BlocklistTest, testYamlParsing) {
4647
ASSERT_FALSE(llvm::sys::fs::createUniqueDirectory(
4748
"BlocklistTest.testYamlParsing", temp));
4849
SWIFT_DEFER { llvm::sys::fs::remove_directories(temp); };
49-
BlockListStore store;
50+
SourceManager sm;
51+
BlockListStore store(sm);
5052
std::string path1, path2;
5153
ASSERT_FALSE(emitFileWithContents(temp, "block1.yaml",
5254
"---\n"

0 commit comments

Comments
 (0)