Skip to content

Commit 046fbbc

Browse files
authored
Tweak the name for the function that diagnoses when fuzzing external libraries (#5974)
The old function name caused some confusion during the review of #5338, sending this to see if it provides a less surprising function name and boolean result. Happy to try other names / approaches as well.
1 parent 223d039 commit 046fbbc

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

toolchain/driver/clang_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ auto ClangSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
5252

5353
// Don't run Clang when fuzzing, it is known to not be reliable under fuzzing
5454
// due to many unfixed issues.
55-
if (!DisableFuzzingExternalLibraries(driver_env, "clang")) {
55+
if (TestAndDiagnoseIfFuzzingExternalLibraries(driver_env, "clang")) {
5656
return {.success = false};
5757
}
5858

toolchain/driver/compile_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ auto CompileSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
923923
if (driver_env.fuzzing && !options_.clang_args.empty()) {
924924
// Parsing specific Clang arguments can reach deep into
925925
// external libraries that aren't fuzz clean.
926-
DisableFuzzingExternalLibraries(driver_env, "compile");
926+
TestAndDiagnoseIfFuzzingExternalLibraries(driver_env, "compile");
927927
return {.success = false};
928928
}
929929
for (auto str : options_.clang_args) {

toolchain/driver/driver_subcommand.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010

1111
namespace Carbon {
1212

13-
auto DriverSubcommand::DisableFuzzingExternalLibraries(DriverEnv& driver_env,
14-
llvm::StringRef name)
15-
-> bool {
13+
auto DriverSubcommand::TestAndDiagnoseIfFuzzingExternalLibraries(
14+
DriverEnv& driver_env, llvm::StringRef name) -> bool {
1615
// Only need to do anything when fuzzing.
1716
if (!driver_env.fuzzing) {
18-
return true;
17+
return false;
1918
}
2019

2120
CARBON_DIAGNOSTIC(
2221
ToolFuzzingDisallowed, Error,
2322
"preventing fuzzing of `{0}` subcommand due to external library",
2423
std::string);
2524
driver_env.emitter.Emit(ToolFuzzingDisallowed, name.str());
26-
return false;
25+
return true;
2726
}
2827

2928
} // namespace Carbon

toolchain/driver/driver_subcommand.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ class DriverSubcommand {
6161
virtual auto Run(DriverEnv& driver_env) -> DriverResult = 0;
6262

6363
protected:
64-
// Diagnoses and returns false if currently fuzzing.
64+
// Tests if fuzzing and if so diagnose and returns true.
6565
//
66-
// This should be used in subcommands to check and diagnose rather than
66+
// This should be used in subcommands to diagnose and exit early rather than
6767
// entering them during fuzzing when they use external libraries that we can't
6868
// keep fuzz-clean.
69-
auto DisableFuzzingExternalLibraries(DriverEnv& driver_env,
70-
llvm::StringRef name) -> bool;
69+
auto TestAndDiagnoseIfFuzzingExternalLibraries(DriverEnv& driver_env,
70+
llvm::StringRef name) -> bool;
7171

7272
private:
7373
// Subcommand information.

toolchain/driver/lld_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ auto LldSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
9595

9696
// Don't run LLD when fuzzing, as we're not currently in a good position to
9797
// debug and fix fuzzer-found bugs within LLD.
98-
if (!DisableFuzzingExternalLibraries(driver_env, "lld")) {
98+
if (TestAndDiagnoseIfFuzzingExternalLibraries(driver_env, "lld")) {
9999
return {.success = false};
100100
}
101101

toolchain/driver/llvm_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ auto LLVMSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
6363
LLVMRunner runner(driver_env.installation, driver_env.vlog_stream);
6464

6565
// Don't run arbitrary LLVM tools and libraries when fuzzing.
66-
if (!DisableFuzzingExternalLibraries(driver_env, "llvm")) {
66+
if (TestAndDiagnoseIfFuzzingExternalLibraries(driver_env, "llvm")) {
6767
return {.success = false};
6868
}
6969

0 commit comments

Comments
 (0)