Skip to content
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

[NFC][Fuzzer] Fix zero-size array argv warning #112944

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
handleExecNameEncodedBEOpts(*argv[0]);
parseFuzzerCLOpts(*argc, *argv);

std::string execName = *argv[0];

if (TargetTriple.empty()) {
errs() << *argv[0] << ": -mtriple must be specified\n";
errs() << execName << ": -mtriple must be specified\n";
exit(1);
}

Expand All @@ -135,10 +137,10 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,
if (auto Level = CodeGenOpt::parseLevel(OptLevel)) {
OLvl = *Level;
} else {
errs() << argv[0] << ": invalid optimization level.\n";
errs() << execName << ": invalid optimization level.\n";
return 1;
}
ExitOnError ExitOnErr(std::string(*argv[0]) + ": error:");
ExitOnError ExitOnErr(std::string(execName) + ": error:");
TM = ExitOnErr(codegen::createTargetMachineForTriple(
Triple::normalize(TargetTriple), OLvl));
assert(TM && "Could not allocate target machine!");
Expand Down
10 changes: 5 additions & 5 deletions llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,27 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc,

// Create TargetMachine
//

std::string execName = *argv[0];
if (TargetTripleStr.empty()) {
errs() << *argv[0] << ": -mtriple must be specified\n";
errs() << execName << ": -mtriple must be specified\n";
exit(1);
}
ExitOnError ExitOnErr(std::string(*argv[0]) + ": error:");
ExitOnError ExitOnErr(std::string(execName) + ": error:");
TM = ExitOnErr(codegen::createTargetMachineForTriple(
Triple::normalize(TargetTripleStr)));

// Check that pass pipeline is specified and correct
//

if (PassPipeline.empty()) {
errs() << *argv[0] << ": at least one pass should be specified\n";
errs() << execName << ": at least one pass should be specified\n";
exit(1);
}

PassBuilder PB(TM.get());
ModulePassManager MPM;
if (auto Err = PB.parsePassPipeline(MPM, PassPipeline)) {
errs() << *argv[0] << ": " << toString(std::move(Err)) << "\n";
errs() << execName << ": " << toString(std::move(Err)) << "\n";
exit(1);
}

Expand Down
Loading