diff options
Diffstat (limited to 'llvm/tools/llvm-dwp/llvm-dwp.cpp')
| -rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index 350a37345e2c..5cd4c0078a45 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/ToolOutputFile.h" @@ -42,9 +43,7 @@ static mc::RegisterMCTargetOptionsFlags MCTargetOptionsFlags; namespace { enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - OPT_##ID, +#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__), #include "Opts.inc" #undef OPTION }; @@ -56,14 +55,9 @@ enum ID { #include "Opts.inc" #undef PREFIX +using namespace llvm::opt; static constexpr opt::OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR, VALUES) \ - { \ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS, OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS, VALUES}, +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), #include "Opts.inc" #undef OPTION }; @@ -77,7 +71,7 @@ public: // Options static std::vector<std::string> ExecFilenames; static std::string OutputFilename; -static bool ContinueOnCuIndexOverflow; +static std::string ContinueOption; static Expected<SmallVector<std::string, 16>> getDWOFilenames(StringRef ExecFilename) { @@ -125,12 +119,13 @@ static Expected<Triple> readTargetTriple(StringRef FileName) { return ErrOrObj->getBinary()->makeTriple(); } -int main(int argc, char **argv) { +int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) { InitLLVM X(argc, argv); DwpOptTable Tbl; llvm::BumpPtrAllocator A; llvm::StringSaver Saver{A}; + OnCuIndexOverflow OverflowOptValue = OnCuIndexOverflow::HardStop; opt::InputArgList Args = Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver, [&](StringRef Msg) { llvm::errs() << Msg << '\n'; @@ -149,7 +144,15 @@ int main(int argc, char **argv) { } OutputFilename = Args.getLastArgValue(OPT_outputFileName, ""); - ContinueOnCuIndexOverflow = Args.hasArg(OPT_continueOnCuIndexOverflow); + if (Args.hasArg(OPT_continueOnCuIndexOverflow)) { + ContinueOption = + Args.getLastArgValue(OPT_continueOnCuIndexOverflow, "continue"); + if (ContinueOption == "soft-stop") { + OverflowOptValue = OnCuIndexOverflow::SoftStop; + } else { + OverflowOptValue = OnCuIndexOverflow::Continue; + } + } for (const llvm::opt::Arg *A : Args.filtered(OPT_execFileNames)) ExecFilenames.emplace_back(A->getValue()); @@ -261,7 +264,7 @@ int main(int argc, char **argv) { if (!MS) return error("no object streamer for target " + TripleName, Context); - if (auto Err = write(*MS, DWOFilenames, ContinueOnCuIndexOverflow)) { + if (auto Err = write(*MS, DWOFilenames, OverflowOptValue)) { logAllUnhandledErrors(std::move(Err), WithColor::error()); return 1; } |
