summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/include-fixer/SymbolIndexManager.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename directory housing clang-include-fixer to be eponymousNico Weber2019-03-251-158/+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-tools-extra] Update uses of DEBUG macro to LLVM_DEBUG.Nicola Zaghen2018-05-151-2/+2
| | | | | | | | | | | 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
* [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.Sam McCall2017-03-131-39/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Add usage count to find-all-symbols.Sam McCall2017-02-281-15/+21
| | | | | | | | | | | | | | | | | | | | | | | 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-111-14/+42
| | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | 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
* [include-fixer] Correct nested class search for identifiers with scoped ↵Haojian Wu2016-08-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | information Summary: include-fixer will firstly try to use scoped namespace context information to search identifier. However, in some cases, it's unsafe to do nested class search, because it might treat the identifier as a nested class of scoped namespace. Given the following code, and the symbol database only has two classes: "foo" and "b::Bar". namespace foo { Bar t; } Before getting fixing, include-fixer will never search "Bar" symbol. Because it firstly tries to search "foo::Bar", there is no "Bar" in foo namespace, then it finds "foo" in database finally. So it treats "Bar" is a nested class of "foo". Reviewers: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23023 llvm-svn: 277442
* [include-fixer] Add missing namespace qualifiers after inserting a missing ↵Haojian Wu2016-07-081-24/+3
| | | | | | | | | | | | | | | | | | | | | | | header. Summary: This is an initial version of fixing namespace issues by adding missing namespace qualifiers to an unidentified symbol. This version only fixes the first discovered unidentified symbol. In the long run, include-fixer should fix all unidentified symbols with a same name at one run. Currently, it works on command-line tool. The vim integration is not implemented yet. Reviewers: klimek, bkramer, djasper Subscribers: bkramer, ioeric, cfe-commits Differential Revision: http://reviews.llvm.org/D21603 llvm-svn: 274832
* [include-fixer] only deduplicate symbols after matching symbols with the ↵Eric Liu2016-06-131-13/+17
| | | | | | | | | | | | | | | | | | undefined identifier. Summary: we should only deduplicate symbols after matching symbols with the undefined identifier. This patch tries to fix the situation where matching symbols are deleted when it has the same header as a non-matching symbol, which can prevent finding the correct header even if there is a matched symbol. Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D21290 llvm-svn: 272576
* [include-fixer] Be smarter about inserting symbols for a prefix.Benjamin Kramer2016-06-031-0/+12
| | | | | | | | | | | | | | | | | | | | | | 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 a DenseMap, order doesn't matter here.Benjamin Kramer2016-05-311-1/+2
| | | | llvm-svn: 271284
* [include-fixer] Rank symbols based on the number of occurrences we found ↵Benjamin Kramer2016-05-311-0/+33
| | | | | | | | | | | | | 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
* [include-fixer] Make search handle fully qualified names correctly.Benjamin Kramer2016-05-191-0/+11
| | | | | | | | | If a search string starts with "::" we don't want to return any results for suffixes of that string. Differential Revision: http://reviews.llvm.org/D20424 llvm-svn: 270055
* [include-fixer] Also look up prefixes of queries.Benjamin Kramer2016-05-181-40/+48
| | | | | | | | | | | | This is used to find nested classes. For a nested name foo::bar::qux we will first look up foo::bar::qux, then foo::bar, then foo unless we find a result. This is used to support nested classes which are not part of the index but can only be used if the header for the parent context is included. Differential Revision: http://reviews.llvm.org/D20372 llvm-svn: 269956
* [include-fixer] Ignore non-scoped enum declaration during search.Haojian Wu2016-05-181-4/+10
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits, ioeric Differential Revision: http://reviews.llvm.org/D20354 llvm-svn: 269890
* [include-fixer] Use scope contexts information to improve query.Haojian Wu2016-05-131-4/+6
| | | | | | | | | | Reviewers: bkramer Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20205 llvm-svn: 269430
* [include-fixer] Rename XrefsDB to SymbolIndex.Benjamin Kramer2016-05-131-0/+70
It's not really containing xrefs so the name didn't fit. No functional change. llvm-svn: 269403
OpenPOWER on IntegriCloud