diff options
author | Fangrui Song <maskray@google.com> | 2020-08-04 08:51:24 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-08-04 08:53:15 -0700 |
commit | 593e19629744d6c8ba45fe4bb78910cf653cd6a7 (patch) | |
tree | b2efecf8c86c7d60afed793c1a0adfce15620cb9 /llvm/lib/Support/CommandLine.cpp | |
parent | 4a04bc8995639e1d333790518e4d42e0961f740e (diff) | |
download | llvm-593e19629744d6c8ba45fe4bb78910cf653cd6a7.zip llvm-593e19629744d6c8ba45fe4bb78910cf653cd6a7.tar.gz llvm-593e19629744d6c8ba45fe4bb78910cf653cd6a7.tar.bz2 |
[llvm-symbolizer] Switch command line parsing from llvm::cl to OptTable
for the advantage outlined by D83639 ([OptTable] Support grouped short options)
Some behavior changes:
* -i={0,false} is removed. Use --no-inlines instead.
* --demangle={0,false} is removed. Use --no-demangle instead
* -untag-addresses={0,false} is removed. Use --no-untag-addresses instead
Added a higher level API OptTable::parseArgs which handles optional
initial options populated from an environment variable, expands response
files recursively, and parses options.
Reviewed By: jhenderson
Differential Revision: https://reviews.llvm.org/D83530
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 4fba6a9..e53421a 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -1251,6 +1251,22 @@ bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, return AllExpanded; } +bool cl::expandResponseFiles(int Argc, const char *const *Argv, + const char *EnvVar, StringSaver &Saver, + SmallVectorImpl<const char *> &NewArgv) { + auto Tokenize = Triple(sys::getProcessTriple()).isOSWindows() + ? cl::TokenizeWindowsCommandLine + : cl::TokenizeGNUCommandLine; + // The environment variable specifies initial options. + if (EnvVar) + if (llvm::Optional<std::string> EnvValue = sys::Process::GetEnv(EnvVar)) + Tokenize(*EnvValue, Saver, NewArgv, /*MarkEOLs=*/false); + + // Command line options can override the environment variable. + NewArgv.append(Argv + 1, Argv + Argc); + return ExpandResponseFiles(Saver, Tokenize, NewArgv); +} + bool cl::readConfigFile(StringRef CfgFile, StringSaver &Saver, SmallVectorImpl<const char *> &Argv) { SmallString<128> AbsPath; |