summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/include-fixer
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-152-12/+14
| | | | | | | | | | | The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM Differential Revision: https://reviews.llvm.org/D44976 llvm-svn: 332371
* 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
* Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-2/+2
| | | | | | | | | | | | std::unique_ptr<>" This reverts commit rL326202 This broke gcc4.8 builds, compiler just segfaults: http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909 http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673 llvm-svn: 326203
* [Tooling] [1/1] Refactor FrontendActionFactory::create() to return ↵Roman Lebedev2018-02-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | std::unique_ptr<> Summary: I'm not sure whether there are any principal reasons why it returns raw owning pointer, or it is just a old code that was not updated post-C++11. I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason, but it does not //appear// asif those failures are related to these changes. This is Clang-tools-extra part. Clang part is D43779. Reviewers: klimek, bkramer, alexfh, pcc Reviewed By: alexfh Subscribers: ioeric, jkorous-apple, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D43780 llvm-svn: 326202
* [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
* [include-fixer] Add more debug headers to the STL header listBenjamin Kramer2018-02-151-0/+4
| | | | | | These are used for std::map/std::set in STL debug mode. llvm-svn: 325298
* [CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai2017-12-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [FindAllSymbols] Cache regexes, creating them is expensiveBenjamin Kramer2017-11-223-15/+27
| | | | | | | | This is a bit annoying because LLVM regexes are always mutable to store errors. Assert that there are never errors and fix broken hardcoded regexes. llvm-svn: 318840
* Adapt clang-tidy checks to changing semantics of hasDeclaration.Manuel Klimek2017-08-021-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D36154 llvm-svn: 309810
* 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-302-2/+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
* Revert "[include-fixer] Don't throw exception when parsing unknown arguments ↵Benjamin Kramer2017-05-171-1/+1
| | | | | | | | | in vim script." This reverts commit r302934. It's wrong, edits the wrong file and was committed without review. llvm-svn: 303242
* [include-fixer] Don't throw exception when parsing unknown arguments inHaojian Wu2017-05-121-1/+1
| | | | | | vim script. llvm-svn: 302934
* Spelling mistakes in comments. NFCI.Simon Pilgrim2017-03-301-1/+1
| | | | | | Based on corrections mentioned in patch for clang for PR27635 llvm-svn: 299074
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-135-42/+257
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-096-29/+20
| | | | | | | | | | | | | | | | | | | 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
* [find-all-symbols] Implement operator== for SymbolAndSignals and ↵Haojian Wu2017-02-282-0/+10
| | | | | | SymbolInfo::Signals. llvm-svn: 296461
* [include-fixer] Add usage count to find-all-symbols.Sam McCall2017-02-2817-158/+279
| | | | | | | | | | | | | | | | | | | | | | | 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
* [CMake] Fix pthread handling for out-of-tree buildsEric Fiselier2017-02-101-1/+1
| | | | | | | | | | | | | | | LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. llvm-svn: 294690
* [include-fixer] Don't return a correction if the header insertion failed.Benjamin Kramer2017-01-181-10/+10
| | | | | | | | This is could happen in cases involving macros and we don't want to return an invalid fixit for it or a confusing error message with no fixit. llvm-svn: 292405
* 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
* Fix the build of the include-fixer plugin for some shared cmake builds and MSVC.Benjamin Kramer2017-01-132-0/+12
| | | | | | | | | | - The include fixer plugin does not directly depend on pthread, but can pick up pthread references transitively through inlining. Just add pthreads to the linked libs unconditionally. - MSVC emits bogus warnings when including <future> and building without exceptions. Blacklist the warnings explicitly. llvm-svn: 291892
* [find-all-symbols] Index partial template specializations.Haojian Wu2017-01-111-4/+14
| | | | | | | | | | | | | | | Summary: Fix no std::function index. Previously, we don't index all the template specialization declarations of functions and classes (Because we assume that template functions/classes are indexed by their template declarations), but this is not always true in some cases like `std::function` which only has a partial template specialization declaration. Reviewers: ioeric, bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27920 llvm-svn: 291669
* Improve include fixer's ranking by taking the paths into account.Manuel Klimek2017-01-114-18/+52
| | | | | | | | | | | | | | | 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
* Only launch asynchronously if threading is enabled.Manuel Klimek2017-01-111-1/+6
| | | | llvm-svn: 291653
* [include-fixer] Load symbol index asynchronously.Benjamin Kramer2017-01-094-39/+49
| | | | | | | | 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
* Reapply "Fix for shared_ptrification in Clang"David Blaikie2017-01-062-3/+4
| | | | | | | | | Aleksey Shlyapnikov pointed out the memory leak I'd introduced, so recommitted the clang change with a fix for that. This reapplies r291186, reverted in r291251. llvm-svn: 291272
* Revert "Fix for shared_ptrification in Clang"David Blaikie2017-01-062-4/+3
| | | | | | | | | The original commit caused an asan-detected memory leak in Clang. Reverting while I investigate. This reverts commit r291186. llvm-svn: 291251
* Fix for shared_ptrification in ClangDavid Blaikie2017-01-052-3/+4
| | | | llvm-svn: 291186
* [include-fixer] Desugar incomplete types.Benjamin Kramer2016-12-161-2/+2
| | | | | | | | This will look through typedefs so include-fixer will look up the target of the typedef instead of the typedef itself (which is already in scope). llvm-svn: 289952
* modernize-use-auto NFC fixesPiotr Padlewski2016-12-141-1/+1
| | | | llvm-svn: 289656
* [include-fixer] Don't skip repeated lookups in plugin mode.Benjamin Kramer2016-11-301-1/+1
| | | | | | | In this mode not all the errors are fixed so it doesn't make sense to ignore later ones. llvm-svn: 288244
* [include-fixer] Don't eat one token too many when replacing a block of includes.Benjamin Kramer2016-11-291-2/+2
| | | | | | | SourceRanges are inclusive token ranges, this was trying to form an exclusive char range. llvm-svn: 288145
* [include-fixer] Don't interfere with typo correction if we found nothing.Benjamin Kramer2016-11-281-3/+4
| | | | | | Just let the existing typo correction machinery handle that. llvm-svn: 288043
* [include-fixer plugin] Make the plugin emit proper fixits in case multiple ↵Benjamin Kramer2016-11-212-17/+35
| | | | | | | | | | | errors are found. The standalone tool only fixes the first one and we managed to bake that assumption into the code :( Also fix a crash when no header is found at all. llvm-svn: 287544
* [include-fixer] Refactor include fixer to be usable as a pluginBenjamin Kramer2016-11-175-245/+451
| | | | | | | | | | | | - Refactor the external sema source into a visible class - Add support for emitting FixIts - Wrap up include fixer as a plugin as I did with clang-tidy Test case will follow as soon as I wire this up in libclang. Differential Revision: https://reviews.llvm.org/D26752 llvm-svn: 287228
* 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
OpenPOWER on IntegriCloud