summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/include-fixer
Commit message (Collapse)AuthorAgeFilesLines
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-2516-280/+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
* Remove the optional dependency from libclang to clang-tidy/include-fixerBenjamin Kramer2018-11-231-25/+0
| | | | | | | clangd does a better job on both of these, so don't slow down everyone's build for a poorly working libclang feature. llvm-svn: 347496
* Fix one additional test broken by the YAML quoting change.Zachary Turner2018-10-121-2/+2
| | | | llvm-svn: 344362
* [cmake] Support running extra clang tool tests without static analyzerMichal Gorny2017-08-291-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Support running the extra clang tool tests when the static analyzer is disabled. Disable the relevant clang-tidy tests and one include-fixer test that require it to work. Previously, the tests were disabled entirely with CLANG_ENABLE_STATIC_ANALYZER being false. Now, the tests are being enabled and the relevant tests are excluded and marked unsupported appropriately. In order to disable clang-tidy tests, the whole test directory is added to the exclude lists, to avoid having to explicitly add 'REQUIRES' line to every single test. If the other solution is preferable, I can update the patch. The yamldb_plugin include-fixer test is also updated to be disabled without static analyzer. It fails in that case because clang is not outputting a replacement suggestion -- but I don't know the exact reason why it does not do that. Differential Revision: https://reviews.llvm.org/D37188 llvm-svn: 311983
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-132-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-094-13/+0
| | | | | | | | | | | | | | | | | | | 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
* [include-fixer] Add usage count to find-all-symbols.Sam McCall2017-02-284-13/+26
| | | | | | | | | | | | | | | | | | | | | | | 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
* Improve include fixer's ranking by taking the paths into account.Manuel Klimek2017-01-112-4/+14
| | | | | | | | | | | | | | | 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] Don't skip repeated lookups in plugin mode.Benjamin Kramer2016-11-301-1/+8
| | | | | | | 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-1/+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/+2
| | | | | | 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-211-0/+7
| | | | | | | | | | | 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] Add a test for the full round trip through libclang and the ↵Benjamin Kramer2016-11-171-0/+10
| | | | | | plugin. llvm-svn: 287230
* [include-fixer] Support finding headers for the symbol under cursor.Haojian Wu2016-09-071-0/+13
| | | | | | | | | | | | | | 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
* Remove most instances of REQUIRES: shell from the tools/extra testsReid Kleckner2016-08-168-13/+5
| | | | | | | | None of these tests actually require bash, they just have quoting bugs when paths contain backslashes and colons. Fix them with the "%/T" lit substitution variants. llvm-svn: 278815
* [include-fixer] Support processing multiple files in one run.Haojian Wu2016-08-092-3/+16
| | | | | | | | | | | | | | | | | | | 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
* [include-fixer] Add mising qualifiers to all instances of an unidentified ↵Haojian Wu2016-07-211-3/+3
| | | | | | | | | | | | symbol. Reviewers: bkramer Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D22567 llvm-svn: 276280
* [include-fixer] A refactoring of IncludeFixerContext.Haojian Wu2016-07-191-3/+3
| | | | | | | | | | | | | | | | | 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
* [include-fixer] Implement adding missing namespace qualifiers in vim ↵Haojian Wu2016-07-132-9/+19
| | | | | | | | | | | | | | | | | 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
* [include-fixer] Keep dot dot in SymbolInfo file paths.Haojian Wu2016-06-081-4/+10
| | | | | | | | | | | | | | | | | | Summary: Currently, removing dot dot in header's path doesn't make include-fixer minimize path correctly in some cases, for example, specify a relative search path based on the build directory("-I../include/"). Besides, removing dot dot can break symbolic link directories. So don't removing it for now. Reviewers: ioeric, bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21132 llvm-svn: 272152
* [include-fixer] explicitly set minimize-paths in test.Eric Liu2016-06-081-1/+1
| | | | llvm-svn: 272151
* [include-fixer] Be smarter about inserting symbols for a prefix.Benjamin Kramer2016-06-032-0/+19
| | | | | | | | | | | | | | | | | | | | | | If prefix search finds something where nothing can be nested under (e.g. a variable or macro) don't add it to the result. This is for cases like: header.h: extern int a; file.cc: namespace a { SOME_MACRO } We will look up a::SOME_MACRO, which doesn't have any results. Then we look up 'a' and find something before we ever look up just 'SOME_MACRO'. With some basic filtering we can avoid this case. Differential Revision: http://reviews.llvm.org/D20960 llvm-svn: 271671
* [include-fixer] Use YAML format in -output-headers and -insert-header mode.Haojian Wu2016-06-012-6/+4
| | | | | | | | | | | | | | | Summary: And some improvements: * Show better error messages on unfound symbols. * Fix a typo. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20827 llvm-svn: 271382
* [include-fixer] Rank symbols based on the number of occurrences we found ↵Benjamin Kramer2016-05-312-0/+27
| | | | | | | | | | | | | while merging. This sorts based on the popularity of the header, not the symbol. If there are mutliple matching symbols in one header we take the maximum popularity for that header and deduplicate. If we know nothing we sort lexicographically based on the header path. Differential Revision: http://reviews.llvm.org/D20814 llvm-svn: 271283
* [find-all-symbols] Add a test to make sure merging actually works.Benjamin Kramer2016-05-313-0/+74
| | | | llvm-svn: 271270
* [include-fixer] collect the number of times a symbols is found in an ↵Eric Liu2016-05-311-0/+2
| | | | | | | | | | | | | | | | indexing run and use it for symbols popularity ranking. Summary: [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking. Reviewers: bkramer Subscribers: cfe-commits, hokein, djasper Differential Revision: http://reviews.llvm.org/D20804 llvm-svn: 271268
* [include-fixer] Create a mode in vim integration to show multiple potential ↵Haojian Wu2016-05-311-0/+12
| | | | | | | | | | | | | | | | | | | headers. Summary: Some changes in the patch: * Add two commandline flags in clang-include-fixer. * Introduce a IncludeFixerContext for the queried symbol. * Pull out CreateReplacementsForHeader. Reviewers: bkramer Subscribers: klimek, cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20621 llvm-svn: 271258
* [include-fixer] Don't insert #includes if a fatal error occurred.Benjamin Kramer2016-05-181-0/+11
| | | | | | | | | This typically happens when the user didn't setup include paths correctly and the fixer starts adding garbage includes. Avoid that. Disable the error limit though, as we might hit that easily with missing includes and still want to fix those cases. llvm-svn: 269923
* [include-fixer] Add lit-test for relative include path.Haojian Wu2016-05-113-0/+32
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20159 llvm-svn: 269177
* [include-fixer] Default to YAML db, it's much more useful than the fixed ↵Benjamin Kramer2016-05-101-1/+1
| | | | | | dummy db. llvm-svn: 269043
* [include-fixer] Autodetect yaml databases in parent directories.Benjamin Kramer2016-05-091-0/+12
| | | | | | | | | | This looks for find_all_symbols_db.yaml in all parent directories of the source file (like we do for compile_commands.json) so we don't have to pass the path manually. Differential Revision: http://reviews.llvm.org/D20066 llvm-svn: 268920
* [include-fixer] Add Yaml database integration.Haojian Wu2016-04-292-0/+20
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits, klimek, djasper Differential Revision: http://reviews.llvm.org/D19648 llvm-svn: 268017
* Clean up the include fixer 'driver' a bit and make the database configurable.Benjamin Kramer2016-04-271-0/+9
Also add a test for it. The library is covered by unit tests, the driver was not. llvm-svn: 267718
OpenPOWER on IntegriCloud