summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/CommandLine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Build fix for Visual Studio. NFC.Chris Bieneman2015-01-281-5/+2
| | | | llvm-svn: 227385
* Refactoring llvm command line parsing and option registration.Chris Bieneman2015-01-281-170/+158
| | | | | | | | | | | | | | | | | | | | | 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-2/+1
| | | | | | 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-1/+2
| | | | | | | | | | | | 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/+1
| | | | llvm-svn: 227154
* Pete Cooper suggested the new API should use ArrayRef instead of ↵Chris Bieneman2015-01-261-2/+1
| | | | | | SmallVectorImpl. Also adding a test case. llvm-svn: 227148
* Add new HideUnrelatedOptions API that takes a SmallVectorImpl.Chris Bieneman2015-01-261-0/+14
| | | | | | Need a new API for clang-modernize that allows specifying a list of option categories to remain visible. This will allow clang-modernize to move off getRegisteredOptions. llvm-svn: 227140
* Putting all the standard tool options into a "Generic" category.Chris Bieneman2015-01-261-9/+16
| | | | | | | | | | | | | | | 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
* If we see UTF-8 BOM sequence at the beginning of a response file, we shallYunzhong Gao2015-01-241-0/+12
| | | | | | | | remove these bytes before parsing. Phabricator Revision: http://reviews.llvm.org/D7156 llvm-svn: 226988
* Adding a new cl::HideUnrelatedOptions API to allow clang to migrate off ↵Chris Bieneman2015-01-211-1/+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
* Running clang-format on CommandLine.h and CommandLine.cpp.Chris Bieneman2015-01-131-273/+262
| | | | | | No functional changes, I'm just going to be doing a lot of work in these files and it would be helpful if they had more current LLVM style. llvm-svn: 225817
* Silence static analyzer warnings in LLVMSupport.Michael Ilseman2014-12-111-0/+2
| | | | | | | The static analyzer catches a few potential bugs in LLVMSupport. Add in asserts to silence the warnings. llvm-svn: 224044
* Update SetVector to rely on the underlying set's insert to return a ↵David Blaikie2014-11-191-1/+1
| | | | | | | | | | | | | pair<iterator, bool> This is to be consistent with StringSet and ultimately with the standard library's associative container insert function. This lead to updating SmallSet::insert to return pair<iterator, bool>, and then to update SmallPtrSet::insert to return pair<iterator, bool>, and then to update all the existing users of those functions... llvm-svn: 222334
* Remove StringMap::GetOrCreateValue in favor of StringMap::insertDavid Blaikie2014-11-191-1/+1
| | | | | | | | | | | | | | Having two ways to do this doesn't seem terribly helpful and consistently using the insert version (which we already has) seems like it'll make the code easier to understand to anyone working with standard data structures. (I also updated many references to the Entry's key and value to use first() and second instead of getKey{Data,Length,} and get/setValue - for similar consistency) Also removes the GetOrCreateValue functions so there's less surface area to StringMap to fix/improve/change/accommodate move semantics, etc. llvm-svn: 222319
OpenPOWER on IntegriCloud