diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2017-08-11 20:13:17 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2017-08-11 20:13:17 +0100 |
commit | 49f2e54339e186fd68cf6cb3ab775d0e3f643eb8 (patch) | |
tree | fec89ff62c9f1cad66d55cc6ec9d25716f2296ac | |
parent | d19500eb93083c8cc6bb72bcb54414015830cacb (diff) | |
download | klee-49f2e54339e186fd68cf6cb3ab775d0e3f643eb8.tar.gz |
Added support for hiding command-line options
-rw-r--r-- | include/klee/CommandLine.h | 14 | ||||
-rw-r--r-- | lib/Basic/CmdLineOptions.cpp | 29 |
2 files changed, 37 insertions, 6 deletions
diff --git a/include/klee/CommandLine.h b/include/klee/CommandLine.h index 64930bb2..79f9286b 100644 --- a/include/klee/CommandLine.h +++ b/include/klee/CommandLine.h @@ -6,9 +6,11 @@ #ifndef KLEE_COMMANDLINE_H #define KLEE_COMMANDLINE_H -#include "llvm/Support/CommandLine.h" #include "klee/Config/config.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/CommandLine.h" + namespace klee { extern llvm::cl::opt<bool> UseFastCexSolver; @@ -66,7 +68,15 @@ extern llvm::cl::opt<klee::MetaSMTBackendType> MetaSMTBackend; #endif /* ENABLE_METASMT */ +class KCommandLine { +public: + /// Hide all options except the ones in the specified category + static void HideUnrelatedOptions(llvm::cl::OptionCategory &Category); + + /// Hide all options except the ones in the specified categories + static void HideUnrelatedOptions( + llvm::ArrayRef<const llvm::cl::OptionCategory *> Categories); +}; } #endif /* KLEE_COMMANDLINE_H */ - diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp index 324f349e..da333884 100644 --- a/lib/Basic/CmdLineOptions.cpp +++ b/lib/Basic/CmdLineOptions.cpp @@ -15,6 +15,12 @@ #include "klee/CommandLine.h" #include "klee/Config/Version.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Support/CommandLine.h" + +using namespace llvm; + namespace klee { llvm::cl::opt<bool> @@ -81,6 +87,25 @@ llvm::cl::opt<bool> UseAssignmentValidatingSolver("debug-assignment-validating-solver", llvm::cl::init(false)); +void KCommandLine::HideUnrelatedOptions(cl::OptionCategory &Category) { + StringMap<cl::Option *> map; + cl::getRegisteredOptions(map); + for (StringMap<cl::Option *>::iterator i = map.begin(), e = map.end(); i != e; + i++) { + if (i->second->Category != &Category) { + i->second->setHiddenFlag(cl::Hidden); + } + } +} + +void KCommandLine::HideUnrelatedOptions( + llvm::ArrayRef<const llvm::cl::OptionCategory *> Categories) { + for (ArrayRef<const cl::OptionCategory *>::iterator i = Categories.begin(), + e = Categories.end(); + i != e; i++) + HideUnrelatedOptions(*i); +} + #ifdef ENABLE_METASMT #ifdef METASMT_DEFAULT_BACKEND_IS_BTOR @@ -156,7 +181,3 @@ llvm::cl::opt<CoreSolverType> DebugCrossCheckCoreSolverWith( #undef METASMT_IS_DEFAULT_STR #undef Z3_IS_DEFAULT_STR #undef DEFAULT_CORE_SOLVER - - - - |