Commit Graph

2388 Commits

Author SHA1 Message Date
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
Ilya Biryukov b122d68687 Test commit(changed comment)
llvm-svn: 303063
2017-05-15 13:50:46 +00:00
Yan Wang 7696b71d64 [clang-tidy] TwineLocalCheck: add param # checking
Summary:
The statement **getArg** tries to get the first one without checking, which may cause segmentation fault.

 

Reviewers: chh, bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, xazax.hun

Tags: #clang-tools-extra

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

llvm-svn: 303001
2017-05-14 04:14:59 +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
Alexander Kornienko d09472e721 [clang-tidy] Add a test for PR33020
Fix committed in clang as r302889.

llvm-svn: 302890
2017-05-12 11:24:58 +00:00
Petr Hosek e60a976fce [clang-tidy][CMake] Make clang-tidy usable as distribution component
Use add_clang_tool rather than add_clang_executable to support
clang-tidy as a distribution component.

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

llvm-svn: 302688
2017-05-10 16:20:54 +00:00
Gabor Horvath a7fcc00d51 [clang-tidy] Add new cert-dcl21-cpp check
This check flags postfix operator++/-- declarations,
where the return type is not a const object.

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

llvm-svn: 302637
2017-05-10 11:16:55 +00:00
Alexander Kornienko 9660d4d328 [clang-tidy] Allow disabling compatibility check for generated fixes.
llvm-svn: 302536
2017-05-09 15:10:26 +00:00
Alexander Kornienko d0488d427c Change EOL style to LF. NFC
llvm-svn: 302534
2017-05-09 14:56:28 +00:00
Alexander Kornienko 7aedf33a24 [clang-tidy] Minor cleanup + a disabled test case for PR26228. NFC
llvm-svn: 302522
2017-05-09 12:41:11 +00:00
Tom Stellard dd50e9fb15 docs: Fix Sphinx detection with out-of-tree builds
Adapt to changes made in r302499.

llvm-svn: 302516
2017-05-09 11:11:52 +00:00
Alexander Kornienko f89e0bb2c4 [clang-tidy] Fix readability-implicit-bool-cast false positives
The patch makes the check treat binary conditional operator (`x ?: y`), `while`
and regular `for` loops as conditional statements for the purpose of
AllowConditional*Cast options.

llvm-svn: 302431
2017-05-08 15:22:09 +00:00
Miklos Vajna 0854f2dd8f clang-tidy: add IgnoreMacros option to modernize-use-default-member-init
Summary:
And also enable it by default to be consistent with e.g.
modernize-use-using.

This helps e.g. when running this check on cppunit client code where the
macro is provided by the system, so there is no easy way to modify it.

Reviewers: alexfh, malcolm.parsons

Reviewed By: malcolm.parsons

Subscribers: cfe-commits

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

llvm-svn: 302429
2017-05-08 15:13:31 +00:00
Alexander Kornienko 096977abbf [clang-tidy] Ignore private =deleted methods in macros.
modernize-use-equals-delete is extremely noisy in code using
DISALLOW_COPY_AND_ASSIGN-style macros and there's no easy way to automatically
fix the warning when macros are in play.

llvm-svn: 302425
2017-05-08 14:17:27 +00:00
Jakub Kuderski 64293fca39 [clang-tidy] Use cxxStdInitializerListExpr in modernize-use-emplace
Summary: Use the cxxStdInitializerListExp matcher from ASTMatchers.h instead of a local one.

Reviewers: aaron.ballman, alexfh, Prazek

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 302317
2017-05-05 23:00:37 +00:00
Jakub Kuderski f8d872c66e [clang-tidy] Fix PR32896: detect initializer lists in modernize-use-empalce
Summary:
This patch fixes [[ https://bugs.llvm.org/show_bug.cgi?id=32896 | PR32896 ]].

The problem was that modernize-use-emplace incorrectly removed changed push_back into emplace_back, removing explicit constructor call with initializer list parameter, resulting in compiler error after applying fixits.
modernize-use-emplace used to check if matched constructor had InitListExpr, but didn't check against CXXStdInitializerListExpr.

Eg.

```
std::vector<std::vector<int>> v;
  v.push_back(std::vector<int>({1})); // --> v.emplace_back({1});
```

Reviewers: Prazek, alexfh, aaron.ballman

Reviewed By: Prazek, alexfh, aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 302281
2017-05-05 20:35:30 +00:00
Alexander Kornienko b48986782b [clang-tidy] Fix misc-move-const-arg for move-only types.
Summary: Fix misc-move-const-arg false positives on move-only types.

Reviewers: sbenza

Reviewed By: sbenza

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 302261
2017-05-05 17:33:49 +00:00
Marc-Andre Laperle 25624f4c41 [clangd] Add documentation page
Summary:
Add a simple documentation page for Clangd.
This will be useful for interested users and contributors to get basic information about how
to get started and the progress of Clangd.

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: Prazek, jbcoe, JDevlieghere, mgehre, JonasToth, kromanenkov, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 302191
2017-05-04 19:57:53 +00:00
Alexander Kornienko c6ba6fc3c8 [clang-tidy] fix readability-implicit-bool-cast false positive with xor
llvm-svn: 302164
2017-05-04 16:06:08 +00:00
Alexander Kornienko b92cb07bad [clang-tidy] fix readability-implicit-bool-cast false alarm on |=, &=
llvm-svn: 302161
2017-05-04 15:34:31 +00:00
Alexander Kornienko cbe8d16da4 [clang-tidy] Code cleanup, (almost) NFC (*).
(*) Printed types of member pointers don't use elaborated type specifiers
(`int struct S::*` -> `int S::*`).

llvm-svn: 302160
2017-05-04 15:34:23 +00:00
Haojian Wu 03c8963c32 [clang-move] Find template class forward declarations more precisely.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 301914
2017-05-02 12:15:11 +00:00
Gabor Horvath 8b8c5a0e5a Reorder release notes, fix missing link and a grammar issue.
Patch by Réka Nikolett Kovács!

llvm-svn: 301836
2017-05-01 21:02:38 +00:00
Jakub Kuderski 57fa1de516 [clang-tidy] Fix naming convention in modernize-use-emplace
Summary: Conform to the llvm naming convention for local variables in modernize-use-emplace check.

Reviewers: Prazek, JonasToth, alexfh

Reviewed By: Prazek, JonasToth, alexfh

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 301780
2017-04-30 21:12:56 +00:00
NAKAMURA Takumi 68ce7c3b0d clang-tools-extra/test/CMakeLists.txt: Rework r297806 (D29851) to make sure test utils should be built.
FIXME: This may be moved to llvm's add_lit_target().
llvm-svn: 301762
2017-04-30 03:19:04 +00:00
Alexander Kornienko 4e001b5bd7 [clang-tidy] Expand AllowConditional*Casts to binary logical operators
llvm-svn: 301743
2017-04-29 12:06:45 +00:00
Jakub Kuderski 2a43d71765 [clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls
Summary:
When there is a push_back with a call to make_pair, turn it into emplace_back and remove the unnecessary make_pair call.

Eg.

```
std::vector<std::pair<int, int>> v;
v.push_back(std::make_pair(1, 2)); // --> v.emplace_back(1, 2);
```

make_pair doesn't get removed when explicit template parameters are provided, because of potential problems with type conversions.

Reviewers: Prazek, aaron.ballman, hokein, alexfh

Reviewed By: Prazek, alexfh

Subscribers: JDevlieghere, JonasToth, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 301651
2017-04-28 16:25:45 +00:00
David Blaikie 5c4ec7cca4 Fix API breaks
llvm-svn: 301468
2017-04-26 20:58:03 +00:00
Haojian Wu 489f363380 [clang-tidy] Support detecting for-range loop in inefficient-vector-operation check.
Summary:
Also add an option "VectorLikeClasses" allowing user specify customized
vectors.

Reviewers: alexfh, aaron.ballman

Reviewed By: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

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

llvm-svn: 301440
2017-04-26 18:13:05 +00:00
Alexander Kornienko eec01adde3 [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores
Summary:
The goal of this change is to fix the following suboptimal replacements currently suggested by clang-tidy:
```
// with MemberPrefix == "_"
int __foo;  // accepted without complaint
```
```
// with MemberPrefix == "m_"
int _foo;
    ^~~~~~
    m__foo
```

I fixed this by
- updating `matchesStyle()` to reject names which have a leading underscore after a prefix has already been stripped, or a trailing underscore if a suffix has already been stripped;
- updating `fixupWithStyle()` to strip leading & trailing underscores before adding the user-defined prefix and suffix.

The replacements are now:
```
// MemberPrefix == "_"
int __foo;
    ^~~~~~
    _foo
```
```
// MemberPrefix == "m_"
int _foo;
    ^~~~~
    m_foo
```

Future improvements might elect to add .clang-tidy flags to improve what is being stripped. For instance, stripping `m_` could allow `m_foo` to be automatically replaced with `_foo`.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Patch by Jacob Bandes-Storch!

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

llvm-svn: 301431
2017-04-26 16:39:11 +00:00
Jakub Kuderski a7410fdbee [clang-tidy] run-clang-tidy.py: check if clang-apply-replacements succeeds
Summary:
When running run-clang-tidy.py with -fix it tries to apply found replacements at the end.
If there are errors running clang-apply-replacements, the script currently crashes or displays no error at all.

This patch checks for errors running clang-apply-replacements the same way clang-tidy binary is handled.

Another option would be probably checking for clang-apply-replacements (when -fix is passed) even before running clang-tidy.

Reviewers: Prazek, alexfh, bkramer, mfherbst

Reviewed By: Prazek, alexfh

Subscribers: kimgr, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 301365
2017-04-25 22:38:39 +00:00
Haojian Wu 8fd72968d4 [clang-tidy] Some Cleanups for performance-faster-string-find check.
NFC

llvm-svn: 301188
2017-04-24 16:41:00 +00:00
Aaron Ballman 72163a9da5 Extend readability-container-size-empty to add comparisons to empty-state objects.
Patch by Josh Zimmerman.

llvm-svn: 301185
2017-04-24 14:57:09 +00:00
Mads Ravn a301498783 [clang-tidy] New check: modernize-replace-random-shuffle.
This check will find occurrences of ``std::random_shuffle`` and replace it with ``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available and thus we need to replace it.

Example of case that it fixes

```
  std::vector<int> v;

  // First example
  std::random_shuffle(vec.begin(), vec.end());

```

Reviewers: hokein, aaron.ballman, alexfh, malcolm.parsons, mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 301167
2017-04-24 09:27:20 +00:00
Miklos Vajna a60cae2648 clang-rename: fix formatting
As detected by clang-format.

llvm-svn: 301130
2017-04-23 16:07:06 +00:00
Benjamin Kramer d3326a04e0 [Clangd] Failed to decode params using 1.x-compatible request message
textDocument/completion sends a TextDocumentPositionParams message in the 2.x
and 3.x. But in 1.x it was instead a TextDocumentPosition with inlined
parameters. This means that the "uri" field is at the top level and not in
textDocument. Because of this, some clients that maintain compability with 1.x
have both uri and textDocument.uri. Clangd, however, early returns in the
presence of anything but 'textDocument' or 'position' which prevents a client
compatible with both 3.x and 1.x to work correctly. If Clangd was a bit more
permissive (no early return), clients implementing all the versions of the
protocol would work.

Patch by Marc-Andre Laperle!

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

llvm-svn: 300991
2017-04-21 15:51:23 +00:00
Benjamin Kramer 8c3ba63d07 [Clangd] Support Authority-less URIs
Clangd strips URIs by removing the file:// part but some clients can send file:
which is also valid according to RFC 3896. For example, if a client sends
file:///home/user, it gets converted to /home/user but if a client sends
file:/home/user, it is left untouched and problems arise.

Patch by Marc-Andre Laperle!

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

llvm-svn: 300990
2017-04-21 15:51:18 +00:00
Gabor Horvath 1a92506f36 [clang-tidy] misc-misplaced-widening-cast: Disable checking of implicit widening casts by default.
Patch by Ádám Balogh!

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

llvm-svn: 300699
2017-04-19 14:55:58 +00:00
Haojian Wu c2c2283223 [clang-tidy] Address a few late comments.
llvm-svn: 300588
2017-04-18 20:47:34 +00:00
Alexander Kornienko 04e5ab3501 [clang-tidy] Fix google-explicit-constructor issue with out-of-line conversions
llvm-svn: 300569
2017-04-18 17:26:00 +00:00
Haojian Wu d8ad303f15 Make the test pass on x86_64-win32 target.
llvm-svn: 300563
2017-04-18 16:25:03 +00:00
NAKAMURA Takumi 7db18e9b66 clang-tools-extra/test/clang-tidy/performance-inefficient-vector-operation.cpp: Appease targeting msvc with -fno-ms-extensions.
FIXME: This may work with -target x86_64-win32.
llvm-svn: 300545
2017-04-18 12:13:30 +00:00