aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Option
AgeCommit message (Collapse)AuthorFilesLines
2018-03-12[NFC] Replace iterators in PrintHelp with range-based forJan Korous1-6/+4
llvm-svn: 327312
2018-03-12[NFC] PrintHelp cleanupJan Korous1-3/+1
llvm-svn: 327311
2018-03-05[Bash-autocompletion] Pass all flags in shell command-line to ClangYuka Takahashi1-2/+2
Previously, we passed "#" to --autocomplete to indicate to enable cc1 flags. For example, when -cc1 or -Xclang was passed to bash, bash executed `clang --autocomplete=#-<flag they want to complete>`. However, this was not a good implementation because it depends -Xclang and -cc1 parsing to shell. So I changed this to pass all flags shell has, so that Clang can handle them internally. I had to change many testcases because API spec changed quite a lot. Reviewers: teemperor, v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39342 llvm-svn: 326684
2018-01-09[Option] For typo '-foo', suggest '--foo'Brian Gesiak1-2/+2
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
2018-01-05[Option] Add 'findNearest' method to catch typosBrian Gesiak1-0/+63
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
2017-10-15Reverting r315590; it did not include changes for llvm-tblgen, which is ↵Aaron Ballman3-3/+3
causing link errors for several people. Error LNK2019 unresolved external symbol "public: void __cdecl `anonymous namespace'::MatchableInfo::dump(void)const " (?dump@MatchableInfo@?A0xf4f1c304@@QEBAXXZ) referenced in function "public: void __cdecl `anonymous namespace'::AsmMatcherEmitter::run(class llvm::raw_ostream &)" (?run@AsmMatcherEmitter@?A0xf4f1c304@@QEAAXAEAVraw_ostream@llvm@@@Z) llvm-tblgen D:\llvm\2017\utils\TableGen\AsmMatcherEmitter.obj 1 llvm-svn: 315854
2017-10-12[dump] Remove NDEBUG from test to enable dump methods [NFC]Don Hinton3-3/+3
Summary: Add LLVM_FORCE_ENABLE_DUMP cmake option, and use it along with LLVM_ENABLE_ASSERTIONS to set LLVM_ENABLE_DUMP. Remove NDEBUG and only use LLVM_ENABLE_DUMP to enable dump methods. Move definition of LLVM_ENABLE_DUMP from config.h to llvm-config.h so it'll be picked up by public headers. Differential Revision: https://reviews.llvm.org/D38406 llvm-svn: 315590
2017-08-29Revert "Revert r311552: [Bash-autocompletion] Add support for static ↵Yuka Takahashi1-6/+19
analyzer flags" This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e. r311552 broke lld buildbot because I've changed OptionInfos type from ArrayRef to vector. However the bug is fixed, so I'll commit this again. llvm-svn: 311958
2017-08-24test commit: fix typo in commentNathan Hawes1-1/+1
llvm-svn: 311701
2017-08-23Revert r311552: [Bash-autocompletion] Add support for static analyzer flagsRui Ueyama1-19/+6
This reverts commit r311552 because it broke ubsan and asan bots. llvm-svn: 311557
2017-08-23[Bash-autocompletion] Add support for static analyzer flagsYuka Takahashi1-6/+19
Summary: This is a patch for clang autocomplete feature. It will collect values which -analyzer-checker takes, which is defined in clang/StaticAnalyzer/Checkers/Checkers.inc, dynamically. First, from ValuesCode class in Options.td, TableGen will generate C++ code in Options.inc. Options.inc will be included in DriverOptions.cpp, and calls OptTable's addValues function. addValues function will add second argument to Option's Values class. Values contains string like "foo,bar,.." which is handed to Values class in OptTable. Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: hiraditya, cfe-commits Differential Revision: https://reviews.llvm.org/D36782 llvm-svn: 311552
2017-07-26[Bash-autocompletion] Show HelpText with possible flagsYuka Takahashi1-1/+3
Summary: `clang --autocomplete=-std` will show ``` -std: Language standard to compile for -std= Language standard to compile for -stdlib= C++ standard library to use ``` after this change. However, showing HelpText with completion in bash seems super tricky, so this feature will be used in other shells (fish, zsh...). Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: cfe-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35759 llvm-svn: 309113
2017-07-26[libOption] - Add flag allowing to print options aliases in help text.George Rimar1-7/+15
By default, we display only options that are not hidden and have help texts. This patch adds flag allowing to display aliases that have no help text. In this case help text of aliased option used instead. Differential revision: https://reviews.llvm.org/D35476 llvm-svn: 309087
2017-07-18[libOption] - Replace std::pair with helper struct. NFC.George Rimar1-12/+13
Splitted from D35476. llvm-svn: 308293
2017-07-08[Bash-autocompletion] Auto complete cc1 options if -cc1 is specifiedYuka Takahashi1-1/+5
Summary: We don't want to autocomplete flags whose Flags class has `NoDriverOption` when argv[1] is not `-cc1`. Another idea for this implementation is to make --autocomplete a cc1 option and handle it in clang Frontend, by porting --autocomplete handler from Driver to Frontend, so that we can handle Driver options and CC1 options in unified manner. Differential Revision: https://reviews.llvm.org/D34770 llvm-svn: 307479
2017-07-05[Bash-autocompletion] Show flags which has HelpText or GroupIDYuka Takahashi1-1/+1
Summary: Otherwise internal flags will be also completed. Differential Revision: https://reviews.llvm.org/D34930 llvm-svn: 307116
2017-06-20[GSoC] Flag value completion for clangYuka Takahashi2-0/+35
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
2017-06-16[BinaryFormat, Option, TableGen] Fix some Clang-tidy modernize-use-using and ↵Eugene Zelenko4-32/+49
Include What You Use warnings; other minor fixes (NFC). llvm-svn: 305537
2017-06-06Sort the remaining #include lines in include/... and lib/....Chandler Carruth1-1/+1
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
2017-05-23[GSoC] Shell autocompletion for clangYuka Takahashi1-0/+14
Summary: This is a first 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. Simple flag completion and path completion is available in this patch. Reviewers: teemperor, v.g.vassilev, ruiu, Bigcheese, efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33237 llvm-svn: 303670
2017-04-12ArgList: cache index ranges containing arguments with each IDRichard Smith1-193/+33
Improve performance of argument list parsing with large numbers of IDs and large numbers of arguments, by tracking a conservative range of indexes within the argument list that might contain an argument with each ID. In the worst case (when the first and last argument with a given ID are at the opposite ends of the argument list), this still results in a linear-time walk of the list, but it helps substantially in the common case where each ID occurs only once, or a few times close together in the list. This gives a ~10x speedup to clang's `test/Driver/response-file.c`, which constructs a very large set of command line arguments and feeds them to the clang driver. Differential Revision: https://reviews.llvm.org/D30130 llvm-svn: 300135
2017-01-28Cleanup dump() functions.Matthias Braun3-0/+6
We had various variants of defining dump() functions in LLVM. Normalize them (this should just consistently implement the things discussed in http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html For reference: - Public headers should just declare the dump() method but not use LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) - The definition of a dump method should look like this: #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MyClass::dump() { // print stuff to dbgs()... } #endif llvm-svn: 293359
2016-09-29Generalize ArgList::AddAllArgs moreDouglas Katzman1-5/+22
llvm-svn: 282755
2016-08-17Replace "fallthrough" comments with LLVM_FALLTHROUGHJustin Bogner1-1/+1
This is a mechanical change of comments in switches like fallthrough, fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead. llvm-svn: 278902
2016-08-12Use the range variant of remove_if instead of unpacking begin/endDavid Majnemer1-3/+3
No functionality change is intended. llvm-svn: 278475
2016-08-11Use the range variant of find instead of unpacking begin/endDavid Majnemer1-2/+2
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
2016-04-15Option parser: class for consuming a joined arg in addition to all remaining ↵Hans Wennborg2-1/+15
args llvm-svn: 266394
2016-01-29Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren1-1/+1
r259192 post commit comment. clang part in r259232, this is the LLVM part of the patch. llvm-svn: 259240
2016-01-26Remove autoconf supportChris Bieneman1-14/+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
2015-12-18Convert Arg, ArgList, and Option to dump() to dbgs() rather than errs().Eric Christopher3-26/+35
Also add print() functions. Patch by Justin Lebar! llvm-svn: 256010
2015-12-18Add a dump method for ArgList.Eric Christopher1-0/+7
Patch by Justin Lebar! llvm-svn: 256009
2015-12-18Revert "[Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgs"Vedant Kumar1-12/+9
This reverts commit r255977. This is part of http://reviews.llvm.org/D15634. llvm-svn: 255978
2015-12-18[Option] Introduce Arg::print(raw_ostream&) and use llvm::dbgsVedant Kumar1-9/+12
llvm-svn: 255977
2015-10-21[Option] Use an ArrayRef to store the Option Infos in OptTable. NFCCraig Topper1-7/+5
llvm-svn: 250901
2015-07-29Add an ArgList::AddAllArgs that accepts a vector of OptSpecifier.Douglas Katzman1-0/+15
This lifts the somewhat arbitrary restriction on 3 OptSpecifiers. Differential Revision: http://reviews.llvm.org/D11597 llvm-svn: 243539
2015-06-23[Option] Plug a leak when move-assigning an InputArgList.Benjamin Kramer1-6/+6
The class has a non-trivial dtor so we have to clean up before we move in new members. Remove misleading comment as a default move assignment operator will never be synthesized for this class. llvm-svn: 240417
2015-06-23Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC)Alexander Kornienko1-2/+2
Apparently, the style needs to be agreed upon first. llvm-svn: 240390
2015-06-22Code cleanup: Remove std::move() around xvalue (NFC)Logan Chien1-1/+1
Remove std::move() around xvalue so that copy elision is eligible. In case that copy elision is not appliable, the c++ standard also guarantees the move semantics on xvalue. Thus, it is not necessary to wrap Args with std::move. This also silence a warning since r240345. llvm-svn: 240355
2015-06-22Modify ParseArgs to return the InputArgList by value - there's no need for ↵David Blaikie1-11/+11
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
2015-06-21Devirtualize ArgList's dtor now that -Wvirtual-dtor and C++11 allow a better ↵David Blaikie1-5/+0
way to describe this situation llvm-svn: 240238
2015-06-21ArrayRef-ify ParseArgsDavid Blaikie1-4/+3
llvm-svn: 240233
2015-06-19Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-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
2015-05-04Option parsing: properly handle flag aliases for joined options (PR23394)Hans Wennborg1-0/+5
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
2015-03-30Remove more superfluous .str() and replace std::string concatenation with Twine.Yaron Keren1-1/+1
Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev. llvm-svn: 233555
2015-03-20Make getLastArgNoClaim work for up to 4 arguments.Filipe Cabecinhas1-0/+20
Summary: This is needed for http://reviews.llvm.org/D8507 I have no idea what stand-alone tests could be done, if needed. Reviewers: Bigcheese, craig.topper, samsonov Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8508 llvm-svn: 232859
2015-03-17Teach Twine to support SmallString.Yaron Keren1-7/+2
Enable removing .str() member calls for these frequent cases. http://reviews.llvm.org/D6372 llvm-svn: 232465
2015-03-16Fix uses of reserved identifiers starting with an underscore followed by an ↵David Blaikie3-25/+19
uppercase letter This covers essentially all of llvm's headers and libs. One or two weird cases I wasn't sure were worth/appropriate to fix. llvm-svn: 232394
2015-03-03Remove explicit no-op dtor in favor of the implicit dtor so as not to ↵David Blaikie1-3/+0
disable/deprecate the copy operations. llvm-svn: 231113
2015-02-17Prefer SmallVector::append/insert over push_back loops.Benjamin Kramer2-10/+6
Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229500
2015-02-11Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects.Zachary Turner1-0/+3
This allows IDEs to recognize the entire set of header files for each of the core LLVM projects. Differential Revision: http://reviews.llvm.org/D7526 Reviewed By: Chris Bieneman llvm-svn: 228798