Commit Graph

2290 Commits

Author SHA1 Message Date
Benjamin Kramer a079cdbeb8 Apply clang-tidy's performance-unnecessary-value-param to clang-tidy.
No functionality change intended.

llvm-svn: 298442
2017-03-21 21:34:58 +00:00
Chandler Carruth 08781dc3b6 Don't make unqualified calls to functions that could well be found via
ADL as reasonable extension points.

All of this would be cleaner if this code followed the more usual LLVM
convention of not having deeply nested namespaces inside of .cpp files
and instead having a `using namespace ...;` at the top. Then the static
function would be in the global namespace and easily referred to as
`::join`. Instead we have to write a fairly contrived qualified name.
I figure the authors can clean this up with a less ambiguous name, using
the newly provided LLVM `join` function, or any other solution, but this
at least fixes the build.

llvm-svn: 298434
2017-03-21 20:15:42 +00:00
Aaron Ballman 163e7166d7 Prevent cppcoreguidelines-pro-bounds-array-to-pointer-decay from diagnosing array to pointer decay stemming from system macros.
Patch by Breno Rodrigues Guimaraes.

llvm-svn: 298421
2017-03-21 19:01:17 +00:00
Eric Liu 8bc2416414 [change-namespace] avoid adding leading '::' when possible.
Summary:
When changing namespaces, the tool adds leading "::" to references that need to
be fully-qualified, which would affect readability.

We avoid adding "::" when the symbol name does not conflict with the new
namespace name. For example, a symbol name "na::nb::X" conflicts with "ns::na"
since it would be resolved to "ns::na::nb::X" in the new namespace.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 298363
2017-03-21 12:41:59 +00:00
Alexander Kornienko f6cd367874 [clang-tidy] readability-container-size-empty fix for (*x).size()
llvm-svn: 298316
2017-03-20 22:15:27 +00:00
Alexander Kornienko 9bf7037ccd [clang-tidy] Small cleanup. NFC.
llvm-svn: 298315
2017-03-20 22:15:19 +00:00
Aaron Ballman dbdbabf205 Rename the clang-tidy safety module to be hicpp, for the High-Integrity C++ coding standard from PRQA.
This commit renames all of the safety functionality to be hicpp, adds an appropriate LICENSE.TXT, and updates the documentation accordingly.

llvm-svn: 298229
2017-03-19 17:23:23 +00:00
Alexander Kornienko b10daaf198 [Clang-tidy] Fix for misc-noexcept-move-constructor false triggers on defaulted declarations
Summary:
There is no need for triggering warning when noexcept specifier in move constructor or move-assignment operator is neither evaluated nor uninstantiated.

This fixes bug reported here: bugs.llvm.org/show_bug.cgi?id=24712

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JonasToth, JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Marek Jenda!

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

llvm-svn: 298101
2017-03-17 16:40:34 +00:00
Eric Liu 284b97c6bc [change-namespace] do not rename specialized template parameters.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 298090
2017-03-17 14:05:39 +00:00
Alexander Kornienko 70c8d291c2 [clang-tidy] Added a test with a different format.
llvm-svn: 298060
2017-03-17 10:05:49 +00:00
Alexander Kornienko bc8d14669d [clang-tidy] readability-misleading-indentation: fix chained if
Summary:
Fixed erroneously flagging of chained if statements when styled like this:

```
if (cond) {
}
else if (cond) {
}
else {
}
```

Reviewers: xazax.hun, alexfh

Reviewed By: xazax.hun, alexfh

Subscribers: JDevlieghere, cfe-commits

Patch by Florian Gross!

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

llvm-svn: 298059
2017-03-17 09:58:30 +00:00
Alexander Kornienko c7c9b75804 [clang-tidy] Verify some conditions in a matcher instead of check(). NFC
llvm-svn: 298057
2017-03-17 09:47:05 +00:00
Alexander Kornienko 7bcf7516df [clang-tidy] Ignore deleted members in google-explicit-constructor.
This fixes http://llvm.org/PR32221.

llvm-svn: 298052
2017-03-17 08:40:07 +00:00
Michal Gorny 6e31072e21 [test] Fix test dependencies when using installed tools
Use the LLVM_UTILS_PROVIDED variable to determine whether test tool
dependencies should be exposed for clang-tools-extra tests. If clang is
being built stand-alone and LLVM test tools (FileCheck, count and not)
are installed, the top-level CMakeLists.txt of clang sets this variable
to indicate that they will not be built as a part of this build,
and therefore no dependencies should be emitted for them. This fixes
the dependency errors when building clang stand-alone with tests
enabled.

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

llvm-svn: 297806
2017-03-15 05:55:43 +00:00
Benjamin Kramer 5957a19630 [clangd] Fix not being able to attach a debugger on macOS
Clangd is often waiting for input on getline as it awaits requests. If the
getline is interrupted, it causes the system call (read) to fail and the EINTR
error to be set. This can be seen when attaching a debugger such as LLDB on
macOS. On macOS (and possibly other operating systems), this system call is not
restarted after interruption but on Linux it is restarted which is why
attaching a debugger does work correctly there.

The solution is to work around the non-restarting system call by checking the
errno for EINTR when the stream fails and try again. This should be safe on all
Unixish platforms.

See also http://bugs.llvm.org/show_bug.cgi?id=32149 for some background
discussion.

Patch by Marc-Andre Laperle!
Differential Revision: https://reviews.llvm.org/D30675

llvm-svn: 297779
2017-03-14 20:41:28 +00:00
Aaron Ballman 9dd8caad1f Add the 'AllowSoleDefaultDtor' and 'AllowMissingMoveFunctions' options to the cppcoreguidelines-special-member-functions check.
Patch by Florian Gross.

llvm-svn: 297671
2017-03-13 21:39:00 +00:00
Sam McCall 9c5ebf7039 [include-fixer] Add fuzzy SymbolIndex, where identifier needn't match exactly.
Summary:
Add fuzzy SymbolIndex, where identifier needn't match exactly.

The purpose for this is global autocomplete in clangd. The query will be a
partial identifier up to the cursor, and the results will be suggestions.

It's in include-fixer because:

  - it handles SymbolInfos, actually SymbolIndex is exactly the right interface
  - it's a good harness for lit testing the fuzzy YAML index
  - (Laziness: we can't unit test clangd until reorganizing with a tool/ dir)

Other questionable choices:

  - FuzzySymbolIndex, which just refines the contract of SymbolIndex. This is
    an interface to allow extension to large monorepos (*cough*)
  - an always-true safety check that Identifier == Name is removed from
    SymbolIndexManager, as it's not true for fuzzy matching
  - exposing -db=fuzzyYaml from include-fixer is not a very useful feature, and
    a non-orthogonal ui (fuzziness vs data source). -db=fixed is similar though.

Reviewers: bkramer

Subscribers: cfe-commits, mgorny

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

llvm-svn: 297630
2017-03-13 15:55:59 +00:00
Haojian Wu b7da0eb50e [clang-rename] Introduce an unittest skeleton for clang-rename.
Summary: This will make references rename tests easier.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits, alexfh, mgorny

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

llvm-svn: 297450
2017-03-10 10:30:14 +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 8247fefead [clang-tidy] Update the doc according to r297311.
llvm-svn: 297367
2017-03-09 09:15:16 +00:00
Alexander Kornienko 5d698cf9a0 [clang-tidy] readability-function-size: remove default param count threshold
llvm-svn: 297311
2017-03-08 22:19:55 +00:00
Martin Bohme 96d29e5761 [clang-tidy] misc-use-after-move: Fix failing assertion
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

This patch also fixes nondeterministic behavior in the source code
location reported for the move when the move is constained in an init list;
this was causing buildbot failures in the previous attempt to submit
this patch (see D30569 and rL297004).

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko, JDevlieghere, cfe-commits

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

llvm-svn: 297272
2017-03-08 12:34:51 +00:00
Haojian Wu d7b45bc76d Do not display highlights for clang-include-fixer-at-point
Summary: When invoking clang-include-fixer-at-point, the QuerySymbolInfos point to offset 0, length 0. Rather than showing a hidden overlay, do not show any overlay at all for zero-length symbols.

Patch by Torsten Marek!

Reviewers: hokein, klimek

Reviewed By: hokein

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

llvm-svn: 297010
2017-03-06 14:49:26 +00:00
Haojian Wu 1aa5885f00 [clang-tidy] Ignore substituted template types in modernize-use-nullptr check.
Reviewers: alexfh

Reviewed By: alexfh

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

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

llvm-svn: 297009
2017-03-06 14:46:44 +00:00
Martin Bohme 2e5f130bf4 Revert "[clang-tidy] misc-use-after-move: Fix failing assertion"
This reverts commit r297004; it was causing buildbots to fail.

llvm-svn: 297006
2017-03-06 09:46:27 +00:00
Martin Bohme a6391ae52b [clang-tidy] misc-use-after-move: Fix failing assertion
Summary:
I've added a test case that (without the fix) triggers the assertion,
which happens when a move happens in an implicitly called conversion
operator.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 297004
2017-03-06 08:55:42 +00:00
Sylvestre Ledru 5038d5c3c5 Replaced UserNullMacros with NullMacros in modernize-use-nullptr check docs
By patch Peter Goldsborough on https://github.com/llvm-mirror/clang-tools-extra/pull/14
See 2cd835ee5b/clang-tidy/modernize/UseNullptrCheck.cpp (L466)

llvm-svn: 296970
2017-03-04 14:06:26 +00:00
Piotr Padlewski b6e1aa58fd [clang-tidy] Yet another docs fixes
llvm-svn: 296888
2017-03-03 17:16:11 +00:00
Piotr Padlewski 26e176e558 [clang-tidy] Fix modernize-use-emplace docs
llvm-svn: 296867
2017-03-03 12:42:22 +00:00
Alexander Kornienko 17a4b2344e [clang-tidy] Format code around applied fixes
Summary:
Add -format option (disabled by default for now) to trigger formatting
of replacements.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: kimgr, malcolm.parsons, JDevlieghere, cfe-commits

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

llvm-svn: 296864
2017-03-03 11:16:34 +00:00
Alexander Kornienko db04cccb87 [clang-tidy] google-readability-casting: don't use constructor call syntax for const types
llvm-svn: 296858
2017-03-03 08:18:49 +00:00
Alexander Kornienko b7f6fe4658 [clang-tidy] google-readability-casting: detect redundant casts with top-level const
llvm-svn: 296755
2017-03-02 15:47:28 +00:00
Alexander Kornienko ce482d9269 [clang-tidy] Fix a few more issues in google-readability-casting
* suggest static_cast instead of reinterpret_cast for casts from void*
* top-level const doesn't need a const_cast
* don't emit a separate "possibly redundant cast" warning, instead suggest
  static_cast (in C++ only) and add a little hint to consider removing the cast

llvm-svn: 296753
2017-03-02 15:27:34 +00:00
Benjamin Kramer 4c18c3743f [clangd] Fix a potential race by copying the FixIts out of ASTManager before releasing the lock.
Also document the locking semantics a bit better.

llvm-svn: 296737
2017-03-02 10:25:00 +00:00
Alexander Kornienko d993e76a18 [clang-tidy] Function names configurable for cppcoreguidelines-nomalloc - checker
Summary:
Hello everybody,

this is an incremental patch for the NoMalloc-Checker I wrote. It allows to configure the memory-management functions, that are checked,
This might be helpful for a code base with custom functions in use, or non-standard functionality, like posix_memalign.

Reviewers: aaron.ballman, hokein, alexfh

Reviewed By: aaron.ballman, alexfh

Subscribers: sbenza, nemanjai, JDevlieghere

Tags: #clang-tools-extra

Patch by Jonas Toth!

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

llvm-svn: 296734
2017-03-02 08:28:55 +00:00
Benjamin Kramer 570c230357 [clangd] Unbreak the shared build.
llvm-svn: 296637
2017-03-01 16:23:40 +00:00
Benjamin Kramer f0af3e6b01 [clangd] Add support for FixIts.
Summary:
This uses CodeActions to show 'apply fix' actions when code actions are
requested for a location. The actions themselves make use of a
clangd.applyFix command which has to be implemented on the editor side. I
included an implementation for vscode.

This also adds a -run-synchronously flag which runs everything on the main
thread. This is useful for testing.

Reviewers: krasimir

Subscribers: cfe-commits

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

llvm-svn: 296636
2017-03-01 16:16:29 +00:00
Alexander Kornienko 36267277d7 [clang-tidy] Attempt to fix the test where exceptions are disabled by default.
llvm-svn: 296627
2017-03-01 14:41:11 +00:00
Krasimir Georgiev 90573e49c9 [clangd] Add a toy VS Code integration for development purposes
Summary: This patch adds bare-bone VS Code integration for development purposes of clangd.

Reviewers: klimek, bkramer, mprobst

Reviewed By: bkramer

Subscribers: mprobst

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

llvm-svn: 296618
2017-03-01 13:53:12 +00:00
Eric Liu 413671507f [change-namespace] get insertion points of forward declarations correct.
Summary:
Previously, the insertion points would conflict with the old namespace
deletion.

Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 296604
2017-03-01 10:29:39 +00:00
Alexander Kornienko 9108644dbf [clang-tidy] Add parametercount for readibility-function-size
Summary:
Add an option to function-size to warn about high parameter counts.

This might be relevant for cppcoreguidelines and the safety module as well. Since the safety module is not landed in master already, i did not create an alias, but that can be done later as well.

Reviewers: sbenza, alexfh, hokein

Reviewed By: alexfh, hokein

Subscribers: JDevlieghere

Patch by Jonas Toth!

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

llvm-svn: 296599
2017-03-01 10:17:32 +00:00
Alexander Kornienko eedf7ec07f [clang-tidy] Fix handling of methods with try-statement as a body in modernize-use-override
Summary:
Fix generated by modernize-use-override caused syntax error when method
used try-statement as a body. `override` keyword was inserted after last
declaration token which happened to be a `try` keyword.

This fixes PR27119.

Reviewers: ehsan, djasper, alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

Tags: #clang-tools-extra

Patch by Paweł Żukowski!

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

llvm-svn: 296598
2017-03-01 10:16:36 +00:00
Haojian Wu b780c59b93 [clang-tidy] Fix a false positive on modernize-use-nullptr check.
Summary:
The false positive happens on two neighbour CXXDefaultArgExpr AST nodes.
like below:

```
CXXFunctionalCastExpr 0x85c9670 <col:7, col:23> 'struct ZZ' functional cast to struct ZZ <ConstructorConversion>
 `-CXXConstructExpr 0x85c9518 <col:7, col:23> 'struct ZZ' 'void (uint64, const uint64 *)'
   |-CallExpr 0x85a0a90 <col:10, col:22> 'uint64':'unsigned long long'
   | |-ImplicitCastExpr 0x85a0a78 <col:10> 'uint64 (*)(uint64)' <FunctionToPointerDecay>
   | | `-DeclRefExpr 0x85a09f0 <col:10> 'uint64 (uint64)' lvalue Function 0x85a06a0 'Hash' 'uint64 (uint64)'
   | `-CXXDefaultArgExpr 0x85a0ac8 <<invalid sloc>> 'uint64':'unsigned long long'
   `-CXXDefaultArgExpr 0x85c94f8 <<invalid sloc>> 'const uint64 *'
```

For each particular CXXDefaultArgExpr node, we need to reset
FirstSubExpr, otherwise FirstSubExpr will refer to an incorrect expr.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 296479
2017-02-28 15:29:52 +00:00
Alexander Kornienko 6414ab726d Misspelled checker description (argument comment)
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: Eugene.Zelenko

Tags: #clang-tools-extra

Patch by Peter Szecsi!

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

llvm-svn: 296472
2017-02-28 14:13:26 +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
Eric Liu 3a7e13140a [change-namespace] trying to fix windows buildbot failure.
llvm-svn: 296458
2017-02-28 10:00:15 +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
Benjamin Kramer f2524e6599 [clangd] Make clangd install to bin
This allows the install target to also install clangd to bin, so that
it can be deployed and used outside the build tree.

Patch by Marc-Andre Laperle!
Differential Revision: https://reviews.llvm.org/D30425

llvm-svn: 296390
2017-02-27 21:40:35 +00:00
Haojian Wu 4a92050ce2 [clang-move] Extend clang-move to support moving global variable.
Summary: Also support dumping global variables.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 296337
2017-02-27 13:19:13 +00:00
Eric Liu 4c8767fa55 [change-namespace] fix asan failure in r296110.
llvm-svn: 296113
2017-02-24 12:56:51 +00:00