Commit Graph

799 Commits

Author SHA1 Message Date
Kirill Bobyrev 405699ef1d minor header guards and help messages cleanup
llvm-svn: 279226
2016-08-19 09:36:14 +00:00
Martin Bohme e9a265a267 Adapt to TraverseLambdaCapture interface change from D23204
Summary:
Depends on D23204.

This is intended to be submitted immediately after D23204 lands.

Reviewers: jdennett, alexfh

Subscribers: cfe-commits

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

llvm-svn: 278934
2016-08-17 15:00:22 +00:00
Haojian Wu 80c1c9f6d8 [clang-tidy] readability-implicit-bool-cast forgets to store its options.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 278791
2016-08-16 11:15:05 +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
Zachary Turner 18cfbc4b8e Analyze include order on a per-file basis.
The include order check would get notified of all include
directives in a depth-first manner.  This created the
possibility of an include directive from a header file
interfering with the sort order of a set of two distinct
blocks from the top level cpp file, if that include directive
was on just the right line.

With this patch we bucket the include directives by the file
in which they appear in and process one bucket at a time,
so that directives from different files do not get mixed
together into the same list.

Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23434

llvm-svn: 278546
2016-08-12 18:38:26 +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
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
Eric Liu 7e5445267f Fix clang-tidy crash when a single fix is applied on multiple files.
Summary:
tooling::Replacements only holds replacements for a single file, so
this patch makes Fix a map from file paths to tooling::Replacements so that it
can be applied on multiple files.

Reviewers: hokein, alexfh

Subscribers: Prazek, cfe-commits

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

llvm-svn: 278101
2016-08-09 07:54:49 +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
John Brawn 4d79ec7fe8 Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
This differs from the previous version by being more careful about template
instantiation/specialization in order to prevent errors when building with
clang -Werror. Specifically:
 * begin is not defined in the template and is instead instantiated when Head
   is. I think the warning when we don't do that is wrong (PR28815) but for now
   at least do it this way to avoid the warning.
 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
   instead provide a template definition then do explicit instantiation. No
   compiler I've tried has problems with doing it the other way, but strictly
   speaking it's not permitted by the C++ standard so better safe than sorry.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 277806
2016-08-05 11:01:08 +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
Etienne Bergeron 58728c6e9a [extra-tools] Fix extra tools build bot warnings due to incorrect doc
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/tools/extra/clang-tidy/mpi/TypeMismatchCheck.cpp:172:12: warning: parameter 'Complex' not found in the function declaration [-Wdocumentation]
/home/llvmbb/llvm-build-dir/clang-x86_64-debian-fast/llvm.src/tools/clang/tools/extra/clang-tidy/mpi/TypeMismatchCheck.cpp:206:12: warning: parameter 'Complex' not fo

llvm-svn: 277578
2016-08-03 06:59:46 +00:00
Etienne Bergeron ee0627fd1b [clang-tidy] Fix missing dependency to static analyzer
Summary:
This patch is fixing the build bot broken for a missing dependency.

The missing dependency is breaking "shared" build.

```
./mpi/TypeMismatchCheck.cpp:
  #include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
```

I'm not a fan of that fix. It's brining a strange dependency.

Reviewers: alexfh

Subscribers: llvm-commits, chrisha

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

llvm-svn: 277539
2016-08-02 22:51:46 +00:00
Jonathan Coe 77ec263e60 [clang-tidy] Fix segfault in cppcore-guidelines-special-member-functions check
Summary:
Use a set rather than a vector of defined special member functions so
that multiple declarations of the same function are only counted once.

Move some private static member functions into the cpp file.

Run clang-format on header.

Reviewers: ericLemanissier, Prazek, aaron.ballman

Subscribers: Prazek, cfe-commits, nemanjai

Projects: #clang-tools-extra

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

llvm-svn: 277523
2016-08-02 21:18:37 +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
Haojian Wu da2a58dd0b [clang-tidy] Fix an unused-using-decl false positive about template arguments in
function call expression.

Summary:
The check doesn't mark the template argument as used when the template
argument is a template.

Reviewers: djasper, alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 277444
2016-08-02 11:26:35 +00:00
Kirill Bobyrev 11cea45cce [clang-tidy] remove trailing whitespaces and retab
llvm-svn: 277340
2016-08-01 12:06:18 +00:00
Martin Bohme d10be62383 [clang-tidy] Prepare modernize-loop-convert for upcoming changes in D22566
Summary:
D22566 will change RecursiveASTVisitor so that it descends into the initialization expressions for lambda captures.

modernize-loop-convert needs to be prepared for this so that it does not interpret these initialization expressions as invalid uses of the loop variable. The change has no ill effects without D22566 in place, i.e. the change does not depend on D22566.

Reviewers: klimek

Subscribers: cfe-commits

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

llvm-svn: 277339
2016-08-01 11:29:17 +00:00
Eric Liu 267034ca9c Changes related to new implementation of tooling::Replacements as class.
Summary: See http://reviews.llvm.org/D21748 for details.

Reviewers: djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 277336
2016-08-01 10:16:39 +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
Aaron Ballman 2931002c8e Sorting includes; NFC.
llvm-svn: 277217
2016-07-29 21:41:18 +00:00
Justin Lebar 41e9dad437 [Typo police] s/proccess/process/, s/auxiliary/auxilliary/.
llvm-svn: 277113
2016-07-29 05:26:58 +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
John Brawn 2853269224 Revert r276973 "Adjust Registry interface to not require plugins to export a registry"
Buildbot failures when building with clang -Werror. Reverting while I try to
figure this out.

llvm-svn: 277008
2016-07-28 17:17:22 +00:00
John Brawn 778c3c6c61 Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"
This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 276973
2016-07-28 12:48:17 +00:00
Martin Bohme 9d01ef97ef Revert test commit
This reverts rL276746.

llvm-svn: 276752
2016-07-26 14:37:39 +00:00
Martin Bohme 5d18c427ed Test commit -- adding a newline
llvm-svn: 276746
2016-07-26 14:01:48 +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
Benjamin Kramer 7035cbf8eb [clang-tidy] Avoid duplicated DenseMap lookup.
The std::string is still constructed on demand. No functionality change
intended.

llvm-svn: 276282
2016-07-21 14:13:45 +00:00
Matthias Gehre 056237a457 clang-tidy modernize-loop-convert: preserve type of alias declaration (bug 28341)
Summary:
Previoly, the added test failed with the fillowing fixit:

     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

i.e. the variable 'value' changes from unsigned char to signed char. And
thus the following 'if' does not work anymore.

With this commit, the fixit is changed to:
     char v[5];

-    for(size_t i = 0; i < 5; ++i)
+    for(unsigned char value : v)
     {
-        unsigned char value = v[i];
         if (value > 127)

Reviewers: alexfh, klimek

Subscribers: cfe-commits

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

llvm-svn: 276111
2016-07-20 12:32:06 +00:00
Kirill Bobyrev 5d8f071a07 [clang-tidy] readability-identifier-naming - support for other case types
Added Camel_Snake_Case and camel_Snake_Back

class Camel_Snake_Case_Class_Name
{
  void private_Camel_Snake_Back_Method_Name();
}

Patch by James Reynolds!

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 276110
2016-07-20 12:28:38 +00:00
Matthias Gehre dd117cf01d cppcoreguidelines-pro-bounds-constant-array-index: ignore implicit constructor
Summary:
The code

  struct A {
    int x[3];
  };

gets an compiler-generated copy constructor that uses ArraySubscriptExpr (see below).
Previously, the check would generate a warning on that copy constructor.
This commit disables the warning on implicitly generated code.
AST:

  |-CXXConstructorDecl 0x337b3c8 <col:8> col:8 implicit used constexpr A 'void (const struct A &) noexcept' inline
  | |-ParmVarDecl 0x337b510 <col:8> col:8 used 'const struct A &'
  | |-CXXCtorInitializer Field 0x3379238 'x' 'int [3]'
  | | `-ImplicitCastExpr 0x337e158 <col:8> 'int' <LValueToRValue>
  | |   `-ArraySubscriptExpr 0x337e130 <col:8> 'const int' lvalue
  | |     |-ImplicitCastExpr 0x337e118 <col:8> 'const int *' <ArrayToPointerDecay>
  | |     | `-MemberExpr 0x337dfc8 <col:8> 'int const[3]' lvalue .x 0x3379238
  | |     |   `-DeclRefExpr 0x337dfa0 <col:8> 'const struct A' lvalue ParmVar 0x337b510 '' 'const struct A &'
  | |     `-ImplicitCastExpr 0x337e098 <col:8> 'unsigned long' <LValueToRValue>
  | |       `-DeclRefExpr 0x337e070 <col:8> 'unsigned long' lvalue Var 0x337e010 '__i0' 'unsigned long'

Reviewers: alexfh, aaron.ballman

Subscribers: aemerson, nemanjai, cfe-commits

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

llvm-svn: 275993
2016-07-19 17:02:54 +00:00
Benjamin Kramer 8ff8fdf4d4 Unbreak extra tools build post r275882.
llvm-svn: 275886
2016-07-18 19:21:22 +00:00
Matthias Gehre 03fadabe47 cppcoreguidelines-pro-bounds-constant-array-index: crash for value dependent index in c++03 mode
Summary:
When the expression is value dependent,
isIntegerConstantExpr() crashes in C++03 mode with
 ../tools/clang/lib/AST/ExprConstant.cpp:9330: (anonymous namespace)::ICEDiag CheckICE(const clang::Expr *, const clang::ASTContext &):
  Assertion `!E->isValueDependent() && "Should not see value dependent exprs!"' failed.
In C++11 mode, that assert does not trigger.

This commit works around this in the check. We don't check
value-dependent indices and instead check their specialization.

Reviewers: alexfh, aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 275461
2016-07-14 20:00:48 +00:00
Haojian Wu 0b067c1252 [clang-tidy] Fix misc-definitions-in-headers misplaced fixing to fully templated function.
Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 275263
2016-07-13 13:55:29 +00:00
Haojian Wu d1218758e1 [clang-tidy] Pass absolute path to OptionsProvider::getOptions/getRawOptions.
Summary:
Although there is no guarantee of getOptions/getRawOptions receiving an
absolute path, we try to make it if possible. So FileOptionProvider subclasses
don't have to convert the path to an absolute path.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 275051
2016-07-11 07:47:04 +00:00
Matthias Gehre a9e812b9cb clang-tidy/readability-identifier-naming: crash on DependentTemplateSpecializationType
Summary:
Previously, the added test cases crashed because the passed a null Decl
to addUsage().

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 274985
2016-07-09 20:09:28 +00:00
Nico Weber 1e348b339c [clang-tidy] Add dependency on clang-headers
Currently, to be able to process a source file including e.g. stddef.h with
clang-tidy, one has to build both clang-tidy and the clang-headers target.
Since stddef.h is needed for virtually any source file, let clang-tidy depend
on clang-headers, so that it Just Works after it has been built.

http://reviews.llvm.org/D22046

llvm-svn: 274751
2016-07-07 13:19:45 +00:00
Etienne Bergeron 00639bc529 [clang-tidy] Enhance redundant-expression check
Summary: This patch is adding support to recognize more complex redundant expressions.

Reviewers: alexfh

Subscribers: aaron.ballman, cfe-commits, chrisha

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

llvm-svn: 274731
2016-07-07 04:03:05 +00:00
Felix Berger 17934da767 [clang-tidy] UnnecessaryValueParamCheck - only warn for virtual methods
Summary:

As changing virtual methods could break method overrides disable applying the fix and just warn.

Reviewers: alexfh, sbenza

Subscribers: cfe-commits

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

llvm-svn: 274552
2016-07-05 14:40:44 +00:00
Haojian Wu c1926075c3 [clang-tidy] Fix more enum declaration cases in misc-unused-using-decls check.
Summary: Fix PR28350.

Reviewers: alexfh

Subscribers: aaron.ballman, Eugene.Zelenko, cfe-commits

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

llvm-svn: 274496
2016-07-04 12:01:56 +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
Samuel Benzaquen 25cd6139e3 [clang-tidy] Do not match on lambdas.
We match on the generated FunctionDecl of the lambda and try to fix it.
This causes a crash.
The right behavior is to ignore lambdas, because they are a definition.

llvm-svn: 274019
2016-06-28 14:19:41 +00:00
Piotr Padlewski b0869a7522 [clang-tidy] boost-use-to-string arg expr location bugfix
Summary: getExprLoc returns location after dot for member call.

Reviewers: alexfh, sbenza, hokein

Subscribers: cfe-commits

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

llvm-svn: 274001
2016-06-28 08:16:20 +00:00
Haojian Wu eb646e0d9b [clang-tidy] Warning enum unused using declarations.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 273882
2016-06-27 14:47:39 +00:00