Commit Graph

1170 Commits

Author SHA1 Message Date
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
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
Haojian Wu c5cc03377e [clang-tidy] Add a clang-tidy check for possible inefficient vector operations
Summary:
The "performance-inefficient-vector-operation" check finds vector oprations in
for-loop statements which may cause multiple memory reallocations.

This is the first version, only detects typical for-loop:

```
std::vector<int> v;
for (int i = 0; i < n; ++i) {
  v.push_back(i);
}

// or

for (int i = 0; i < v2.size(); ++i) {
  v.push_back(v2[i]);
}
```

We can extend it to handle more cases like for-range loop in the future.

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: zaks.anna, Eugene.Zelenko, mgorny, cfe-commits, djasper

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

llvm-svn: 300534
2017-04-18 07:46:39 +00:00
Gabor Horvath 6f0e2ac858 [clang-tidy] Fixes to misc-forwarding-reference-overload check.
* Style fixes to tests
* Make it work consistently on all platforms

Patch by András Leitereg!

llvm-svn: 300320
2017-04-14 12:31:36 +00:00
Krasimir Georgiev 4714f7cba9 [clangd] Implement item kind for completion results
Summary: The patch implements the conversion method from CXCursorKind to clangd::CompletionItemKind.
Contributed by stanionascu!

Reviewers: cfe-commits, bkramer, krasimir

Reviewed By: krasimir

Tags: #clang-tools-extra

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

llvm-svn: 299935
2017-04-11 13:27:15 +00:00
Reid Kleckner 08126372e3 Revert "XFAIL clangd tests on Windows"
This reverts r299849, apparently these tests only fail on my machine.

llvm-svn: 299850
2017-04-10 16:55:48 +00:00
Reid Kleckner 7e1548d6db XFAIL clangd tests on Windows
They all assert. Filed as PR32596.

llvm-svn: 299849
2017-04-10 16:50:55 +00:00
Krasimir Georgiev 5776e2f8e1 [clangd] Fix nondeterminism in clangd test
llvm-svn: 299844
2017-04-10 14:06:54 +00:00
Alexander Kornienko 434b333afd [clang-tidy] A couple of minor fixes in modernize-use-using tests
llvm-svn: 299752
2017-04-07 09:41:27 +00:00
Gabor Horvath edaf907d36 [clang-tidy] Temporarily disable a test-case that does not work on windows.
llvm-svn: 299657
2017-04-06 15:58:57 +00:00
Gabor Horvath e228f68811 Attempt to fix build bots after r299638.
llvm-svn: 299645
2017-04-06 12:49:35 +00:00
Gabor Horvath b3856d65ea [clang-tidy] Check for forwarding reference overload in constructors.
Patch by András Leitereg!

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

llvm-svn: 299638
2017-04-06 09:56:42 +00:00
Krasimir Georgiev beaff10d39 [clangd] Fix completion test to not depend on the standard library
llvm-svn: 299440
2017-04-04 15:08:42 +00:00
Krasimir Georgiev d7f1512897 [clangd] Remove private vector fields from completion test.
llvm-svn: 299426
2017-04-04 10:42:22 +00:00
Krasimir Georgiev 6d2131a04c [clangd] Add code completion support
Summary: Adds code completion support to clangd.

Reviewers: bkramer, malaperle-ericsson

Reviewed By: bkramer, malaperle-ericsson

Subscribers: stanionascu, malaperle-ericsson, cfe-commits

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

llvm-svn: 299421
2017-04-04 09:46:39 +00:00
Krystyna Gajczyk 3a42e73c3f Fixes for modernize-use-using check:
- removed unnessacary namespaces
- added option to print warning in macros
- no fix for typedef with array
- removed "void" word from functions with 0 parameters

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

llvm-svn: 299340
2017-04-02 19:12:20 +00:00
Alexander Kornienko 5816a8bbb1 [clang-tidy] Fix diag message for catch-by-value
Summary:
```
catch (std::exception ex)
{
}
```

Was flagged with "catch handler catches a pointer value".

Reviewers: alexfh, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits, JDevlieghere

Patch by Florian Gross!

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

llvm-svn: 298608
2017-03-23 15:17:44 +00:00
Alexander Kornienko c3acd2e9c0 [clang-tidy] Catch trivially true statements like a != 1 || a != 3
Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state != STARTING)
...

Patch by Blaise Watson!

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

llvm-svn: 298607
2017-03-23 15:13:54 +00:00
Alexander Kornienko 33ec2d6cb1 [clang-tidy] Tests should not rely on STL headers being available.
llvm-svn: 298501
2017-03-22 12:50:10 +00:00
Aaron Ballman 73f283e6fc Reverting r298421 due to using a header that's unavailable to all systems and some other post-commit review feedback.
llvm-svn: 298470
2017-03-22 01:08:54 +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
Alexander Kornienko f6cd367874 [clang-tidy] readability-container-size-empty fix for (*x).size()
llvm-svn: 298316
2017-03-20 22:15:27 +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
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 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
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
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
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 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
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
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 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
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
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 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 7fccc9995a [change-namepsace] make it possible to whitelist symbols so they don't get updated.
Reviewers: hokein

Reviewed By: hokein

Subscribers: cfe-commits

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

llvm-svn: 296110
2017-02-24 11:54:45 +00:00
Daniel Marjamaki 80c3b17410 [clang-tidy] Fix readability-redundant-declaration false positive
Differential Revision: https://reviews.llvm.org/D27048

llvm-svn: 296100
2017-02-24 09:02:44 +00:00
Alexander Kornienko 93748ebf82 [clang-tidy] google-readability-casting: Handle user-defined conversions
llvm-svn: 295544
2017-02-18 09:45:00 +00:00
Simon Pilgrim 356bb00b7e Fix windows buildbots that don't have full shell support
llvm-svn: 295498
2017-02-17 21:31:31 +00:00
Ehsan Akhgari fae3ac3e9b [clang-tidy] Add -path option to clang-tidy-diff.py
Summary:
This flag allows specifying a custom path for the compilation
database.  Unfortunately we can't use the -p flag like other
clang-tidy tools because it's already taken.

Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295482
2017-02-17 19:31:43 +00:00
Gabor Horvath e2fa53030e [clang-tidy] Add cert-dcl58-cpp (do not modify the 'std' namespace) check.
Differential Revision: https://reviews.llvm.org/D23421

llvm-svn: 295435
2017-02-17 08:52:51 +00:00
Krasimir Georgiev 1b8bfd4b76 [clangd] Implement format on type
Summary:
This patch adds onTypeFormatting to clangd.

The trigger character is '}' and it works by scanning for the matching '{' and formatting the range in-between.

There are problems with ';' as a trigger character, the cursor position is before the `|`:
```
int main() {
  int i;|
}
```
becomes:
```
int main() {  int i;| }
```
which is not likely what the user intended.

Also formatting at semicolon in a non-properly closed scope puts the following tokens in the same unwrapped line, which doesn't reformat nicely.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

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

llvm-svn: 295304
2017-02-16 10:49:46 +00:00
Jonas Devlieghere f9e7b3caba [clang-tidy] Fix test modernize-return-braced-init-list
llvm-svn: 295207
2017-02-15 17:37:58 +00:00
Jonas Devlieghere 2789043178 [clang-tidy] Add check 'modernize-return-braced-init-list'
Summary:
Replaces explicit calls to the constructor in a return with a braced
initializer list. This way the return type is not needlessly duplicated in the
return type and the return statement.

```
Foo bar() {
  Baz baz;
  return Foo(baz);
}

// transforms to:

Foo bar() {
  Baz baz;
  return {baz};
}
```

Reviewers: hokein, Prazek, aaron.ballman, alexfh

Reviewed By: Prazek, aaron.ballman, alexfh

Subscribers: malcolm.parsons, mgorny, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 295199
2017-02-15 17:06:06 +00:00
Malcolm Parsons a3bc480455 [clang-tidy] Don't delay parsing of templates in test for misc-unconventional-assign-operator
llvm-svn: 295192
2017-02-15 16:32:55 +00:00
Benjamin Kramer 4486a6c4c7 [clangd] Wire up ASTUnit and publish diagnostics with it.
Summary:
This requires an accessible compilation database. The parsing is done
asynchronously on a separate thread.

Reviewers: klimek, krasimir

Subscribers: cfe-commits, mgorny

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

llvm-svn: 295180
2017-02-15 15:04:20 +00:00
Haojian Wu ead59eeade [clang-tidy] Ignore instantiated functions and static data members of classes in misc-definitions-in-headers.
Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295178
2017-02-15 14:10:50 +00:00
Malcolm Parsons 51642f9d0a [clang-tidy] Don't warn about call to unresolved operator*
Summary:
The misc-unconventional-assign-operator check had a false positive
warning when the 'operator*' in 'return *this' was unresolved.

Change matcher to allow calls to unresolved operator.

Fixes PR31531.

Reviewers: alexfh, aaron.ballman

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295176
2017-02-15 14:01:41 +00:00
Benjamin Kramer d1013b44e3 [clang-tidy] Add support for NOLINTNEXTLINE.
Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295049
2017-02-14 12:47:56 +00:00
Haojian Wu be2588fa7f [clang-tidy] Improve diagnostic message for misc-definitions-in-header.
Summary:
Users might get confused easily when they see the check's message on
full template function speciliations.

Add a note to the output message, which mentions these kind of function
specializations are treated as regular functions.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 295048
2017-02-14 12:39:22 +00:00
Gabor Horvath e647bd59f6 [clang-tidy] Add readability-misleading-indentation check.
Differential Revision: https://reviews.llvm.org/D19586

llvm-svn: 295041
2017-02-14 10:03:27 +00:00
Mads Ravn 6ff978fd54 [clang-tidy] Fix for bug 31838: readability-delete-null-pointer does not work for class members
I have made a small fix for readability-delete-null-pointer check so it also checks for class members.

Example of case that it fixes
```
  struct A {
    void foo() {
      if(mp)
        delete mp;
    }
    int *mp;
  };
```

Reviewers: JDevlieghere, aaron.ballman, alexfh, malcolm.parsons

Subscribers: cfe-commits

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

llvm-svn: 294912
2017-02-12 20:09:59 +00:00
Alexander Kornienko 01496fe455 [clang-tidy] Fix handling of function types in google-readability-casting
llvm-svn: 294751
2017-02-10 14:57:19 +00:00
Ehsan Akhgari b7418d3b4a [clang-tidy] Add -quiet option to suppress extra output
Summary:
This new flag instructs clang-tidy to not output anything
except for errors and warnings.  This makes it easier to
script clang-tidy to run as part of external build systems.

Reviewers: bkramer, alexfh, klimek

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 294607
2017-02-09 18:32:02 +00:00
Alexander Kornienko 28239b166f [clang-tidy] Fix misc-unused-using-decls false positives in presence of compile errors
llvm-svn: 294578
2017-02-09 10:41:27 +00:00
Alexander Kornienko 385c2a3134 [clang-tidy] hasErrorOccurred() -> hasUncompilableErrorOccurred()
hasErrorOccurred() -> hasUncompilableErrorOccurred(), since we only care about
errors that lead to invalid AST.

llvm-svn: 294467
2017-02-08 16:11:22 +00:00
Alexander Kornienko bb64200e16 [clang-tidy] Supresses misc-move-constructor-init warning for const fields.
Patch by CJ DiMeglio!

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

llvm-svn: 294459
2017-02-08 14:56:16 +00:00
Benjamin Kramer d115a574b5 [clangd] Ignore comments in clangd input, so we can write tests without sed.
Another attempt on making this work on windows.

llvm-svn: 294312
2017-02-07 15:37:17 +00:00
Simon Pilgrim 24f1d340b3 Disable test on windows buildbots without shell support
llvm-svn: 294299
2017-02-07 13:08:22 +00:00
Benjamin Kramer d588b0f525 [clangd] Harden test against sed implementations that strip \r.
Also clean up logging and don't print \0.

llvm-svn: 294294
2017-02-07 11:49:03 +00:00
Alexander Kornienko 258d9a528e [clang-tidy] misc-argument-comment - extended gmock support
It looks like direct calls to mocked methods happen in the wild. This patch
add support for these as well.

llvm-svn: 294293
2017-02-07 11:39:56 +00:00
Benjamin Kramer bb1cdb63e5 Add a prototype for clangd
clangd is a language server protocol implementation based on clang. It's
supposed to provide editor integration while not suffering from the
confined ABI of libclang.

This implementation is limited to the bare minimum functionality of
doing (whole-document) formatting and rangeFormatting. The JSON parsing
is based on LLVM's YAMLParser but yet most of the code of clangd is
currently dealing with JSON serialization and deserialization.

This was only tested with VS Code so far, mileage with other LSP clients
may vary.

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

llvm-svn: 294291
2017-02-07 10:28:20 +00:00
Jonathan Coe 3032d3c3f3 [clang-tidy] safety-no-assembler
Summary:
Add a new clang-tidy module for safety-critical checks.

Include a check for inline assembler.

Reviewers: Prazek, dtarditi, malcolm.parsons, alexfh, aaron.ballman, idlecode

Reviewed By: idlecode

Subscribers: idlecode, JonasToth, Eugene.Zelenko, mgorny, JDevlieghere, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 294255
2017-02-06 22:57:14 +00:00
Alexander Kornienko d9fa4e95ec [clang-tidy] misc-argument-comment support for gmock
Now for real. The use case supported previously is used by approximately nobody.
What's needed is support for matching argument comments in EXPECT_xxx calls to
the names of parameters of the mocked methods.

llvm-svn: 294193
2017-02-06 15:47:17 +00:00
Alexander Kornienko 73c69a3714 [clang-tidy] misc-argument-comment support for gmock
llvm-svn: 293845
2017-02-02 00:37:08 +00:00
Alexander Kornienko 165fe63b4e [clang-tidy] misc-argument-comment: ignore comments after arguments
llvm-svn: 293771
2017-02-01 15:28:25 +00:00
Diana Picus 9141501721 Revert "Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications."
This reverts commit r293217, its follow-up 293218 and part of 293234 because it
broke all bots that build clang-tools-extra.

llvm-svn: 293267
2017-01-27 07:19:22 +00:00
Aaron Ballman abb5b7965a Correcting a typo in the test case to appease bots.
llvm-svn: 293218
2017-01-26 22:39:01 +00:00
Aaron Ballman 8ec373af3d Implement a new clang-tidy check that suggests users replace dynamic exception specifications with noexcept exception specifications.
Patch by Don Hinton.

llvm-svn: 293217
2017-01-26 22:34:24 +00:00
Gabor Horvath 3ac2ad7d6c [clang-tidy] Don't modernize-raw-string-literal if replacement is longer.
Fixes PR30964. The old behavior can be achieved using a setting.

Patch by: Andras Leitereg!

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

llvm-svn: 292938
2017-01-24 15:18:11 +00:00
Alexander Kornienko 2e888fe165 [clang-tidy] Fix NOLINT test
Summary:
Test cases I've added in review D26218 were too brittle and weren't working properly.
This patch fixes this.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

Patch by Nikita Kakuev!

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

llvm-svn: 292926
2017-01-24 12:42:26 +00:00
Alexander Kornienko 4b1dfbbc78 [clang-tidy] Avoid incorrect fixes in modernize-use-using
Avoid fixes for typedefs with multiple types and for typedefs with struct
definitions. Partially addresses http://llvm.org/PR28334

llvm-svn: 292918
2017-01-24 11:41:02 +00:00
Alexander Kornienko c456e686a9 [clang-tidy] Add more tests for modernize-use-using.
llvm-svn: 292917
2017-01-24 11:40:23 +00:00
Malcolm Parsons 3de05a2fda [clang-tidy] Ignore implicit functions in performance-unnecessary-value-param
Summary:
The performance-unnecessary-value-param check mangled inherited
constructors, as the constructors' parameters do not have useful source
locations. Fix this by ignoring implicit functions.

Fixes PR31684.

Reviewers: flx, alexfh, aaron.ballman

Subscribers: madsravn, JDevlieghere, cfe-commits

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

llvm-svn: 292786
2017-01-23 13:18:08 +00:00
Felix Berger 08df246407 [clang-tidy] Do not trigger move fix for non-copy assignment operators in performance-unnecessary-value-param check
Reviewers: alexfh, sbenza, malcolm.parsons

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 292491
2017-01-19 15:51:10 +00:00
Alexander Kornienko 0d7a7cdb28 [clang-tidy] Fix crash in modernize-use-using (http://llvm.org/PR29135)
llvm-svn: 292229
2017-01-17 16:14:03 +00:00
Haojian Wu 4775ce56ec [clang-move] Handle helpers with forward declarations.
Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 292215
2017-01-17 13:22:37 +00:00
Haojian Wu b3d9888449 [clang-move] Ignore using decls which are defined in macros.
Summary:
Also ignore helpers which are defined in macro. Currently clang-move doesn't
handle macro well enough, especiall for complex macros. This patch will ignore
declarations in macros to make the behavior of clang-move more correct.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: cfe-commits

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

llvm-svn: 292207
2017-01-17 10:08:11 +00:00
Malcolm Parsons 6b3e27219e [clang-tidy] Fix check for trivially copyable types in modernize-pass-by-value
Summary:
rL270567 excluded trivially copyable types from being moved by
modernize-pass-by-value, but it didn't exclude references to them.
Change types used in the tests to not be trivially copyable.

Reviewers: madsravn, aaron.ballman, alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 291796
2017-01-12 19:20:35 +00:00
Manuel Klimek a47515ec4a Improve include fixer's ranking by taking the paths into account.
Instead of just using popularity, we also take into account how similar the
path of the current file is to the path of the header.
Our first approach is to get popularity into a reasonably small scale by taking
log2 (which is roughly intuitive to how humans would bucket popularity), and
multiply that with the number of matching prefix path fragments of the included
header with the current file.
Note that currently we do not take special care for unclean paths containing
"../" or "./".

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

llvm-svn: 291664
2017-01-11 10:32:47 +00:00
Malcolm Parsons b744ce87fc [clang-tidy] Ignore default arguments in modernize-default-member-init
Summary:
Default member initializers cannot refer to constructor parameters, but modernize-default-member-init was trying to when the default constructor had default arguments.

Change the check to ignore default arguments to the default constructor.

Fixes PR31524.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits, JDevlieghere, Eugene.Zelenko

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

llvm-svn: 290972
2017-01-04 17:33:55 +00:00
Haojian Wu d69d90753c [clang-move] Support moving type alias declarations.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 290967
2017-01-04 14:50:49 +00:00
Alexander Kornienko 563de799e3 [clang-tidy] Add check name to YAML export (clang-tools-extra part)
Add a field indicating the associated check for every replacement to the YAML
report generated with the '-export-fixes' option.  Update
clang-apply-replacements to handle the new format.

Patch by Alpha Abdoulaye!

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

llvm-svn: 290893
2017-01-03 14:36:13 +00:00
Haojian Wu 32a552f6b0 [clang-move] Support moving enum declarations.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 290891
2017-01-03 14:22:25 +00:00
Malcolm Parsons cfa7d3748e [clang-tidy] Handle constructors in performance-unnecessary-value-param
Summary:
modernize-pass-by-value doesn't warn about value parameters that
cannot be moved, so performance-unnecessary-value-param should.

Reviewers: aaron.ballman, flx, alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 290883
2017-01-03 12:10:44 +00:00
Haojian Wu 3626516b14 [clang-move] Only move used helper declarations.
Summary:
Instead of moving all the helper declarations blindly, this patch
implements an AST-based call graph solution to make clang-move only move used
helper decls to new.cc and remove unused decls in old.cc.

Depends on D27674.

Reviewers: ioeric

Subscribers: mgorny, cfe-commits

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

llvm-svn: 290873
2017-01-03 09:00:51 +00:00
Gabor Horvath 7510d9aa8a [clang-tidy] Add delete null pointer check.
This check detects and fixes redundant null checks before deletes.

Patch by: Gergely Angeli!

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

llvm-svn: 290784
2016-12-31 12:45:59 +00:00
Alexander Kornienko 2042f833fd [clang-tidy] google-explicit-constructor: ignore macros
llvm-svn: 290756
2016-12-30 15:15:14 +00:00
Alexander Kornienko 56d0806644 [clang-tidy] google-explicit-constructor: ignore template instantiations
llvm-svn: 290753
2016-12-30 13:25:03 +00:00
Mads Ravn 72bcc049f2 [clang-tidy] Add check 'misc-string-compare'.
I have a created a new check for clang tidy: misc-string-compare. This will check for incorrect usage of std::string::compare when used to check equality or inequality of string instead of the string equality or inequality operators.

Example:
```
  std::string str1, str2;
  if (str1.compare(str2)) {
  }
```

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

Subscribers: xazax.hun, Eugene.Zelenko, cfe-commits, malcolm.parsons, Prazek, mgorny, JDevlieghere

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

llvm-svn: 290747
2016-12-30 10:09:46 +00:00
Gabor Horvath 6f896a9866 Fix another nondeterminism in a tidy test.
llvm-svn: 290745
2016-12-30 09:20:10 +00:00
Alexander Kornienko dd0c0ba82c [clang-tidy] google-explicit-constructor: ignore compiler-generated conversion operators.
llvm-svn: 290668
2016-12-28 13:48:03 +00:00
Gabor Horvath de1f4a4496 Attempt to fix non-determinism in tests.
llvm-svn: 290605
2016-12-27 11:56:54 +00:00
Gabor Horvath 2953b42a2e [clang-tidy] Add enum misuse check.
The checker detects various cases when an enum is probably misused
(as a bitmask).

Patch by: Peter Szecsi!

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

llvm-svn: 290600
2016-12-27 10:07:39 +00:00
Alexander Kornienko bbd8536321 [clang-tidy] Flag implicit conversion operators.
llvm-svn: 290434
2016-12-23 15:03:12 +00:00
Clement Courbet 4d260bf0c7 [clang-tidy] cppcoreguidelines-slicing: display discarded state size in bytes
https://reviews.llvm.org/D27212

llvm-svn: 290340
2016-12-22 14:12:31 +00:00
Alexander Kornienko b5ca17f817 [clang-tidy] Ignore `size() == 0` in the container implementation.
llvm-svn: 290289
2016-12-21 23:44:23 +00:00
Malcolm Parsons 4f392d3fa3 Comment out char16_t and char32_t tests
llvm-svn: 290210
2016-12-20 22:57:21 +00:00
Malcolm Parsons d5508b4e89 [clang-tidy] Add modernize-use-default-member-init check
Summary: Fixes PR18858

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: JDevlieghere, Eugene.Zelenko, Prazek, mgorny, cfe-commits, modocache

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

llvm-svn: 290202
2016-12-20 21:26:07 +00:00
Malcolm Parsons 79578cc936 [clang-tidy] Remove duplicated check from move-constructor-init
Summary:
An addition to the move-constructor-init check was duplicating the
modernize-pass-by-value check.
Remove the additional check and UseCERTSemantics option.
Run the move-constructor-init test with both checks enabled.
Fix modernize-pass-by-value false-positive when initializing a base
class.
Add option to modernize-pass-by-value to only warn about parameters
that are already values.

Reviewers: alexfh, flx, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 290051
2016-12-17 20:23:14 +00:00
Felix Berger 519de4b692 [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop
Summary: This fixes a bug where the performance-unnecessary-value-param check suggests a fix to move the parameter inside of a loop which could be invoked multiple times.

Reviewers: sbenza, aaron.ballman, alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 289912
2016-12-16 02:47:56 +00:00
Malcolm Parsons 8e67aa9a9b [clang-tidy] Enhance modernize-use-auto to templated function casts
Summary:
Use auto when declaring variables that are initialized by calling a templated
function that returns its explicit first argument.

Fixes PR26763.

Reviewers: aaron.ballman, alexfh, staronj, Prazek

Subscribers: Eugene.Zelenko, JDevlieghere, cfe-commits

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

llvm-svn: 289797
2016-12-15 10:19:56 +00:00
Eric Liu 4fe99e1431 [change-namespace] don't crash when type reference is in function type parameter list.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 289672
2016-12-14 17:01:52 +00:00
Justin Lebar 2edf6f1683 [clang-tidy] Suggest including <cmath> if necessary in type-promotion-in-math-fn-check.
Reviewers: alexfh

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 289637
2016-12-14 06:52:23 +00:00
Justin Lebar ecb10f4a9a [ClangTidy] Add new performance-type-promotion-in-math-fn check.
Summary:
This checks for calls to double-precision math.h with single-precision
arguments.  For example, it suggests replacing ::sin(0.f) with
::sinf(0.f).

Subscribers: mgorny, cfe-commits

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

llvm-svn: 289627
2016-12-14 03:15:01 +00:00
Bill Seurer 09d29f9e01 [powerpc] deactivate readability-identifier-naming.cpp test on powerpc64le
The test case clang-tidy/readability-identifier-naming.cpp segfaults on
powerpc64 little endian (starting with r288563) when a bootstrap build/test
is done.  To get the buildbot running again deactivate the test.
When the issue is resolved reactivate it.

llvm-svn: 289581
2016-12-13 20:26:35 +00:00
Reid Kleckner b1653c6cd7 Fix size_t typdef in new cppcoreguidelines-no-malloc.cpp test
llvm-svn: 289580
2016-12-13 20:25:47 +00:00
Alexander Kornienko 1647f3855f Remove trailing whitespace in docs and clang-tidy sources.
llvm-svn: 289547
2016-12-13 16:38:45 +00:00
Alexander Kornienko ebdfb9cf0c [Clang-tidy] check for malloc, realloc and free calls
Summary:
This checker flags the use of C-style memory management functionality and notes about modern alternatives.
In an earlier revision it tried to autofix some kind of patterns, but that was a bad idea. Since memory management can be so widespread in a program, manual updating is most likely necessary.
Maybe for special cases, there could be later additions to this basic checker.

This is the first checker I wrote and I never did something with clang (only compiling programs). So whenever I missed conventions or did plain retarded stuff, feel free to point it out! I am willing to fix them and write a better checker.

I hope the patch does work, I never did this either. On a testapply in my repository it did, but I am pretty unconfident in my patching skills :)

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

Subscribers: cfe-commits, JDevlieghere, nemanjai, Eugene.Zelenko, Prazek, mgorny, modocache

Tags: #clang-tools-extra

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

Patch by Jonas Toth!

llvm-svn: 289546
2016-12-13 16:38:18 +00:00
Malcolm Parsons e7be4a004b [clang-tidy] Add check for redundant function pointer dereferences
Reviewers: alexfh, aaron.ballman, hokein

Subscribers: mgorny, JDevlieghere, cfe-commits

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

llvm-svn: 289524
2016-12-13 08:04:11 +00:00
Felix Berger e4ab0602f2 [clang-tidy] Do not trigger unnecessary-value-param check on methods marked as final
Summary: Virtual method overrides of dependent types cannot be recognized unless
they are marked as override or final.

Exclude methods marked as final from check and add test.

Reviewers: sbenza, hokein, alexfh

Subscribers: malcolm.parsons, JDevlieghere, cfe-commits

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

llvm-svn: 288502
2016-12-02 14:44:16 +00:00
Eric Liu c265b02bec [change-namespace] don't generate replacements for files that don't match file pattern.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 288376
2016-12-01 17:25:55 +00:00
Malcolm Parsons bcf23661d0 [clang-tidy] Rename modernize-use-default to modernize-use-equals-default
Reviewers: angelgarcia, aaron.ballman, alexfh

Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits

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

llvm-svn: 288375
2016-12-01 17:24:42 +00:00
Benjamin Kramer 35d53951a4 [include-fixer] Don't skip repeated lookups in plugin mode.
In this mode not all the errors are fixed so it doesn't make sense to
ignore later ones.

llvm-svn: 288244
2016-11-30 14:37:40 +00:00
Benjamin Kramer b2a346d5e4 [include-fixer] Don't eat one token too many when replacing a block of includes.
SourceRanges are inclusive token ranges, this was trying to form an
exclusive char range.

llvm-svn: 288145
2016-11-29 15:15:26 +00:00
Benjamin Kramer 7902aa79bb [include-fixer] Don't interfere with typo correction if we found nothing.
Just let the existing typo correction machinery handle that.

llvm-svn: 288043
2016-11-28 17:16:18 +00:00
Benjamin Kramer 1eba23b308 [clang-rename] Add test case for r287758.
llvm-svn: 287759
2016-11-23 13:14:19 +00:00
Benjamin Kramer b568d99dd7 [clang-rename] Prune away AST nodes more correctly and effectively when looking for a point
Due to the way the preprocessor works nodes can be half in a macro or a
different file. This means checking the file name of the start location
of a Decl is not a correct way of checking if the entire Decl is in that
file. Remove that flawed assumption and replace it with a more effective
check: If the point we're looking for is *inside* of the begin and end
location of a Decl, look inside.

This should make clang-rename more reliable (for example macro'd namespaces
threw it off before, as seen in the test case) and maybe a little faster
by pruning off more stuff that the RecursiveASTVisitor doesn't have to
drill into.

llvm-svn: 287649
2016-11-22 17:29:45 +00:00
Daniel Marjamaki 13e45e135f clang-tidy: improve my test for readability-redundant-declaration
llvm-svn: 287550
2016-11-21 16:08:17 +00:00
Daniel Marjamaki d752c44612 clang-tidy: Attempt to fix build bot failure with mismatching size_t platform type.
llvm-svn: 287546
2016-11-21 15:46:40 +00:00
Benjamin Kramer 87eb9667bf [include-fixer plugin] Make the plugin emit proper fixits in case multiple errors are found.
The standalone tool only fixes the first one and we managed to bake that
assumption into the code :(

Also fix a crash when no header is found at all.

llvm-svn: 287544
2016-11-21 15:28:50 +00:00
Daniel Marjamaki ae66045705 readability-redundant-declaration: Fix crash
Differential Revision: https://reviews.llvm.org/D26911

llvm-svn: 287540
2016-11-21 14:29:53 +00:00
Haojian Wu 50a45d9371 [clang-move] Fix not moving using-decls in global namespace in old.cc
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287330
2016-11-18 10:51:16 +00:00
Benjamin Kramer 99eaf84589 [include-fixer] Add a test for the full round trip through libclang and the plugin.
llvm-svn: 287230
2016-11-17 15:23:06 +00:00
Malcolm Parsons d549e3a23c [clang-tidy] Ignore template instantiations in modernize-use-equals-delete check
Summary: Template instantiations were causing misplaced fixits.

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: hokein, cfe-commits

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

llvm-svn: 287221
2016-11-17 11:40:02 +00:00
Malcolm Parsons 5be5092c49 [clang-tidy] Changes to modernize-use-default check
Summary:
Warn about special member functions that only contain a comment.
Report the location of the special member function, unless it is
defined in a macro.  Reporting the location of the body in a macro is
more helpful as it causes the macro expansion location to be reported too.

Fixes PR30920.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287215
2016-11-17 09:14:04 +00:00
Eric Fiselier 732a3e0dd1 [clang-tidy] Fix identifier naming for initializer list member initializers.
Summary:
This patch adds handling for member initializers in a constructors initializer list. Previously we only handled base-class and delegating initializers, which are transformed by the `TypeLoc` matcher. For Example:

```
// Style options: All identifiers should start with an upper case letter.
struct base { ...  }; 
struct der :  base {
  int field;  // FIXES: int Field;
  der() : der(42) {} // FIXES: Der() : Der(42) {}
  der(int X) : base(), field(X) {} // FIXES: Der(int X) : Base(), field(X)
  // Note that `field` doesn't get replaced
};
```

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287153
2016-11-16 21:15:58 +00:00
Eric Liu ff51f011d1 [change-namespace] handle constructor initializer: Derived : Base::Base() {} and added conflict detections
Summary:
namespace nx { namespace ny { class Base { public: Base(i) {}} } }
namespace na {
namespace nb {
class X : public nx::ny {
public:
  X() : Base::Base(1) {}
};
}
}

When changing from na::nb to x::y, "Base::Base" will be changed to "nx::ny::Base" and
 "Base::" in "Base::Base" will be replaced with "nx::ny::Base" too, which causes
conflict. This conflict should've been detected when adding replacements but was hidden by `addOrMergeReplacement`. We now also detect conflict when adding replacements where conflict must not happen.

The namespace lookup is tricky here, we simply replace "Base::Base()" with "nx::ny::Base()" as a workaround, which compiles but not perfect.

Reviewers: hokein

Subscribers: bkramer, cfe-commits

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

llvm-svn: 287118
2016-11-16 16:54:53 +00:00
Gabor Horvath 678dd8fc62 [clang-tidy] New check to prefer transparent functors to non-transparent ones.
llvm-svn: 287107
2016-11-16 14:42:10 +00:00
Haojian Wu 4543feceb3 [clang-move] Support moving function.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287101
2016-11-16 13:05:19 +00:00
Malcolm Parsons 31055c6ace [clang-tidy] Handle template instantiations in modenize-use-default check
Summary:
Duplicate fixes were being created for explicit template instantiations
of out-of-line constructors or destructors.

Fixes PR30921.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 287091
2016-11-16 09:51:40 +00:00
Malcolm Parsons 49fe4037a1 [clang-tidy] Change readability-redundant-member-init to get base type from constructor
Summary: Fixes PR30835

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: Prazek, cfe-commits

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

llvm-svn: 286990
2016-11-15 17:49:00 +00:00
Malcolm Parsons e293eab46f [clang-tidy] Add modernize-use-equals-delete check
Summary: Fixes PR27872

Reviewers: klimek, hokein, alexfh, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, danielmarjamaki, cfe-commits, mgorny

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

llvm-svn: 286472
2016-11-10 16:46:59 +00:00
Haojian Wu b53ec46773 [clang-move] Support template class.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286427
2016-11-10 05:33:26 +00:00
Felix Berger 85f9e8b316 [clang-tidy] Do not issue fix for functions that are referenced outside of callExpr
Summary: Suppress fixes for functions that are referenced within the
compilation unit outside of a call expression as the signature change
could break the code referencing the function.

We still issue a warning in this case so that users can decide to
manually change the function signature.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286424
2016-11-10 01:28:22 +00:00
Haojian Wu 2930be1421 [clang-move] Move all code from old.h/cc directly when moving all class declarations from old.h.
Summary: When moving all code to new.h/cc,  these code also will be formatted based on the given code style.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286281
2016-11-08 19:55:13 +00:00