Commit Graph

357 Commits

Author SHA1 Message Date
Mads Ravn 041b804a9f [clang-tidy] Added hh, hxx and hpp to header guard checks.
Changed the extension check to include the option of ",h,hh,hpp,hxx" instead of just returning whether the file ended with ".h".

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

llvm-svn: 279803
2016-08-26 05:59:53 +00:00
Eugene Zelenko 5f45722b03 Clang-tidy documentation style. Two Google checks are aliases.
Differential revision: https://reviews.llvm.org/D23815

llvm-svn: 279659
2016-08-24 20:05:36 +00:00
Eugene Zelenko 29da951a3a [Documentation] Fix style of Clang-tidy readability-non-const-parameter.
llvm-svn: 279541
2016-08-23 17:57:24 +00:00
Daniel Marjamaki 9e4ecfaec7 [clang-tidy] readability-non-const-parameter: add new check that warns when function parameters should be const
The check will warn when the constness will make the function interface safer.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 279507
2016-08-23 10:09:08 +00:00
Eugene Zelenko f0ae81da0b Fix style in some Clang-tidy checks documentation.
Differential revision: https://reviews.llvm.org/D23728

llvm-svn: 279494
2016-08-23 00:19:43 +00:00
Alexander Kornienko 179c18d338 [clang-tidy docs] Further cleanup of options
llvm-svn: 279442
2016-08-22 17:19:23 +00:00
Eugene Zelenko a1c76530d9 [Documentation] Fixed style in modernize-use-emplace.rst.
llvm-svn: 279170
2016-08-18 22:11:27 +00:00
Alexander Kornienko 0f85498a0b [clang-tidy docs] Move option descriptions to the Options section
+ random fixes

llvm-svn: 279115
2016-08-18 18:43:47 +00:00
Alexander Kornienko 93794b2351 [clang-tidy docs] Minor fix
llvm-svn: 279051
2016-08-18 11:12:03 +00:00
Alexander Kornienko 23768f4d03 [clang-tidy docs] Fix formatting.
llvm-svn: 279050
2016-08-18 11:10:52 +00:00
Alexander Kornienko 76eae751b5 [clang-tidy docs] Fix build errors on Sphinx 1.4.5
llvm-svn: 279049
2016-08-18 11:06:09 +00:00
Eugene Zelenko cb93ba56ec [Release notes] Mention Emacs integration in Include-fixer.
llvm-svn: 279009
2016-08-17 23:36:22 +00:00
Eugene Zelenko c139a1c252 [Documentation] Remove duplicated checks groups descriptions from clang-tidy/index.rst.
Differential revision: https://reviews.llvm.org/D23596

llvm-svn: 279006
2016-08-17 23:20:00 +00:00
Eugene Zelenko d09a44a220 [Documentation] Improve checks groups descriptions in clang-tidy/index.rst
Use table to avoid tautology. List all existing checks groups. Use alphabetical order.

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

llvm-svn: 278686
2016-08-15 17:44:29 +00:00
Alexander Droste 1512f9a0f9 [clang-tidy] MPIBufferDerefCheck
...
This check verifies if a buffer passed to an MPI (Message Passing Interface)
function is sufficiently dereferenced. Buffers should be passed as a single
pointer or array. As MPI function signatures specify void * for their buffer
types, insufficiently dereferenced buffers can be passed, like for example
as double pointers or multidimensional arrays, without a compiler warning
emitted.

Instructions on how to apply the check can be found at:
https://github.com/0ax1/MPI-Checker/tree/master/examples

Reviewers: Haojian Wu
Differential revision: https://reviews.llvm.org/D22729

llvm-svn: 278553
2016-08-12 19:30:31 +00:00
Eugene Zelenko 3ed5011d51 [Documentation] Improve consistency.
Mention Clang-rename Emacs integration in release notes.

llvm-svn: 278295
2016-08-10 22:00:49 +00:00
Eugene Zelenko 9ef6b6b4f4 [Documentation] Fix style and grammar mistake in Clang-tidy readability-else-after-return description spotted by Alexander Kornienko.
llvm-svn: 278279
2016-08-10 19:49:38 +00:00
Eugene Zelenko 12b0acc727 [Documentation] Highlighting consistency and spelling mistake fix in Clang-tidy readability-else-after-return description.
llvm-svn: 278263
2016-08-10 18:30:14 +00:00
Eugene Zelenko cdfdb4f110 [Release Notes] Consistency in Clang-tidy entries' style.
llvm-svn: 278262
2016-08-10 18:15:51 +00:00
Kirill Bobyrev 34789edbbf [clang-tidy] enhance readability-else-after-return
`readability-else-after-return` only warns about `return` calls, but LLVM Coding
Standars stat that `throw`, `continue`, `goto`, etc after `return` calls are
bad, too.

Reviwers: alexfh, aaron.ballman

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

llvm-svn: 278257
2016-08-10 18:05:47 +00:00
Eugene Zelenko 7fa868b31d [Documentation] Fix grammar mistakes in docs/clang-tidy/index.rst spotted by Alexander Kornienko.
llvm-svn: 278255
2016-08-10 18:02:15 +00:00
Kirill Bobyrev 8694cb97c2 [clang-tidy] minor improvements in modernise-deprecated-headers check
This patch introduces a minor list of changes as proposed by Richard Smith in
the mailing list.

See original comments with an impact on the future check state below:

[comments.begin

> +                          {"complex.h", "ccomplex"},

It'd be better to convert this one to <complex>, or leave it alone.
<ccomplex> is an unnecessary wart.

(The contents of C++11's <complex.h> / <ccomplex> / <complex> (all of
which are identical) aren't comparable to C99's <complex.h>, so if
this was C++98 code using the C99 header, the code will be broken with
or without this transformation.)

> +                          {"iso646.h", "ciso646"},

Just delete #includes of this one. <ciso646> does nothing.

> +              {"stdalign.h", "cstdalign"},
> +              {"stdbool.h", "cstdbool"},

We should just delete these two includes. These headers do nothing in C++.

comments.end]

Reviewers: alexfh, aaron.ballman

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

llvm-svn: 278254
2016-08-10 18:01:45 +00:00
Miklos Vajna c29c81a03f clang-rename YAML reader: address post-commit comments
llvm-svn: 278201
2016-08-10 07:13:29 +00:00
Eugene Zelenko b614148024 [Documentation] Fix spelling mistakes in docs/clang-tidy/index.rst.
llvm-svn: 278198
2016-08-10 01:55:51 +00:00
Miklos Vajna 3d71b51bc5 clang-rename rename-all: support reading old/newname pairs from a YAML file
This is handy in case by the time clang-rename is invoked, an external
tool already genereated a list of oldname -> newname pairs to handle.

Reviewers: omtcyfz

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

llvm-svn: 278145
2016-08-09 18:20:41 +00:00
Kirill Bobyrev 75de8968b6 [clang-tidy] enhance modernize-use-bool-literals to check ternary operator
modernize-use-bool-literals doesn't checks operands in ternary operator.

For example:

``` c++
static int Value = 1;

bool foo() {
  bool Result = Value == 1 ? 1 : 0;
  return Result;
}

bool boo() {
  return Value == 1 ? 1 : 0;
}
```

This issue was reported in bug 28854. The patch fixes it.

Reviewers: alexfh, aaron.ballman, Prazek

Subscribers: Prazek, Eugene.Zelenko

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

llvm-svn: 278022
2016-08-08 17:11:56 +00:00
Alexander Kornienko 6b2a4d5e8f [clang-tidy] misc-argument-comment non-strict mode
Summary:
The misc-argument-comment check now ignores leading and trailing underscores and
case. The new `StrictMode` local/global option can be used to switch back to
strict checking.

Add getLocalOrGlobal version for integral types, minor cleanups.

Reviewers: hokein, aaron.ballman

Subscribers: aaron.ballman, Prazek, cfe-commits

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

llvm-svn: 277729
2016-08-04 14:54:54 +00:00
Alexander Kornienko dcbf57d198 [clang-tidy] Inefficient string operation
Patch by Bittner Barni!

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

llvm-svn: 277677
2016-08-03 23:06:03 +00:00
Kirill Bobyrev f9e2f4410e [docs] fix typo in clang-rename docs
clang-rename is a refactoring tool, not "linter" tool. Fix typo in docs.

llvm-svn: 277623
2016-08-03 18:15:07 +00:00
Kirill Bobyrev cf162a3031 [clang-tidy] address concerns with rL277340
alexfh raised a concern with https://reviews.llvm.org/rL277340

After retabbing indentation of .. code-block:: was increased to 8, 4 spaces
indentation should be enough.

Reviewers: alexfh
llvm-svn: 277577
2016-08-03 06:54:24 +00:00
Alexander Kornienko 053826f146 [docs] Fix links format.
llvm-svn: 277517
2016-08-02 20:29:47 +00:00
Alexander Kornienko 5e0a50c2d7 [clang-tidy] MPITypeMismatchCheck
This check verifies if buffer type and MPI (Message Passing Interface)
datatype pairs match. All MPI datatypes defined by the MPI standard (3.1)
are verified by this check. User defined typedefs, custom MPI datatypes and
null pointer constants are skipped, in the course of verification.

Instructions on how to apply the check can be found at:
https://github.com/0ax1/MPI-Checker/tree/master/examples

Patch by Alexander Droste!

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

llvm-svn: 277516
2016-08-02 20:29:35 +00:00
Miklos Vajna aaec9b6cfc clang-rename: split existing options into two new subcommands
- rename-at is meant to be integrated with editors and works mainly off
  of a location in a file, and this is the default
- rename-all is optimized for one or more oldname->newname renames, and
  works with clang-apply-replacements

Reviewers: bkramer, klimek

Subscribers: omtcyfz

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

llvm-svn: 277438
2016-08-02 09:51:31 +00:00
Kirill Bobyrev aa4845004d [clang-rename] add basic Emacs integration
This patch aims to add very basic Emacs integration.

Reviewers: hokein, alexfh

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

llvm-svn: 277433
2016-08-02 08:51:26 +00:00
Kirill Bobyrev 11cea45cce [clang-tidy] remove trailing whitespaces and retab
llvm-svn: 277340
2016-08-01 12:06:18 +00:00
Jonathan Coe 5d304b2456 [clang-tidy] add check cppcoreguidelines-special-member-functions
Summary:
Check for classes that violate the rule of five and zero as specified in CppCoreGuidelines:

"If a class defines or deletes a default operation then it should define or delete them all."

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, cfe-commits, ericLemanissier, nemanjai

Projects: #clang-tools-extra

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

llvm-svn: 277262
2016-07-30 08:58:54 +00:00
Piotr Padlewski 8f80229109 [clang-tidy] Fixes to modernize-use-emplace
Not everything is valid, but it should works for 99.8% cases

https://reviews.llvm.org/D22208

llvm-svn: 277097
2016-07-29 02:10:23 +00:00
Kirill Bobyrev 5c339ec830 fix typo in clang-rename and clang-tidy docs
llvm-svn: 276871
2016-07-27 14:26:03 +00:00
Kirill Bobyrev c4018e2db6 change Vim key binding for include-fixer and clang-rename
Change Vim key binding for include-fixer (`,cf` -> `<leader>cf`) and
clang-rename (`,cr` -> `<leader>cr`) to use `<leader>` instead of `,` like
cool Vim people (tm) do.

Reviewers: ioeric

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

llvm-svn: 276870
2016-07-27 14:23:47 +00:00
Haojian Wu 499375ceaa [include-fixer] Update document.
llvm-svn: 276862
2016-07-27 13:17:16 +00:00
Haojian Wu 32afa383cb [clang-tidy] Add cppcoreguidelines-slicing entry to list.rst.
llvm-svn: 276861
2016-07-27 13:11:50 +00:00
Benjamin Kramer 57d070e6fd [clang-include-fixer] Added Emacs integration for clang-include-fixer.
Patch by Jens Massberg! Thanks a lot.

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

llvm-svn: 276853
2016-07-27 10:11:06 +00:00
Alexander Kornienko df4b4a8fab Revert "MPITypeMismatchCheck for Clang-Tidy"
This reverts commit r276640. Breaks multiple buildbots.

llvm-svn: 276651
2016-07-25 17:08:18 +00:00
Alexander Kornienko 651767dbc7 MPITypeMismatchCheck for Clang-Tidy
Summary:
This check verifies if buffer type and MPI (Message Passing Interface)
datatype pairs match. All MPI datatypes defined by the MPI standard (3.1)
are verified by this check. User defined typedefs, custom MPI datatypes and
null pointer constants are skipped, in the course of verification.

Instructions on how to apply the check can be found at: https://github.com/0ax1/MPI-Checker/tree/master/examples

Reviewers: alexfh

Subscribers: cfe-commits

Projects: #clang-tools-extra

Patch by Alexander Droste!

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

llvm-svn: 276640
2016-07-25 15:43:14 +00:00
Clement Courbet 22c9e93147 Revert "Revert "[clang-tidy] new cppcoreguidelines-slicing""
Second try for r276408

llvm-svn: 276415
2016-07-22 13:45:00 +00:00
Clement Courbet bd7aa358f0 Revert "[clang-tidy] new cppcoreguidelines-slicing"
Tests fail on clang-x64-ninja-win7 due to too narrow expectation.

llvm-svn: 276413
2016-07-22 13:33:51 +00:00
Clement Courbet f67fbfaa8c [clang-tidy] new cppcoreguidelines-slicing
Flags slicing of member variables or vtable. See:

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es63-dont-slice
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c145-access-polymorphic-objects-through-pointers-and-references

Differential revision:
http://reviews.llvm.org/D21974

llvm-svn: 276408
2016-07-22 12:42:19 +00:00
Eugene Zelenko 0c5b92cae6 Restructure release notes.
Differential revision: https://reviews.llvm.org/D22605

llvm-svn: 276371
2016-07-22 00:34:42 +00:00
Hans Wennborg 4b4c90bf7a docs/conf.py: update version to 4.0
llvm-svn: 275849
2016-07-18 18:13:46 +00:00
Hans Wennborg 21669b4e49 Trunk release notes are now for 4.0.0
The 3.9 release are on the 3.9 branch.

llvm-svn: 275846
2016-07-18 18:08:59 +00:00
Benjamin Kramer b67e1e2dd7 [clang-rename] add documentation
clang-rename needs at least to have a minimum documentation to provide a
small introduction for new users

Patch by Kirill Bobyrev!

Differential Revision: http://reviews.llvm.org/D22129

llvm-svn: 275388
2016-07-14 09:46:07 +00:00
Etienne Bergeron 238429bd1c fix missing newline in sphinx doc
llvm-svn: 275254
2016-07-13 06:06:48 +00:00
Felix Berger 7f8827576c [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved.
Summary:

Make check more useful in the following two cases:

The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor.
The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator.
In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended.

Reviewers: alexfh, sbenza

Subscribers: cfe-commits, Prazek

Differential Revision: http://reviews.llvm.org/D20277

llvm-svn: 274380
2016-07-01 20:12:15 +00:00
Krystyna Gajczyk c37933a12a [clang-tidy] Add modernize-use-using
http://reviews.llvm.org/D18919

llvm-svn: 273786
2016-06-25 18:37:53 +00:00
Piotr Padlewski 552d449482 [clang-tidy] Add modernize-use-emplace
Summary: Add check that replaces call of push_back to emplace_back

Reviewers: hokein

Differential Revision: http://reviews.llvm.org/D20964

llvm-svn: 273275
2016-06-21 15:23:27 +00:00
Alexander Kornienko c9c8290251 [clang-tidy] Fix doxygen errors. NFC.
llvm-svn: 272994
2016-06-17 11:43:33 +00:00
Alexander Kornienko 2150390a2a [clang-tidy] readability-identifier-naming - Support for Macros
Summary:
Added support for macro definitions.
--

1. Added a pre-processor callback to catch macro definitions
2. Changed the type of the failure map so that macros and declarations can share the same map
3. Added extra tests to ensure fix-ups work using the new map
4. Added fix-ups for type aliases in variable and function declarations as part of adding the new tests

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Patch by James Reynolds!

Differential Revision: http://reviews.llvm.org/D21020

llvm-svn: 272993
2016-06-17 09:25:24 +00:00
Alexander Kornienko 28b34b043e [clang-tidy] misc-move-const-arg: Detect if result of std::move() is being passed as a const ref argument
Summary:
Conceptually, this is very close to the existing functionality of misc-move-const-arg, which is why I'm adding it here and not creating a new check. For example, for a type A that is both movable and copyable, this

  const A a1;
  A a2(std::move(a1));

is not only a case where a const argument is being passed to std::move(), but the result of std::move() is also being passed as a const reference (due to overload resolution).

The new check typically triggers (exclusively) in cases where people think they're dealing with a movable type, but in fact the type is not movable.

Reviewers: hokein, aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

Patch by Martin Boehme!

Differential Revision: http://reviews.llvm.org/D21223

llvm-svn: 272896
2016-06-16 14:32:41 +00:00
Eugene Zelenko 930e031d64 [Clang-tidy] Alphabetical checks order in release notes.
Highlight return statement in misc-unconventional-assign-operator documentation.

llvm-svn: 272042
2016-06-07 18:38:42 +00:00
Eugene Zelenko 04c14db108 [Clang-tidy] Documentation style consistency.
llvm-svn: 272038
2016-06-07 18:29:15 +00:00
Aaron Ballman d96ce2a94c Adding a release note for the misc-misplaced-const check added in r272025.
llvm-svn: 272026
2016-06-07 17:29:49 +00:00
Aaron Ballman cf6cefd88a Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type.
llvm-svn: 272025
2016-06-07 17:22:47 +00:00
Haojian Wu e64cee81bf [include-fixer] Mention more details in the document.
Reviewers: bkramer

Subscribers: Eugene.Zelenko, cfe-commits, ioeric

Differential Revision: http://reviews.llvm.org/D20467

llvm-svn: 271989
2016-06-07 07:50:48 +00:00
Alexander Kornienko c0308c451b [clang-tidy] modernize-use-auto: don't remove stars by default
Summary:
By default, modernize-use-auto check will retain stars when replacing an explicit type with `auto`: `MyType *t = new MyType;` will be changed to `auto *t = new MyType;`, thus resulting in more consistency with the recommendations to use `auto *` for iterating over pointers in range-based for loops: http://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto

The new  `RemoveStars` option allows to revert to the old behavior: with the new option turned on the check will change `MyType *t = new MyType;` to `auto t = new MyType;`.

Reviewers: aaron.ballman, sbenza

Subscribers: Eugene.Zelenko, cfe-commits

Differential Revision: http://reviews.llvm.org/D20917

llvm-svn: 271739
2016-06-03 21:22:58 +00:00
Alexander Kornienko 1c6d827015 Fix docs
llvm-svn: 270288
2016-05-20 22:42:03 +00:00
Haojian Wu 17baf85e41 [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.
Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20463

llvm-svn: 270197
2016-05-20 09:38:25 +00:00
Alexander Kornienko a20bab46cd [clang-tidy] Fix/add style guide links.
Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)!

llvm-svn: 270033
2016-05-19 09:31:30 +00:00
Alexander Kornienko 77c8b2ed9f [clang-tidy] Fix doc titles.
llvm-svn: 270032
2016-05-19 09:29:46 +00:00
Eric Liu c7f3b108e2 [clang-include-fixer] Added Vim integration for clang-include-fixer.
Summary: [clang-include-fixer] Added Vim integration for clang-include-fixer.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D20329

llvm-svn: 269927
2016-05-18 14:10:16 +00:00
Eugene Zelenko 804e58d62e [Release notes] Mention Clang-tidy modernize-avoid-bind check.
Fix some problems in its documentation.

llvm-svn: 269517
2016-05-13 23:35:56 +00:00
Benjamin Kramer a3d823336a [include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.

llvm-svn: 269403
2016-05-13 09:27:54 +00:00
Jonathan Coe a30c69c9e4 [clang-tidy] Adds modernize-avoid-bind check
Summary:
This patch adds a check that replaces std::bind with a lambda.

Not yet working for member functions.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D16962

llvm-svn: 269341
2016-05-12 20:06:04 +00:00
Etienne Bergeron c87599f480 [clang-tidy] Improve misc-redundant-expression and decrease false-positive
Summary:
This patch is adding support for conditional expression and overloaded operators.

To decrease false-positive, this patch is adding a list of banned macro names that
has multiple variant with same integer value.

Also fixed support for template instantiation and added an unittest.

Reviewers: alexfh

Subscribers: klimek, Sarcasm, cfe-commits

Differential Revision: http://reviews.llvm.org/D19703

llvm-svn: 269275
2016-05-12 04:32:47 +00:00
Eugene Zelenko 1592d76d73 [Clang-tidy] modernize-use-bool-literals: documentation style.
Fix readability-redundant-control-flow warnings in regression test.

llvm-svn: 269229
2016-05-11 20:31:50 +00:00
Jakub Staron f7df72694a [clang-tidy] Adds modernize-use-bool-literals check.
Review link: http://reviews.llvm.org/D18745

llvm-svn: 269171
2016-05-11 11:33:16 +00:00
Benjamin Kramer bfcab592ad [include-fixer] Add basic documentation.
Differential Revision: http://reviews.llvm.org/D20094

llvm-svn: 269167
2016-05-11 09:44:10 +00:00
Haojian Wu 1172668682 [clang-tidy] new google-default-arguments check
Summary:
To check the google style guide rule here:
https://google.github.io/styleguide/cppguide.html#Default_Arguments

Patch by Clement Courbet!

Reviewers: hokein

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19534

llvm-svn: 268919
2016-05-09 13:43:58 +00:00
Alexander Kornienko 5a520f6cd5 Trying to fix docs.
llvm-svn: 268905
2016-05-09 10:56:57 +00:00
Alexander Kornienko 5d0f2d2135 Fix docs.
llvm-svn: 268899
2016-05-09 10:00:52 +00:00
Eugene Zelenko 07fa815c65 [Documentation] List Clang-tidy checks alphabetically.
llvm-svn: 268659
2016-05-05 18:25:53 +00:00
Gabor Horvath 112d1e80c0 [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature
Summary: Finds return statements in assign operator bodies where the return value is different from '*this'. Only assignment operators with correct return value Class& are checked.

Reviewers: aaron.ballman, alexfh, sbenza

Subscribers: o.gyorgy, baloghadamsoftware, LegalizeAdulthood, aaron.ballman, Eugene.Zelenko, xazax.hun, cfe-commits

Differential Revision: http://reviews.llvm.org/D18265

llvm-svn: 268492
2016-05-04 12:02:22 +00:00
Piotr Padlewski ce18ade406 [clang-tidy] Add modernize-make-shared check
Because modernize-make-shared do almost the same job as
modernize-make-unique, I refactored common code to MakeSmartPtrCheck.

http://reviews.llvm.org/D19183

llvm-svn: 268253
2016-05-02 16:56:39 +00:00
Eugene Zelenko 5b407543c0 [Release Notes] Mention Clang-tidy cert-err34-c check.
Fix order and style of Boost related notes.

llvm-svn: 268140
2016-04-30 00:11:10 +00:00
Aaron Ballman d744e63d90 Add a clang-tidy check that flags string-to-number conversion functions that have insufficient error checking, suggesting a better alternative.
This check corresponds to: https://www.securecoding.cert.org/confluence/display/c/ERR34-C.+Detect+errors+when+converting+a+string+to+a+number

llvm-svn: 268100
2016-04-29 20:56:48 +00:00
Piotr Padlewski 5625f65667 Add boost-use-to-string
http://reviews.llvm.org/D18136

llvm-svn: 268079
2016-04-29 17:58:29 +00:00
Alexander Kornienko fabdbe4732 [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain about static variables
Summary:
Variables with static storage duration are zero-initialized per
[stmt.dcl]p4 and [basic.start.init]p2.

Reviewers: sbenza, aaron.ballman

Subscribers: michael_miller, flx, cfe-commits

Differential Revision: http://reviews.llvm.org/D19672

llvm-svn: 267933
2016-04-28 20:20:01 +00:00
Alexander Kornienko 900cadd3ad [clang-tidy] Now adding correct misc-move-const-arg documentation ;]
+ brushed the code a bit and renamed the test file to match the check name

llvm-svn: 267592
2016-04-26 19:33:49 +00:00
Alexander Kornienko 1af58fc1e5 [clang-tidy] Added misc-move-const-arg docs.
llvm-svn: 267587
2016-04-26 18:48:59 +00:00
Eugene Zelenko ca943b3929 [Release notes] Mention Clang-tidy misc-fold-init-type check.
Highlighting consistency in Clang-tidy misc-fold-init-type check documentation.

llvm-svn: 267576
2016-04-26 17:54:00 +00:00
Etienne Bergeron bda187decd [clang-tidy] New checker for redundant expressions.
Summary:
This checker finds redundant expression on both side of a binary operator.

The current implementation provide a function to check whether expressions
are equivalent. This implementation is able to recognize the common
subset encounter in C++ program. Side-effects like "x++" are not considered
to be equivalent.

There are many False Positives related to macros and to floating point
computations (detecting NaN). The checker is ignoring these cases.

Example:
```
    if( !dst || dst->depth != desired_depth ||
        dst->nChannels != desired_num_channels ||
        dst_size.width != src_size.width ||
        dst_size.height != dst_size.height )    <<--- bug
    {
```

Reviewers: alexfh

Subscribers: danielmarjamaki, fahlgren, jordan_rose, zaks.anna, Eugene.Zelenko, cfe-commits

Differential Revision: http://reviews.llvm.org/D19451

llvm-svn: 267574
2016-04-26 17:30:30 +00:00
Alexander Kornienko 6e2f32c561 A clang-tidy check for std:accumulate.
Summary:
For folds (e.g. std::accumulate), check matches between the provided init value and the range's value_type. A typical error is "std::accumulate(begin, end, 0);", where begin and end have float value_type. See the documentation for more examples.

For now we check std::accumulate, std::reduce and std::inner_product.

Reviewers: hokein, alexfh

Subscribers: Prazek, aaron.ballman, cfe-commits, courbet

Patch by Clément Courbet!

Differential Revision: http://reviews.llvm.org/D18442

llvm-svn: 267542
2016-04-26 10:05:45 +00:00
Haojian Wu bee3c88ec6 [clang-tidy] fix link in Release Notes
Summary: This is intended to fix https://llvm.org/bugs/show_bug.cgi?id=27426

Patch by Kirill Bobyrev!

Reviewers: alexfh, LegalizeAdulthood, hokein

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19406

llvm-svn: 267155
2016-04-22 14:43:39 +00:00
Eugene Zelenko 656eb13fe0 [Release Notes] Mention Clang-tidy misc-string-constructor and misc-suspicious-string-compare checks.
Fix excessive line in misc-string-constructor documentation.

llvm-svn: 267026
2016-04-21 18:13:09 +00:00
Etienne Bergeron 1dbd582387 [clang-tidy] New checker to detect suspicious string constructor.
Summary:
Checker to validate string constructor parameters.

A common mistake is to swap parameter for the fill-constructor.
```
  std::string str('x', 4);
  std::string str('4', x);
```

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19146

llvm-svn: 267011
2016-04-21 17:28:08 +00:00
Etienne Bergeron bae829ede5 [clang-tidy] Add new checker for comparison with runtime string functions.
Summary:
This checker is validating suspicious usage of string compare functions.

Example:
```
  if (strcmp(...))       // Implicitly compare to zero
  if (!strcmp(...))      // Won't warn
  if (strcmp(...) != 0)  // Won't warn
```

This patch was checked over large amount of code.
There is three checks:
  [*] Implicit comparator to zero (coding-style, many warnings found),
  [*] Suspicious implicit cast to non-integral (bugs!?, almost none found),
  [*] Comparison to suspicious constant (bugs!?, found two cases),

Example:
[[https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c |
https://github.com/kylepjohnson/sigma/blob/master/sigma/native-installers/debian/dependencies/files/opt/sigma/E/HEURISTICS/che_to_precgen.c]]

```
      else if(strcmp(id, "select") == 0)
      {
         array->array[i].key1 = 25;
      }
      else if(strcmp(id, "sk") == 28)      // BUG!?
      {
         array->array[i].key1 = 20;
      }
```

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Differential Revision: http://reviews.llvm.org/D18703

llvm-svn: 267009
2016-04-21 17:19:36 +00:00
Eugene Zelenko e0e87aff5c [Release Notes] Mention Clang-tidy misc-unused-using-decls check.
llvm-svn: 266770
2016-04-19 17:31:58 +00:00
Daniel Jasper 727fd1aeed Initial version of misc-unused-using-decl check.
llvm-svn: 266735
2016-04-19 13:48:39 +00:00
Eugene Zelenko dca3812252 [Release Notes] mention Clang-tidy misc-multiple-statement-macro check.
llvm-svn: 266455
2016-04-15 17:32:19 +00:00
Etienne Bergeron 1f696b316c [clang-tidy] Add new checker for suspicious sizeof expressions
Summary:
This check is finding suspicious cases of sizeof expression.

Sizeof expression is returning the size (in bytes) of a type or an
expression. Programmers often abuse or misuse this expression.

This checker is adding common set of patterns to detect some
of these bad constructs.


Some examples found by this checker:

R/packages/ifultools/ifultools/src/fra_neig.c
```
        /* free buffer memory */
        (void) mutil_free( dist_buff, sizeof( ctr * sizeof( double ) ) );
        (void) mutil_free( nidx_buff, sizeof( ctr * sizeof( sint32 ) ) );
```


graphviz/v2_20_2/lib/common/utils.c
```
static Dtdisc_t mapDisc = {
    offsetof(item, p),
    sizeof(2 * sizeof(void *)),
    offsetof(item, link),
    (Dtmake_f) newItem,
    (Dtfree_f) freeItem,
    (Dtcompar_f) cmpItem,
    NIL(Dthash_f),
    NIL(Dtmemory_f),
    NIL(Dtevent_f)
};
```


mDNSResponder/mDNSShared/dnsextd.c
```
	context = ( TCPContext* ) malloc( sizeof( TCPContext ) );
	require_action( context, exit, err = mStatus_NoMemoryErr; LogErr( "AcceptTCPConnection", "malloc" ) );
	mDNSPlatformMemZero( context, sizeof( sizeof( TCPContext ) ) );
	context->d		 = self;
```

Reviewers: alexfh

Subscribers: malcolm.parsons, Eugene.Zelenko, cfe-commits

Differential Revision: http://reviews.llvm.org/D19014

llvm-svn: 266451
2016-04-15 16:36:00 +00:00
Etienne Bergeron 3c5be6c9a7 [clang-tidy] Add checker for operations between integrals and pointers
Summary:
This check is finding suspicious operations involving pointers and integral types; which are most likely bugs.

Examples:
subversion/v1_6/subversion/libsvn_subr/utf.c
```
static const char *
fuzzy_escape(const char *src, apr_size_t len, apr_pool_t *pool)
{
  [...]
   while (src_orig < src_end)
    {
      if (! svn_ctype_isascii(*src_orig) || src_orig == '\0')   // Should be *src_orig
        {
```

apache2/v2_2_23/modules/metadata/mod_headers.c
```
static char *parse_format_tag(apr_pool_t *p, format_tag *tag, const char **sa)
{
  [...]
    tag->arg = '\0';   // ERROR: tag->arg has type char*

    /* grab the argument if there is one */
    if (*s == '{') {
        ++s;
        tag->arg = ap_getword(p,&s,'}');
    }
```

Reviewers: alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Differential Revision: http://reviews.llvm.org/D19118

llvm-svn: 266450
2016-04-15 16:31:15 +00:00