Commit Graph

2429 Commits

Author SHA1 Message Date
Ilya Biryukov 2260299830 [clangd] Mark results of clangd requests with a tag provided by the FileSystemProvider.
Summary:
This allows an implementation of FileSystemProvider that can track which vfs::FileSystem
were used for each of the requests.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 304214
2017-05-30 15:11:02 +00:00
Alexander Kornienko 0055d97d4b [clang-tidy] Use getLocalOrGlobal for the StrictMode option
llvm-svn: 304154
2017-05-29 13:59:27 +00:00
NAKAMURA Takumi 2efabeb933 ClangdTests.cpp: Use "clang/Config/config.h" instead of "llvm/Config/config.h".
llvm-svn: 304082
2017-05-27 23:19:28 +00:00
NAKAMURA Takumi 4455641ae0 ClangdTests.cpp: Fix a possible typo, it was "if (TmpDir2 != TmpDir2)"
It caused failures in unittests if TmpDir2 is not "/tmp" .

llvm-svn: 304067
2017-05-27 08:06:52 +00:00
Ilya Biryukov 90fecdb47c [clangd] Attempt to fix tests failing on Windows
llvm-svn: 303993
2017-05-26 14:34:34 +00:00
Ilya Biryukov 0f62ed2bbe [clangd] Allow to use vfs::FileSystem for file accesses.
Summary:
Custom vfs::FileSystem is currently used for unit tests.
This revision depends on https://reviews.llvm.org/D33397.

Reviewers: bkramer, krasimir

Reviewed By: bkramer, krasimir

Subscribers: klimek, cfe-commits, mgorny

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

llvm-svn: 303977
2017-05-26 12:26:51 +00:00
Erich Keane a37711b1e2 Earlier revert introduced an extra space, remove it.
llvm-svn: 303909
2017-05-25 20:29:17 +00:00
Eugene Zelenko eed5f028ee [Documentation] Mention hicpp check group in Clang-tidy main document.
llvm-svn: 303884
2017-05-25 17:22:29 +00:00
Erich Keane ea0f630055 Revert 303872/303877 since the patch that caused these issues
is also being reverted.

llvm-svn: 303881
2017-05-25 16:23:00 +00:00
Erich Keane 594d0d592d Clang-tidy doesn't understand -fno-ms-compatibility, so just removing 'not'
llvm-svn: 303877
2017-05-25 16:07:19 +00:00
Erich Keane e6617e47d2 Disable MSVC-Compat mode for two tests that use C++Operator Names
MSVC doesn't support C++ operator names (using 'or' instead of ||, 
'not' instead of '!', etc), so this was disabled in MSVC mode in r303798.
This fixes the regression noticed on the buildbots.

llvm-svn: 303872
2017-05-25 15:39:24 +00:00
Florian Gross 7ce3a83c50 (no commit message)
llvm-svn: 303849
2017-05-25 11:43:06 +00:00
Serge Pavlov 0d4cc9bfbf Modify test so that it looks for patterns in stderr as well
With the change https://reviews.llvm.org/D33013 driver will not build
compilation object if command line is invalid, in particular, if
unrecognized option is provided. In such cases it will prints diagnostics
on stderr. The test 'clang-tidy/diagnostic.cpp' checks reaction on
unrecognized option and will fail when D33013 is applied because it checks
only stdout for test patterns and expects the name of diagnostic category
prepared by clang-tidy. With this change the test makes more general check
and must work in either case.

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

llvm-svn: 303735
2017-05-24 10:50:56 +00:00
Chih-Hung Hsieh 2857b1245b [clang-tidy] Do not dereference a null BaseType
Check BaseType before dereference.
Simplified test case is derived from Android Open Source code.

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

llvm-svn: 303645
2017-05-23 16:19:04 +00:00
Ilya Biryukov 9bab8eab49 [clangd] Added a missing dependency on clangdAST to fix the build
llvm-svn: 303636
2017-05-23 13:59:37 +00:00
Ilya Biryukov f01af686a2 [clangd] Replaced WorkerRequest with std::function...
Summary:
And implemented a helper function to dump an AST of a file for
testing/debugging purposes.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303634
2017-05-23 13:42:59 +00:00
Benjamin Kramer 85c7827a0a [clangd] Explicitly link against pthread.
llvm-svn: 303625
2017-05-23 10:29:54 +00:00
Benjamin Kramer b2dfa0b840 [clangd] Pick up deps via LLVM components, which will hopefully include pthread.
llvm-svn: 303623
2017-05-23 10:17:48 +00:00
Ilya Biryukov af4ed4528a [clangd] Split clangd into library+executable (mainly for unit tests).
Summary:
This commit itself doesn't add any unit tests, but one that does will
follow shortly.

Reviewers: krasimir, bkramer

Reviewed By: bkramer

Subscribers: mgorny, klimek, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303616
2017-05-23 08:12:45 +00:00
Alexander Kornienko f2dc6492ed [clang-tidy] misc-move-const-arg shouldn't complain on std::move(lambda)
llvm-svn: 303554
2017-05-22 14:30:14 +00:00
Alexander Kornienko 1e034c3f22 [clang-tidy] readability-redundant-declaration false positive for defaulted function
Summary:
```
template <class T>
struct C {
  C();
};

template <class T>
C<T>::C() = default;
```

Causes a readability-redundant-declaration diagnostic. This is caused by `isDefinition` not matching defaulted functions.

Reviewers: alexfh, danielmarjamaki

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Patch by Florian Gross!
Differential Revision: https://reviews.llvm.org/D33358

llvm-svn: 303552
2017-05-22 13:58:57 +00:00
Alexander Kornienko a0ddf5fc1c [clang-tidy] readability-braces-around-statements false positive with char literals
Summary:
Single-line if statements cause a false positive when the last token in the conditional statement is a char constant:

```
if (condition)
  return 'a';
```

For some reason `findEndLocation` seems to skips too many (vertical) whitespaces in this case. The same problem already occured with string literals (https://reviews.llvm.org/D25558), and was fixed by adding a special check for this very case. I just extended the condition to also include char constants. No idea what really causes the issue though.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Patch by Florian Gross!
Differential Revision: https://reviews.llvm.org/D33354

llvm-svn: 303551
2017-05-22 13:58:16 +00:00
Krasimir Georgiev d814533851 [clangd] Switch to incomplete translation units
Summary: This speeds up code completion. All the cool kids (ycmd) are doing it.

Reviewers: bkramer, ilya-biryukov

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 303547
2017-05-22 12:49:08 +00:00
Benjamin Kramer 0daf2be704 [clangd] Make formatting.test asynchronous again.
This test doesn't rely on the order of asynchronous messages, enable
threads so we have at least some coverage for those code paths.

llvm-svn: 303376
2017-05-18 20:10:04 +00:00
Simon Pilgrim 8d81c22164 Fix 'not all control paths return a value' warning on windows buildbots.
llvm-svn: 303344
2017-05-18 10:48:23 +00:00
Alexander Kornienko 6180337fe1 [clang-tidy] Optimize GlobList::contains
With large lists of checks and large number of warnings GlobList::contains
starts being ridiculously CPU hungry, since it runs regexp match per glob.
Caching results of glob matching in a StringMap significantly speeds up check
filtering even for small GlobLists.

/tmp/q.cc:

void f() {
  int I;
  {int I;}
  {int I;}
  {int I;}
  ... // 200k times
}

Before the patch:

GlobList with 2 entries:
  $ time clang-tidy-old -checks=-*,modernize-use-override /tmp/q.cc -- -Wshadow
  200000 warnings generated.
  Suppressed 200000 warnings (200000 with check filters).

  real    0m3.826s
  user    0m3.176s
  sys     0m0.504s

GlobList with 28 entries:
  $ time clang-tidy-old -checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override /tmp/q.cc -- -Wshadow
  200000 warnings generated.
  Suppressed 200000 warnings (200000 with check filters).

  real    0m5.000s
  user    0m4.744s
  sys     0m0.060s

GlobList with 158 entries:
  $ time clang-tidy-old -checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override /tmp/q.cc -- -Wshadow
  200000 warnings generated.
  Suppressed 200000 warnings (200000 with check filters).

  real    0m13.920s
  user    0m13.636s
  sys     0m0.104s

With the patch runtime is practically independent from the length of the GlobList:
  $ time clang-tidy-new -checks=-*,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,modernize-use-override /tmp/q.cc -- -Wshadow
  200000 warnings generated.
  Suppressed 200000 warnings (200000 with check filters).

  real    0m2.300s
  user    0m2.104s
  sys     0m0.044s

llvm-svn: 303321
2017-05-18 01:13:51 +00:00
Alexander Kornienko 21375185e7 Change getChecksFilter() interface to hide implementation details.
llvm-svn: 303264
2017-05-17 14:39:47 +00:00
Alexander Kornienko c321a4f2b9 [clang-tidy] Replace matchesName with hasName where no regex is needed
llvm-svn: 303263
2017-05-17 14:39:39 +00:00
Haojian Wu dbc3911ce2 Recommit "[include-fixer] Don't throw exception when parsing unknown ar… …guments in vim script."
Summary: To make it work in neovim.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 303260
2017-05-17 14:13:59 +00:00
Alexander Kornienko 63144359c5 [clang-tidy] A bit of refactoring of modernize-replace-auto-ptr. NFC
llvm-svn: 303256
2017-05-17 12:57:06 +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
Alexander Kornienko 4d5dd3b7ef [clang-tidy] Optimize misc-unused-parameters. NFCI
Don't traverse AST each time we need to find references to a certain function.
Traverse the AST once using RAV and cache the index of function references.

The speed up on a particular large file was about 1000x.

llvm-svn: 303230
2017-05-17 02:25:11 +00:00
Alexander Kornienko b215d473dd [clang-tidy] Speed up performance-unnecessary-value-param check
Moved slower matchers closer to the end. The total speed up on a large file I
was interested in is not huge, just about 10%, since the check seems to be doing
a lot in the check() method.

llvm-svn: 303191
2017-05-16 17:28:17 +00:00
Alexander Kornienko 50de3ad341 [clang-tidy] Optimize readability-implicit-bool-cast, NFC
Rearrange matchers to put the most expensive ones closer to the end. Speed up
another 3-5x on some files.

llvm-svn: 303187
2017-05-16 16:40:46 +00:00
Alexander Kornienko e133140fd1 [clang-tidy] Optimize matchers in readability-implicit-bool-cast. NFC
Don't repeat `isInTemplateInstantiation()` and `hasAncestor()` unnecessarily.
This speeds up the check by a factor of up to 3 on some large files.

llvm-svn: 303180
2017-05-16 15:44:42 +00:00
Ilya Biryukov 687b92a993 Added missing includes in clangd to fix the build.
This commit should fix buildbot failures.

llvm-svn: 303177
2017-05-16 15:23:55 +00:00
Ilya Biryukov afb555473e [clangd] Refactor ProtocolHandlers to decouple them from ClangdLSPServer
Summary:
A refactoring to decouple ProtocolHandlers and Language Server input parsing
loop from the ClangdLSPServer.
The input parsing was extracted from `main` to a function(runLanguageServerLoop).
ProtocolHandlers now provide an interface to handle various LSP methods,
this interface is used by ClangdLSPServer.
Methods for code formatting were moved from ProtocolHandlers to ClangdServer.
ClangdLSPServer now provides a cleaner interface that only runs Language Server
input loop.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

Tags: #clang-tools-extra

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

llvm-svn: 303173
2017-05-16 14:40:30 +00:00
Haojian Wu be6ef0eff9 [clang-tidy] Add "emplace_back" detection in inefficient-vector-operation.
Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: cfe-commits, Prazek, malcolm.parsons, xazax.hun

Tags: #clang-tools-extra

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

llvm-svn: 303157
2017-05-16 10:39:55 +00:00
Ilya Biryukov 2f314104e0 Fixing compilation failures on buildbots.
llvm-svn: 303154
2017-05-16 10:06:20 +00:00
Ilya Biryukov 38d79774d0 Restored r303067 and fixed failing test.
Summary:
This commit restores r303067(reverted by r303094) and fixes the 'formatting.test'
failure.
The failure is due to destructors of `ClangdLSPServer`'s fields(`FixItsMap` and
`FixItsMutex`) being called before destructor of `Server`. It led to the worker
thread calling `consumeDiagnostics` after `FixItsMutex` and `FixItsMap`
destructors were called.
Also, clangd is now run with '-run-synchronously' flag in 'formatting.test'.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: mgorny, cfe-commits, klimek

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

llvm-svn: 303151
2017-05-16 09:38:59 +00:00
Jakub Kuderski 4cdeb41072 [clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls
Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.

Eq.

```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```

Reviewers: alexfh, aaron.ballman, Prazek, hokein

Reviewed By: Prazek

Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303145
2017-05-16 06:32:38 +00:00
Jakub Kuderski 9ac6c03989 Revert "[clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls"
This reverts commit r303139. The commit made docs build emit a warning.

llvm-svn: 303140
2017-05-16 05:07:40 +00:00
Jakub Kuderski 7ff204ffdc [clang-tidy] modernize-use-emplace: Remove unnecessary make_tuple calls
Summary:
This patch makes modernize-use-emplace remove unnecessary make_ calls from push_back calls and turn them into emplace_back -- the same way make_pair calls are handled.
Custom make_ calls can be removed for custom tuple-like types -- two new options that control that are `TupleTypes` and `TupleMakeFunctions`. By default, the check removes calls to `std::make_pair` and `std::make_tuple`.

Eq.

```
std::vector<std::tuple<int, char, bool>> v;
v.push_back(std::make_tuple(1, 'A', true)); // --> v.emplace_back(1, 'A', true);
```

Reviewers: alexfh, aaron.ballman, Prazek, hokein

Reviewed By: Prazek

Subscribers: JDevlieghere, xazax.hun, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 303139
2017-05-16 04:25:42 +00:00
Haojian Wu ce4b17fdf3 [clang-tidy] Fix a typo: dequeue => deque
llvm-svn: 303095
2017-05-15 18:18:28 +00:00
Adam Nemet 076047b4d9 Revert "[ClangD] Refactor clangd into separate components"
This reverts commit r303067.

Caused http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/34305/

And even after Simon's fix there is still a test failure.

llvm-svn: 303094
2017-05-15 18:14:35 +00:00
Adam Nemet 6cd179893d Revert "Fix windows buildbots - missing include and namespace"
This reverts commit r303078.

One test is still failing even after this:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA_check/31374/consoleFull#18373900728254eaf0-7326-4999-85b0-388101f2d404

llvm-svn: 303093
2017-05-15 18:14:31 +00:00
Alexander Kornienko 1ca0e322a2 Make google-build-using-namespace skip std::.*literals
Summary:
C++14 added a couple of user-defined literals in the standard library. E.g.
std::chrono_literals and std::literals::chrono_literals . Using them
requires a using directive so do not warn in google-build-using-namespace
if namespace name starts with "std::" and ends with "literals".

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Patch by Martin Ejdestig!

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

llvm-svn: 303085
2017-05-15 17:37:48 +00:00
Alexander Kornienko 7009d65714 [clang-tidy] Partly rewrite readability-simplify-boolean-expr using RAV
The check was using AST matchers in a very inefficient manner. By rewriting the
BinaryOperator-related parts using RAV, the check was sped up by a factor of
up to 10000 on some files (mostly, generated code using binary operators in
tables), but also significantly sped up for regular large files.
As a side effect, the code became clearer and more readable.

llvm-svn: 303081
2017-05-15 17:06:51 +00:00
Simon Pilgrim 47f1ca91cf Fix windows buildbots - missing include and namespace
llvm-svn: 303078
2017-05-15 16:36:11 +00:00
Ilya Biryukov 96a13635f5 [ClangD] Refactor clangd into separate components
Summary: Major refactoring to split LSP implementation, Clang API calls and threading(mostly synchronization)

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: cfe-commits, mgorny, klimek

Tags: #clang-tools-extra

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

llvm-svn: 303067
2017-05-15 14:17:35 +00:00