Skip to content

Frontend: pass down blocklist file paths from frontend options. NFC #65024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/swift/Basic/BlockList.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace swift {

enum class BlockListAction: uint8_t {
Undefined = 0,
ShouldUseBinaryModule,
ShouldUseTextualModule,
#define BLOCKLIST_ACTION(NAME) NAME,
#include "BlockListAction.def"
};

enum class BlockListKeyKind: uint8_t {
Expand Down
25 changes: 25 additions & 0 deletions include/swift/Basic/BlockListAction.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===--- BlockListAction.def - Define all blocklist actions -----*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This definition file describes all block list actions for meta-programming
// purposes.
//
//===----------------------------------------------------------------------===//

#ifndef BLOCKLIST_ACTION
#define BLOCKLIST_ACTION(NAME)
#endif

BLOCKLIST_ACTION(ShouldUseBinaryModule)
BLOCKLIST_ACTION(ShouldUseTextualModule)

#undef BLOCKLIST_ACTION
2 changes: 1 addition & 1 deletion include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ namespace swift {
ConcurrencyModel ActiveConcurrencyModel = ConcurrencyModel::Standard;

/// All block list configuration files to be honored in this compilation.
std::vector<std::string> BlocklistConfigFilePath;
std::vector<std::string> BlocklistConfigFilePaths;

bool isConcurrencyModelTaskToThread() const {
return ActiveConcurrencyModel == ConcurrencyModel::TaskToThread;
Expand Down
2 changes: 2 additions & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ class FrontendOptions {
/// textual imports
bool EmitClangHeaderWithNonModularIncludes = false;

/// All block list configuration files to be honored in this compilation.
std::vector<std::string> BlocklistConfigFilePaths;
private:
static bool canActionEmitDependencies(ActionType);
static bool canActionEmitReferenceDependencies(ActionType);
Expand Down
2 changes: 1 addition & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ ASTContext::ASTContext(
if (!OutputBackend)
OutputBackend = llvm::makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>();
// Insert all block list config paths.
for (auto path: langOpts.BlocklistConfigFilePath) {
for (auto path: langOpts.BlocklistConfigFilePaths) {
blockListConfig.addConfigureFilePath(path);
}
}
Expand Down
6 changes: 2 additions & 4 deletions lib/Basic/BlockList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ void swift::BlockListStore::Implementation::addConfigureFilePath(StringRef path)
for (auto &pair: *dyn_cast<yaml::MappingNode>(N)) {
std::string key = getScalaString(pair.getKey());
auto action = llvm::StringSwitch<BlockListAction>(key)
#define CASE(X) .Case(#X, BlockListAction::X)
CASE(ShouldUseBinaryModule)
CASE(ShouldUseTextualModule)
#undef CASE
#define BLOCKLIST_ACTION(X) .Case(#X, BlockListAction::X)
#include "swift/Basic/BlockListAction.def"
.Default(BlockListAction::Undefined);
if (action == BlockListAction::Undefined)
continue;
Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/ArgsToFrontendOptionsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ bool ArgsToFrontendOptionsConverter::convert(
}
Opts.emptyABIDescriptor = Args.hasArg(OPT_empty_abi_descriptor);
Opts.DeterministicCheck = Args.hasArg(OPT_enable_deterministic_check);
for (auto A : Args.getAllArgValues(options::OPT_block_list_file)) {
Opts.BlocklistConfigFilePaths.push_back(A);
}
return false;
}

Expand Down
4 changes: 1 addition & 3 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,

Opts.DumpTypeWitnessSystems = Args.hasArg(OPT_dump_type_witness_systems);

for (auto A : Args.getAllArgValues(options::OPT_block_list_file)) {
Opts.BlocklistConfigFilePath.push_back(A);
}
Opts.BlocklistConfigFilePaths = FrontendOpts.BlocklistConfigFilePaths;
if (const Arg *A = Args.getLastArg(options::OPT_concurrency_model)) {
Opts.ActiveConcurrencyModel =
llvm::StringSwitch<ConcurrencyModel>(A->getValue())
Expand Down