Commit Graph

59 Commits

Author SHA1 Message Date
Richard Smith 02c3baaad2 Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
This is a short-term fix for PR33650 aimed to get the modules build bots green again.

Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR
macros to try to locally specialize a global template for a global type. That's
not how C++ works.

Instead, we now centrally define how to format vectors of fundamental types and
of string (std::string and StringRef). We use flow formatting for the former
cases, since that's the obvious right thing to do; in the latter case, it's
less clear what the right choice is, but flow formatting is really bad for some
cases (due to very long strings), so we pick block formatting. (Many of the
cases that were using flow formatting for strings are improved by this change.)

Other than the flow -> block formatting change for some vectors of strings,
this should result in no functionality change.

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

Corresponding LLVM change is r306878.

llvm-svn: 306879
2017-06-30 20:57:16 +00:00
Benjamin Kramer f044405351 Revert "[include-fixer] Don't throw exception when parsing unknown arguments in vim script."
This reverts commit r302934. It's wrong, edits the wrong file and was
committed without review.

llvm-svn: 303242
2017-05-17 09:24:28 +00:00
Haojian Wu a9231af7dd [include-fixer] Don't throw exception when parsing unknown arguments in
vim script.

llvm-svn: 302934
2017-05-12 19:01:02 +00:00
Sam McCall 573050e703 [include-fixer] Remove line number from Symbol identity
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
2017-03-09 10:47:44 +00:00
Haojian Wu d09ed40e95 [find-all-symbols] Implement operator== for SymbolAndSignals and SymbolInfo::Signals.
llvm-svn: 296461
2017-02-28 10:13:26 +00:00
Sam McCall b27dc2245f [include-fixer] Add usage count to find-all-symbols.
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
2017-02-28 08:13:15 +00:00
Haojian Wu ffdd072858 [find-all-symbols] Index partial template specializations.
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
2017-01-11 11:47:44 +00:00
Piotr Padlewski 08124b110a modernize-use-auto NFC fixes
llvm-svn: 289656
2016-12-14 15:29:23 +00:00
Haojian Wu cd63701245 [include-fixer] Support finding headers for the symbol under cursor.
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
2016-09-07 16:34:35 +00:00
Eugene Zelenko 1a14e4734e [include-fixer] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D24179

llvm-svn: 280741
2016-09-06 19:53:26 +00:00
Zachary Turner d08eb4b8bf Revert "Revert "[Include-fixer] Install executables and support scripts""
This reverts commit 2aff596257e1c45fa54baae823ecbe61a785174e.

I'm having a bad day apparently.  I reverted the wrong CL.  This
puts it back.

llvm-svn: 278978
2016-08-17 20:58:14 +00:00
Zachary Turner e5fba53bed Revert "[Include-fixer] Install executables and support scripts"
This reverts commit b725a314a9b7f746c37f70909ec3c4dcb6d9f6b5.

The patch that made this test work needed to be reverted, so this
test needs to be reverted as well.

llvm-svn: 278977
2016-08-17 20:56:47 +00:00
Eugene Zelenko 473da657c7 [Include-fixer] Install executables and support scripts
Differential revision: https://reviews.llvm.org/D23045

llvm-svn: 278949
2016-08-17 17:27:56 +00:00
Haojian Wu dd14b18def [include-fixer] Correct some header mappings.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 277811
2016-08-05 11:54:34 +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 c97b9bda76 Fix broken build caused by r274494.
llvm-svn: 274495
2016-07-04 11:42:37 +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
Haojian Wu d58dc298ef [include-fixer] Correct two wrong header mappings.
Reviewers: bkramer

Subscribers: ioeric, cfe-commits

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

llvm-svn: 272773
2016-06-15 11:15:12 +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
Eric Liu 5bc39ab592 [include-fixer] fixed a wrong header mapping.
llvm-svn: 271638
2016-06-03 09:33:22 +00:00
Eric Liu 1ebb7cf052 [include-fixer] added GNU symbols hardcoded header mapping.
Summary: [include-fixer] added GNU symbols hardcoded header mapping.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 271637
2016-06-03 09:25:03 +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 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
Benjamin Kramer a3f3a7bdd8 [include-fixer] Inline trivial methods.
Putting them into the .cpp file is both more verbose and slower than
having them in the header. No functional change intended.

llvm-svn: 271285
2016-05-31 14:40:10 +00:00
Eric Liu c893070ff1 [include-fixer] collect the number of times a symbols is found in an 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
2016-05-31 12:01:48 +00:00
Benjamin Kramer bc90075629 [include-fixer] Add a missing .h.
llvm-svn: 270989
2016-05-27 12:49:58 +00:00
Eric Liu fff1335fce [include-fixer] /usr/include/xlocal.h to include/xlocal.h in hardcoded map.
llvm-svn: 270703
2016-05-25 14:17:09 +00:00
Benjamin Kramer 0e871f0b66 Include local header with quotes instead of angle brackets.
This works by accident because we pass '-I.'

llvm-svn: 270701
2016-05-25 14:14:52 +00:00
Eric Liu 748308ad35 [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.
Summary: [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 270696
2016-05-25 13:53:33 +00:00
Eric Liu 54b68779b2 [include-fixer][find-all-symbols] added missing dependencies.
llvm-svn: 270578
2016-05-24 16:35:24 +00:00
Eric Liu 0a28e680f7 [include-fixer][find-all-symbols] removed unused const member from YamlReporter to fix build bot failure.
llvm-svn: 270571
2016-05-24 15:34:37 +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 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
Eric Liu 6c9472c57f [find-all-symbols] fix failing unittest for Windows build bot.
llvm-svn: 270202
2016-05-20 11:14:36 +00:00
Eric Liu 81554e7257 [find-all-symbols] fixed FindAllMacros compilation error.
llvm-svn: 270196
2016-05-20 09:23:19 +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
NAKAMURA Takumi e1f0ed0a1f findAllSymbols: Prune unused libdeps.
llvm-svn: 269875
2016-05-18 00:53:31 +00:00
NAKAMURA Takumi 37c64ee4ec include-fixer: They require clangLex.
llvm-svn: 269873
2016-05-18 00:49:16 +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
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 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
Haojian Wu db98f1d9c9 [find-all-symbols] Add EnumDecl type in YAML traits.
llvm-svn: 269422
2016-05-13 14:53:10 +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 075ba119b2 [find-all-symbols] Save relative file path for each symbol.
Summary:
The HeaderSearch::suggestPathToFileForDiagnostics used in include-fixer
doesn't work well with absolute file path, it assumes a relative file
path based on header searching path.

So saving relative file path to make include-fixer get the most
appropriate header path.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269173
2016-05-11 11:50:08 +00:00