Commit Graph

917 Commits

Author SHA1 Message Date
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 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
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
Ehsan Akhgari 221ab77ff7 [clang-tidy] Add -extra-arg and -extra-arg-before to run-clang-tidy.py
Summary:
These flags allow specifying extra arguments to the tool's command
line which don't appear in the compilation database.

Reviewers: alexfh

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

llvm-svn: 292415
2017-01-18 17:49:35 +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
Antonio Maiorano 0d7d9c20a5 Update tools to use new getStyle API
Depends on https://reviews.llvm.org/D28081

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

llvm-svn: 292175
2017-01-17 00:13:32 +00:00
Malcolm Parsons 3c3ae0e6db Remove unused lambda captures. NFC
llvm-svn: 291940
2017-01-13 18:56:04 +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
Alexander Kornienko e3d91a5c4b Correctly classify main file includes if there is a prefix added
Summary:
Prevents misclassifying includes based on the command-line filename (e.g. if a project is in a subdirectory).

This is slightly more robust than the additional duplicate detection, however the current classification scheme is still kind of brittle for a lot of code.

Reviewers: hokein, alexfh

Subscribers: cfe-commits, #clang-tools-extra

Patch by Julian Bangert!

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

llvm-svn: 291767
2017-01-12 15:31:50 +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
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
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
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
Alexander Kornienko dd0c0ba82c [clang-tidy] google-explicit-constructor: ignore compiler-generated conversion operators.
llvm-svn: 290668
2016-12-28 13:48:03 +00:00
Malcolm Parsons 51bfe42a70 [clang-tidy] Make 2 checks register matchers for C++ only.
llvm-svn: 290633
2016-12-27 22:14:40 +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
Malcolm Parsons 0cc3051d8e [clang-tidy] Remove local hasInClassInitializer matcher. NFC
llvm-svn: 290493
2016-12-24 14:30:29 +00:00
Marek Sokolowski 23dd4c37be [clang-tidy] refactor ExprSequence out of use-after-move check
Differential Revision: https://reviews.llvm.org/D27700

llvm-svn: 290489
2016-12-24 12:45:07 +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 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
Piotr Padlewski 28da400854 [clang-tidy] fix missing anchor for MPI Module
Summary: MPIModule was not linked to plugins

Reviewers: alexfh, Alexander_Droste, hokein

Subscribers: JDevlieghere, cfe-commits

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

llvm-svn: 289930
2016-12-16 09:14:47 +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
Piotr Padlewski 08124b110a modernize-use-auto NFC fixes
llvm-svn: 289656
2016-12-14 15:29:23 +00:00
Stephan Bergmann 17c7f70362 Replace APFloatBase static fltSemantics data members with getter functions
At least the plugin used by the LibreOffice build
(<https://wiki.documentfoundation.org/Development/Clang_plugins>) indirectly
uses those members (through inline functions in LLVM/Clang include files in turn
using them), but they are not exported by utils/extract_symbols.py on Windows,
and accessing data across DLL/EXE boundaries on Windows is generally
problematic.

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

llvm-svn: 289647
2016-12-14 11:57:17 +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
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
Alexander Kornienko 9f58fe08bf Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}
llvm-svn: 289542
2016-12-13 16:19:19 +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
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
Jonas Devlieghere 7319184946 [clang-tidy] Make format style customizable
Summary: I came across an outstanding FIXME to make the format style customizable. Inspired by the include fixer, I added an new option `-style` to configure the fallback style in case no clang-format configuration file is found. The default remains "llvm". 

Reviewers: Prazek, aaron.ballman, hokein, alexfh

Subscribers: cfe-commits, malcolm.parsons

Tags: #clang-tools-extra

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

llvm-svn: 288258
2016-11-30 18:06:42 +00:00
Eugene Zelenko 86150471c6 Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes (NFC).
This preparation to remove SetVector.h dependency on SmallSet.h.

llvm-svn: 288175
2016-11-29 18:24:01 +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
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
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
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