summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/include-fixer/tool
Commit message (Collapse)AuthorAgeFilesLines
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-255-1233/+0
| | | | | | | | | | | Makes the name of this directory consistent with the names of the other directories in clang-tools-extra. Similar to r356254. No intended behavior change. Differential Revision: https://reviews.llvm.org/D59750 llvm-svn: 356897
* 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
* clang-include-fixer.el: support remote filesPhilipp Stephani2018-12-141-5/+15
| | | | | | | | | | | | | | Summary: Support remote files (e.g., Tramp) in the Emacs integration for clang-include-fixer Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54672 llvm-svn: 349150
* Add explicit dependency on clangSerialization after rC348911Fangrui Song2018-12-121-0/+1
| | | | llvm-svn: 348916
* Replace hardcoded format styles in a few tools with the default style in ↵Eric Liu2018-08-021-2/+4
| | | | | | libFormat. llvm-svn: 338696
* Improve completion experience for headersPhilipp Stephani2018-04-091-5/+9
| | | | | | | | | | | | | | Summary: When calling `completing-read', we should provide a default to prevent the behavior described in https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection. Also, don't use an assertion to check whether the user selected a header; raise a proper signal instead. Reviewers: klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43969 llvm-svn: 329566
* [clang-include-fixer] Use add_clang_tool instead add_clang_executablePetr Hosek2018-02-161-1/+1
| | | | | | | | | This makes it possible to include clang-include-fixer as distribution component when building Clang based toolchain using CMake. Differential Revision: https://reviews.llvm.org/D43371 llvm-svn: 325381
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 llvm-svn: 319840
* Add autoload cookies for clang-include-fixer lisp functions.Manuel Klimek2017-07-181-0/+3
| | | | | | | | | Annotate all public functions with the autoload magic cookie so that update-directory-autoloads will find them. Patch by Brendan O'Dea. llvm-svn: 308290
* Use new command replace-buffer-contents if availablePhilipp Stephani2017-07-111-3/+3
| | | | | | | | | | Reviewers: klimek Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D35211 llvm-svn: 307635
* Improve error message when run from a buffer that doesn't visit a filePhilipp Stephani2017-07-101-0/+2
| | | | | | | | | | | | Summary: In this case, users currently get a confusing type error. Make the error message more obvious. Reviewers: klimek Reviewed By: klimek Differential Revision: https://reviews.llvm.org/D35197 llvm-svn: 307535
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding LLVM change is r306878. llvm-svn: 306879
* Recommit "[include-fixer] Don't throw exception when parsing unknown ar… ↵Haojian Wu2017-05-171-1/+6
| | | | | | | | | | | | | | | | …guments in vim script." Summary: To make it work in neovim. Reviewers: bkramer Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33273 llvm-svn: 303260
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-131-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add fuzzy SymbolIndex, where identifier needn't match exactly. The purpose for this is global autocomplete in clangd. The query will be a partial identifier up to the cursor, and the results will be suggestions. It's in include-fixer because: - it handles SymbolInfos, actually SymbolIndex is exactly the right interface - it's a good harness for lit testing the fuzzy YAML index - (Laziness: we can't unit test clangd until reorganizing with a tool/ dir) Other questionable choices: - FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is an interface to allow extension to large monorepos (*cough*) - an always-true safety check that Identifier == Name is removed from SymbolIndexManager, as it's not true for fuzzy matching - exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though. Reviewers: bkramer Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D30720 llvm-svn: 297630
* [include-fixer] Remove line number from Symbol identitySam McCall2017-03-091-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Remove line number from Symbol identity. For our purposes (include-fixer and clangd autocomplete), function overloads within the same header should mostly be treated as a single combined symbol. We may want to track individual occurrences (line number, full type info) and aggregate this during mapreduce, but that's not done here. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30685 llvm-svn: 297371
* Do not display highlights for clang-include-fixer-at-pointHaojian Wu2017-03-062-12/+26
| | | | | | | | | | | | | | Summary: When invoking clang-include-fixer-at-point, the QuerySymbolInfos point to offset 0, length 0. Rather than showing a hidden overlay, do not show any overlay at all for zero-length symbols. Patch by Torsten Marek! Reviewers: hokein, klimek Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D30577 llvm-svn: 297010
* [include-fixer] Add usage count to find-all-symbols.Sam McCall2017-02-281-5/+9
| | | | | | | | | | | | | | | | | | | | | | | Summary: Add usage count to find-all-symbols. FindAllSymbols now finds (most!) main-file usages of the discovered symbols. The per-TU map output has NumUses=0 or 1 (only one use per file is counted). The reducer aggregates these to find the number of files that use a symbol. The NumOccurrences is now set to 1 in the mapper rather than being inferred by the reducer, for consistency. The idea here is to use NumUses for ranking: intuitively number of files that use a symbol is more meaningful than number of files that include the header. Reviewers: hokein, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D30210 llvm-svn: 296446
* Make clang-include-fixer--insert-line work when the difference is on an ↵Manuel Klimek2017-02-232-7/+18
| | | | | | | | | | | | | | | | | | empty line `clang-include-fixer--insert-line` has an off-by-one error because it uses `(goto-char (point-min)) (forward-char chars)`, which is (goto-char (1+ chars))`. Because of this, when the first difference was on an empty line (i.e. an include was appended to the block of includes), the pointer in the `to` buffer would be on the next line. Also wrapped calls inside another process sentinel inside `with-local-quit`. Patch by Torsten Marek. Differential Revision: https://reviews.llvm.org/D30292 llvm-svn: 295988
* Completion related fixes for clang-include-fixer.el.Manuel Klimek2017-02-221-21/+24
| | | | | | | | | | | | | | | | 1. Quitting inside a process sentinel is not allowed, but the sentinel invokes completion, where the user is free to hit C-g. By wrapping the call in with-local-quit, the process sentinel invocation can finish without triggering an error 2. Invoke completing-read instead of ido-completing-read, since this may interfere with user customizations to completing-read-function. The user should use something like ido-ubiquitous if ido completion is wanted 3. Compare the string returned from completion with string=, since it may be a copy of the original string in the collection Patch by Torsten Marek. llvm-svn: 295818
* Adds a hook clang-include-fixer-add-include-hook that is invoked with the ↵Manuel Klimek2017-02-221-3/+20
| | | | | | | | | | path and type of the added include. This patch also adds a new function clang-include-fixer-from-symbol, which prompts the user for a symbol to resolve and include. Patch by Torsten Marek. llvm-svn: 295814
* Update tools to use new getStyle APIAntonio Maiorano2017-01-171-5/+12
| | | | | | | | Depends on https://reviews.llvm.org/D28081 Differential Revision: https://reviews.llvm.org/D28315 llvm-svn: 292175
* Improve include fixer's ranking by taking the paths into account.Manuel Klimek2017-01-111-1/+2
| | | | | | | | | | | | | | | Instead of just using popularity, we also take into account how similar the path of the current file is to the path of the header. Our first approach is to get popularity into a reasonably small scale by taking log2 (which is roughly intuitive to how humans would bucket popularity), and multiply that with the number of matching prefix path fragments of the included header with the current file. Note that currently we do not take special care for unclean paths containing "../" or "./". Differential Revision: https://reviews.llvm.org/D28548 llvm-svn: 291664
* [include-fixer] Load symbol index asynchronously.Benjamin Kramer2017-01-091-19/+25
| | | | | | | | We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. llvm-svn: 291446
* Fix grammarPhilipp Stephani2016-11-091-2/+2
| | | | | | "allow" requires a direct object in this case. llvm-svn: 286381
* [include-fixer] Make error message sound less like clang crashed.Benjamin Kramer2016-10-281-2/+6
| | | | | | | | | We suppress all Clang diagnostics (because they would be wrong, include-fixer does custom recovery) but still want to give some feedback in case there was a compiler error we couldn't recover from. The most common case for this is a #include in the file that couldn't be found. llvm-svn: 285396
* include-fixer: Don't overwrite buffer changesManuel Klimek2016-10-251-1/+7
| | | | | | | | | Raise a signal if the buffer has been modified before replacing it, to avoid overwriting users' changes. Patch by Philipp Stephani. llvm-svn: 285060
* Load clang-include-fixer.el from the unit test suite so that the unit tests ↵Manuel Klimek2016-10-251-0/+2
| | | | | | | | can run in batch mode. Patch by Philipp Stephani. llvm-svn: 285059
* Don't copy replacements in for-range loop. NFC.Benjamin Kramer2016-10-191-1/+1
| | | | llvm-svn: 284589
* clang-include-fixer.el: Don't prompt the user about killing ↵Manuel Klimek2016-10-111-0/+2
| | | | | | | | | | | | clang-include-fixer processes By default, Emacs prompts the user when killing processes on exit. This is useful for stateful processes such as interactive shells. However, clang-include-fixer processes are stateless; the only effect of killing them is to cancel a clang-include-fixer operation. Therefore prompting the user is just a nuisance. Patch by Philipp Stephani. Differential Revision: https://reviews.llvm.org/D25378 llvm-svn: 283863
* Make Emacs libraries compatible with Emacs 24.Manuel Klimek2016-10-111-2/+7
| | | | | | | | Emacs 24 doesn't have format-message, fall back to format in that case. Patch by Philipp Stephani. llvm-svn: 283861
* [include-fixer] query-mode should be false by default.Haojian Wu2016-10-101-1/+1
| | | | | | Makes it consistent with documentations. llvm-svn: 283754
* Use `let' instead of `let*' in one place where `let*' isn't necessaryManuel Klimek2016-10-101-3/+3
| | | | | | | | Differential Revision: https://reviews.llvm.org/D25395 Patch by Philipp Stephani. llvm-svn: 283736
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-2/+1
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* Overhaul clang-include-fixer.elHaojian Wu2016-10-052-190/+406
| | | | | | | | | | | | | | | | | | | | | | | | General overhaul to fix many coding bugs, simplify the code, and improve readability. * Clarify documentation strings of user options. * Say that clang-include-fixer-executable is a file to have auto completion. * Allow user to select available options for clang-include-fixer-input-format. Turn it into a symbol as it's not a free-form string. * Remove clang-include-fixer-query-mode. This option was apparently used to select between two different operation modes, which is not a typical use case for user options. Provide two separate commands instead. * Add a face for the overlay highlighting so that users can customize it. Move user commands to the front so that readers of the code aren't buried in internal functions. * Make process calls asynchronous. This is possible here because clang-include-fixer doesn't change files in place. This means input is no longer blocked while clang-include-fixer is running. * Factor out logic in helper functions to keep functions short. * Add comments where appropriate. * Provide an alternative buffer replacement strategy for the case that a single line was inserted (the normal case in the case of clang-include-fixer). This keeps point, markers, and other buffer information intact. * Use let-alist and association lists instead of property lists to shorten the code. * Instead of highlighting only the first occurrence of a symbol, highlight all occurrences and move point to the closest one. * Detect qualified names at point. * Use filepos-to-bufferpos if available. * Formatting. Patch by Philipp Stephani! llvm-svn: 283306
* [include-fixer] Support finding headers for the symbol under cursor.Haojian Wu2016-09-073-12/+96
| | | | | | | | | | | | | | Summary: * Add a `query-symbol` option to query symbol without parsing the source file. * Update Vim & Emacs integration scripts. Reviewers: bkramer, massberg Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24075 llvm-svn: 280824
* [include-fixer] Fix an undefined variable exception in vim script when there isHaojian Wu2016-09-011-0/+1
| | | | | | only one candidate header. llvm-svn: 280359
* Revert "Revert "[Include-fixer] Install executables and support scripts""Zachary Turner2016-08-171-1/+14
| | | | | | | | | This reverts commit 2aff596257e1c45fa54baae823ecbe61a785174e. I'm having a bad day apparently. I reverted the wrong CL. This puts it back. llvm-svn: 278978
* Revert "[Include-fixer] Install executables and support scripts"Zachary Turner2016-08-171-14/+1
| | | | | | | | | This reverts commit b725a314a9b7f746c37f70909ec3c4dcb6d9f6b5. The patch that made this test work needed to be reverted, so this test needs to be reverted as well. llvm-svn: 278977
* [Include-fixer] Install executables and support scriptsEugene Zelenko2016-08-171-1/+14
| | | | | | Differential revision: https://reviews.llvm.org/D23045 llvm-svn: 278949
* [include-fixer] Update -help message.Haojian Wu2016-08-171-1/+3
| | | | llvm-svn: 278922
* [include-fixer] Support processing multiple files in one run.Haojian Wu2016-08-092-51/+65
| | | | | | | | | | | | | | | | | | | Summary: Previously, if we pass multiple files or a file pattern (e.g. /path/to/*.cc) to include-fixer, include-fixer will apply all replacements to the first argument, which probably causes crashes. With this patch, include-fixer can process multiple files now. Vim and Emacs integration are tested manually. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23266 llvm-svn: 278102
* Changes related to new implementation of tooling::Replacements as class.Eric Liu2016-08-011-2/+2
| | | | | | | | | | | | Summary: See http://reviews.llvm.org/D21748 for details. Reviewers: djasper, klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D21749 llvm-svn: 277336
* change Vim key binding for include-fixer and clang-renameKirill Bobyrev2016-07-271-3/+3
| | | | | | | | | | | | Change Vim key binding for include-fixer (`,cf` -> `<leader>cf`) and clang-rename (`,cr` -> `<leader>cr`) to use `<leader>` instead of `,` like cool Vim people (tm) do. Reviewers: ioeric Differential Revision: https://reviews.llvm.org/D22854 llvm-svn: 276870
* [clang-include-fixer] Added Emacs integration for clang-include-fixer.Benjamin Kramer2016-07-271-0/+207
| | | | | | | | Patch by Jens Massberg! Thanks a lot. Differential Revision: https://reviews.llvm.org/D22805 llvm-svn: 276853
* [include-fixer] Add mising qualifiers to all instances of an unidentified ↵Haojian Wu2016-07-212-46/+40
| | | | | | | | | | | | symbol. Reviewers: bkramer Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D22567 llvm-svn: 276280
* [include-fixer] Make error messages a bit prettier and make sure toBenjamin Kramer2016-07-201-2/+4
| | | | | | include a newline at the end. llvm-svn: 276098
* [include-fixer] A refactoring of IncludeFixerContext.Haojian Wu2016-07-192-14/+25
| | | | | | | | | | | | | | | | | Summary: No functional changes in this patch. It is a refactoring (pull out a structure representing the symbol being queried). This is a preparing step for inserting missing namespace qualifiers to all instances of an unidentified symbol. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D22510 llvm-svn: 275980
* Unbreak extra tools build post r275882.Benjamin Kramer2016-07-181-0/+1
| | | | llvm-svn: 275886
* [include-fixer] Add an options allow moving the cursor to #include line in vimHaojian Wu2016-07-181-12/+25
| | | | | | | | | | | | | | | | | after inserting a missing header. Summary: A small improvement: Don't print newline character at the end of message, so that users don't have to type ENTER manually after running the python script. Reviewers: bkramer Subscribers: djasper, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D22351 llvm-svn: 275781
* [include-fixer] Implement adding missing namespace qualifiers in vim ↵Haojian Wu2016-07-132-31/+114
| | | | | | | | | | | | | | | | | integration. Summary: The patch extends include-fixer's "-output-headers", and "-insert-headers" command line options to make it dump more information (e.g. QualifiedSymbol), so that vim-integration can add missing qualifiers. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D22299 llvm-svn: 275279
OpenPOWER on IntegriCloud