diff options
author | Manuel Klimek <klimek@google.com> | 2017-01-11 10:32:47 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2017-01-11 10:32:47 +0000 |
commit | a47515ec4adf3652903d2fdb6eb765d37633aee9 (patch) | |
tree | cafa79496d57e40f0d3a2ec1f4e5cd54ecb8d558 /clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp | |
parent | c22c889f777c9f12dc5ec275ce12d22ffaba2084 (diff) | |
download | bcm5719-llvm-a47515ec4adf3652903d2fdb6eb765d37633aee9.tar.gz bcm5719-llvm-a47515ec4adf3652903d2fdb6eb765d37633aee9.zip |
Improve include fixer's ranking by taking the paths into account.
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
Diffstat (limited to 'clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp')
-rw-r--r-- | clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp b/clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp index 351cad5e07f..47942a97afa 100644 --- a/clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp +++ b/clang-tools-extra/include-fixer/tool/ClangIncludeFixer.cpp @@ -332,7 +332,8 @@ int includeFixerMain(int argc, const char **argv) { // Query symbol mode. if (!QuerySymbol.empty()) { - auto MatchedSymbols = SymbolIndexMgr->search(QuerySymbol); + auto MatchedSymbols = SymbolIndexMgr->search( + QuerySymbol, /*IsNestedSearch=*/true, SourceFilePath); for (auto &Symbol : MatchedSymbols) { std::string HeaderPath = Symbol.getFilePath().str(); Symbol.SetFilePath(((HeaderPath[0] == '"' || HeaderPath[0] == '<') |