Commit Graph

1548 Commits

Author SHA1 Message Date
Jonas Toth e8b31285aa [clang-tidy] use CHECK-NOTES in bugprone-forwarding-reference-overload
Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 342459
2018-09-18 10:21:33 +00:00
Jonas Toth ebf03001c1 [clang-tidy] use CHECK-NOTES in tests for bugprone-argument-comment
Summary:
This patch uses CHECK-NOTES for the tests.
Its part of an effort to test *ALL* generated diagnostics in clang-tidy,
as emitted notes were previously ignored.

Reviewers: alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 342458
2018-09-18 10:15:15 +00:00
Sam McCall 3bf9b6d920 [clangd] dexp tool uses llvm::cl to parse its flags.
Summary:
We can use cl::ResetCommandLineParser() to support different types of
command-lines, as long as we're careful about option lifetimes.
(I tried using subcommands, but the error messages were bad)
I found a mostly-reasonable pattern to isolate the fiddly parts.

Added -scope and -limit flags to the `find` command to demonstrate.
(Note that scope support seems to be broken in dex?)

Fixed symbol lookup to parse symbol IDs.

Caveats:
 - with command help (e.g. `find -help`), you also get some spam
   about required arguments. This is a bug in llvm::cl, which prints
   these to errs() rather than the designated stream.

Reviewers: kbobyrev

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

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

llvm-svn: 342456
2018-09-18 09:49:57 +00:00
Shuai Wang 13f5dd5280 [clang-tidy] Fix tests for performance-for-range-copy
Test failed as D52120 made ExprMutationAnalyzer smarter, fixed by:
- Add move-ctor for `Mutable` to make it actually movable.
- Properly implement `remove_reference`.

The failed test case is:
void negativeVarIsMoved() {
  for (auto M : View<Iterator<Mutable>>()) {
    auto Moved = std::move(M);
  }
}
Before D52120, `std::move(M)` itself is considered as a mutation to `M`,
while after D52120 it's only considered as a cast to rvalue, the
move-assignment is what causes the actual mutation. The test case didn't
mock things properly so the intended move-assignement was actually a
copy-assignment.

llvm-svn: 342417
2018-09-17 21:28:08 +00:00
Jonas Toth b1efe51dd9 [clang-tidy] fix PR37913, templated exception factory diagnosed correctly
Summary:
PR37913 documents wrong behaviour for a templated exception factory function.
The check does misidentify dependent types as not derived from std::exception.

The fix to this problem is to ignore dependent types, the analysis works correctly
on the instantiated function.

Reviewers: aaron.ballman, alexfh, hokein, ilya-biryukov

Reviewed By: alexfh

Subscribers: lebedev.ri, nemanjai, mgorny, kbarton, xazax.hun, cfe-commits

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

llvm-svn: 342393
2018-09-17 13:55:10 +00:00
Idriss Riouak 87242f1052 Fix
llvm-svn: 342389
2018-09-17 12:58:19 +00:00
Idriss Riouak 09767acae1 [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void
Summary:
Hello, i would like to suggest a fix for one of the checks in clang-tidy.The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=32575 where you can find more information.

For example:
```
template <typename T0>
struct S {
  template <typename T>
  void g() const {
    int a;
    (void)a;
  }
};

void f() {
  S<int>().g<int>();
}
```


this piece of code should not trigger any warning by the check modernize-redundant-void-arg but when we execute the following command


```
clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11
```

we obtain the following warning:

/Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6: warning: redundant void argument list in function declaration [modernize-redundant-void-arg]
    (void)a;
     ^~~~

Reviewers: aaron.ballman, hokein, alexfh, JonasToth

Reviewed By: aaron.ballman, JonasToth

Subscribers: JonasToth, lebedev.ri, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 342388
2018-09-17 12:29:29 +00:00
Reid Kleckner 11511ab5cf Mark index-tools.test as REQUIRES: shell so that it does not run with the internal lit shell which does not support "if"
llvm-svn: 342282
2018-09-14 20:51:07 +00:00
Benjamin Kramer bb999e507c [modernize-use-transparent-functors] TypeLocs can be implicitly created, don't crash when encountering those.
llvm-svn: 342252
2018-09-14 18:05:30 +00:00
Vedant Kumar 8d8579ff8f Update a clang-tidy test for r342194
The location of implicit captures has changed. Update a use-after-move
checker test to reflect that.

This fixes a bot failure:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/36500

llvm-svn: 342195
2018-09-13 23:50:20 +00:00
Kirill Bobyrev e6dd0806c7 [clangd] Cleanup FuzzyFindRequest filtering limit semantics
As discussed during D51860 review, it is better to use `llvm::Optional`
here as it has clear semantics which reflect intended behavior.

Reviewed By: sammccall

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

llvm-svn: 342138
2018-09-13 14:27:03 +00:00
Kirill Bobyrev 60be1f59bd [clangd] Use JSON format in benchmark requests reader
After `FuzzyFindRequest` JSON (de)serialization was introduced, it
should replace ad-hoc fuzzy-find request parsing implemented in the
IndexBenchmark driver.

Reviewed By: ilya-biryukov

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

llvm-svn: 342137
2018-09-13 14:21:50 +00:00
Ilya Biryukov 33b72d8d34 [clangd] Rename global-symbol-builder to clangd-indexer.
Summary:
Given that the indexer binary is put directly into ./bin directory
when built, 'clangd-' prefix seems to provide better context to the
reader than 'global-'.

The new name is also shorter and easier to type.

Reviewers: ioeric, sammccall, kadircet

Reviewed By: ioeric, sammccall

Subscribers: kbobyrev, ilya-biryukov, mgorny, MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 342123
2018-09-13 09:44:11 +00:00
Kirill Bobyrev 03a9aa8f67 Fix buildbots after r342027
llvm-svn: 342036
2018-09-12 09:27:55 +00:00
Kirill Bobyrev 73c201da51 [clangd] Add index benchmarks
This patch introduces index benchmarks on top of the proposed LLVM
benchmark pull.

Reviewed By: sammccall, lebedev.ri

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

llvm-svn: 342026
2018-09-12 07:49:44 +00:00
Julie Hockett ac68cab9e1 Reland "Implement a (simple) Markdown generator"
Relanding with fixes to tests for the failing bots.

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

llvm-svn: 341955
2018-09-11 15:56:55 +00:00
Benjamin Kramer 8f776db7ff [clang-tidy] Insert absl::StrAppend when replacing StrCat.
There might be no using decl for StrAppend around, inserting the
qualified name is less likely to break things.

llvm-svn: 341929
2018-09-11 12:19:45 +00:00
Benjamin Kramer 4f3c0e27b6 [clang-tidy] Add a missing comma after "flags"
llvm-svn: 341925
2018-09-11 10:37:08 +00:00
Benjamin Kramer 14dd35c30b [clang-tidy] Abseil: Allow macros inside of absl to use internal absl things
llvm-svn: 341643
2018-09-07 09:25:23 +00:00
Sam McCall c54dd0a731 [clangd] Fix references.test assertions
llvm-svn: 341466
2018-09-05 13:17:51 +00:00
Sam McCall 1ad142fe26 [clangd] Add xrefs LSP boilerplate implementation.
Reviewers: ilya-biryukov, ioeric

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

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

llvm-svn: 341462
2018-09-05 11:53:07 +00:00
Fangrui Song 8810f3319c Import lit.llvm after rL341130
llvm-svn: 341152
2018-08-31 00:26:46 +00:00
Nico Weber b737d4d560 Remove LIT_SITE_CFG_IN_FOOTER, clang-tools-extra
It's always replaced with the same (short) static string, so just put that
there directly.

No intended behavior change.
https://reviews.llvm.org/D51357

llvm-svn: 341130
2018-08-30 22:10:13 +00:00
Jonas Toth 5c0f66b1fe [clang-tidy] fix check_clang_tidy to forbid mixing of CHECK-NOTES and CHECK-MESSAGES
Summary:
The check_clang_tidy.py script would allow mixing of `CHECK-NOTES` and `CHECK-MESSAGES` but running `FileCheck` for that would implicitly fail, because `CHECK-NOTES` bails out if there is a warning.

That means a clang-tidy test can not mix these constructs to check warnings with `CHECK-MESSAGES` and notes with `CHECK-NOTES`. The script gives now a clear error if that happens.

Reviewers: alexfh, aaron.ballman, lebedev.ri, hokein

Reviewed By: lebedev.ri

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 341039
2018-08-30 08:44:27 +00:00
Jonas Toth 51aadb463e [clang-tidy] Add abseil-no-internal-dependencies check
Finds instances where the user depends on internal details and warns them against doing so.
Should not be run on internal Abseil files or Abseil source code.

Patch by hugoeg!

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

llvm-svn: 340928
2018-08-29 14:23:15 +00:00
Aaron Ballman ca5f775dbe Introduce the abseil-redundant-strcat-calls check.
This flags redundant calls to absl::StrCat where the result is being passed to another call to absl::StrCat or absl::StrAppend. Patch by Hugo Gonzalez and Samuel Benzaquen.

llvm-svn: 340918
2018-08-29 11:29:07 +00:00
Aaron Ballman a22d24a36c Introduce the abseil-str-cat-append check.
This flags uses of absl::StrCat when absl::StrAppend should be used instead. Patch by Hugo Gonzalez and Benjamin Kramer.

llvm-svn: 340915
2018-08-29 11:17:31 +00:00
Haojian Wu d2f7b04d1b [clang-tidy] Abseil: no namepsace check
This check ensures that users of Abseil do not open namespace absl in their code, as that violates our compatibility guidelines.

AbseilMatcher.h written by Hugo Gonzalez.

Patch by Deanna Garcia!

llvm-svn: 340800
2018-08-28 07:48:28 +00:00
Alex Lorenz 0ce8a7a039 [clangd] send diagnostic categories only when 'categorySupport'
capability was given by the client

After r339738 Clangd started sending categories with each diagnostic, but that
broke the eglot client. This commit puts the categories behind a capability to
fix that breakage.

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

llvm-svn: 340449
2018-08-22 20:30:06 +00:00
Haojian Wu 279d72d37d [clang-tidy] Abseil: faster strsplit delimiter check
This check is an abseil specific check that checks for code using single character string literals as delimiters and transforms the code into characters.

The check was developed internally and has been running at google, this is just
a move to open source the check. It was originally written by @sbenza.

Patch by Deanna Garcia!

llvm-svn: 340411
2018-08-22 13:58:25 +00:00
Haojian Wu 5cd630d341 [clang-tidy] Abseil: integral division of Duration check
This check is an abseil specific test that tests to ensure users utilize abseil specific floating point division when trying to divide with abseil duration types.

Patch by Deanna Garcia!

llvm-svn: 340038
2018-08-17 15:19:19 +00:00
Julie Hockett 921e195633 Revert "Implement a (simple) Markdown generator"
This reverts commit r339948, as it's breaking a few bots in ways that I
can't reproduce right now.

llvm-svn: 339966
2018-08-16 23:50:51 +00:00
Julie Hockett 1bcd1b0324 Implement a (simple) Markdown generator
Implementing a simple Markdown generator from the emitted bitcode
summary of declarations. Very primitive at this point, but will be
expanded. Currently emits an .md file for each class and namespace,
listing its contents.

For a more detailed overview of the tool, see the design document
on the mailing list:
http://lists.llvm.org/pipermail/cfe-dev/2017-December/056203.html

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

llvm-svn: 339948
2018-08-16 21:54:34 +00:00
Jan Korous 59890002db [clangd][tests] Rename tests of clangd instance termination
Just making testnames better reflect their testing scenarios.

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

llvm-svn: 339782
2018-08-15 15:58:05 +00:00
Jan Korous 61b0758aa9 [clangd][tests] Fix typo in tests - invalid LSP exit message
Syntactically invalid JSON payload was causing clangd to terminate because of unexpected EOF rather than exit as a response to LSP exit message.

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

llvm-svn: 339781
2018-08-15 15:50:45 +00:00
Alex Lorenz 44fdf2dad6 [clangd] update the new test to check for diagnostic's category as well
llvm-svn: 339739
2018-08-14 22:27:03 +00:00
Alex Lorenz 37146431d2 [clangd] add an extension field to LSP to transfer the diagnostic's category
This patch adds a 'category' extension field to the LSP diagnostic that's sent
by Clangd. This extension is always on by default.

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

llvm-svn: 339738
2018-08-14 22:21:40 +00:00
Alex Lorenz 3738dba69b [clangd] add missing test from r339454
I forgot to checkin the test for the fixits into SVN.

llvm-svn: 339737
2018-08-14 22:20:35 +00:00
Julie Hockett 4955422f9e [clang-doc] Pass over function-internal declarations
llvm-svn: 339592
2018-08-13 18:05:50 +00:00
Kadir Cetinkaya d4218dcd79 Fix lint tests for D50449
Reviewers: ilya-biryukov, hokein

Reviewed By: hokein

Subscribers: hokein, ioeric, jkorous, arphaman, cfe-commits

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

llvm-svn: 339572
2018-08-13 14:32:19 +00:00
Martin Bohme e47a631d1c [clang-tidy] Recognize [[clang::reinitializes]] attribute in bugprone-use-after-move
Summary:
This allows member functions to be marked as reinitializing the object. After a
moved-from object has been reinitialized, the check will no longer consider it
to be in an indeterminate state.

The patch that adds the attribute itself is at https://reviews.llvm.org/D49911

Reviewers: ilya-biryukov, aaron.ballman, alexfh, hokein, rsmith

Reviewed By: aaron.ballman

Subscribers: dblaikie, xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 339571
2018-08-13 14:24:52 +00:00
Aaron Ballman bc8f5ac754 Add a new check to the readability module that flags uses of "magic numbers" (both floating-point and integral).
Patch by Florin Iucha <florin@signbit.net>

llvm-svn: 339516
2018-08-12 14:35:13 +00:00
Roman Lebedev 70fcafc096 [clang-tidy] check_clang_tidy.py: support CHECK-NOTES prefix
Summary:
Currently, there is two configured prefixes: `CHECK-FIXES` and `CHECK-MESSAGES`
`CHECK-MESSAGES` checks that there are no test output lines with `warning:|error:`, which are not explicitly handled in lit tests.
However there does not seem to be a nice way to enforce for all the `note:` to be checked.
This was useful for me when developing D36836.

Reviewers: alexfh, klimek, aaron.ballman, hokein

Reviewed By: alexfh, aaron.ballman

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

Tags: #clang-tools-extra

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

llvm-svn: 339437
2018-08-10 15:05:46 +00:00
Alexander Kornienko f337f5b7a5 [clang-tidy: modernize] modernize-redundant-void-arg crashes when a function body is in a macro
Fixes https://bugs.llvm.org/show_bug.cgi?id=28406

Patch by IdrissRio.

Differential revision: https://reviews.llvm.org/D49800

llvm-svn: 339433
2018-08-10 13:59:33 +00:00
Haojian Wu 25efa0fad3 [clang-tidy] Omit cases where loop variable is not used in loop body in
performance-for-range-copy check.

Summary:
The upstream change r336737 make the check too smart to fix the case
where loop variable could be used as `const auto&`.

But for the case below, changing to `const auto _` will introduce
an unused complier warning.

```
for (auto _ : state) {
  // no references for _.
}
```

This patch omit this case, and it is safe to do it as the case is very rare.

Reviewers: ilya-biryukov, alexfh

Subscribers: xazax.hun, cfe-commits

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

llvm-svn: 339415
2018-08-10 08:25:51 +00:00
Petr Hosek eb46c95c3e [CMake] Use normalized Windows target triples
Changes the default Windows target triple returned by
GetHostTriple.cmake from the old environment names (which we wanted to
move away from) to newer, normalized ones. This also requires updating
all tests to use the new systems names in constraints.

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

llvm-svn: 339307
2018-08-09 02:16:18 +00:00
Martin Bohme b7d621b7b6 [clang-tidy] Sequence init statements, declarations, and conditions correctly in if, switch, and while
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36516.

Reviewers: ilya-biryukov, alexfh, aaron.ballman, hokein

Reviewed By: alexfh

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 338932
2018-08-03 22:20:04 +00:00
Alex Lorenz b411cf3275 [clangd] capitalize diagnostic messages
The diagnostic messages that are sent to the client from Clangd are now always
capitalized.

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

llvm-svn: 338919
2018-08-03 20:43:28 +00:00
Simon Marchi 70e209b816 [clangd] Add test for changing build configuration
Summary:
This patch adds tests for the two ways of changing build configuration
(pointing to a particular compile_commands.json):

- Through the workspace/didChangeConfiguration notification.
- Through the initialize request.

Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits

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

llvm-svn: 338914
2018-08-03 19:40:19 +00:00
Shuai Wang c2d93d6619 Use ExprMutationAnalyzer in performance-unnecessary-value-param
Summary:
This yields better recall as ExprMutationAnalyzer is more accurate.

One common pattern this check is now able to catch is:
```
void foo(std::vector<X> v) {
  for (const auto& elm : v) {
    // ...
  }
}
```

Reviewers: george.karpenkov

Subscribers: a.sidorin, cfe-commits

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

llvm-svn: 338903
2018-08-03 17:23:37 +00:00