summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/CommandLineTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth2017-06-061-2/+2
| | | | | | | | | | | | | | | clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. llvm-svn: 304786
* Reverted r304083 as it seems there is a desire to address this in the ↵Galina Kistanova2017-05-281-6/+3
| | | | | | googletest. llvm-svn: 304084
* Added braces to address gcc warning: suggest explicit braces to avoid ↵Galina Kistanova2017-05-281-3/+6
| | | | | | ambiguous 'else' [-Wdangling-else]. NFC. llvm-svn: 304083
* [Support][CommandLine] Make it possible to get error messages from ↵Eric Liu2017-03-151-21/+55
| | | | | | | | | | | | | | | | | | | 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
* Attempt to pacify buildbotSerge Pavlov2016-11-011-1/+1
| | | | llvm-svn: 285676
* Allow resolving response file names relative to including fileSerge Pavlov2016-11-011-0/+65
| | | | | | | | | | | | | | 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
* [Support][CommandLine] Add cl::getRegisteredSubcommands()Dean Michael Berris2016-10-051-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | 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-24/+24
| | | | llvm-svn: 283007
* Revert "[Support][CommandLine] Add cl::getRegisteredSubcommands()"Zachary Turner2016-09-131-23/+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/+23
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Resubmit "Update llvm command line parser to support subcommands."Zachary Turner2016-06-291-3/+213
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-201/+3
| | | | llvm-svn: 274072
* Update llvm command line parser to support subcommands.Zachary Turner2016-06-281-3/+201
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use gcc's rules for parsing gcc-style response filesNico Weber2016-04-261-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | In gcc, \ escapes every character in response files. It is true that this makes it harder to mention Windows files in rsp files, but not doing this means clang disagrees with gcc, and also disagrees with the shell (on non-Windows) which rsp file quoting is supposed to match. clang isn't free to choose what to do here. In general, the idea for response files is to take bits of your command line and write them to a file unchanged, and have things work the same way. Since the command line would've been interpreted by the shell, things in the rsp file need to be subject to the same shell quoting rules. People who want to put Windows-style paths in their response files either need to do any of: * escape their backslashes * or use clang-cl which uses cl.exe/cmd.exe quoting rules * pass --rsp-quoting=windows to clang to tell it to use cl.exe/cmd.exe quoting rules for response files. Fixes PR27464. http://reviews.llvm.org/D19417 llvm-svn: 267556
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-051-10/+5
| | | | | | | | | | files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
* Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; ↵Eugene Zelenko2016-04-051-5/+10
| | | | | | | | | | | | other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 llvm-svn: 265454
* StringRef-ify some Option APIsDavid Blaikie2015-11-171-6/+6
| | | | | | | | Patch by Eugene Kosov! Differential Revision: http://reviews.llvm.org/D14711 llvm-svn: 253360
* There is only one saver of strings.Rafael Espindola2015-08-131-1/+1
| | | | llvm-svn: 244854
* Bring in a BumpPtrStringSaver from lld and simplify the interface.Rafael Espindola2015-06-131-9/+4
| | | | | | | | | | | | 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
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-3/+1
| | | | | | | | | | | | | | The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' \ -j=32 -fix -format http://reviews.llvm.org/D8925 llvm-svn: 234679
* Silence some Win64 clang-cl warnings about unused stuff due to ifdefsReid Kleckner2015-02-261-0/+2
| | | | llvm-svn: 230685
* Refactoring llvm command line parsing and option registration.Chris Bieneman2015-01-281-7/+5
| | | | | | | | | | | | | | | | | | | | | Summary: The primary goal of this patch is to remove the need for MarkOptionsChanged(). That goal is accomplished by having addOption and removeOption properly sort the options. This patch puts the new add and remove functionality on a CommandLineParser class that is a placeholder. Some of the functionality in this class will need to be merged into the OptionRegistry, and other bits can hopefully be in a better abstraction. This patch also removes the RegisteredOptionList global, and the need for cl::Option objects to be linked list nodes. The changes in CommandLineTest.cpp are required because these changes shift when we validate that options are not duplicated. Before this change duplicate options were only found during certain cl API calls (like cl::ParseCommandLine). With this change duplicate options are found during option construction. Reviewers: dexonsmith, chandlerc, pete Reviewed By: pete Subscribers: pete, majnemer, llvm-commits Differential Revision: http://reviews.llvm.org/D7132 llvm-svn: 227345
* Re-landing changes to use ArrayRef instead of SmallVectorImpl, and new API test.Chris Bieneman2015-01-271-3/+28
| | | | | | This contains the changes from r227148 & r227154, and also fixes to the test case to properly clean up the stack options. llvm-svn: 227255
* Revert r227148 & r227154 which added a test which infinitely loops.Richard Trieu2015-01-271-25/+0
| | | | | | | | | | | | r227148 added test CommandLineTest.HideUnrelatedOptionsMulti which repeatedly outputs two following lines: -tool: CommandLine Error: Option 'test-option-1' registered more than once! -tool: CommandLine Error: Option 'test-option-2' registered more than once! r227154 depends on changes from r227148 llvm-svn: 227167
* One more fix to the new API to fix const-correctness.Chris Bieneman2015-01-271-1/+2
| | | | llvm-svn: 227154
* Pete Cooper suggested the new API should use ArrayRef instead of ↵Chris Bieneman2015-01-261-0/+24
| | | | | | SmallVectorImpl. Also adding a test case. llvm-svn: 227148
* Putting all the standard tool options into a "Generic" category.Chris Bieneman2015-01-261-0/+5
| | | | | | | | | | | | | | | Summary: This puts all the options that CommandLine.cpp implements into a category so that the APIs to hide options can not hide based on the generic category instead of string matching a partial list of argument strings. This patch is pretty simple and straight forward but it does impact the -help output of all tools using cl::opt. Specifically the options implemented in CommandLine.cpp (help, help-list, help-hidden, help-list-hidden, print-options, print-all-options, version) are all grouped together into an Option category, and these options are never hidden by the cl::HideUnrelatedOptions API. Reviewers: dexonsmith, chandlerc, majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7150 llvm-svn: 227093
* Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off ↵Chris Bieneman2015-01-211-0/+11
| | | | | | | | | | | | | | | | cl::getRegisteredOptions. Summary: cl::getRegisteredOptions really exposes some of the innards of how command line parsing is implemented. Exposing new APIs that allow us to disentangle client code from implementation details will allow us to make more extensive changes to command line parsing. Reviewers: chandlerc, dexonsmith, beanz Reviewed By: dexonsmith Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7100 llvm-svn: 226729
* Fix PR17239 by changing the semantics of the RemainingArgsClass Option kindReid Kleckner2014-08-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | This patch contains the LLVM side of the fix of PR17239. This bug that happens because the /link (clang-cl.exe argument) is marked as "consume all remaining arguments". However, when inside a response file, /link should only consume all remaining arguments inside the response file where it is located, not the entire command line after expansion. My patch will change the semantics of the RemainingArgsClass kind to always consume only until the end of the response file when the option originally came from a response file. There are only two options in this class: dash dash (--) and /link. Reviewed By: rnk Differential Revision: http://reviews.llvm.org/D4899 Patch by Rafael Auler! llvm-svn: 216280
* Revert "[Support] Promote cl::StringSaver to a separate utility"Sean Silva2014-08-151-2/+9
| | | | | | | | | This reverts commit r215784 / 3f8a26f6fe16cc76c98ab21db2c600bd7defbbaa. LLD has 3 StringSaver's, one of which takes a lock when saving the string... Need to investigate more closely. llvm-svn: 215790
* [Support] Promote cl::StringSaver to a separate utilitySean Silva2014-08-151-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is generally useful. In breaking it out, the primary change is that it has been made non-virtual. It seems like being abstract led to there being 3 different (2 in llvm + 1 in clang) concrete implementations which disagreed about the ownership of the saved strings (see the manual call to free() in the unittest StrDupSaver; yes this is different from the CommandLine.cpp StrDupSaver which owns the stored strings; which is different from Clang's StringSetSaver which just holds a reference to a std::set<std::string> which owns the strings). I've identified 2 other places in the codebase that are open-coding this pattern: memcpy(Alloc.Allocate<char>(strlen(S)+1), S, strlen(S)+1) I'll be switching them over. They are * llvm::sys::Process::GetArgumentVector * The StringAllocator member of YAMLIO's Input class This also will allow simplifying Clang's driver.cpp quite a bit. Let me know if there are any other places that could benefit from StringSaver. I'm also thinking of adding a saveStringRef member for getting a stable StringRef. llvm-svn: 215784
* Support: Fix option handling when using cl::Required with aliasoptJustin Bogner2014-07-141-0/+19
| | | | | | | | | | | | | | | | Until now, attempting to create an alias of a required option would complain if the user supplied the alias, because the required option didn't have a value. Similarly, if you said the alias was required, then using the base option would complain that the alias wasn't supplied. Lastly, if you put required on both, *neither* option would work. By changning alias to overload addOccurrence and setting cl::Required on the original option, we can get this to behave in a more useful way. I've also added a test and updated a user that was getting this wrong. llvm-svn: 212986
* [C++11] Use 'nullptr'.Craig Topper2014-06-081-1/+1
| | | | llvm-svn: 210442
* Switch all uses of LLVM_OVERRIDE to just use 'override' directly.Craig Topper2014-03-021-1/+1
| | | | llvm-svn: 202621
* Remove C++11ism from r200407.Jordan Rose2014-01-291-1/+1
| | | | | | Oops! llvm-svn: 200412
* [CommandLine] Aliases require an value if their target requires a value.Jordan Rose2014-01-291-2/+53
| | | | | | | | | This can still be overridden by explicitly setting a value requirement on the alias option, but by default it should be the same. PR18649 llvm-svn: 200407
* Re-sort all of the includes with ./utils/sort_includes.py so thatChandler Carruth2014-01-071-1/+1
| | | | | | | | | | subsequent changes are easier to review. About to fix some layering issues, and wanted to separate out the necessary churn. Also comment and sink the include of "Windows.h" in three .inc files to match the usage in Memory.inc. llvm-svn: 198685
* Implement TokenizeWindowsCommandLine.Rui Ueyama2013-07-301-9/+28
| | | | | | | | | | This is a follow up patch for r187390 to implement the parser for the Windows-style command line. This should follow the rule as described at http://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx Differential Revision: http://llvm-reviews.chandlerc.com/D1235 llvm-svn: 187430
* [Support] Beef up and expose the response file parsing in llvm::clReid Kleckner2013-07-181-0/+24
| | | | | | | | | | | | | | | | | | | The plan is to use it for clang and lld. Major behavior changes: - We can now parse UTF-16 files that have a byte order mark. - PR16209: Don't drop backslashes on the floor if they don't escape anything. The actual parsing loop was based on code from Clang's driver.cpp, although it's been rewritten to track its state with control flow rather than state variables. Reviewers: hans Differential Revision: http://llvm-reviews.chandlerc.com/D1170 llvm-svn: 186587
* Implemented public interface for modifying registered (not positional or ↵Andrew Trick2013-05-061-3/+47
| | | | | | | | sink options) command line options at runtime. Patch by Dan Liew! llvm-svn: 181254
* Support command line option categories.Andrew Trick2013-05-061-0/+8
| | | | | | Patch by Dan Liew! llvm-svn: 181253
* Sort the #include lines for unittest/...Chandler Carruth2012-12-041-3/+1
| | | | llvm-svn: 169250
* Added test for non-static use of cl::opt (fixed in r160170)Alexander Kornienko2012-08-131-0/+11
| | | | llvm-svn: 161751
* Fix a compile failure introduced by r82675 on MinGW which doesn't haveJeffrey Yasskin2009-09-251-0/+12
| | | | | | | setenv(). This patch just disables the test rather than getting putenv() to work. Thanks to Sandeep Patel for reporting the problem. llvm-svn: 82797
* Roll back r82348, which introduced an infinite loop in ParseCStringVector() thatJeffrey Yasskin2009-09-241-0/+48
a trivial unittest would have caught. This revision also adds the trivial unittest. llvm-svn: 82675
OpenPOWER on IntegriCloud