summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Option
Commit message (Collapse)AuthorAgeFilesLines
* Option spell checking: Penalize delimiter flags if input has no argumentNico Weber2019-05-012-5/+17
| | | | | | | | | | | | | | | If the user passes a flag like `-version` to a program, it's more likely they mean `--version` than `-version:`, since there's no parameter passed. Hence, give delimited arguments a penalty of 1 if the user input doesn't contain the delimiter or no data after it. The motivation is that with this, lld-link can suggest "--version" instead of "-version:" for "-version" and "-nodefaultlib" instead of "-nodefaultlib:" for "-nodefaultlibs". Differential Revision: https://reviews.llvm.org/D61382 llvm-svn: 359701
* Fix OptTable::findNearest() adding delimiter for freeNico Weber2019-05-012-0/+8
| | | | | | | | | | | Prior to this, OptTable::findNearest() thought that the input `--foo` had an editing distance of 0 from an existing flag `--foo=`, which made it suggest flags with delimiters more often than flags without one. After this, it correctly assigns this case an editing distance of 1. Differential Revision: https://reviews.llvm.org/D61373 llvm-svn: 359685
* Re-reland "[Option] Fix PR37006 prefix choice in findNearest"Nico Weber2019-04-302-0/+5
| | | | | | | | | | | | | | | | This was first reviewed in https://reviews.llvm.org/D46776 and landed in r332299, but got reverted because it broke the PS4 bots. https://reviews.llvm.org/D50410 fixed this, and then this change was re-reviewed at https://reviews.llvm.org/D50515 and relanded in r341329. It got reverted due to causing MSan issues. However, nobody wrote down the error message and the bot link is dead, so I'm relanding this to capture the MSan error. I'll then either fix it, or copy it somewhere and revert if fixing looks difficult. llvm-svn: 359580
* 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
* [opt] Change the parameter of OptTable::PrintHelp from Name to Usage and ↵Fangrui Song2018-10-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | don't append "[options] <inputs>" Summary: Before, "[options] <inputs>" is unconditionally appended to the `Name` parameter. It is more flexible to change its semantic to `Usage` and let user customize the usage line. % llvm-objcopy ... USAGE: llvm-objcopy <input> [ <output> ] [options] <inputs> With this patch: % llvm-objcopy ... USAGE: llvm-objcopy input [output] Reviewers: rupprecht, alexshap, jhenderson Reviewed By: rupprecht Subscribers: jakehehrlich, mehdi_amini, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D51009 llvm-svn: 344097
* Revert r341329 due to MSAN errorBrian Gesiak2018-09-032-5/+0
| | | | | | | Pushing https://reviews.llvm.org/rL341329 revealed an MSAN error. Revert it so that we can fix the error. llvm-svn: 341333
* Re-push "[Option] Fix PR37006 prefix choice in findNearest"Brian Gesiak2018-09-032-0/+5
| | | | | | | | | | | | | | | | | | | | Summary: Original changeset (https://reviews.llvm.org/D46776) by @modocache. It was reverted after the PS4 bot failed. The issue has been determined to be with the way the PS4 SDK handles this particular option. https://reviews.llvm.org/D50410 removes this test, so we can push this again. Patch by Arnaud Coomans! Reviewers: cfe-commits, modocache Reviewed By: modocache Differential Revision: https://reviews.llvm.org/D50515 llvm-svn: 341329
* Re-revert "[Option] Fix PR37006 prefix choice in findNearest"Brian Gesiak2018-05-192-5/+0
| | | | | | | | Summary: Reverting due to a test failure in an llvm-mt test on some buildbots, namely http://green.lab.llvm.org/green/job/clang-stage2-configure-Rlto/26020/. llvm-svn: 332812
* Un-revert "[Option] Fix PR37006 prefix choice in findNearest"Brian Gesiak2018-05-192-0/+5
| | | | | | | | | | | | | Summary: In https://reviews.llvm.org/rL332804 I loosed the assertion in the Clang driver test that forced me to revert https://reviews.llvm.org/rL332299. Once this lands I should be able to narrow down what caused PS4 buildbots to fail, and reinstate the check in that test. Test Plan: check-llvm & check-clang llvm-svn: 332805
* Revert "[Option] Fix PR37006 prefix choice in findNearest"Brian Gesiak2018-05-142-5/+0
| | | | | | | | | | | Summary: This revision causes build failures in PS4 and ppc64le buildbots (for example, http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/29988). I'll revert for now and try to diagnose the issue. Test Plan: check-llvm check-clang llvm-svn: 332304
* [Option] Fix PR37006 prefix choice in findNearestBrian Gesiak2018-05-142-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: In https://bugs.llvm.org/show_bug.cgi?id=37006 Nico Weber points out a flaw in `OptTable::findNearest`: if an option "foo"'s prefixes are "--" and "-", then the nearest option for "--fob" will be "-foo". This is incorrect, however, since the function is expected to return "--foo". The bug is due to a naive loop that attempts to predetermines which prefix is best. Instead, compute the edit distance for each prefix/name pair. Test Plan: `check-llvm` Reviewers: thakis Reviewed By: thakis Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46776 llvm-svn: 332299
* [Option] For typo '-foo', suggest '--foo'Brian Gesiak2018-01-092-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/rL321877 introduced the `OptTable::findNearest` method, to find the closest edit distance option for a given string. However, the implementation contained a bug: for a typo `-foo` with an edit distance of 1 away from a valid option `--foo`, `findNearest` would suggest a nearby option of `foo`. That is, the result would not include the `--` prefix, and so was not a valid option. Fix the bug by ensuring that the prefix string is initialized to one of the valid prefixes for the option. Test Plan: `check-llvm-unit` Reviewers: v.g.vassilev, teemperor, ruiu, jroelofs, yamaguchi Reviewed By: jroelofs Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41873 llvm-svn: 322109
* [Option] Add 'findNearest' method to catch typosBrian Gesiak2018-01-052-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add a method `OptTable::findNearest`, which allows users of OptTable to check user input for misspelled options. In addition, have llvm-mt check for misspelled options. For example, if a user invokes `llvm-mt /oyt:foo`, the error message will indicate that while an option named `/oyt:` does not exist, `/out:` does. The method ports the functionality of the `LookupNearestOption` method from LLVM CommandLine to libLLVMOption. This allows tools like Clang and Swift, which do not use CommandLine, to use this functionality to suggest similarly spelled options. As room for future improvement, the new method as-is cannot yet properly suggest nearby "joined" options -- that is, for an option string "-FozBar", where "-Foo" is the correct option name and "Bar" is the value being passed along with the misspelled option, this method will calculate an edit distance of 4, by deleting "Bar" and changing "z" to "o". It should instead calculate an edit distance of just 1, by changing "z" to "o" and recognizing "Bar" as a value. This commit includes a disabled test that expresses this limitation. Test Plan: `check-llvm` Reviewers: yamaguchi, v.g.vassilev, teemperor, ruiu, jroelofs Reviewed By: jroelofs Subscribers: jroelofs, llvm-commits Differential Revision: https://reviews.llvm.org/D41732 llvm-svn: 321877
* [GSoC] Flag value completion for clangYuka Takahashi2017-06-201-6/+7
| | | | | | | | | | | | This is patch for GSoC project, bash-completion for clang. To use this on bash, please run `source clang/utils/bash-autocomplete.sh`. bash-autocomplete.sh is code for bash-completion. In this patch, Options.td was mainly changed in order to add value class in Options.inc. llvm-svn: 305805
* Fix some ArgList uses after API change in r300135.Richard Smith2017-04-121-4/+4
| | | | llvm-svn: 300139
* Option parser: class for consuming a joined arg in addition to all remaining ↵Hans Wennborg2016-04-152-0/+53
| | | | | | args llvm-svn: 266394
* OptionParsingTest.cpp: reorder EXPECT_EQs to put expectation on the left. NFC.Hans Wennborg2016-04-151-25/+25
| | | | | | | This provides for better error messages from the framework when the expected and actual values don't match. llvm-svn: 266393
* Remove autoconf supportChris Bieneman2016-01-261-23/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* [Option] Use an ArrayRef to store the Option Infos in OptTable. NFCCraig Topper2015-10-211-1/+1
| | | | llvm-svn: 250901
* Modify ParseArgs to return the InputArgList by value - there's no need for ↵David Blaikie2015-06-221-65/+64
| | | | | | | | | | | | dynamic allocation/ownership here The one caller that does anything other than keep this variable on the stack is the single use of DerivedArgList in Clang, which is a bit more interesting but can probably be cleaned up/simplified a bit further (have DerivedArgList take ownership of the InputArgList rather than needing to reference its Args indirectly) which I'll try to after this. llvm-svn: 240345
* ArrayRef-ify ParseArgsDavid Blaikie2015-06-211-19/+11
| | | | llvm-svn: 240233
* Option parsing: properly handle flag aliases for joined options (PR23394)Hans Wennborg2015-05-042-0/+16
| | | | | | | | | A joined option always needs to have an argument, even if it's an empty one. Clang would previously assert when trying to use --extra-warnings, which is a flag alias for -W, which is a joined option. llvm-svn: 236434
* Retire llvm::array_endof in favor of non-member std::end.Benjamin Kramer2014-04-121-10/+10
| | | | | | While there make array_lengthof constexpr if we have support for it. llvm-svn: 206112
* Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles2014-03-061-9/+15
| | | | | | | | | | This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
* [CMake] Also OptionTests can be free from add_dependencies() with ↵NAKAMURA Takumi2013-11-281-2/+0
| | | | | | add_public_tablegen_target(). llvm-svn: 195928
* Option parsing: support case-insensitive option matching.Rui Ueyama2013-08-281-3/+23
| | | | | | Re-submitting r189416 with fix for Windows build on where strcasecmp is not defined. llvm-svn: 189501
* Revert "Option parsing: support case-insensitive option matching." as it ↵Rui Ueyama2013-08-281-23/+3
| | | | | | | | broke Windows buildbot. This reverts r189416. llvm-svn: 189424
* Option parsing: support case-insensitive option matching.Rui Ueyama2013-08-271-3/+23
| | | | | | | | | | | | | | Link.exe's command line options are case-insensitive. This patch adds a new attribute to OptTable to let the option parser to compare options, ignoring case. Command lines are generally case-insensitive on Windows. CL.exe is an exception. So this new attribute should be useful for other commands running on Windows. Differential Revision: http://llvm-reviews.chandlerc.com/D1485 llvm-svn: 189416
* Options: explicit handling of --Hans Wennborg2013-08-131-14/+1
| | | | | | | | | | | Clients of the option parsing library should handle it explicitly using a KIND_REMAINING_ARGS option. Clang and lld have been updated in r188316 and r188318, respectively. Also fix -Wsign-compare warning in the option parsing test. llvm-svn: 188323
* Options: Add new option kind that consumes remaining argumentsHans Wennborg2013-08-132-0/+29
| | | | | | | | | | | | | | | | This adds KIND_REMAINING_ARGS, a class of options that consume all remaining arguments on the command line. This will be used to support /link in clang-cl, which is used to forward all remaining arguments to the linker. It also allows us to remove the hard-coded handling of "--", allowing clients (clang and lld) to implement that functionality themselves with this new option class. Differential Revision: http://llvm-reviews.chandlerc.com/D1387 llvm-svn: 188314
* Option parsing: recognize the special -- tokenHans Wennborg2013-08-021-0/+13
| | | | | | | | | | | | | | Everything that comes after -- should be treated as a filename. This enables passing in filenames that would otherwise be conflated with command-line options. This is especially important for clang-cl which supports options starting with /, which are easily conflatable with Unix-style path names. Differential Revision: http://llvm-reviews.chandlerc.com/D1274 llvm-svn: 187675
* Option parsing: remove non-SUPPORT_ALIASARGS fall-backHans Wennborg2013-07-311-2/+0
| | | | | | | | The clients of this code have been updated to all support AliasArgs. This depends on Clang r187538 and lld r187541. llvm-svn: 187546
* Option parsing: add support for alias arguments.Hans Wennborg2013-07-312-3/+19
| | | | | | | | | | | | | | | | | | This makes option aliases more powerful by enabling them to pass along arguments to the option they're aliasing. For example, if we have a joined option "-foo=", we can now specify a flag option "-bar" to be an alias of that, with the argument "baz". This is especially useful for the cl.exe compatible clang driver, where many options are aliases. For example, this patch enables us to alias "/Ox" to "-O3" (-O is a joined option), and "/WX" to "-Werror" (again, -W is a joined option). Differential Revision: http://llvm-reviews.chandlerc.com/D1245 llvm-svn: 187537
* Option parsing: allow aliases in groupsHans Wennborg2013-07-222-0/+12
| | | | | | | | | Option aliases in option groups were previously disallowed by an assert. As far as I can tell, there was no technical reason for this, and I would like to be able to put cl.exe compatible options in their own group for Clang, so let's change the assert. llvm-svn: 186838
* Add Option unit tests to the make buildHans Wennborg2013-07-201-0/+23
| | | | | | Previously, they were only built and run in the CMake build. llvm-svn: 186756
* Add some flag exclusion tests.Reid Kleckner2013-07-192-12/+49
| | | | llvm-svn: 186704
* llvm/unittests: Use OwningPtr to fix --vg-leak.NAKAMURA Takumi2013-01-231-1/+6
| | | | llvm-svn: 173240
* Whitespace.NAKAMURA Takumi2013-01-231-1/+1
| | | | llvm-svn: 173234
* Sort a few more #include lines in tools/... unittests/... and utils/...Chandler Carruth2013-01-021-1/+0
| | | | llvm-svn: 171363
* Copy clang/Driver/<Option parsing stuff> to llvm.Michael J. Spencer2012-12-053-0/+130
llvm-svn: 169344
OpenPOWER on IntegriCloud