Skip to content

Commit 3c9ff9a

Browse files
committed
Basics: only allow ASTContext to add block list path
1 parent aa76845 commit 3c9ff9a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

include/swift/Basic/BlockList.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace swift {
2525

26-
enum class BlockListAction : uint8_t {
26+
enum class BlockListAction: uint8_t {
2727
ShouldUseBinaryModule = 0,
2828
ShouldUseTextualModule,
2929
};
@@ -38,10 +38,11 @@ class BlockListStore {
3838
struct Implementation;
3939
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
4040
BlockListAction action);
41-
void addConfigureFilePath(StringRef path);
4241
BlockListStore();
4342
~BlockListStore();
4443
private:
44+
friend class ASTContext;
45+
void addConfigureFilePath(StringRef path);
4546
Implementation &Impl;
4647
};
4748

lib/Basic/BlockList.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "llvm/ADT/STLExtras.h"
14+
#include "llvm/ADT/StringSwitch.h"
15+
#include "llvm/Support/YAMLParser.h"
16+
#include "llvm/Support/YAMLTraits.h"
1317
#include "swift/Basic/BlockList.h"
18+
#include "swift/Basic/SourceManager.h"
1419

1520
struct swift::BlockListStore::Implementation {
21+
llvm::StringMap<std::vector<BlockListAction>> ModuleActionDict;
22+
llvm::StringMap<std::vector<BlockListAction>> ProjectActionDict;
1623
void addConfigureFilePath(StringRef path);
1724
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
1825
BlockListAction action);
@@ -33,7 +40,12 @@ void swift::BlockListStore::addConfigureFilePath(StringRef path) {
3340

3441
bool swift::BlockListStore::Implementation::hasBlockListAction(StringRef key,
3542
BlockListKeyKind keyKind, BlockListAction action) {
36-
return false;
43+
auto *dict = keyKind == BlockListKeyKind::ModuleName ? &ModuleActionDict :
44+
&ProjectActionDict;
45+
auto it = dict->find(key);
46+
if (it == dict->end())
47+
return false;
48+
return llvm::is_contained(it->second, action);
3749
}
3850

3951
void swift::BlockListStore::Implementation::addConfigureFilePath(StringRef path) {

0 commit comments

Comments
 (0)