summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add initial support for debug countingDaniel Berlin2017-02-191-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* CommandLine option: Relax the assertion introduced in r290467 to allows for ↵Mehdi Amini2017-01-081-1/+1
| | | | | | | | | empty string This is used in LDC for custom boolean commandline options, setArgStr is called with an empty string before using AddLiteralOption. llvm-svn: 291406
* Add an assertion for cl::opt names: they can't start with '-'Mehdi Amini2016-12-231-0/+1
| | | | llvm-svn: 290467
* Don't double-initialize cl::opt for iterating in reverse order to uncover ↵Mehdi Amini2016-12-141-1/+1
| | | | | | | | | | | non-determinism in codegen by default Bots are broken and needs to be fixed before having this on by default. The feature was committed in r289619. I tried to disable it in r289624 and failed because it was initialized in two places. llvm-svn: 289626
* [llvm] Iterate SmallPtrSet in reverse order to uncover non-determinism in ↵Mandeep Singh Grang2016-12-141-0/+11
| | | | | | | | | | | | | | | | | | codegen Summary: Given a flag (-mllvm -reverse-iterate) this patch will enable iteration of SmallPtrSet in reverse order. The idea is to compile the same source with and without this flag and expect the code to not change. If there is a difference in codegen then it would mean that the codegen is sensitive to the iteration order of SmallPtrSet. This is enabled only with LLVM_ENABLE_ABI_BREAKING_CHECKS. Reviewers: chandlerc, dexonsmith, mehdi_amini Subscribers: mgorny, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D26718 llvm-svn: 289619
* Fix file name resolution in nested response filesSerge Pavlov2016-11-201-0/+6
| | | | | | | | | | If a response file in construct `@file` was specified by relative name, constructs `@file` nested within it were resolved incorrectly if the flag RelativeNames in call to ExpandResponseFile was set to true. This feature is used in configuration files, tests for it are in respective change (see D24933). llvm-svn: 287482
* Allow resolving response file names relative to including fileSerge Pavlov2016-11-011-6/+23
| | | | | | | | | | | | | | 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] Display subcommands in help when there are less than 3Alex Lorenz2016-10-121-1/+1
| | | | | | | | | | | | | | subcommands This commit fixes a bug where the help output doesn't display subcommands when a tool has less than 3 subcommands. This change doesn't include a corresponding unittest as there is no viable way to provide a unittest for it. Differential Revision: https://reviews.llvm.org/D25463 llvm-svn: 283998
* [cl] Don't print subcommand help when no subcommands present.Zachary Turner2016-10-111-4/+6
| | | | | | | | | | | | | | | | Previously we would print USAGE: <exe> [subcommand] [options] Even if no subcommands were present. This changes the output format to only print "[subcommand]" if there is at least one subcommand. Fixes llvm.org/pr30598 Patch by Serge Guelton llvm-svn: 283892
* [Support][CommandLine] Add cl::getRegisteredSubcommands()Dean Michael Berris2016-10-051-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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 StringSaver API (NFC)Mehdi Amini2016-10-051-5/+5
| | | | llvm-svn: 283290
* Use StringRef in CommandLine Options handling (NFC)Mehdi Amini2016-10-011-52/+54
| | | | llvm-svn: 283007
* Revert "[Support][CommandLine] Add cl::getRegisteredSubcommands()"Zachary Turner2016-09-131-11/+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/+11
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner2016-08-171-3/+3
| | | | | | Follow up to r278902. I had missed "fall through", with a space. llvm-svn: 278970
* Use the range variant of find instead of unpacking begin/endDavid Majnemer2016-08-111-1/+1
| | | | | | | | | If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. llvm-svn: 278433
* [CommandLine] Use Process::GetEnv instead of _wgetenvDavid Majnemer2016-07-241-21/+4
| | | | | | | | | | Process::GetEnv does the right thing across our platforms. CommandLine.cpp had, more or less, the same logic. Let's remove the duplication. No functional change is intended. llvm-svn: 276572
* [llvm-cov] - Improve llvm-cov error messageYing Yi2016-07-221-1/+2
| | | | | | | | | | | | | | | | | | | Summary: When giving the following command: % llvm-cov report -instr-profile=default.profraw llvm-cov will give the following error message: >llvm-cov report: Not enough positional command line arguments specified! >Must specify at least 1 positional arguments: See: orbis-llvm-cov report -help This patch changes the error message from '1 positional arguments' to '1 positional argument'. Differential Revision: https://reviews.llvm.org/D22621 llvm-svn: 276404
* Get rid of call to StringRef::substr that's never used.Justin Lebar2016-07-191-1/+0
| | | | | | | | | | | | Summary: substr doesn't modify the string, so this line has no effect. Reviewers: majnemer Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D22540 llvm-svn: 276057
* Resubmit "Update llvm command line parser to support subcommands."Zachary Turner2016-06-291-98/+383
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-378/+98
| | | | llvm-svn: 274072
* Update llvm command line parser to support subcommands.Zachary Turner2016-06-281-98/+378
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Avoid duplicated map lookups. No functionality change intended.Benjamin Kramer2016-06-171-6/+4
| | | | llvm-svn: 273030
* [STLExtras] Introduce and use llvm::count_if; NFCSanjoy Das2016-06-101-5/+4
| | | | | | (This is split out from was D21115) llvm-svn: 272435
* 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
* Remove LLVM_ENABLE_TIMESTAMPSChris Bieneman2016-05-051-3/+0
| | | | | | | | | | | | | | | | | | | Summary: As per the discussion on LLVM-dev this patch proposes removing LLVM_ENABLE_TIMESTAMPS. The only complicated bit of this patch is the Windows support. On windows we used to log an error if /INCREMENTAL was passed to the linker when timestamps were disabled. With this change since timestamps in code are always disabled we will always compile on windows with /Brepro unless /INCREMENTAL is specified, and we will log a warning when /INCREMENTAL is specified to notify the user that the build will be non-deterministic. See: http://lists.llvm.org/pipermail/llvm-dev/2016-May/098990.html Reviewers: bogner, silvas, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19892 llvm-svn: 268670
* Use gcc's rules for parsing gcc-style response filesNico Weber2016-04-261-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [CMake] Add PACKAGE_VENDOR for customizing version outputChris Bieneman2016-03-151-2/+6
| | | | | | | | | | | | Summary: This change adds a PACKAGE_VENDOR variable. When set it makes the version output more closely resemble the clang version output. Reviewers: aprantl, bogner Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18159 llvm-svn: 263566
* More UTF string conversion wrappersMarianne Mailhot-Sarrasin2016-03-111-0/+19
| | | | | | | | | | | Added new string conversion wrappers that convert between `std::string` (of UTF-8 bytes) and `std::wstring`, which is particularly useful for Win32 interop. Also fixed a missing string conversion for `getenv` on Win32, using these new wrappers. The motivation behind this is to provide the support functions required for LLDB to work properly on Windows with non-ASCII data; however, the functions are not LLDB specific. Patch by cameron314 Differential Revision: http://reviews.llvm.org/D17549 llvm-svn: 263247
* Avoid overly large SmallPtrSet/SmallSetMatthias Braun2016-01-301-1/+1
| | | | | | | These sets perform linear searching in small mode so it is never a good idea to use SmallSize/N bigger than 32. llvm-svn: 259283
* Refactor: Simplify boolean conditional return statements in llvm/lib/SupportAlexander Kornienko2015-12-281-4/+1
| | | | | | | | | | | | | | Summary: Use clang-tidy to simplify boolean conditional return statements Reviewers: rafael, bkramer, ddunbar, Bigcheese, chandlerc, chapuni, nicholas, alexfh Subscribers: alexfh, craig.topper, llvm-commits Patch by Richard Thomson! Differential Revision: http://reviews.llvm.org/D9978 llvm-svn: 256500
* StringRef-ify some Option APIsDavid Blaikie2015-11-171-26/+25
| | | | | | | | 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-2/+2
| | | | llvm-svn: 244854
* Remove macro guards for extern template instantiations.Benjamin Kramer2015-07-131-15/+15
| | | | | | | 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
* Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko2015-06-231-2/+2
| | | | | | Apparently, the style needs to be agreed upon first. llvm-svn: 240390
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-191-2/+2
| | | | | | | | | | | | | The patch is generated using this command: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ llvm/lib/ Thanks to Eugene Kosov for the original patch! llvm-svn: 240137
* Bring in a BumpPtrStringSaver from lld and simplify the interface.Rafael Espindola2015-06-131-28/+10
| | | | | | | | | | | | 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-1/+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
* Remove more superfluous .str() and replace std::string concatenation with Twine.Yaron Keren2015-03-301-1/+1
| | | | | | Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev. llvm-svn: 233555
* Purge unused includes throughout libSupport.Benjamin Kramer2015-03-231-2/+0
| | | | | | NFC. llvm-svn: 232976
* CommandLine: Replace cold std::sort with array_pod_sort.Benjamin Kramer2015-03-141-11/+12
| | | | | | | | | Also replace an old use of qsort with it. Compiles down to the same thing but gives us some type safety. Safes a couple of kb on CommandLine.o. NFC. llvm-svn: 232236
* Simplify expressions involving boolean constants with clang-tidyDavid Blaikie2015-03-091-2/+2
| | | | | | | | Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8154 llvm-svn: 231617
* Prefer SmallVector::append/insert over push_back loops.Benjamin Kramer2015-02-171-3/+1
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229500
* Fixing broken bots.Chris Bieneman2015-02-131-1/+1
| | | | llvm-svn: 229176
* NFC. Moving the RegisteredOptionCategories global into the CommandLineParser ↵Chris Bieneman2015-02-131-15/+18
| | | | | | class. llvm-svn: 229172
* NFC. clang-format wants to change this from two lines to one.Chris Bieneman2015-02-131-2/+1
| | | | llvm-svn: 229171
* NFC. More code cleanup making LookupOption a member of the CommandLineParser.Chris Bieneman2015-02-131-4/+6
| | | | llvm-svn: 229170
* Make helper functions/classes/globals static. NFC.Benjamin Kramer2015-02-061-0/+4
| | | | llvm-svn: 228410
* NFC. Making printOptionValues an API on the parser class.Chris Bieneman2015-01-301-3/+7
| | | | llvm-svn: 227626
* CommandLineParser: Avoid non-static member nitializer(s).NAKAMURA Takumi2015-01-291-2/+4
| | | | llvm-svn: 227428
OpenPOWER on IntegriCloud