Skip to content

Commit ba31c97

Browse files
committed
Basics: add a stub for centralized configurations for block list
1 parent 9d5df0b commit ba31c97

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "swift/Basic/LangOptions.h"
3131
#include "swift/Basic/Located.h"
3232
#include "swift/Basic/Malloc.h"
33+
#include "swift/Basic/BlockList.h"
3334
#include "swift/SymbolGraphGen/SymbolGraphOptions.h"
3435
#include "clang/AST/DeclTemplate.h"
3536
#include "llvm/ADT/ArrayRef.h"
@@ -359,6 +360,8 @@ class ASTContext final {
359360
/// The Swift module currently being compiled.
360361
ModuleDecl *MainModule = nullptr;
361362

363+
/// The block list where we can find special actions based on module name;
364+
BlockListStore blockListConfig;
362365
private:
363366
/// The current generation number, which reflects the number of
364367
/// times that external modules have been loaded.

include/swift/Basic/BlockList.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//===--- BlockList.h ---------------------------------------------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines some miscellaneous overloads of hash_value() and
14+
// simple_display().
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef SWIFT_BASIC_BLOCKLIST_H
19+
#define SWIFT_BASIC_BLOCKLIST_H
20+
21+
#include "swift/Basic/LLVM.h"
22+
#include "llvm/ADT/StringRef.h"
23+
24+
namespace swift {
25+
26+
enum class BlockListAction : uint8_t {
27+
ShouldUseBinaryModule = 0,
28+
ShouldUseTextualModule,
29+
};
30+
31+
enum class BlockListKeyKind: uint8_t {
32+
ModuleName,
33+
ProjectName
34+
};
35+
36+
class BlockListStore {
37+
public:
38+
struct Implementation;
39+
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
40+
BlockListAction action);
41+
void addConfigureFilePath(StringRef path);
42+
BlockListStore();
43+
~BlockListStore();
44+
private:
45+
Implementation &Impl;
46+
};
47+
48+
} // namespace swift
49+
50+
#endif // SWIFT_BASIC_BLOCKLIST_H

lib/Basic/BlockList.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//===--- BlockList.cpp - BlockList utilities ------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "swift/Basic/BlockList.h"
14+
15+
struct swift::BlockListStore::Implementation {
16+
void addConfigureFilePath(StringRef path);
17+
bool hasBlockListAction(StringRef key, BlockListKeyKind keyKind,
18+
BlockListAction action);
19+
};
20+
21+
swift::BlockListStore::BlockListStore(): Impl(*new Implementation()) {}
22+
23+
swift::BlockListStore::~BlockListStore() { delete &Impl; }
24+
25+
bool swift::BlockListStore::hasBlockListAction(StringRef key,
26+
BlockListKeyKind keyKind, BlockListAction action) {
27+
return Impl.hasBlockListAction(key, keyKind, action);
28+
}
29+
30+
void swift::BlockListStore::addConfigureFilePath(StringRef path) {
31+
Impl.addConfigureFilePath(path);
32+
}
33+
34+
bool swift::BlockListStore::Implementation::hasBlockListAction(StringRef key,
35+
BlockListKeyKind keyKind, BlockListAction action) {
36+
return false;
37+
}
38+
39+
void swift::BlockListStore::Implementation::addConfigureFilePath(StringRef path) {
40+
41+
}

lib/Basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ add_swift_host_library(swiftBasic STATIC
7878
Unicode.cpp
7979
UUID.cpp
8080
Version.cpp
81+
BlockList.cpp
8182

8283
${llvm_revision_inc}
8384
${clang_revision_inc}

0 commit comments

Comments
 (0)