Commit Graph

2275 Commits

Author SHA1 Message Date
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
Malcolm Parsons 51bfe42a70 [clang-tidy] Make 2 checks register matchers for C++ only.
llvm-svn: 290633
2016-12-27 22:14:40 +00:00
Malcolm Parsons 5cc08f865b [clang-tidy] Replace dead link in modernize-pass-by-value doc
llvm-svn: 290630
2016-12-27 22:01:37 +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
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
Eric Liu 180dac6396 [change-namespace] consider namespace aliases to shorten qualified names.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 290421
2016-12-23 10:47:09 +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
Eric Liu e3f35e4db6 [change-namespace] do not fix calls to overloaded operator functions.
Summary: Also make sure one function reference is only processed once.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 290176
2016-12-20 14:39:04 +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
Benjamin Kramer bc805aef33 [include-fixer] Desugar incomplete types.
This will look through typedefs so include-fixer will look up the target
of the typedef instead of the typedef itself (which is already in
scope).

llvm-svn: 289952
2016-12-16 16:09:06 +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
Eric Liu 0c0aea0c0a [change-namespace] fix a case references to templated using alias are qualified types.
llvm-svn: 289816
2016-12-15 13:02:41 +00:00
Eric Liu 26cf68af3a [change-namespace] handling templated type aliases correctly.
Summary: This fixes templated type aliases and templated type aliases in classes.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 289799
2016-12-15 10:42:35 +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
Piotr Padlewski ce452ceb6a Deleted unused typedef
llvm-svn: 289658
2016-12-14 15:42:23 +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
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 a3dc05b363 Fix sphinx build.
llvm-svn: 289549
2016-12-13 16:49:10 +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
Haojian Wu dc4edba576 [clang-move] Fix incorrect EndLoc for declarations in macros.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 289541
2016-12-13 15:35:47 +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
Alexander Shaposhnikov b8c997f1d2 [clang-move] Fix buildbot failures
Fix the buildbot failures introduced by D27669

llvm-svn: 289465
2016-12-12 20:24:44 +00:00
Alexander Shaposhnikov 62a154dab6 [clang-move] Use appendArgumentsAdjuster for adding extra arguments
1. Remove some boilerplate code for appending -fparse-all-comments to the list of arguments.
2. Run clang-format -i against ClangMoveMain.cpp.

Test plan: make check-all

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

llvm-svn: 289464
2016-12-12 19:56:37 +00:00
Eric Liu 97f87add50 [change-namespace] always add a '::' prefix when a symbol reference needs to be fully-qualified.
llvm-svn: 288969
2016-12-07 20:08:02 +00:00
Eric Liu 8685c76472 [change-namespace] don't fix using shadow decls in classes.
Summary:
Using shadow declarations in classes always refers to base class, which does not
need to be fixed/qualified since it can be inferred from inheritance.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 288919
2016-12-07 17:04:07 +00:00
Eric Liu 41552d6a37 [change-namespace] move template class forward-declarations and don't move fwd-decls in classes.
Summary:
Forward declarations in moved namespaces should be moved back to the old
namespaces. We should also move template class forward declarations.

Also fix a bug that moves forward declarations of nested classes.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 288908
2016-12-07 14:20:52 +00:00
Eric Liu 47a42d53fc [clang-move] ignore unsupported symbol kinds when checking if all symbols are moved.
llvm-svn: 288791
2016-12-06 10:12:23 +00:00
Eric Liu 2dd0e1bca3 [change-namespace] get changing namespace to global correct.
llvm-svn: 288662
2016-12-05 11:17:04 +00:00
Eric Liu 033b3a8b25 [clang-move] don't miss ',' in json output when there are duplicate elements.
llvm-svn: 288586
2016-12-03 15:28:03 +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
Haojian Wu 08e402ac93 [clang-move] some tweaks.
* Don't save SourceManager for each declarations.
* Rename some out-dated methods.

No functionality change.

llvm-svn: 288498
2016-12-02 12:39:39 +00:00
Eric Liu 4bf67af2d5 Fix a buildbot failure in include-fixer.
llvm-svn: 288495
2016-12-02 11:23:07 +00:00
Malcolm Parsons 7636149f31 Add a blank line to make sphinx happy.
llvm-svn: 288384
2016-12-01 17:38:54 +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
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
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
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
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
Eric Liu da22b3cb8a [change-namespace] fix non-calling function references.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 288139
2016-11-29 14:15:14 +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
NAKAMURA Takumi 5843abc912 ClangMoveTests.cpp: Fix a bogus comparison of iterator.
msc Debug build detected it.

llvm-svn: 288034
2016-11-28 14:27:37 +00:00
Haojian Wu b15c8da089 [clang-move] Enable dump all declarations in old header.
Summary:
* Add -dump_dels option to dump all declarations from old header. It
  will allow clang-move used as a frontend to get declarations from
  header. Further more, this will make debugging stuff easier. Currently only
  class/function types are supported.
* Refactoring code a little bit by creating a ClangMoveContext which
  holds all options for ClangMoveTool, which can simplify the code in
  some degree.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287863
2016-11-24 10:17:17 +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 66039d39e1 [clang-rename] Fix non-functional offset check.
Adding something to a SourceLocation will only produce an invalid
SourceLocation in edge cases (overflow or adding 0 to an invalid one).
Check that the offset is inside the file instead and add a test case to
verify that the error message works.

llvm-svn: 287758
2016-11-23 13:10:07 +00:00
Haojian Wu 48ac304c8e [clang-move] Add some options allowing to add old/new.h to new/old.h respectively.
Summary:
* --new_depend_on_old: new header will include old header
* --old_depend_on_new: old header will include new header.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 287752
2016-11-23 10:04: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
Benjamin Kramer cd2494e93f [include-fixer] Refactor include fixer to be usable as a plugin
- Refactor the external sema source into a visible class
- Add support for emitting FixIts
- Wrap up include fixer as a plugin as I did with clang-tidy

Test case will follow as soon as I wire this up in libclang.

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

llvm-svn: 287228
2016-11-17 15:16:05 +00:00
Malcolm Parsons 5831a00634 [docs] Remove doubled spaces
Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 287226
2016-11-17 14:26:45 +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
Haojian Wu 53315a7b98 [clang-move] Make the output code look more pretty.
Summary:
Add decent blank lines between declarations:
* Add extra blank line after #define or #includes.
* Add extra blank line between declarations.
* Add extra blank line in front of #endif.

Previously, the new generated code is quite tight:

```
#ifndef FOO_H
#define FOO_H
namespace a {
class A { public: int f(); };
int A::f() { return 0; }
} // namespace a
#endif // FOO_H
```

After this patch, the code looks like:

```
#ifndef FOO_H
#define FOO_H

namespace a {
class A { public: int f(); };

int A::f() { return 0; }
} // namespace a

#endif // FOO_H
```

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286943
2016-11-15 09:06:59 +00:00
Eric Liu 3215886b7a [change-namespace] consider typedef/using alias decls in the moved namespace.
Summary: If a TypeLoc refers to a type alias defined in the moved namespace, we do not need to update its specifier since the type alias decl will be moved along with the type reference.

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286873
2016-11-14 19:37:55 +00:00
Haojian Wu 2467539800 [clang-move] Fix an incorrect range for the functions whose returned value is a macro
Summary:
Fix an incorrect range for the functions whose returned value is a macro
(e.g. `bool`). This incorrect range can lead to modifications of an unexpected
file where the macro is in.

We should use expansion location instead of spelling location.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286833
2016-11-14 14:46:48 +00:00
Haojian Wu 35ca946760 [clang-move] Abstract a ClassMather for matching class declarations.
Summary:
No functionality change.

This is a refactoring patch, which makes the code more readable and easy
to extend it to support more types.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 286825
2016-11-14 14:15:44 +00:00
Eric Liu 6aa9416d06 Handle adding new nested namespace in old namespace.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286486
2016-11-10 18:29:01 +00:00
Eric Liu 231c655851 [change-namespace] dyn_cast -> cast.
llvm-svn: 286485
2016-11-10 18:15:34 +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
Malcolm Parsons d784f20c13 [clang-tidy] Add missing meta refresh for cert-msc30-c doc. NFC
llvm-svn: 286466
2016-11-10 16:19:17 +00:00
Simon Pilgrim 0e0f29c09f Fix -Wdocumentation warning
llvm-svn: 286449
2016-11-10 13:54:39 +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
Alexander Kornienko a6a52b2d63 [clang-tidy docs] Minor formatting changes.
llvm-svn: 286404
2016-11-09 22:31:07 +00:00
Alexander Kornienko 967f753e10 [clang-tidy docs] Recommend using add_new_check.py more
llvm-svn: 286390
2016-11-09 20:03:30 +00:00
Philipp Stephani 9934c54cca Fix grammar
"allow" requires a direct object in this case.

llvm-svn: 286381
2016-11-09 17:47:56 +00:00
Eric Liu b9bf1b5b85 [change-namespace] shorten namespace qualifier based on UsingDecl and UsingDirectiveDecl.
Summary:
when replacing symbol references in moved namespaces, trying to make the replace
name as short as possible by considering UsingDecl (i.e. UsingShadow) and
UsingDirectiveDecl (i.e. using namespace decl).

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 286307
2016-11-08 22:44:17 +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
Alexander Kornienko ed999fe0b2 Remove mentions of clang-analyzer-alpha
llvm-svn: 286257
2016-11-08 18:12:56 +00:00
Kirill Bobyrev b0cf6a3840 [clang-tidy] Improve rename_check.py.
-Start using argparse instead of mimicking CLI parsing.
-PEPify the code.
-Decrease the number of imports by slightly cleaning up the script.

Reviewers: alexfh

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

llvm-svn: 286228
2016-11-08 11:43:50 +00:00
Alexander Kornienko 7783ea6a61 [clang-tidy] clang-analyzer-alpha* checks are not registered, so there's no need to disable them
llvm-svn: 286222
2016-11-08 08:28:19 +00:00
Mandeep Singh Grang 7c7ea7d0ae [clang-tools-extra] Format sources with clang-format. NFC.
Summary:
Ran clang-format on all .c/.cpp/.h files in clang-tools-extra.
Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories.

Reviewers: klimek, alexfh

Subscribers: nemanjai

Tags: #clang-tools-extra

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

llvm-svn: 286221
2016-11-08 07:50:19 +00:00
Alexander Kornienko 179e89f188 Use AnalyzerOptions::getRegisteredCheckers() instead of clang/StaticAnalyzer/Checkers/Checkers.inc
Summary: Depends on D26310.

Reviewers: zaks.anna, hokein

Subscribers: cfe-commits

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

llvm-svn: 286219
2016-11-08 07:43:42 +00:00
Alexander Kornienko 76e4315a0e [clang-tidy] Simplify matchers
llvm-svn: 286213
2016-11-08 05:58:07 +00:00
Haojian Wu 06e39a3aed [clang-tidy] Don't warn implicit variables in peformance-unnecessary-copy-initialization.
Summary:

This will prevent the check warning the variables which have been
implicitly added by compiler, like the following case (in for-range loop):

  the variable '__end' is copy-constructed from a const reference...

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 286186
2016-11-08 00:45:34 +00:00
Haojian Wu a29ae6f2d7 [clang-tidy] Fix a regression issue introduced by r285239.
Summary:
r285239 changes the behavior of AST CXXDefaultArgExpr node.

Update `modernize-use-nullptr` to handle CXXDefaultArgExpr correctly.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 286156
2016-11-07 21:46:24 +00:00
Felix Berger 4a3f94c442 [clang-tidy] Move incomplete type test into separate test file
Summary: Move in complete type test which does not compile into its own test file.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286155
2016-11-07 21:45:58 +00:00
Felix Berger 7c6d289d66 [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified
Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286010
2016-11-04 20:51:31 +00:00
Felix Berger 3938033282 [clang-tidy] Ignore incomplete types when determining whether they are expensive to copy
Summary: IsExpensiveToCopy can return false positives for incomplete types, so ignore them.

All existing ClangTidy tests that depend on this function still pass as the types are complete.

Reviewers: alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 286008
2016-11-04 20:29:22 +00:00
Malcolm Parsons c35be36962 [clang-tidy] Fixed readability-else-after-return for cascade statements
Summary:
Fix generated by this check changed program semantics
in the case where 'if' was a part (direct child) of other statement.

Fixes PR30652.

Patch by Paweł Żukowski.

Reviewers: malcolm.parsons, alexfh, djasper

Subscribers: mgehre, omtcyfz, cfe-commits

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

llvm-svn: 285999
2016-11-04 16:32:14 +00:00
Jonathan Coe 89f12c0c50 [clang-tidy] Ignore forward declarations without definitions in the same translation unit in readability-identifier-naming
Summary: This change ensures that forward declarations of classes are not considered for identifier naming checks within a translation unit.

Reviewers: alexfh, aaron.ballman

Subscribers: mgehre

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

llvm-svn: 285907
2016-11-03 13:52:09 +00:00
Malcolm Parsons 8b70e2631c [clang-tidy] Handle data() in readability-redundant-string-cstr
Summary:
std::string::data() and std::string::c_str() are equivalent.
Enhance the readability-redundant-string-cstr check to also handle
calls to data().

Reviewers: etienneb, alexfh, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 285901
2016-11-03 12:56:48 +00:00
Malcolm Parsons cb2e749e46 [clang-tidy] Suppress notes for warnings that were ignored
Fixes PR30565.

Patch by Nikita Kakuev

llvm-svn: 285861
2016-11-02 21:14:22 +00:00
Eugene Zelenko 1867c6cd42 [Documentation] Fix Clang-tidy misc-use-after-move and cert-msc50-cpp style and misspelling.
llvm-svn: 285848
2016-11-02 18:23:52 +00:00
Martin Bohme 5d9d417a08 [clang-tidy] Extend misc-use-after-move to support unique_ptr and shared_ptr.
Summary:
As a unique_ptr or shared_ptr that has been moved from is guaranteed to be null,
we only warn if the pointer is dereferenced.

Reviewers: hokein, alexfh, aaron.ballman

Subscribers: Prazek, cfe-commits

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

llvm-svn: 285842
2016-11-02 17:34:47 +00:00
Aaron Ballman 7bfa685611 Add a new clang-tidy check for cert-msc50-cpp (and cert-msc30-c) that corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/MSC50-CPP.+Do+not+use+std%3A%3Arand%28%29+for+generating+pseudorandom+numbers
Patch by Benedek Kiss

llvm-svn: 285809
2016-11-02 14:16:36 +00:00
Eugene Zelenko ae8e12e79f [Documentation] Clang-tidy readability-redundant-declaration consistency.
Release notes checks order and consistent Clang-tidy readability-redundant-declaration description.

llvm-svn: 285778
2016-11-02 00:43:23 +00:00
Malcolm Parsons 883ebacd78 [clang-tidy] Handle bitfields in cppcoreguidelines-pro-type-member-init
Summary:
Unnamed bitfields cannot be initialized.
Bitfields cannot be in-class initialized.

Reviewers: alexfh, hokein, aaron.ballman

Subscribers: Prazek, nemanjai, cfe-commits

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

llvm-svn: 285752
2016-11-01 21:26:53 +00:00
Malcolm Parsons d03c254662 [clang-query] Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: pcc, dblaikie

Subscribers: cfe-commits

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

llvm-svn: 285731
2016-11-01 20:07:05 +00:00
Eugene Zelenko 90c117a61b [Clang-tidy] Fix copy-paste error in misc-redundant-expression detected by PVS-Studio
Also fix some Include What You Use and modernize-use-bool-literals warnings.

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

llvm-svn: 285721
2016-11-01 18:33:50 +00:00
Daniel Marjamaki 399a50cf35 [clang-tidy] Add check readability-redundant-declaration
Finds redundant variable and function declarations.

  extern int X;
  extern int X;  // <- redundant

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

llvm-svn: 285689
2016-11-01 13:26:15 +00:00
Malcolm Parsons 2792dccb36 [clang-tidy] Update cert-err58-cpp to match its new generalised form.
Summary:
Aaron modified cert-err58-cpp to include all exceptions thrown before main()
Update the check to match.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 285653
2016-10-31 22:47:04 +00:00
Eugene Zelenko 01fd221a29 [Release notes] Highlight reset() as language/library artifact.
llvm-svn: 285645
2016-10-31 22:05:45 +00:00
Malcolm Parsons d1b54492cd Add modernize-use-auto tests for casts inside macros
llvm-svn: 285601
2016-10-31 17:17:45 +00:00
Malcolm Parsons 54c5a545be [clang-tidy] Enhance modernize-make-unique to handle unique_ptr.reset()
Summary:
Avoid naked new in unique_ptr.reset() by using make_unique

Fixes http://llvm.org/PR27383

Reviewers: alexfh, aaron.ballman

Subscribers: Prazek, cfe-commits

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

llvm-svn: 285589
2016-10-31 15:48:01 +00:00
Malcolm Parsons 88818b725d Add -frtti for Windows buildbot.
llvm-svn: 285583
2016-10-31 15:15:00 +00:00
Malcolm Parsons aa800837d3 Fix link to check
llvm-svn: 285581
2016-10-31 14:48:49 +00:00
Malcolm Parsons db04833fca [clang-tidy] Enhance modernize-use-auto to casts
Summary:
Extend modernize-use-auto to cases when a variable is assigned with a cast.

e.g.
Type *Ptr1 = dynamic_cast<Type*>(Ptr2);

http://llvm.org/PR25499

Reviewers: angelgarcia, aaron.ballman, klimek, Prazek, alexfh

Subscribers: Prazek, Eugene.Zelenko, cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 285579
2016-10-31 14:43:37 +00:00
Eric Liu 8393cb0191 [change-namespace] fix namespace specifiers of template arguments.
llvm-svn: 285549
2016-10-31 08:28:29 +00:00
Benjamin Kramer 2df9a3f2c4 [include-fixer] Make error message sound less like clang crashed.
We suppress all Clang diagnostics (because they would be wrong,
include-fixer does custom recovery) but still want to give some feedback
in case there was a compiler error we couldn't recover from. The most
common case for this is a #include in the file that couldn't be found.

llvm-svn: 285396
2016-10-28 13:00:49 +00:00
Manuel Klimek 63c6989d70 include-fixer: Don't overwrite buffer changes
Raise a signal if the buffer has been modified before replacing it, to
avoid overwriting users' changes.

Patch by Philipp Stephani.

llvm-svn: 285060
2016-10-25 11:31:22 +00:00
Manuel Klimek 8e5f5ff4c1 Load clang-include-fixer.el from the unit test suite so that the unit tests can run in batch mode.
Patch by Philipp Stephani.

llvm-svn: 285059
2016-10-25 11:30:28 +00:00
Jason Henline 481e6aaa45 [clang-tidy] Fix identifier naming in macro args.
Summary:
clang-tidy should fix identifier naming even when the identifier is
referenced inside a macro expansion, provided that the identifier enters
the macro expansion completely within a macro argument.

For example, this will allow fixes to the naming of the identifier
'global' when it is declared and used as follows:

  int global;
  #define USE_IN_MACRO(m) auto use_##m = m
  USE_IN_MACRO(global);

Reviewers: alexfh

Subscribers: jlebar, cfe-commits

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

llvm-svn: 284992
2016-10-24 17:20:32 +00:00
Eugene Zelenko 566b34d9b7 [Release notes] Mention removed Clang-tidy misc-pointer-and-integral-operation check
llvm-svn: 284894
2016-10-21 22:35:58 +00:00
Richard Smith 00c03c5de7 Remove 'misc-pointer-and-integral-operation' clang-tidy check. The only cases
it detects are ill-formed (some per C++ core issue 1512, others always have
been).

llvm-svn: 284888
2016-10-21 21:50:28 +00:00
Justin Lebar ae90ad2065 [clang-tidy] Don't use a SmallSetVector of an enum.
Summary:
This doesn't work after converting SmallSetVector to use DenseSet.

Instead we can just use a SmallVector.

Reviewers: timshen

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 284873
2016-10-21 20:13:39 +00:00
Haojian Wu 29c38f75a2 [clang-move] Support moving template class forward declarations.
llvm-svn: 284859
2016-10-21 19:26:43 +00:00
Malcolm Parsons 5c24a1148d [clang-tidy] Add check 'readability-redundant-member-init'
Summary: The check emits a warning if a member-initializer calls the member's default constructor with no arguments.

Reviewers: sbenza, alexfh, aaron.ballman

Subscribers: modocache, mgorny, Eugene.Zelenko, etienneb, Prazek, hokein, cfe-commits, beanz

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

llvm-svn: 284742
2016-10-20 16:08:03 +00:00
Malcolm Parsons e9425b24b7 Use auto in for loop
llvm-svn: 284737
2016-10-20 15:40:34 +00:00
Malcolm Parsons c2da631c5a [clang-tidy] Simplify modernize-use-default
Summary:
clang-tidy now cleans up after replacements, so leave colon and comma
removal to that.

Reviewers: angelgarcia, alexfh, aaron.ballman, djasper, ioeric

Subscribers: djasper, cfe-commits

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

llvm-svn: 284735
2016-10-20 15:31:34 +00:00
Haojian Wu 7c870a7e54 [clang-tidy] Fix an assertion failure in cppcoreguidelines-pro-type-member-init.
Summary:
The matcher for matching "class with default constructor" still match
some classes without default constructor, which trigger an assert at
Line 307. This patch makes the matcher more strict.

Reviewers: aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 284727
2016-10-20 13:15:40 +00:00
Haojian Wu 157e46dd45 [Clang-tidy]: Fix modernize-avoid-bind erroneous scope resolution.
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.
The check is modernize-avoid-bind.

Consider the following:

  void bar(int x, int y);

  namespace N {
    void bar(int x, int y);
  }

  void foo(){
    auto Test = std::bind(N::bar,1,1);
  }

clang-tidy’s modernize-avoid-bind check suggests writing:

  void foo(){
    auto Test =[] {return bar(1,1);};
  }

instead of:

  void foo(){
    auto Test = [] {return N::bar(1,1);};
  }

So clang-tidy has proposed an incorrect Fix.

Patch by IdrissRio!

Reviewers: alexfh, hokein, aaron.ballman

Subscriber: cfe-commits
llvm-svn: 284719
2016-10-20 11:32:47 +00:00
Marek Kurdej 2cf1dc2add [clang-tidy] Add cert-err09-cpp check alias.
Summary: This adds cert-err09-cpp alias for completeness, similar to cert-err61-cpp.

Reviewers: alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 284596
2016-10-19 14:28:19 +00:00
Haojian Wu 67bb651ad1 [clang-move] Move using-decl in old cc.
Summary:
Another fix is to move the whole anonymous namespace declaration
completely instead of moving fun/var declarations only.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284592
2016-10-19 14:13:21 +00:00
Benjamin Kramer 089a39e859 Don't copy replacements in for-range loop. NFC.
llvm-svn: 284589
2016-10-19 13:50:17 +00:00
Simon Pilgrim 6b6291aa9b Fix signed/unsigned comparison warnings
llvm-svn: 284476
2016-10-18 13:15:31 +00:00
Alexander Kornienko 98d3391a59 [clang-tidy] Clean up code after applying replacements.
Summary:
Remove empty namespaces and initializer list commas / colons in
affected ranges. Initial patch: proper options for enabling the cleanup and
specifying the format style are needed.

Reviewers: hokein, ioeric

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284399
2016-10-17 17:25:02 +00:00
Haojian Wu ac97fc3902 [clang-move] Fix generating illegal header guard.
The filepath might contain some characters (i.e. '@') which are not
illegal in c identifiers. This patch changes all non-alphanumeric characters
to '_'.

llvm-svn: 284391
2016-10-17 15:26:34 +00:00
Haojian Wu bd31488083 Fix windows buildbot error.
llvm-svn: 284370
2016-10-17 10:05:25 +00:00
Haojian Wu ada286202e Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser"
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 284368
2016-10-17 08:33:59 +00:00
NAKAMURA Takumi 0cfbbaeca3 ClangMoveTests.cpp: Appease msc18.
clang-tools-extra\unittests\clang-move\ClangMoveTests.cpp(216) : error C2593: 'operator =' is ambiguous
          llvm\include\llvm/ADT/SmallVector.h(898): could be 'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)'
          llvm\include\llvm/ADT/SmallVector.h(893): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVectorImpl<T> &&)'
          with
          [
              T=std::string
          ]
          llvm\include\llvm/ADT/SmallVector.h(883): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(llvm::SmallVector<std::string,4> &&)'
          llvm\include\llvm/ADT/SmallVector.h(873): or       'const llvm::SmallVector<std::string,4> &llvm::SmallVector<std::string,4>::operator =(const llvm::SmallVector<std::string,4> &)'
          while trying to match the argument list '(llvm::SmallVector<std::string,4>, initializer-list)'

llvm-svn: 284360
2016-10-17 05:09:58 +00:00
NAKAMURA Takumi 7a6277a318 Reformat.
llvm-svn: 284359
2016-10-17 05:08:49 +00:00
Malcolm Parsons 778269dd78 [clang-tidy] Use ignoreImplicit in cert-err58-cpp check
Summary:
Fix a false negative in cert-err58-cpp check when calling a constructor
creates objects that require cleanup.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 284332
2016-10-16 09:47:10 +00:00
Alexander Shaposhnikov 5fe0678bd8 [clang-move] Use cl::list for the list of names
This diff replaces manual parsing of the comma-separated list of names with 
cl::list and cl::CommaSeparated.
Test plan: make -j8 check-clang-tools

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

llvm-svn: 284291
2016-10-14 23:16:25 +00:00
Haojian Wu 53eab1efcf [clang-move] Don't overuse Replacements::add.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284236
2016-10-14 13:43:49 +00:00
Martin Bohme 934743f8f8 [clang-tidy] Add additional diagnostic to misc-use-after-move
Summary:
This adds a diagnostic to the misc-use-after-move check that is output when the
use happens on a later loop iteration than the move, for example:

    A a;
    for (int i = 0; i < 10; ++i) {
      a.foo();
      std::move(a);
    }

This situation can be confusing to users because, in terms of source code
location, the use is above the move. This can make it look as if the warning
is a false positive, particularly if the loop is long but the use and move are
close together.

In cases like these, misc-use-after-move will now output an additional
diagnostic:

  a.cpp:393:7: note: the use happens in a later loop iteration than the move

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 284235
2016-10-14 13:23:39 +00:00
Haojian Wu 220c755dfc [clang-move] Add header guard for the new header.
Summary:
The header guard generated by clang-move isn't always a perfect
style, just avoid getting the header included multiple times during
compiling period.

Also, we can use llvm-Header-guard clang-tidy check to correct the guard
automatically.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284233
2016-10-14 13:01:36 +00:00
Haojian Wu 7bd492c53a [clang-move] Matching static class member more correctly.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284221
2016-10-14 10:07:58 +00:00
Marek Kurdej 505434bd28 [clang-tidy] Fix readability-braces-around-statements false positive
Summary:
This fixes a false-positive e.g. when string literals are returned from if statement.

This patch includes as well a small fix to includes and renames of the test suite that collided with the name of the check.

Reviewers: alexfh, hokein

Subscribers: hokein

Tags: #clang-tools-extra

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

llvm-svn: 284212
2016-10-14 08:10:08 +00:00
Eric Liu 6ed762ce18 [clang-move] error out when fail to create new files.
llvm-svn: 284155
2016-10-13 19:49:19 +00:00
Eric Liu 92db01ebd7 Print stack trace for clang-move tool.
llvm-svn: 284148
2016-10-13 19:04:19 +00:00
Eric Liu 3db05219f7 Print stack trace for clang-change-namespace tool.
llvm-svn: 284147
2016-10-13 18:56:14 +00:00
Haojian Wu e77bcc7371 [clang-move] Better support enclosing class.
Summary:
* When moving an outermost enclosing class, all its nested classes should also
  be moved together.
* Add a test for not moving nested class.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 284111
2016-10-13 10:31:00 +00:00
Haojian Wu 9df3ac1f56 Recommit r283538 "[clang-move] Support moving multiple classes in one run."
llvm-svn: 284109
2016-10-13 08:48:42 +00:00
Haojian Wu db72657774 [clang-move] Compare with real paths of symlinks
Summary: MakeAbsolutePath does wrong things with symlinks previously. When comparing with a symlink, we need to compare with the real path of it. This fixes issues when the build directory is a symlink.

Reviewers: ioeric

Subscribers: beanz, mgorny, cfe-commits, bkramer

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

llvm-svn: 284020
2016-10-12 15:50:30 +00:00
Eric Liu 73f49fd3f9 [change-namespace] don't miss comments in the beginning of a namespace block.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 284011
2016-10-12 12:34:18 +00:00
Marek Kurdej be07d1184b [clang-tidy-vs] Fix ClangTidy extension name in the manifest.
llvm-svn: 283986
2016-10-12 08:32:59 +00:00
Haojian Wu 4900c18d66 Revert "[ClangTidy] Add UsingInserter and NamespaceAliaser"
This reverts commit r283981. This patch breaks the buildbot.

llvm-svn: 283985
2016-10-12 08:19:44 +00:00
Haojian Wu 6c24d9345d [ClangTidy] Add UsingInserter and NamespaceAliaser
Summary: This adds helper classes to add using declaractions and namespace aliases to function bodies. These help making function calls to deeply nested functions concise (e.g. when calling helpers in a refactoring)

Patch by Julian Bangert!

Reviewers: alexfh, hokein

Subscribers: cfe-commits

Tags: #clang-tools-extra

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

llvm-svn: 283981
2016-10-12 07:59:54 +00:00
Malcolm Parsons 66b7014092 [clang-tidy] Ignore empty members and bases in cppcoreguidelines-pro-type-member-init
Summary: Empty/incomplete variables/members/bases don't need to be initialized

Reviewers: mgehre, aaron.ballman, alexfh

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 283886
2016-10-11 14:49:24 +00:00
Haojian Wu 09c8d2e19f [clang-tidy] Fix template agrument false positives in unused-using-decls.
Summary:
* Fix a false postive when an using class is used in an explicit template instantiation.
* Fix a false postive when an using template class is used as template argument.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 283879
2016-10-11 13:50:34 +00:00
Malcolm Parsons 8cb9b02c7e [clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix
Summary: Bugfix for 30398.  Don't warn for template instantiations

Reviewers: aaron.ballman, hokein, alexfh

Subscribers: omtcyfz, cfe-commits

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

llvm-svn: 283873
2016-10-11 12:02:16 +00:00
Malcolm Parsons 7a325537fb [clang-tidy] modernize-use-default default constructor bugfix
Summary:
Only member initializers that are written should prevent
using '= default' on a default constructor.

Reviewers: klimek, sbenza, aaron.ballman, alexfh

Subscribers: Eugene.Zelenko, alexfh, klimek, cfe-commits

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

llvm-svn: 283869
2016-10-11 10:47:06 +00:00
Malcolm Parsons f156079921 Fix typo in documentation
llvm-svn: 283865
2016-10-11 09:42:13 +00:00
Manuel Klimek 516a3df5cf clang-include-fixer.el: Don't prompt the user about killing clang-include-fixer processes
By default, Emacs prompts the user when killing processes on exit. This is useful for stateful processes such as interactive shells. However, clang-include-fixer processes are stateless; the only effect of killing them is to cancel a clang-include-fixer operation. Therefore prompting the user is just a nuisance.

Patch by Philipp Stephani.

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

llvm-svn: 283863
2016-10-11 09:21:20 +00:00
Manuel Klimek 750f6a780b Make Emacs libraries compatible with Emacs 24.
Emacs 24 doesn't have format-message, fall back to format in that case.

Patch by Philipp Stephani.

llvm-svn: 283861
2016-10-11 09:15:10 +00:00
Mehdi Amini 7ba59edbfb Fix clang-tools-extra build after r283815 (Store FileEntry::Filename as a StringRef instead of raw pointer)
llvm-svn: 283819
2016-10-10 23:24:16 +00:00
Haojian Wu eaf77911b2 [clang-tidy] Add a whitelist option in google-runtime-references.
Reviewers: aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 283777
2016-10-10 16:38:11 +00:00
Haojian Wu ea99ff719b [include-fixer] query-mode should be false by default.
Makes it consistent with documentations.

llvm-svn: 283754
2016-10-10 14:21:55 +00:00
Manuel Klimek 5f85048385 Use `let' instead of `let*' in one place where `let*' isn't necessary
Differential Revision: https://reviews.llvm.org/D25395

Patch by Philipp Stephani.

llvm-svn: 283736
2016-10-10 10:22:40 +00:00
Mehdi Amini 732afdd09a Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:

 va_start(ValueArgs, Desc);

with Desc being a StringRef.

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

llvm-svn: 283671
2016-10-08 19:41:06 +00:00
Renato Golin 0dccd1a0fd Revert "[clang-move] Support moving multiple classes in one run."
This reverts commit r283526 et al as it keeps randomly breaking bots, even after
the commit has gone, on other people's commit ranges.

Revert "[clang-move] Simplify lint tests" (r283545).
Revert "Fix buildbot error." (r283534).
Revert "Revert "fix buildbot error" since it is not right fix." (r283538).

llvm-svn: 283553
2016-10-07 13:58:10 +00:00
Haojian Wu 1854bd5ae8 [clang-move] Simplify lint tests
No need to use compilation database.

llvm-svn: 283545
2016-10-07 12:35:37 +00:00
Haojian Wu 91c3aa22a9 Revert "fix buildbot error" since it is not right fix.
llvm-svn: 283538
2016-10-07 10:59:03 +00:00
Haojian Wu 18424c8e5a Fix buildbot error.
The error maybe caused by the mixed environment of the two lint tests.
Cleanup the environment before running each test.

llvm-svn: 283534
2016-10-07 09:23:28 +00:00
Haojian Wu a709e384ce [clang-move] Support moving multiple classes in one run.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 283526
2016-10-07 08:29:20 +00:00
Mehdi Amini 9ff8e87ca4 Revert "Revert "Add a static_assert to enforce that parameters to llvm::format() are not totally unsafe""
This reverts commit r283510 and reapply r283509, with updates to
clang-tools-extra as well.

llvm-svn: 283525
2016-10-07 08:25:42 +00:00
Haojian Wu 9abbeaad55 [clang-move] Move comments which are associated with the moved class.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 283425
2016-10-06 08:59:24 +00:00
Haojian Wu 253d596d4a [clang-move] Cleanup around replacements.
Summary:
cleanup the remaining empty namespace after moving out the
class defintitions.

Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 283424
2016-10-06 08:29:32 +00:00
Haojian Wu b530f1649e [change-namespace] Pass Style to ChangeNamespaceTool.
llvm-svn: 283338
2016-10-05 17:00:40 +00:00
Eric Liu 447164dea2 [change-namespace] Fixed a bug in getShortestQualifiedNameInNamespace.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 283333
2016-10-05 15:52:39 +00:00
Haojian Wu 0e1a50e9c4 Overhaul clang-include-fixer.el
General overhaul to fix many coding bugs, simplify the code, and improve readability.

* Clarify documentation strings of user options.
* Say that clang-include-fixer-executable is a file to have auto completion.
* Allow user to select available options for clang-include-fixer-input-format. Turn it into a symbol as it's not a free-form string.
* Remove clang-include-fixer-query-mode. This option was apparently used to select between two different operation modes, which is not a typical use case for user options. Provide two separate commands instead.
* Add a face for the overlay highlighting so that users can customize it.
Move user commands to the front so that readers of the code aren't buried in internal functions.
* Make process calls asynchronous. This is possible here because clang-include-fixer doesn't change files in place. This means input is no longer blocked while clang-include-fixer is running.
* Factor out logic in helper functions to keep functions short.
* Add comments where appropriate.
* Provide an alternative buffer replacement strategy for the case that a single line was inserted (the normal case in the case of clang-include-fixer). This keeps point, markers, and other buffer information intact.
* Use let-alist and association lists instead of property lists to shorten the code.
* Instead of highlighting only the first occurrence of a symbol, highlight all occurrences and move point to the closest one.
* Detect qualified names at point.
* Use filepos-to-bufferpos if available.
* Formatting.

Patch by Philipp Stephani!

llvm-svn: 283306
2016-10-05 10:04:13 +00:00
Zachary Turner e97f6707c3 Make building the clang-tidy VS extension less spammy.
The package that strong name signs the 3rd party references
spams a ton of output to the log, making the build really ugly.
Make this quiet.

llvm-svn: 283261
2016-10-04 21:27:09 +00:00
Aaron Ballman fdaabf1ca7 Fix some false-positives with cppcoreguidelines-pro-type-member-init. Handle classes with default constructors that are defaulted or are not present in the AST.
Classes with virtual methods or virtual bases are not trivially default constructible, so their members and bases need to be initialized.

Patch by Malcolm Parsons.

llvm-svn: 283224
2016-10-04 14:48:05 +00:00
Haojian Wu ef445b7824 Fix a documentation warning.
llvm-svn: 283211
2016-10-04 10:40:52 +00:00
Haojian Wu ef8a6dcd09 [change-namespace] Fix a misplaced case when there is no trailing newline character at the end of the file.
Reviewers: ioeric

Subscribers: cfe-commits

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

llvm-svn: 283210
2016-10-04 10:35:53 +00:00
Haojian Wu c6f125e9a5 Fix windows builtbot error.
llvm-svn: 283205
2016-10-04 09:49:20 +00:00
Haojian Wu d2a6d7b203 [clang-move] Make it support both relative and absolute file path arguments.
Reviewers: ioeric

Subscribers: beanz, mgorny, cfe-commits

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

llvm-svn: 283202
2016-10-04 09:05:31 +00:00
Kirill Bobyrev bbce7e21e5 [clang-rename] Overhaul clang-rename.el.
* Use lexical binding, as recommended for new libraries.
* Fix customization variable (set correct group and type).
* Create a new customization group for the library.
* Autoload the main clang-rename command so that users don't have to explicitly load the library.
* Correctly translate between file and buffer positions using bufferpos-to-filepos (if available) or a fallback.
* Don't invoke the shell, it's not necessary and adds complexity.
* Save clang-rename output in a buffer and display that on failure.
* Save all buffers before calling clang-rename. This is required anyway and prevents data loss when the buffer is later reverted.
* In revert-buffer, use keywords instead of t for Boolean arguments to improve readability.
* Don't reset buffer modes when reverting.
* Emacs treats the character after a symbol as part of the symbol, while clang-rename doesn't; resolve this inconsistency.
* Formatting.

Patch by Philipp Stephani!

Reviewers: omtcyfz

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

llvm-svn: 283067
2016-10-02 14:51:33 +00:00
Richard Smith b6a5578c5c Fix tests to not assume they know exactly what will be in Clang's predefines buffer.
llvm-svn: 282984
2016-09-30 23:47:58 +00:00
Eric Liu 159f0135b1 [change-namespace] fix namespace specifier of global variables.
Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 282837
2016-09-30 04:32:39 +00:00
Matthias Gehre 6207d459a4 [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers
Summary:
This fixes https://llvm.org/bugs/show_bug.cgi?id=30487 where
```
warning: uninitialized record type: 's' [cppcoreguidelines-pro-type-member-init]
```
is emitted on
```
struct MyStruct
{
    int a = 5;
    int b = 7;
};

int main()
{
    MyStruct s;
}
```

Reviewers: alexfh, aaron.ballman

Subscribers: nemanjai, cfe-commits

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

llvm-svn: 282625
2016-09-28 20:06:18 +00:00
Eric Liu 912d039462 Workaround ASTMatcher crashes. Added some more test cases.
Summary:
- UsingDecl matcher crashed when `UsingShadowDecl` has no parent map. Workaround by moving parent check into `UsingDecl`.
- FunctionDecl matcher crashed when there is a lambda defined in parameter list (also due to no parent map).
  Workaround by putting `unless(cxxMethodDecl())` before parent check.

Reviewers: klimek, sbenza, aaron.ballman, hokein

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 282486
2016-09-27 12:54:48 +00:00
Haojian Wu 54f8efaa26 [include-fixer] Add customized editor settings documents.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 282480
2016-09-27 10:43:38 +00:00