Commit Graph

259 Commits

Author SHA1 Message Date
Haojian Wu 5644618049 [include-fixer] Don't add qualifiers in missing complete type cases.
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
2016-07-26 16:32:42 +00:00
NAKAMURA Takumi 9faa0dc08e ClangRenameTests: Update libdeps.
llvm-svn: 276445
2016-07-22 17:33:04 +00:00
Haojian Wu 62aee528f6 [include-fixer] Add mising qualifiers to all instances of an unidentified symbol.
Reviewers: bkramer

Subscribers: ioeric, cfe-commits

Differential Revision: https://reviews.llvm.org/D22567

llvm-svn: 276280
2016-07-21 13:47:09 +00:00
NAKAMURA Takumi 5541c8f4c2 ClangRenameTests: Update libdeps. r275958 introduced clangASTMatchers.
llvm-svn: 275985
2016-07-19 15:33:14 +00:00
Haojian Wu 39a718c48b [include-fixer] Always add as few as possible qualifiers to the unidentified symbol.
Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22367

llvm-svn: 275542
2016-07-15 08:12:48 +00:00
Haojian Wu 0c05e2e4b6 [include-fixer] Correct an incorrecst judgement about prefix scoped qualifiers.
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
2016-07-14 09:39:12 +00:00
Haojian Wu 68c34a083d [include-fixer] Implement adding missing namespace qualifiers in vim 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
2016-07-13 16:43:54 +00:00
Eric Liu a452db4d0f Changes related to tooling::applyAllReplacements interface change in D21601.
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
2016-07-11 13:53:21 +00:00
Haojian Wu 5d9482d887 [include-fixer] Don't add qualifiers to symbols which have global scope operator.
Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D22127

llvm-svn: 274848
2016-07-08 14:28:43 +00:00
Haojian Wu 627ca96e4d [include-fixer] Add missing namespace qualifiers after inserting a missing 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
2016-07-08 09:10:29 +00:00
Eric Liu bb11252113 [include-fixer] reduce stack size by changing RegexHeaderMap to use const char * pair.
llvm-svn: 274501
2016-07-04 13:34:11 +00:00
Eric Liu f33bc95f8f [include-fixer] make HeaderMapCollector maps from regex instead of postfix.
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
2016-07-04 11:22:35 +00:00
Miklos Vajna b70539c317 Fix build of ClangRenameTests
Adapt the test to the code change introduced in r273304.

llvm-svn: 273314
2016-06-21 20:30:40 +00:00
Eric Liu de027f2791 [clang-apply-replacements] use Range::operator==() instead of self-defined operator.
llvm-svn: 273291
2016-06-21 17:59:57 +00:00
Eric Liu a4be83a302 [include-fixer] only deduplicate symbols after matching symbols with the 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
2016-06-13 19:05:07 +00:00
Eric Liu 1899d54ed0 [include-fixer] do not index friend function declaration.
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
2016-06-09 14:18:40 +00:00
Haojian Wu 13d3048ced [include-fixer] Keep dot dot in SymbolInfo file paths.
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
2016-06-08 15:10:18 +00:00
Eric Liu 072ccfc997 [include-fixer] do not add enum forward declaration into symbol index table.
llvm-svn: 272132
2016-06-08 12:13:14 +00:00
Haojian Wu 9c6cb035f3 [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.
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
2016-06-03 11:26:02 +00:00
Eric Liu 140b1fba91 [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.
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
2016-06-01 12:01:06 +00:00
Eric Liu 74ccbd61af [include-fixer] disable path cleaning test for windows and mingw.
llvm-svn: 271321
2016-05-31 19:22:01 +00:00
Eric Liu 65cb39eb12 [find-all-symbols] remove dots in SymbolInfo file paths.
Summary: remove dots in SymbolInfo file paths.

Reviewers: bkramer, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20819

llvm-svn: 271302
2016-05-31 17:37:38 +00:00
NAKAMURA Takumi e18fc2130d IncludeFixerTests: Update libdeps.
llvm-svn: 271295
2016-05-31 16:41:39 +00:00
Eric Liu 516f18e515 [include-fixer] use clang-format cleaner to insert header.
Summary: clang-format's cleanupAroundReplacements() takes care of header insertions.

Reviewers: bkramer

Subscribers: cfe-commits, hokein

Differential Revision: http://reviews.llvm.org/D20816

llvm-svn: 271287
2016-05-31 14:48:45 +00:00
Eric Liu f83187deb9 [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
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
2016-05-31 13:52:59 +00:00
Haojian Wu 11e9bd2450 [include-fixer] Create a mode in vim integration to show multiple potential 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
2016-05-31 09:31:51 +00:00
Eric Liu a7d19414da [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.
Summary: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

Differential Revision: http://reviews.llvm.org/D20566

llvm-svn: 270566
2016-05-24 15:10:58 +00:00
Haojian Wu cc0c10e300 [find-all-symbols] Some cleanups in unittest.
llvm-svn: 270211
2016-05-20 12:47:56 +00:00
Haojian Wu a23ac3d249 [find-all-symbol] Ignore inline namespace context.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20465

llvm-svn: 270206
2016-05-20 12:04:56 +00:00
Haojian Wu 20dec208e9 [find-all-symbol] Try to fix the failure windows unittest.
llvm-svn: 270199
2016-05-20 10:36:53 +00:00
Eric Liu 83a4d7fbba [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and FindAllMacros.
llvm-svn: 270193
2016-05-20 09:12:01 +00:00
Haojian Wu 5e4f0255a1 [find-all-symbol] Add macro support.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20420

llvm-svn: 270189
2016-05-20 08:04:36 +00:00
Benjamin Kramer 9b15b6f2d7 [include-fixer] Make search handle fully qualified names correctly.
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
2016-05-19 12:41:56 +00:00
Benjamin Kramer 04666a2d5d [include-fixer] Remove obsolete windows hack.
llvm-svn: 270045
2016-05-19 11:39:56 +00:00
Eric Liu 702cfd1b2b [include-fixer] Sort headers after inserting new headers.
Summary: [include-fixer] Sort headers after inserting new headers.

Reviewers: bkramer

Subscribers: klimek, djasper, hokein, cfe-commits

Differential Revision: http://reviews.llvm.org/D20370

llvm-svn: 270031
2016-05-19 08:21:09 +00:00
Benjamin Kramer 5e6b35f4d1 [include-fixer] Also look up prefixes of queries.
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
2016-05-18 16:42:38 +00:00
Benjamin Kramer 2ecd0902c7 [include-fixer] Run tests with -fno-ms-compatibility.
Something behind that flag makes us get fewer typo correction callbacks,
unbreak the tests on windows for now.

llvm-svn: 269894
2016-05-18 09:28:45 +00:00
Haojian Wu ff6d195c2d [include-fixer] Ignore non-scoped enum declaration during search.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20354

llvm-svn: 269890
2016-05-18 09:04:43 +00:00
NAKAMURA Takumi ea46e8b674 FindAllSymbolsTests doesn't require clangToolingCore.
llvm-svn: 269874
2016-05-18 00:53:27 +00:00
NAKAMURA Takumi 37c64ee4ec include-fixer: They require clangLex.
llvm-svn: 269873
2016-05-18 00:49:16 +00:00
NAKAMURA Takumi 62e8ec5721 IncludeFixerTest.cpp: Add explicit triple for some tests. They are failing for targeting *-win32.
llvm-svn: 269870
2016-05-18 00:20:46 +00:00
Haojian Wu 2a6d78b820 [find-all-symbols] Add IWYU private pragma support.
Reviewers: djasper, klimek

Subscribers: kimgr, cfe-commits, bkramer, ioeric

Differential Revision: http://reviews.llvm.org/D19816

llvm-svn: 269779
2016-05-17 16:48:49 +00:00
Haojian Wu 39170d70c0 [find-all-symbols] Ignore anonymous enum declarations.
llvm-svn: 269762
2016-05-17 13:38:18 +00:00
Benjamin Kramer af34e06c69 [include-fixer] Make the "extend to the right" hack support typos without nested names in the front.
This handles cases where the initial namespace is unknown.

llvm-svn: 269758
2016-05-17 12:35:18 +00:00
Etienne Bergeron 8db5174395 [include-fixer] Fix broken dependency shared build
Summary:
The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o: In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o: In function `clang::include_fixer::(anonymous namespace)::runIncludeFixer(llvm::StringRef, std::vector<std::string, std::allocator<std::string> > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
```

Reviewers: bkramer, hokein

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20245

llvm-svn: 269441
2016-05-13 17:38:22 +00:00
Haojian Wu 57cdcb07d6 [include-fixer] Use scope contexts information to improve query.
Reviewers: bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20205

llvm-svn: 269430
2016-05-13 15:44:16 +00:00
Haojian Wu 631e5f23f9 [include-fixer] Simplify unittest code.
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
2016-05-13 15:17:17 +00:00
Benjamin Kramer a3d823336a [include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.

llvm-svn: 269403
2016-05-13 09:27:54 +00:00
Haojian Wu 22014750b4 [find-all-symbols] Add enum type support.
Summary:
Also change enums defined in SymbolInfo to scoped enums to avoid
conflicts.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20203

llvm-svn: 269401
2016-05-13 09:15:37 +00:00
Haojian Wu 1a352d564f [find-all-symbols] Slim SymbolInfo.
Summary:
SymbolInfo has some optional fields, which is a bad-smell
implementation. For now, we

* remove the optional field since we don't need them (we can probably
  add them back if we actually need them in the future)
* make SymbolInfo to be a class.

By this change, the code is more simplified.

Reviewers: klimek

Subscribers: cfe-commits, ioeric, bkramer

Differential Revision: http://reviews.llvm.org/D20095

llvm-svn: 269162
2016-05-11 08:38:21 +00:00