summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/Support/CommandLine.h
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Add support for prefix-only CLI optionsThomas Preud'homme2019-01-141-2/+6
| | | | | | | | | | | | | | | | | | | | | | Summary: Add support for options that always prefix their value, giving an error if the value is in the next argument or if the option is given a value assignment (ie. opt=val). This is the desired behavior for the -D option of FileCheck for instance. Copyright: - Linaro (changes in version 2 of revision D55940) - GraphCore (changes in later versions and introduced when creating D56549) Reviewers: jdenny Subscribers: llvm-commits, probinson, kristina, hiraditya, JonChesterfield Differential Revision: https://reviews.llvm.org/D56549 llvm-svn: 351038
* [FileCheck] Parse command-line options from FILECHECK_OPTSJoel E. Denny2018-11-061-1/+10
| | | | | | | | | | | | | | | | | This feature makes it easy to tune FileCheck diagnostic output when running the test suite via ninja, a bot, or an IDE. For example: ``` $ FILECHECK_OPTS='-color -v -dump-input-on-failure' \ LIT_FILTER='OpenMP/for_codegen.cpp' ninja check-clang \ | less -R ``` Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D53517 llvm-svn: 346272
* [CommandLine] Error message for incorrect PositionalEatArgs usageKeno Fischer2018-05-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: bugpoint has several options specified as `PositionalEatArgs` to pass options through to the underlying tool, e.g. `-tool-args`. The `-help` message suggests the usage is: `-tool-args=<string>`. However, this is misleading, because that's not how these arguments work. Rather than taking a value, the option consumes all positional arguments until the next recognized option (or all arguments if `--` is specified at some point). To make this slightly clearer, instead print the help as: ``` -tool-args <string>... - <tool arguments>... ``` Additionally, add an error if the user attempts to use a `PositionalEatArgs` argument with a value, instead of silently ignoring it. Example: ``` ./bin/bugpoint -tool-args=-mpcu=skylake-avx512 bugpoint: for the -tool-args option: This argument does not take a value. Instead, it consumes any positional arguments until the next recognized option. ``` Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D46787 llvm-svn: 332311
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-11/+11
| | | | | | | | | | | | | | | | We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
* Added support for reading configuration filesSerge Pavlov2017-12-301-0/+27
| | | | | | | | | | | | | Configuration file is read as a response file in which file names in the nested constructs `@file` are resolved relative to the directory where the including file resides. Lines in which the first non-whitespace character is '#' are considered as comments and are skipped. Trailing backslashes are used to concatenate lines in the same way as they are used in shell scripts. Differential Revision: https://reviews.llvm.org/D24926 llvm-svn: 321586
* Reverted 321580: Added support for reading configuration filesSerge Pavlov2017-12-301-27/+0
| | | | | | It caused buildbot fails. llvm-svn: 321582
* Added support for reading configuration filesSerge Pavlov2017-12-301-0/+27
| | | | | | | | | | | | | Configuration file is read as a response file in which file names in the nested constructs `@file` are resolved relative to the directory where the including file resides. Lines in which the first non-whitespace character is '#' are considered as comments and are skipped. Trailing backslashes are used to concatenate lines in the same way as they are used in shell scripts. Differential Revision: https://reviews.llvm.org/D24926 llvm-svn: 321580
* typoAdrian Prantl2017-09-201-1/+1
| | | | llvm-svn: 313837
* Don't call exit from cl::PrintHelpMessage.Rafael Espindola2017-09-071-2/+0
| | | | | | | | | Most callers were not expecting the exit(0) and trying to exit with a different value. This also adds back the call to cl::PrintHelpMessage in llvm-ar. llvm-svn: 312761
* [Support][CommandLine] Add cl::Option::setDefault()Evgeny Mankov2017-08-281-0/+22
| | | | | | | | | | | | | | | Add abstract virtual method setDefault() to class Option and implement it in its inheritors in order to be able to set all the options to its default values in user's code without actually knowing all these options. For instance: for (auto &OM : cl::getRegisteredOptions(*cl::TopLevelSubCommand)) { cl::Option *O = OM.second; O->setDefault(); } Reviewed by: rampitec, Eugene.Zelenko, kasaurov Differential Revision: http://reviews.llvm.org/D36877 llvm-svn: 311887
* [Support] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko2017-06-091-28/+40
| | | | | | warnings; other minor fixes (NFC). llvm-svn: 305119
* Allow VersionPrinter to print to arbitrary raw_ostreamsDimitry Andric2017-06-061-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: I would like to add printing of registered targets to clang's version information. For this to work correctly, the VersionPrinter logic in CommandLine.cpp should support printing to arbitrary raw_ostreams, instead of always defaulting to outs(). Add a raw_ostream& parameter to the function pointer type used for VersionPrinter, and while doing so, introduce a typedef for convenience. Note that VersionPrinter::print() will still default to using outs(), the clang part will necessarily go into a separate review. Reviewers: beanz, chandlerc, dberris, mehdi_amini, zturner Reviewed By: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33899 llvm-svn: 304835
* Sort the remaining #include lines in include/... and lib/....Chandler Carruth2017-06-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | I did this a long time ago with a janky python script, but now clang-format has built-in support for this. I fed clang-format every line with a #include and let it re-sort things according to the precise LLVM rules for include ordering baked into clang-format these days. I've reverted a number of files where the results of sorting includes isn't healthy. Either places where we have legacy code relying on particular include ordering (where possible, I'll fix these separately) or where we have particular formatting around #include lines that I didn't want to disturb in this patch. This patch is *entirely* mechanical. If you get merge conflicts or anything, just ignore the changes in this patch and run clang-format over your #include lines in the files. Sorry for any noise here, but it is important to keep these things stable. I was seeing an increasing number of patches with irrelevant re-ordering of #include lines because clang-format was used. This patch at least isolates that churn, makes it easy to skip when resolving conflicts, and gets us to a clean baseline (again). llvm-svn: 304787
* [Support][CommandLine] Make it possible to get error messages from ↵Eric Liu2017-03-151-1/+4
| | | | | | | | | | | | | | | | | | | ParseCommandLineOptions when ignoring errors. Summary: Previously, ParseCommandLineOptions returns false and ignores error messages when IgnoreErrors. It would be useful to also return error messages if users decide to check parsing result instead of having the program exit on error. Reviewers: chandlerc, mehdi_amini, rnk Reviewed By: rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D30893 llvm-svn: 297810
* Add initial support for debug countingDaniel Berlin2017-02-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We have support for bisection, and bugpoint can reduce testcases often to a single pass. But that doesn't help reduce it to a single transform by a single pass. Which debug counting lets us do. Debug counting lets you instrument a pass so that it only executes a certain thing (rwhatever you want) after skipping it a certain time of times, and then only does a certain number of executions before saying "skip" again. To make it concrete, for predicateinfo, if i instrument use renaming, i can make it so it skips renaming the first N uses, renames the next N, and then skips the rest. This lets you narrow down a miscompilation to, often, a single transformation, and then also debug it (by using the same command line parameters). Reviewers: chandlerc, davide, mehdi_amini Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D29998 llvm-svn: 295593
* Make some operator bools explicit for sanity/safety.David Blaikie2017-01-111-1/+1
| | | | | | | | There are a couple left in bool-like containers (BitVector, etc) where the implicit conversions seem more suitable - though it might be worth considering explicitifying those too. llvm-svn: 291694
* [IR] Fix some Clang-tidy modernize-use-equals-delete and Include What You ↵Eugene Zelenko2016-12-051-1/+0
| | | | | | | | Use warnings; other minor fixes (NFC). Also remove obsolete comment from CommandLine.h spotted by Malcolm Parsons. llvm-svn: 288714
* Fix broken buildbots because of r288424 (NFC).Eugene Zelenko2016-12-011-0/+1
| | | | llvm-svn: 288426
* [ADT, Support, TableGen] Fix some Clang-tidy modernize-use-default and ↵Eugene Zelenko2016-12-011-33/+64
| | | | | | Include What You Use warnings; other minor fixes (NFC). llvm-svn: 288424
* [CommandLine] Remove redundant initializers for StringRef membersMalcolm Parsons2016-11-241-4/+4
| | | | | | | | | | | | Summary: The default constructor for a StringRef stores an empty string. Reviewers: beanz, zturner Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27067 llvm-svn: 287857
* Allow resolving response file names relative to including fileSerge Pavlov2016-11-011-1/+3
| | | | | | | | | | | | | | If a response file included by construct @file itself includes a response file and that file is specified by relative file name, current behavior is to resolve the name relative to the current working directory. The change adds additional flag to ExpandResponseFiles that may be used to resolve nested response file names relative to including file. With the new mode a set of related response files may be kept together and reference each other with short position independent names. Differential Revision: https://reviews.llvm.org/D24917 llvm-svn: 285675
* Add `llvm::` in clEnumVal macro (NFC)Mehdi Amini2016-10-141-2/+2
| | | | | | This allows to use llvm:cl::opt without `using namespace llvm;` llvm-svn: 284190
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-33/+24
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* [Support][CommandLine] Add cl::getRegisteredSubcommands()Dean Michael Berris2016-10-051-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | This should allow users of the library to get a range to iterate through all the subcommands that are registered to the global parser. This allows users to define subcommands in libraries that self-register to have dispatch done at a different stage (like main). It allows for writing code like the following: for (auto *S : cl::getRegisteredSubcommands()) { if (*S) { // Dispatch on S->getName(). } } This change also contains tests that show this usage pattern. Reviewers: zturner, dblaikie, echristo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D24489 llvm-svn: 283296
* Use StringRef in CommandLine Options handling (NFC)Mehdi Amini2016-10-011-52/+52
| | | | llvm-svn: 283007
* Fix a typo, depricated -> deprecatedMartin Storsjo2016-09-271-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D22849 llvm-svn: 282534
* Revert "[Support][CommandLine] Add cl::getRegisteredSubcommands()"Zachary Turner2016-09-131-22/+0
| | | | | | | This reverts r281290, as it breaks unit tests. http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/303 llvm-svn: 281292
* [Support][CommandLine] Add cl::getRegisteredSubcommands()Dean Michael Berris2016-09-131-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | This should allow users of the library to get a range to iterate through all the subcommands that are registered to the global parser. This allows users to define subcommands in libraries that self-register to have dispatch done at a different stage (like main). It allows for writing code like the following: for (auto *S : cl::getRegisteredSubcommands()) { if (*S) { // Dispatch on S->getName(). } } This change also contains tests that show this usage pattern. Reviewers: zturner, dblaikie, echristo Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D24489 llvm-svn: 281290
* Use range algorithms instead of unpacking begin/endDavid Majnemer2016-08-111-1/+2
| | | | | | No functionality change is intended. llvm-svn: 278417
* Add a default parameter for getRegisteredOptions.Zachary Turner2016-07-061-1/+1
| | | | llvm-svn: 274640
* Resubmit "Update llvm command line parser to support subcommands."Zachary Turner2016-06-291-5/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where occurrence counts would be unexpectedly reset when parsing different parts of a command line multiple times. **ORIGINAL COMMIT MESSAGE** This allows command line tools to use syntaxes like the following: llvm-foo.exe command1 -o1 -o2 llvm-foo.exe command2 -p1 -p2 Where command1 and command2 contain completely different sets of valid options. This is backwards compatible with previous uses of llvm cl which did not support subcommands, as any option which specifies no optional subcommand (e.g. all existing code) goes into a special "top level" subcommand that expects dashed options to appear immediately after the program name. For example, code which is subcommand unaware would generate a command line such as the following, where no subcommand is specified: llvm-foo.exe -q1 -q2 The top level subcommand can co-exist with actual subcommands, as it is implemented as an actual subcommand which is searched if no explicit subcommand is specified. So llvm-foo.exe as specified above could be written so as to support all three aforementioned command lines simultaneously. There is one additional "special" subcommand called AllSubCommands, which can be used to inject an option into every subcommand. This is useful to support things like help, so that commands such as: llvm-foo.exe --help llvm-foo.exe command1 --help llvm-foo.exe command2 --help All work and display the help for the selected subcommand without having to explicitly go and write code to handle each one separately. This patch is submitted without an example of anything actually using subcommands, but a followup patch will convert the llvm-pdbdump tool to use subcommands. Reviewed By: beanz llvm-svn: 274171
* Revert r274054 to try to appease the botManman Ren2016-06-281-73/+5
| | | | llvm-svn: 274072
* Update llvm command line parser to support subcommands.Zachary Turner2016-06-281-5/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows command line tools to use syntaxes like the following: llvm-foo.exe command1 -o1 -o2 llvm-foo.exe command2 -p1 -p2 Where command1 and command2 contain completely different sets of valid options. This is backwards compatible with previous uses of llvm cl which did not support subcommands, as any option which specifies no optional subcommand (e.g. all existing code) goes into a special "top level" subcommand that expects dashed options to appear immediately after the program name. For example, code which is subcommand unaware would generate a command line such as the following, where no subcommand is specified: llvm-foo.exe -q1 -q2 The top level subcommand can co-exist with actual subcommands, as it is implemented as an actual subcommand which is searched if no explicit subcommand is specified. So llvm-foo.exe as specified above could be written so as to support all three aforementioned command lines simultaneously. There is one additional "special" subcommand called AllSubCommands, which can be used to inject an option into every subcommand. This is useful to support things like help, so that commands such as: llvm-foo.exe --help llvm-foo.exe command1 --help llvm-foo.exe command2 --help All work and display the help for the selected subcommand without having to explicitly go and write code to handle each one separately. This patch is submitted without an example of anything actually using subcommands, but a followup patch will convert the llvm-pdbdump tool to use subcommands. Reviewed By: beanz Differential Revision: http://reviews.llvm.org/D21485 llvm-svn: 274054
* Apply most suggestions of clang-tidy's performance-unnecessary-value-paramBenjamin Kramer2016-06-081-1/+1
| | | | | | | Avoids unnecessary copies. All changes audited & pass tests with asan. No functional change intended. llvm-svn: 272190
* StringRef-ify some Option APIsDavid Blaikie2015-11-171-16/+13
| | | | | | | | Patch by Eugene Kosov! Differential Revision: http://reviews.llvm.org/D14711 llvm-svn: 253360
* Support, IR: silence -Wunused-parameterSaleem Abdulrasool2015-10-231-1/+1
| | | | | | If this is used outside of LLVM with -Werror, this would cause a failure. llvm-svn: 251094
* There is only one saver of strings.Rafael Espindola2015-08-131-1/+0
| | | | llvm-svn: 244854
* Remove macro guards for extern template instantiations.Benjamin Kramer2015-07-131-14/+14
| | | | | | | This is a C++11 feature that both GCC and MSVC have supported as ane extension long before C++11 was approved. llvm-svn: 242042
* Bring in a BumpPtrStringSaver from lld and simplify the interface.Rafael Espindola2015-06-131-10/+3
| | | | | | | | | | | | StringSaver now always saves to a BumpPtrAllocator. The only reason for having the virtual saveImpl is so lld can have a thread safe version. The reason for the distinct BumpPtrStringSaver class is to avoid the virtual destructor. llvm-svn: 239669
* Fixing broken bots after r238505.Chris Bieneman2015-05-281-0/+7
| | | | | | Need non-const iterator inserts too. These failures seem to be due to differences in the versions of libstdc++ on various operating systems. llvm-svn: 238516
* Fixing the polly build.Chris Bieneman2015-05-281-0/+5
| | | | | | I broke the polly build in r238505. This fixes the failure by adding non-const iterator erase methods to cl::list_storage. llvm-svn: 238509
* Re-landing "Refactoring cl::list_storage from "is a" to "has a" std::vector."Chris Bieneman2015-05-281-10/+55
| | | | | | | | Originally landed r238485 MSVC resolves identifiers differently from Clang and GCC, this resulted in build bot failures. This pach re-lands r238485 and fixes the build failures. llvm-svn: 238505
* Revert "Refactoring cl::list_storage from "is a" to "has a" std::vector."Chris Bieneman2015-05-281-52/+7
| | | | | | This reverts commit 117715ca0613d3db144241499401f2ec5398f1d5. llvm-svn: 238491
* Refactoring cl::list_storage from "is a" to "has a" std::vector.Chris Bieneman2015-05-281-7/+52
| | | | | | | | | | | | | | Summary: This isn't necessarily an ideal change, and I want to at least reduce the API surface area, but for the new API we really shouldn't be relying on cl::list being a std::vector. Reviewers: chandlerc Reviewed By: chandlerc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10093 llvm-svn: 238485
* Recommit r231221: "Devirtualize ~parser<T> by making it protected in base ↵David Blaikie2015-03-041-10/+16
| | | | | | | | | | classes and making derived classes final" Reverted in r231254 due to a self-hosting crash of Clang (see Clang PR22793). Workaround the crash by using {} instead of = default to define a dtor. llvm-svn: 231274
* Revert r231221, "Devirtualize ~parser<T> by making it protected in base ↵NAKAMURA Takumi2015-03-041-15/+10
| | | | | | | | classes and making derived classes final" It broke seflhosting. llvm-svn: 231254
* Devirtualize ~parser<T> by making it protected in base classes and making ↵David Blaikie2015-03-041-10/+15
| | | | | | | | | derived classes final These objects are never owned/destroyed polymorphically, so there's no need for a virtual dtor. llvm-svn: 231221
* Avoid copying parser objectsDavid Blaikie2015-03-041-2/+2
| | | | | | | Use of their copy members is deprecated since they have a user-declared dtor. llvm-svn: 231220
* Make OptionValue explicitly copyableDavid Blaikie2015-03-041-0/+8
| | | | | | | | | Since OptionValue (& its base classes) have user-declared dtors, use of the implicit copy ctor/assignment operator is deprecated in C++11. Provide them explicitly (defaulted) to avoid depending on this deprecated feature. llvm-svn: 231218
OpenPOWER on IntegriCloud