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
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
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
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
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
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
Summary: In missing complete type cases, we don't know where to add the qualifiers.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D22812
llvm-svn: 276761
Summary:
The judgement that checks whether the fully-qualified name has scoped qualifiers
prefix is incorrect. Should always check whether the first matched postion is the
beginning position.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D22343
llvm-svn: 275386
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
Summary:
this patch contains changes related to the interface change from
http://reviews.llvm.org/D21601. Only submit this patch after D21601 is
submitted.
Reviewers: djasper, klimek
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D21602
llvm-svn: 275063
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
Summary:
this enables us to map a group of headers to one header name,
e.g. headers from one directory can be mapped to the same header.
Reviewers: bkramer
Subscribers: cfe-commits, hokein
Differential Revision: http://reviews.llvm.org/D21787
llvm-svn: 274494
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
Summary:
we want to exclude friend declaration, but the `DeclContext` of a
friend function declaration is not the class in which it is declared, so we need
to explicitly check if the parent is a `friendDecl`.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D21175
llvm-svn: 272261
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
Summary:
The further solution is to add the missing header to the file where the
symbol comes from.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20950
llvm-svn: 271660
Summary: added PathConfig.cpp and use includer of .inc header to be the file path of a symbol from .inc header.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20855
llvm-svn: 271385
Summary: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
Differential Revision: http://reviews.llvm.org/D20813
llvm-svn: 271279
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
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
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
Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20232
llvm-svn: 269427