Skip to content

Commit b257874

Browse files
Merge pull request #76737 from cachemeifyoucan/eng/PR-block-list-vfs
[Blocklist] Make sure blocklist config is read through VFS
2 parents 4f53f18 + 7adaf50 commit b257874

File tree

6 files changed

+36
-10
lines changed

6 files changed

+36
-10
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;

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ def primary_file : Separate<["-"], "primary-file">,
8686
Flags<[FrontendOption, NoDriverOption, ArgumentIsPath]>,
8787
HelpText<"Produce output for this file, not the whole module">;
8888

89+
def block_list_file
90+
: Separate<["-"], "blocklist-file">, MetaVarName<"<path>">,
91+
Flags<[FrontendOption, NoDriverOption, ArgumentIsPath]>,
92+
HelpText<"The path to a blocklist configuration file">;
93+
8994
let Flags = [FrontendOption, NoDriverOption] in {
9095

9196
def triple : Separate<["-"], "triple">, Alias<target>;
@@ -287,10 +292,6 @@ def Raccess_note : Separate<["-"], "Raccess-note">,
287292
HelpText<"Control access note remarks (default: all)">;
288293
def Raccess_note_EQ : Joined<["-"], "Raccess-note=">,
289294
Alias<Raccess_note>;
290-
291-
def block_list_file
292-
: Separate<["-"], "blocklist-file">, MetaVarName<"<path>">,
293-
HelpText<"The path to a blocklist configuration file">;
294295
} // end let Flags = [FrontendOption, NoDriverOption]
295296

296297
def debug_crash_Group : OptionGroup<"<automatic crashing options>">;

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: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@
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 -I %t/include \
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
1011
// RUN: %swift_frontend_plain @%t/shim.cmd
12+
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json A > %t/A.cmd
13+
// RUN: %swift_frontend_plain @%t/A.cmd
14+
15+
// RUN: %FileCheck %s -check-prefix CMD -input-file=%t/A.cmd
16+
// CMD: -blocklist-file
17+
// CMD-NEXT: /^tmp/blocklist.yml
18+
// CMD-NEXT: -blocklist-file
19+
// CMD-NEXT: /^tmp/empty.yml
1120

1221
// RUN: %{python} %S/Inputs/SwiftDepsExtractor.py %t/deps.json Test casFSRootID > %t/fs.casid
1322
// DISABLE: llvm-cas --cas %t/cas --ls-tree-recursive @%t/fs.casid | %FileCheck %s -check-prefix FS
@@ -25,15 +34,17 @@
2534
// RUN: -swift-version 5 -disable-implicit-swift-modules \
2635
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
2736
// RUN: -module-name Test -explicit-swift-module-map-file @%t/map.casid \
28-
// RUN: -blocklist-file %t/blocklist.yml -blocklist-file %t/empty.yml \
37+
// RUN: -blocklist-file /^tmp/blocklist.yml -blocklist-file /^tmp/empty.yml \
2938
// RUN: -enable-layout-string-value-witnesses -enable-layout-string-value-witnesses-instantiation \
3039
// 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
40+
// RUN: -cache-replay-prefix-map /^tmp=%t \
41+
// RUN: /^tmp/main.swift @%t/MyApp.cmd 2>&1 | %FileCheck %s --check-prefix CHECK-BLOCKED
3242

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

3646
//--- main.swift
47+
import A
3748
public struct Bar {
3849
let x: Int
3950
let y: AnyObject
@@ -45,6 +56,11 @@ public enum Foo {
4556
case c
4657
}
4758

59+
//--- include/A.swiftinterface
60+
// swift-interface-format-version: 1.0
61+
// swift-module-flags: -module-name A -O -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib -user-module-version 1.0
62+
public func a() { }
63+
4864
//--- blocklist.yml
4965
---
5066
ShouldUseLayoutStringValueWitnesses:

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)