Commit Graph

1826 Commits

Author SHA1 Message Date
Miklos Vajna e9c756512b clang-rename: fix the DynamicCastExpr test on ps4
It has RTTI disabled by default, so need to enable it explicitly.

Reviewers: silvas

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

llvm-svn: 272381
2016-06-10 08:29:02 +00:00
Eric Liu 1899d54ed0 [include-fixer] do not index friend function declaration.
Summary:
we want to exclude friend declaration, but the `DeclContext` of a
friend function declaration is not the class in which it is declared, so we need
to explicitly check if the parent is a `friendDecl`.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 272261
2016-06-09 14:18:40 +00:00
Richard Smith 22252f9847 Update to match LLVM r272232.
llvm-svn: 272235
2016-06-09 00:54:42 +00:00
Miklos Vajna 85b7b1c06a clang-rename: implement renaming of classes inside dynamic_cast
Refactor to do the same as what is done already for static_cast.

Reviewers: klimek

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

llvm-svn: 272188
2016-06-08 18:38:23 +00:00
Alexander Kornienko 3971dbac57 [clang-tidy] misc-argument-comment: don't bail out when an argument is a macro expansion (e.g. NULL).
Add CHECK-FIX tests.

llvm-svn: 272155
2016-06-08 15:27:46 +00:00
Haojian Wu 13d3048ced [include-fixer] Keep dot dot in SymbolInfo file paths.
Summary:
Currently, removing dot dot in header's path doesn't make include-fixer
minimize path correctly in some cases, for example, specify a relative search
path based on the build directory("-I../include/").

Besides, removing dot dot can break symbolic link directories. So don't
removing it for now.

Reviewers: ioeric, bkramer

Subscribers: cfe-commits

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

llvm-svn: 272152
2016-06-08 15:10:18 +00:00
Eric Liu 81689dab6c [include-fixer] explicitly set minimize-paths in test.
llvm-svn: 272151
2016-06-08 14:57:43 +00:00
Alexander Kornienko fb90b51e63 [clang-tidy] correct clang-tidy-diff.py help message
Summary:
Looks like the original code was copied from clang-format-diff.py.
Update help message to make it clang-tidy specific.

Reviewers: klimek, alexfh

Subscribers: Eugene.Zelenko, cfe-commits

Patch by Igor Sugak!

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

llvm-svn: 272144
2016-06-08 14:27:43 +00:00
Eric Liu 072ccfc997 [include-fixer] do not add enum forward declaration into symbol index table.
llvm-svn: 272132
2016-06-08 12:13:14 +00:00
Daniel Marjamaki 8ba0233e46 [clang-tidy] misc-macro-parentheses - avoid adding parentheses in variable declarations
Fixes bugzilla issues 26273 and 27399

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 272128
2016-06-08 10:30:24 +00:00
Eugene Zelenko 930e031d64 [Clang-tidy] Alphabetical checks order in release notes.
Highlight return statement in misc-unconventional-assign-operator documentation.

llvm-svn: 272042
2016-06-07 18:38:42 +00:00
Eugene Zelenko 04c14db108 [Clang-tidy] Documentation style consistency.
llvm-svn: 272038
2016-06-07 18:29:15 +00:00
Aaron Ballman 4c4bdba28a Fixing a build bot issue with duplicate explicit instantiations.
llvm-svn: 272027
2016-06-07 17:32:07 +00:00
Aaron Ballman d96ce2a94c Adding a release note for the misc-misplaced-const check added in r272025.
llvm-svn: 272026
2016-06-07 17:29:49 +00:00
Aaron Ballman cf6cefd88a Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type.
llvm-svn: 272025
2016-06-07 17:22:47 +00:00
Eric Liu f832eb7e9f [include-fixer] try to make vim header selection more friendly.
Summary: use 'input()' to get user's input so that we can support more options.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 272004
2016-06-07 12:21:43 +00:00
Alexander Kornienko 5ae76e09ad [clang-tidy] readability-identifier-naming - Support for Type Aliases
Summary: Added support for Type Alias declarations.

Reviewers: alexfh

Subscribers: cfe-commits

Patch by James Reynolds!

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

llvm-svn: 271992
2016-06-07 09:11:19 +00:00
Haojian Wu ba992cf3de [clang-tidy] Ignore the deleted function in misc-definitions-in-headers.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271991
2016-06-07 08:55:38 +00:00
Haojian Wu e64cee81bf [include-fixer] Mention more details in the document.
Reviewers: bkramer

Subscribers: Eugene.Zelenko, cfe-commits, ioeric

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

llvm-svn: 271989
2016-06-07 07:50:48 +00:00
Miklos Vajna b54a26d19d clang-rename: implement renaming of classes inside static_cast
"Derived" in static_cast<Derived&>(...) wasn't renamed, nor in its
pointer equivalent.

Reviewers: klimek

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

llvm-svn: 271933
2016-06-06 19:40:12 +00:00
Samuel Benzaquen 79c76101ce [clang-tidy] Do not try to suggest a fix if the parameter is partially in a macro.
It is not easy to tell where to do the suggestion and whether the
suggestion will be correct.

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

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

Reviewers: aaron.ballman, sbenza

Subscribers: Eugene.Zelenko, cfe-commits

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

llvm-svn: 271739
2016-06-03 21:22:58 +00:00
Benjamin Kramer b53452b2b1 [include-fixer] Be smarter about inserting symbols for a prefix.
If prefix search finds something where nothing can be nested under (e.g.
a variable or macro) don't add it to the result.

This is for cases like:
header.h:
  extern int a;

file.cc:
namespace a {
  SOME_MACRO
}

We will look up a::SOME_MACRO, which doesn't have any results. Then we
look up 'a' and find something before we ever look up just 'SOME_MACRO'.
With some basic filtering we can avoid this case.

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

llvm-svn: 271671
2016-06-03 14:07:38 +00:00
Haojian Wu 9c6cb035f3 [include-fixer] Don't add missing header if the unindentified symbol isn't from the main file.
Summary:
The further solution is to add the missing header to the file where the
symbol comes from.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271660
2016-06-03 11:26:02 +00:00
Eric Liu 5bc39ab592 [include-fixer] fixed a wrong header mapping.
llvm-svn: 271638
2016-06-03 09:33:22 +00:00
Eric Liu 1ebb7cf052 [include-fixer] added GNU symbols hardcoded header mapping.
Summary: [include-fixer] added GNU symbols hardcoded header mapping.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 271637
2016-06-03 09:25:03 +00:00
Haojian Wu d80c7c4808 [clang-tidy] Ignore function context in misc-unused-using-decls.
Summary: Make the check's behavior more correct when handling using-decls in multiple scopes.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271632
2016-06-03 08:05:11 +00:00
Miklos Vajna 617409f0c0 clang-rename: fix renaming heap allocations
The check failed, 'Cla *C = new Cla();' was renamed to 'D *C = new Cla();'.

Reviewers: klimek

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

llvm-svn: 271572
2016-06-02 20:00:22 +00:00
Samuel Benzaquen aa05ae91fb Fix uninitialized memory access when the token 'const' is not present in
the program.

If the token is not there, we still warn but we don't try to give a
fixit hint.

llvm-svn: 271426
2016-06-01 20:37:23 +00:00
Eric Liu 140b1fba91 [include-fixer] use includer of .inc header to be the file path of a symbol from .inc header.
Summary: added PathConfig.cpp and use includer of .inc header to be the file path of a symbol from .inc header.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271385
2016-06-01 12:01:06 +00:00
Haojian Wu 17a54e3618 [include-fixer] Use YAML format in -output-headers and -insert-header mode.
Summary:
And some improvements:
* Show better error messages on unfound symbols.
* Fix a typo.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271382
2016-06-01 11:43:10 +00:00
Eric Liu 74ccbd61af [include-fixer] disable path cleaning test for windows and mingw.
llvm-svn: 271321
2016-05-31 19:22:01 +00:00
Eric Liu 65cb39eb12 [find-all-symbols] remove dots in SymbolInfo file paths.
Summary: remove dots in SymbolInfo file paths.

Reviewers: bkramer, klimek

Subscribers: cfe-commits

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

llvm-svn: 271302
2016-05-31 17:37:38 +00:00
NAKAMURA Takumi e18fc2130d IncludeFixerTests: Update libdeps.
llvm-svn: 271295
2016-05-31 16:41:39 +00:00
Eric Liu 78985da8cc [include-fixer] removed unused forward declaration.
llvm-svn: 271294
2016-05-31 16:03:09 +00:00
Piotr Padlewski e93a73fb7a [ASTMatchers] Added ignoringParenImpCasts to has matchers
has matcher changed behaviour, and now it matches "as is" and
doesn't skip implicit and paren casts

http://reviews.llvm.org/D20801

llvm-svn: 271289
2016-05-31 15:26:56 +00:00
Eric Liu 516f18e515 [include-fixer] use clang-format cleaner to insert header.
Summary: clang-format's cleanupAroundReplacements() takes care of header insertions.

Reviewers: bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 271287
2016-05-31 14:48:45 +00:00
Benjamin Kramer a3f3a7bdd8 [include-fixer] Inline trivial methods.
Putting them into the .cpp file is both more verbose and slower than
having them in the header. No functional change intended.

llvm-svn: 271285
2016-05-31 14:40:10 +00:00
Benjamin Kramer 99985b864b [include-fixer] Use a DenseMap, order doesn't matter here.
llvm-svn: 271284
2016-05-31 14:37:10 +00:00
Benjamin Kramer 658d28014b [include-fixer] Rank symbols based on the number of occurrences we found while merging.
This sorts based on the popularity of the header, not the symbol. If
there are mutliple matching symbols in one header we take the maximum
popularity for that header and deduplicate. If we know nothing we sort
lexicographically based on the header path.

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

llvm-svn: 271283
2016-05-31 14:33:28 +00:00
Eric Liu f83187deb9 [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.
Summary: [include-fixer] use tooling::Replacements since the order of replacements don't matter anymore.

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

llvm-svn: 271279
2016-05-31 13:52:59 +00:00
Haojian Wu eb6ce0643d [include-fixer] Code cleanup.
Summary:
* Abstract the DB setting code to a function.
* Remove the unused FallbackStyle.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271273
2016-05-31 13:23:00 +00:00
Benjamin Kramer 03016b85b6 [find-all-symbols] Add a test to make sure merging actually works.
llvm-svn: 271270
2016-05-31 12:12:19 +00:00
Eric Liu c893070ff1 [include-fixer] collect the number of times a symbols is found in an indexing run and use it for symbols popularity ranking.
Summary:
[include-fixer] collect the number of times a symbols is found in an
indexing run and use it for symbols popularity ranking.

Reviewers: bkramer

Subscribers: cfe-commits, hokein, djasper

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

llvm-svn: 271268
2016-05-31 12:01:48 +00:00
Benjamin Kramer 8f961aab25 Make the vim integration output a bit prettier and drop the -debug flag.
llvm-svn: 271266
2016-05-31 11:28:34 +00:00
Haojian Wu e3801b0023 [include-fixer] Add missing dependency.
llvm-svn: 271261
2016-05-31 10:06:12 +00:00
Haojian Wu 11e9bd2450 [include-fixer] Create a mode in vim integration to show multiple potential headers.
Summary:
Some changes in the patch:

* Add two commandline flags in clang-include-fixer.
* Introduce a IncludeFixerContext for the queried symbol.
* Pull out CreateReplacementsForHeader.

Reviewers: bkramer

Subscribers: klimek, cfe-commits, ioeric

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

llvm-svn: 271258
2016-05-31 09:31:51 +00:00
Felix Berger 98e4019a58 [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified.
Summary:

Also trigger the check in the following case:

void foo() {
  ExpensiveToCopy Obj;
  const auto UnnecessaryCopy = Obj.constReference();
  Obj.onlyUsedAsConst();
}

i.e. when the object the method is called on is not const but is never
modified.

Reviewers: alexfh, fowles

Subscribers: cfe-commits

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

llvm-svn: 271239
2016-05-31 00:25:57 +00:00
Etienne Bergeron 6885229cb8 [clang-tidy] Remove redundant quote in add_new_check script
Summary:
Remove redundant quote.
These quotes were added here: http://reviews.llvm.org/D20766

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 271210
2016-05-30 15:42:08 +00:00
Etienne Bergeron 1c51a2d1d4 [clang-tidy] Fix script adding new clang-tidy check
Summary:
The `getName()` call is useless. It's better to show a better example
as tutorial.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271207
2016-05-30 15:05:10 +00:00
Haojian Wu 3b9f4cf462 Fix a wrong check in misc-unused-using-decls
Summary:
We should check whether a UsingDecl is defined in macros or in class
definition, not TargetDecls of the UsingDecl.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 271199
2016-05-30 07:42:22 +00:00
Benjamin Kramer bc90075629 [include-fixer] Add a missing .h.
llvm-svn: 270989
2016-05-27 12:49:58 +00:00
NAKAMURA Takumi 201c955fbc clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp: Tweak for r270775.
llvm-svn: 270841
2016-05-26 11:20:54 +00:00
Samuel Benzaquen 7663d3be15 Speed up check by using a recursive visitor.
Summary:
Use a recursive visitor instead of forEachDescendant() matcher.
The latter requires several layers of virtual function calls for each node and
it is more expensive than the visitor.
Benchmark results show improvement of ~6% walltime in clang-tidy.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 270714
2016-05-25 16:19:23 +00:00
Eric Liu fff1335fce [include-fixer] /usr/include/xlocal.h to include/xlocal.h in hardcoded map.
llvm-svn: 270703
2016-05-25 14:17:09 +00:00
Benjamin Kramer 0e871f0b66 Include local header with quotes instead of angle brackets.
This works by accident because we pass '-I.'

llvm-svn: 270701
2016-05-25 14:14:52 +00:00
Haojian Wu 218febb8eb [include-fixer] Simplify the code since we won't handle multiple includes at once.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 270700
2016-05-25 14:06:12 +00:00
Eric Liu 748308ad35 [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.
Summary: [include-fixer] moved STLPostfixMap into findAllSymbols library and make it a static variable in function.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 270696
2016-05-25 13:53:33 +00:00
Benjamin Kramer c85e14e0d6 [clang-tidy] Fix typo in test file name.
polo

llvm-svn: 270682
2016-05-25 09:44:35 +00:00
Miklos Vajna 10e25748b0 clang-rename: fix renaming non-members variables when referenced as macro arguments
The second check failed, FOO(C::X) wasn't renamed to FOO(C::Y).

Reviewers: klimek

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

llvm-svn: 270599
2016-05-24 19:08:53 +00:00
Benjamin Kramer e78ace55df [clang-tidy] Don't rely on <array> being available.
The STL isn't necessarily around when running tests. Make our own fake
std::array to test this.

llvm-svn: 270581
2016-05-24 16:54:26 +00:00
Eric Liu 54b68779b2 [include-fixer][find-all-symbols] added missing dependencies.
llvm-svn: 270578
2016-05-24 16:35:24 +00:00
Mads Ravn ef88dc8fe4 [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
Adding to revision 270567. The lit-style test was wrong. This is being fixed by this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270575
2016-05-24 16:09:24 +00:00
Eric Liu 0a28e680f7 [include-fixer][find-all-symbols] removed unused const member from YamlReporter to fix build bot failure.
llvm-svn: 270571
2016-05-24 15:34:37 +00:00
Mads Ravn 28cc243930 [clang-tidy] modernize-pass-by-value bugfix. Reverting lit-style test
Adding to revision 270565. The lit-style test was wrong. This is being fixed by this commit.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270567
2016-05-24 15:13:44 +00:00
Eric Liu a7d19414da [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.
Summary: [find-all-symbols] Added hardcode header mapping from header postfix to header name for STL symbols.

Reviewers: klimek, bkramer

Subscribers: cfe-commits, hokein

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

llvm-svn: 270566
2016-05-24 15:10:58 +00:00
Mads Ravn 7175c2ce4d [clang-tidy] modernize-pass-by-value bugfix
Modified the clang-tidy PassByValue check. It now stops adding std::move to type which is trivially copyable because that caused the clang-tidy MoveConstArg to complain and revert, thus creating a cycle.

I have also added a lit-style test to verify the bugfix.

This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731

This is the code review on phabricator: http://reviews.llvm.org/D20365

llvm-svn: 270565
2016-05-24 15:00:16 +00:00
Mads Ravn 86d5f8ad4c Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270473
2016-05-23 18:27:05 +00:00
Mads Ravn dfa3b3d3ee Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270472
2016-05-23 18:15:40 +00:00
Mads Ravn d01743a3f7 Commiting for http://reviews.llvm.org/D20365
llvm-svn: 270470
2016-05-23 18:06:29 +00:00
Alexander Kornienko 1c6d827015 Fix docs
llvm-svn: 270288
2016-05-20 22:42:03 +00:00
Alexander Kornienko 5d08bb72d9 [clang-tidy] Switch to a more common way of customizing check behavior.
This should have been done this way from the start, however I somehow missed
r257177.

llvm-svn: 270215
2016-05-20 13:42:40 +00:00
Haojian Wu cc0c10e300 [find-all-symbols] Some cleanups in unittest.
llvm-svn: 270211
2016-05-20 12:47:56 +00:00
Haojian Wu a23ac3d249 [find-all-symbol] Ignore inline namespace context.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270206
2016-05-20 12:04:56 +00:00
Miklos Vajna ed28d41b1a clang-rename: fix renaming members when referenced as macro arguments
The second check failed, FOO(C.X) wasn't renamed to FOO(C.Y).

Reviewers: klimek

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

llvm-svn: 270204
2016-05-20 11:43:59 +00:00
Eric Liu 6c9472c57f [find-all-symbols] fix failing unittest for Windows build bot.
llvm-svn: 270202
2016-05-20 11:14:36 +00:00
Haojian Wu 20dec208e9 [find-all-symbol] Try to fix the failure windows unittest.
llvm-svn: 270199
2016-05-20 10:36:53 +00:00
Haojian Wu 17baf85e41 [clang-tidy] Add more descriptive comments and examples in misc-definitions-in-headers check.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 270197
2016-05-20 09:38:25 +00:00
Eric Liu 81554e7257 [find-all-symbols] fixed FindAllMacros compilation error.
llvm-svn: 270196
2016-05-20 09:23:19 +00:00
Eric Liu 83a4d7fbba [find-all-symbols] make HeaderMapCollector optional in FindAllSymbols and FindAllMacros.
llvm-svn: 270193
2016-05-20 09:12:01 +00:00
Haojian Wu 1cea6e5531 [clang-tidy] Handle using-decls with more than one shadow decl.
Reviewers: alexfh

Subscribers: cfe-commits, djasper

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

llvm-svn: 270191
2016-05-20 08:34:32 +00:00
Haojian Wu 5e4f0255a1 [find-all-symbol] Add macro support.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 270189
2016-05-20 08:04:36 +00:00
Benjamin Kramer ee4e522c26 [include-fixer] Fix unused variable warning in Release builds.
llvm-svn: 270082
2016-05-19 16:57:57 +00:00
Haojian Wu 0de7226236 [include-fixer] Remove an unused local variable ExistingHeaders.
llvm-svn: 270059
2016-05-19 13:23:27 +00:00
Benjamin Kramer 9b15b6f2d7 [include-fixer] Make search handle fully qualified names correctly.
If a search string starts with "::" we don't want to return any results
for suffixes of that string.

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

llvm-svn: 270055
2016-05-19 12:41:56 +00:00
Benjamin Kramer 04666a2d5d [include-fixer] Remove obsolete windows hack.
llvm-svn: 270045
2016-05-19 11:39:56 +00:00
Alexander Kornienko a20bab46cd [clang-tidy] Fix/add style guide links.
Thanks to Tim Halloran for the initial patch (http://reviews.llvm.org/D15089)!

llvm-svn: 270033
2016-05-19 09:31:30 +00:00
Alexander Kornienko 77c8b2ed9f [clang-tidy] Fix doc titles.
llvm-svn: 270032
2016-05-19 09:29:46 +00:00
Eric Liu 702cfd1b2b [include-fixer] Sort headers after inserting new headers.
Summary: [include-fixer] Sort headers after inserting new headers.

Reviewers: bkramer

Subscribers: klimek, djasper, hokein, cfe-commits

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

llvm-svn: 270031
2016-05-19 08:21:09 +00:00
Benjamin Kramer 5e6b35f4d1 [include-fixer] Also look up prefixes of queries.
This is used to find nested classes. For a nested name foo::bar::qux we
will first look up foo::bar::qux, then foo::bar, then foo unless we find
a result. This is used to support nested classes which are not part of
the index but can only be used if the header for the parent context is
included.

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

llvm-svn: 269956
2016-05-18 16:42:38 +00:00
Miklos Vajna 5a6d2985d7 clang-rename: handle non-inline ctor definitions when renaming classes
The result of the test was C::D(), not D::D().

Reviewers: cfe-commits, klimek

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

llvm-svn: 269952
2016-05-18 16:12:48 +00:00
Haojian Wu 1bc05a681e [clang-tidy] Use unresolvedLookupExpr node matcher from ASTMatcher.
Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269928
2016-05-18 14:11:20 +00:00
Eric Liu c7f3b108e2 [clang-include-fixer] Added Vim integration for clang-include-fixer.
Summary: [clang-include-fixer] Added Vim integration for clang-include-fixer.

Reviewers: hokein, bkramer

Subscribers: cfe-commits

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

llvm-svn: 269927
2016-05-18 14:10:16 +00:00
Benjamin Kramer 6b5160a369 [include-fixer] Don't insert #includes if a fatal error occurred.
This typically happens when the user didn't setup include paths correctly
and the fixer starts adding garbage includes. Avoid that. Disable the error
limit though, as we might hit that easily with missing includes and still
want to fix those cases.

llvm-svn: 269923
2016-05-18 13:32:38 +00:00
Haojian Wu 4405d5b2cc [clang-tidy] Fix misc-unused-using-decls test failure in windows
buildbot.

llvm-svn: 269918
2016-05-18 13:07:13 +00:00
Haojian Wu 47ea5424d2 [clang-tidy] Fix a template function false positive in misc-unused-using-decls check.
Summary: Ignore warning uninstantiated template function usages.

Reviewers: djasper, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269906
2016-05-18 11:49:34 +00:00
Benjamin Kramer 8b55a2b76c [clang-tidy] Fix a functional change from r269656.
Instead of forming char ranges that patch made us form token ranges,
which behave subtly different. Sadly I'm only seeing this as part of a
larger test case that I haven't fully reduced yet.

llvm-svn: 269896
2016-05-18 09:48:46 +00:00
Benjamin Kramer 2ecd0902c7 [include-fixer] Run tests with -fno-ms-compatibility.
Something behind that flag makes us get fewer typo correction callbacks,
unbreak the tests on windows for now.

llvm-svn: 269894
2016-05-18 09:28:45 +00:00
Haojian Wu ff6d195c2d [include-fixer] Ignore non-scoped enum declaration during search.
Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269890
2016-05-18 09:04:43 +00:00
NAKAMURA Takumi e1f0ed0a1f findAllSymbols: Prune unused libdeps.
llvm-svn: 269875
2016-05-18 00:53:31 +00:00
NAKAMURA Takumi ea46e8b674 FindAllSymbolsTests doesn't require clangToolingCore.
llvm-svn: 269874
2016-05-18 00:53:27 +00:00
NAKAMURA Takumi 37c64ee4ec include-fixer: They require clangLex.
llvm-svn: 269873
2016-05-18 00:49:16 +00:00
NAKAMURA Takumi 62e8ec5721 IncludeFixerTest.cpp: Add explicit triple for some tests. They are failing for targeting *-win32.
llvm-svn: 269870
2016-05-18 00:20:46 +00:00
Etienne Bergeron e15ef2f609 [clang-tidy] Lift common matchers to utils namespace
Summary:
This patch is lifting matchers used by more than one checkers
to the common namespace.

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 269804
2016-05-17 19:36:09 +00:00
Miklos Vajna a7445f1b5e clang-rename: avoid StringRef members in USRLocFindingASTVisitor
Even if this is defined in the .cpp file and only used as part of the
function (so here it's safe), usually storing StringRefs in the class is
dangerous, so don't do so.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269796
2016-05-17 18:17:16 +00:00
Vedant Kumar 5119923cdd [clang-tidy] Skip misc-macro-parentheses for namespaces (Fix PR27400)
If a use of a macro argument is preceded by the `namespace` keyword, do
not warn that the use should be wrapped in parentheses.

Patch by Mads Ravn!

llvm-svn: 269786
2016-05-17 17:26:02 +00:00
Haojian Wu 2a6d78b820 [find-all-symbols] Add IWYU private pragma support.
Reviewers: djasper, klimek

Subscribers: kimgr, cfe-commits, bkramer, ioeric

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

llvm-svn: 269779
2016-05-17 16:48:49 +00:00
Haojian Wu 39170d70c0 [find-all-symbols] Ignore anonymous enum declarations.
llvm-svn: 269762
2016-05-17 13:38:18 +00:00
Benjamin Kramer af34e06c69 [include-fixer] Make the "extend to the right" hack support typos without nested names in the front.
This handles cases where the initial namespace is unknown.

llvm-svn: 269758
2016-05-17 12:35:18 +00:00
Etienne Bergeron 8d73de9eac [clang-tidy] Cleanups utils files
Summary:
Cleanup some code by using appropriate APIs.
Some coding style cleanups.

There is no behavior changes.

 - Function `IncludeSorter::CreateFixIt` can be replaced by `FixItHint::CreateReplacement`.
 - Function `cleanPath` is a wrapper for `llvm::sys::path::remove_dots`.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269656
2016-05-16 14:34:20 +00:00
Felix Berger 9435f54167 [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
Reviewers: alexfh, sbenza

Subscribers: etienneb, aaron.ballman, cfe-commits

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

llvm-svn: 269581
2016-05-14 22:43:50 +00:00
Eugene Zelenko 804e58d62e [Release notes] Mention Clang-tidy modernize-avoid-bind check.
Fix some problems in its documentation.

llvm-svn: 269517
2016-05-13 23:35:56 +00:00
Etienne Bergeron 8db5174395 [include-fixer] Fix broken dependency shared build
Summary:
The shared build is broken (again).

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Errors:
```
tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o: In function `(anonymous namespace)::includeFixerMain(int, char const**)':
ClangIncludeFixer.cpp:(.text._ZN12_GLOBAL__N_116includeFixerMainEiPPKc+0xbe9): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
collect2: error: ld returned 1 exit status
```

```
tools/clang/tools/extra/unittests/include-fixer/CMakeFiles/IncludeFixerTests.dir/IncludeFixerTest.cpp.o: In function `clang::include_fixer::(anonymous namespace)::runIncludeFixer(llvm::StringRef, std::vector<std::string, std::allocator<std::string> > const&)':
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x10e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x1dc): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x2f3): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x40e): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
IncludeFixerTest.cpp:(.text._ZN5clang13include_fixer12_GLOBAL__N_1L15runIncludeFixerEN4llvm9StringRefERKSt6vectorISsSaISsEE+0x526): undefined reference to `clang::find_all_symbols::SymbolInfo::SymbolInfo(llvm::StringRef, clang::find_all_symbols::SymbolInfo::SymbolKind, llvm::StringRef, int, std::vector<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string>, std::allocator<std::pair<clang::find_all_symbols::SymbolInfo::ContextType, std::string> > > const&)'
```

Reviewers: bkramer, hokein

Subscribers: cfe-commits

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

llvm-svn: 269441
2016-05-13 17:38:22 +00:00
Haojian Wu 57cdcb07d6 [include-fixer] Use scope contexts information to improve query.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269430
2016-05-13 15:44:16 +00:00
Etienne Bergeron a4bc53afba [clang-rename] Fix broken dependency on shared build.
Summary:
The build is broken due to a missing dependency.

To repro: [Release + Shared]
```
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
```

Which produce this error:
```
tools/clang/tools/extra/clang-rename/CMakeFiles/clangRename.dir/USRLocFinder.cpp.o: In function `clang::RecursiveASTVisitor<clang::rename::(anonymous namespace)::USRLocFindingASTVisitor>::TraverseCXXConstructorDecl(clang::CXXConstructorDecl*)':
USRLocFinder.cpp:(.text._ZN5clang19RecursiveASTVisitorINS_6rename12_GLOBAL__N_123USRLocFindingASTVisitorEE26TraverseCXXConstructorDeclEPNS_18CXXConstructorDeclE+0x170): undefined reference to `clang::Lexer::getSourceText(clang::CharSourceRange, clang::SourceManager const&, clang::LangOptions const&, bool*)'
```

Reviewers: alexfh, yaron.keren

Subscribers: yaron.keren, cfe-commits

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

llvm-svn: 269429
2016-05-13 15:38:54 +00:00
Haojian Wu 631e5f23f9 [include-fixer] Simplify unittest code.
Summary:
The InMemorySymbolIndex only constructs hard-coded Class symbols from a string
map. The patch provide a flexable way in InMemorySymbolIndex to create a custom
SymbolInfo in the include-fixer unittest.

Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269427
2016-05-13 15:17:17 +00:00
Haojian Wu db98f1d9c9 [find-all-symbols] Add EnumDecl type in YAML traits.
llvm-svn: 269422
2016-05-13 14:53:10 +00:00
Benjamin Kramer a3d823336a [include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.

llvm-svn: 269403
2016-05-13 09:27:54 +00:00
Miklos Vajna 1d48e50159 clang-rename: check that the source location we find actually has the old name
This more general check could have prevented the specific problem
"getSourceOrder() == -1" guards.

Reviewers: cfe-commits, klimek

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

llvm-svn: 269402
2016-05-13 09:17:32 +00:00
Haojian Wu 22014750b4 [find-all-symbols] Add enum type support.
Summary:
Also change enums defined in SymbolInfo to scoped enums to avoid
conflicts.

Reviewers: bkramer

Subscribers: cfe-commits, ioeric

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

llvm-svn: 269401
2016-05-13 09:15:37 +00:00
Felix Berger 6d3d746ff5 [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.
Summary: This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325

Reviewers: alexfh

Subscribers: cfe-commits

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

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

Not yet working for member functions.

Reviewers: aaron.ballman, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269341
2016-05-12 20:06:04 +00:00
Haojian Wu 7a4d510ccb [clang-tidy] Ignore using-declarations defined in marcro in misc-unused-using-decls checks.
Reviewers: djasper

Subscribers: cfe-commits

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

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

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

Also fixed support for template instantiation and added an unittest.

Reviewers: alexfh

Subscribers: klimek, Sarcasm, cfe-commits

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

llvm-svn: 269275
2016-05-12 04:32:47 +00:00
Etienne Bergeron 4bf0e62d5a [clang-tidy] Add missing dependency of libtooling to misc module
Summary:
The new API for fixit is in libtooling and the library misc in clang-tidy
didn't had the appropriate dependency.

This commit was breaking some build bots:
http://reviews.llvm.org/D19547

This commit tried (but failed) to fix it:
http://reviews.llvm.org/D20180

To repro, you can make a build with these flags:
```
cmake -DBUILD_SHARED_LIBS=ON
```

Thanks rnk@ for helping figuring out.

Reviewers: alexfh, rnk

Subscribers: cfe-commits

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

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

llvm-svn: 269229
2016-05-11 20:31:50 +00:00
Etienne Bergeron 8311c446fc [clang-tidy] Refactoring of FixHintUtils
Summary:
Refactor some checkers to use the tooling re-writing API.
see: http://reviews.llvm.org/D19941

Reviewers: klimek, alexfh

Subscribers: cfe-commits

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

llvm-svn: 269210
2016-05-11 17:38:22 +00:00
Etienne Bergeron e646a833ab [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker.
Summary:
Arguments can be swapped using fixit when they are not in macros.
This is the same implementation than SwappedArguments. Some code 
got lifted to be reused.

Others checks are not safe to be fixed as they tend to be bugs or errors.
It is better to let the user manually review them.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269208
2016-05-11 17:32:12 +00:00
Benjamin Kramer 79acc976ea [include-fixer] Always ignore SFINAE contexts.
This could lead to spurious includes being added for identifiers that
are supposed to be not available.

llvm-svn: 269195
2016-05-11 15:33:30 +00:00
Benjamin Kramer 3246fba975 [include-fixer] Also output the location where we found an unknown identifier.
For debugging only, makes it a bit easier when there are queries coming
out of headers.

llvm-svn: 269194
2016-05-11 15:33:28 +00:00
Haojian Wu 2d07ed4530 [include-fixer] Add lit-test for relative include path.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 269177
2016-05-11 12:30:45 +00:00
Haojian Wu 075ba119b2 [find-all-symbols] Save relative file path for each symbol.
Summary:
The HeaderSearch::suggestPathToFileForDiagnostics used in include-fixer
doesn't work well with absolute file path, it assumes a relative file
path based on header searching path.

So saving relative file path to make include-fixer get the most
appropriate header path.

Reviewers: bkramer

Subscribers: cfe-commits

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

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

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

llvm-svn: 269167
2016-05-11 09:44:10 +00:00
Haojian Wu 1a352d564f [find-all-symbols] Slim SymbolInfo.
Summary:
SymbolInfo has some optional fields, which is a bad-smell
implementation. For now, we

* remove the optional field since we don't need them (we can probably
  add them back if we actually need them in the future)
* make SymbolInfo to be a class.

By this change, the code is more simplified.

Reviewers: klimek

Subscribers: cfe-commits, ioeric, bkramer

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

llvm-svn: 269162
2016-05-11 08:38:21 +00:00
Miklos Vajna 6477682c98 clang-rename: fix renaming of field with implicit initializers
The last check failed as Cla::Cla() was rewritten to Cla::hector().

Reviewers: cfe-commits, klimek

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

llvm-svn: 269161
2016-05-11 08:08:07 +00:00
NAKAMURA Takumi c92b8e51ae Disable IncludeFixerTests/IncludeFixer.NestedName for now. It doesn't pass for targeting win32. Investigating.
llvm-svn: 269135
2016-05-10 22:46:32 +00:00
Etienne Bergeron de1ec03779 [clang-tidy] Lift parsing of sequence of names functions to utils.
Summary:
Lift some common code used by multiple checkers.

This function is also used by checkers that are coming.
It is quite common for a checker to parse a list of names.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 269065
2016-05-10 15:31:15 +00:00
Benjamin Kramer 8fd85a5788 [include-fixer] Default to YAML db, it's much more useful than the fixed dummy db.
llvm-svn: 269043
2016-05-10 11:35:47 +00:00
Benjamin Kramer 8fe4c159b5 [include-fixer] Remove unused includes and accessor.
llvm-svn: 269036
2016-05-10 10:12:00 +00:00
Benjamin Kramer 5471829351 [include-fixer] Emit some terminal output so users can see that the tool is working.
llvm-svn: 269030
2016-05-10 08:36:56 +00:00
Benjamin Kramer ad93500c52 [include-fixer] Work around partial names in both directions.
We already handled the case where we had a nested name specifier where
parts from the beginning don't get a callback, also handle the case
where the end doesn't get a callback. This happens with function calls
in unknown namespaces.

The way we do this for now based on character data is a bit of a hack, we
may need to refine this later or fix clang to produce different callbacks.

llvm-svn: 269029
2016-05-10 08:25:31 +00:00
Benjamin Kramer c3459a5002 [include-fixer] For now, only add the first suggested include.
We used a std::set which made the picked include somewhat random (well,
lexicographically sorted). Make the behavior more consistent by always
picking the first one we found.

llvm-svn: 269028
2016-05-10 08:25:28 +00:00
Haojian Wu bdb54eb457 Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields
Summary:
Fixed a crash in cppcoreguidelines-pro-type-member-init when checking record types with indirect fields pre-C++11.
Fixed handling of indirect fields so they are properly checked and suggested fixes are proposed.

Patch by Michael Miller!

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 269024
2016-05-10 07:42:19 +00:00
Benjamin Kramer b6aed5f441 [include-fixer] Autodetect yaml databases in parent directories.
This looks for find_all_symbols_db.yaml in all parent directories of the
source file (like we do for compile_commands.json) so we don't have to
pass the path manually.

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

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

Patch by Clement Courbet!

Reviewers: hokein

Subscribers: cfe-commits

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

llvm-svn: 268919
2016-05-09 13:43:58 +00:00
Haojian Wu 769eb0d5d5 Support variables and functions types in misc-unused-using-decls.
Summary: Fix PR27429.

Reviewers: djasper

Subscribers: cfe-commits

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

llvm-svn: 268917
2016-05-09 13:37:12 +00:00
Alexander Kornienko 5a520f6cd5 Trying to fix docs.
llvm-svn: 268905
2016-05-09 10:56:57 +00:00
Alexander Kornienko 5d0f2d2135 Fix docs.
llvm-svn: 268899
2016-05-09 10:00:52 +00:00
Miklos Vajna 0f450b6b9a clang-rename tests: move the run lines to the top of the test files
Summary: To be consistent with the other tests.

Reviewers: cfe-commits, klimek

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

llvm-svn: 268897
2016-05-09 08:47:18 +00:00
Miklos Vajna 65f088f528 clang-rename: when renaming a field, rename initializers of that field as well
Summary: The second check failed, the initializer wasn't renamed.

Reviewers: cfe-commits, klimek

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

llvm-svn: 268857
2016-05-07 14:32:59 +00:00
Eugene Zelenko 07fa815c65 [Documentation] List Clang-tidy checks alphabetically.
llvm-svn: 268659
2016-05-05 18:25:53 +00:00
Alexander Kornienko 1ccc219125 [clang-tidy] Improve -warnings-as-errors tests.
llvm-svn: 268579
2016-05-05 00:09:29 +00:00
Alexander Kornienko dbefbdb6d1 [clang-tidy] Apply NOLINT filtering to Clang warnings.
llvm-svn: 268555
2016-05-04 21:18:31 +00:00
Gabor Horvath 30e962a158 [clang-tidy] Remove STL dependency from a test.
llvm-svn: 268494
2016-05-04 12:17:55 +00:00
Gabor Horvath 112d1e80c0 [clang-tidy] New: checker misc-unconventional-assign-operator replacing misc-assign-operator-signature
Summary: Finds return statements in assign operator bodies where the return value is different from '*this'. Only assignment operators with correct return value Class& are checked.

Reviewers: aaron.ballman, alexfh, sbenza

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

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

llvm-svn: 268492
2016-05-04 12:02:22 +00:00
Manuel Klimek 13e2c1a709 When renaming a class, ename pointers to that class as well.
Patch by Miklos Vajna.

llvm-svn: 268484
2016-05-04 09:45:44 +00:00
Eric Liu 692aca6980 Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.
Summary: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

Reviewers: hokein, djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 268480
2016-05-04 08:22:35 +00:00
Felix Berger 99a0dddb3a [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.
Reviewers: alexfh

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 268461
2016-05-03 23:07:44 +00:00
Samuel Benzaquen 4e05b82cc4 [clang-tidy] Speedup misc-static-assert.
Summary:
Speedup the misc-static-assert check by not use `stmt()` as the toplevel matcher.
The framework runs a filter on the matchers before trying them on each node and
uses the toplevel type for this.
Using `stmt()` as the toplevel causes the matcher to be run on every `Stmt` node,
even if the node doesn't match the desired types.

This change speeds up clang-tidy by ~5% in a benchmark.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268430
2016-05-03 20:11:09 +00:00
Haojian Wu 2e1ebca2c4 Fix cppcoreguidelines-pro-type-member-init failure test on Windows.
llvm-svn: 268374
2016-05-03 11:19:46 +00:00
Haojian Wu a315dcb3da [include-fixer] Abstract includeFixerMain function.
llvm-svn: 268371
2016-05-03 08:38:35 +00:00
Haojian Wu b5cac80c77 Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base
Summary: Fix a crash when a record type initializes itself in its own base class initializer list.

Patch by Michael Miller!

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: cfe-commits

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

llvm-svn: 268369
2016-05-03 08:11:47 +00:00
Etienne Bergeron 2a4c00f243 [clang-tidy] Cleanup namespace in utils folder.
Summary:
This is a step forward cleaning up the namespaces in clang-tidy/utils.
There is no behavior change.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268356
2016-05-03 02:54:05 +00:00
Felix Berger b6947a5847 [clang-tidy] ProTypeMemberInitCheck - check that field decls do not have in-class initializer.
Reviewers: alexfh, JVApen, aaron.ballman

Subscribers: flx, aaron.ballman, cfe-commits

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

llvm-svn: 268352
2016-05-03 01:41:19 +00:00
Eugene Zelenko a19859d589 [Clang-tidy] Fix Clang-tidy modernize-use-override and some Include What You Use warnings in modernize/MakeSmartPtrCheck.h.
llvm-svn: 268349
2016-05-03 01:13:27 +00:00
Etienne Bergeron 456177b98f [clang-tidy] Cleaning namespaces to be more consistant across checkers.
Summary:
The goal of the patch is to bring checkers in their appropriate namespace.
This path doesn't change any behavior.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 268264
2016-05-02 18:00:29 +00:00
Eugene Zelenko a54a212d9d [include-fixer] Fix Clang-tidy modernize-use-override and some Include What You Use warnings.
Differential revision: http://reviews.llvm.org/D19755

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

http://reviews.llvm.org/D19183

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

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

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

llvm-svn: 268079
2016-04-29 17:58:29 +00:00
Piotr Padlewski 74ca1cc7d0 small reformat to test access
llvm-svn: 268076
2016-04-29 17:45:20 +00:00
Benjamin Kramer 683e592ff3 [find-all-symbols] Parallelize the merge step.
There is still more parallelism to get here because we synchonize on the
actual uniquing but just doing YAML parsing in parallel already gives a
significant speedup.

Merging all symbols in LLVM+clang+compiler-rt+lld+libc++, 48 cores.
before: 201.55s user 1.47s system 99% cpu 3:23.04 total
after:  276.99s user 7.63s system 838% cpu 33.947 total

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

llvm-svn: 268037
2016-04-29 12:46:27 +00:00
Benjamin Kramer 4f3c985edd Make run-find-all-symbols executable.
llvm-svn: 268022
2016-04-29 10:33:11 +00:00
Benjamin Kramer 027163e98b [find-all-symbols] Fix racy yaml file writing.
If multiple find-all-symbols processes access the temporary directory
simultaneously with two files with the same name they would collide and
create a broken yaml file. Fix this by using the safe createUniqueFile
API from LLVM instead.

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

llvm-svn: 268021
2016-04-29 10:16:28 +00:00
Haojian Wu e5966e7309 [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.
Reviewers: bkramer

Subscribers: cfe-commits

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

llvm-svn: 268019
2016-04-29 09:45:09 +00:00
Haojian Wu d8c12badad [include-fixer] Add Yaml database integration.
Reviewers: bkramer

Subscribers: cfe-commits, klimek, djasper

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

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

Reviewers: sbenza, aaron.ballman

Subscribers: michael_miller, flx, cfe-commits

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

llvm-svn: 267933
2016-04-28 20:20:01 +00:00
Benjamin Kramer 3a45fab72b [include-fixer] Add an option to minimize include paths.
This will always pick the shortest possible path based on -I options. Based
on the #include suggestion code for modules.

llvm-svn: 267868
2016-04-28 11:21:29 +00:00
Manuel Klimek bc5f581d47 Add missing newline in clang-rename output.
Patch by Miklos Vajna.

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

llvm-svn: 267855
2016-04-28 06:46:44 +00:00
NAKAMURA Takumi d016c3e3a0 FindAllSymbolsTest.CTypedefTest: Tweak for LLP64 like x86_64-win32.
In file included from symbol.cc:1:
  symbols.h:2:24: error: typedef redefinition with different types ('unsigned int'
        vs 'unsigned long long')
        typedef unsigned size_t;
                         ^

llvm-svn: 267841
2016-04-28 02:15:16 +00:00
Stephen Hines 15643352eb Fix include path in ClangTidy.cpp.
Summary:
https://llvm.org/bugs/show_bug.cgi?id=27355
To compile with other binary output directory structures in build systems like Android.

Reviewers: srhines, alexfh

Subscribers: tberghammer, danalbert, cfe-commits

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

llvm-svn: 267835
2016-04-28 01:42:12 +00:00
NAKAMURA Takumi f46c273977 clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp: Appease ms targets with -fno-delayed-template-parsing.
llvm-svn: 267828
2016-04-28 00:39:48 +00:00
Simon Pilgrim b9f255878e Wdocumentation fix
llvm-svn: 267786
2016-04-27 20:43:32 +00:00
David Blaikie 5593ce5633 Fix a bunch of sign-compare warnings
llvm-svn: 267754
2016-04-27 18:47:45 +00:00
Benjamin Kramer 5567ce0f98 [find-all-symbols] Also update unittest dependencies.
llvm-svn: 267739
2016-04-27 16:56:29 +00:00
Benjamin Kramer bac3a96389 [find-all-symbols] Clean up dependencies, fixing cmake shared build.
llvm-svn: 267738
2016-04-27 16:50:17 +00:00
Haojian Wu 8eb70bc625 Fix explain-check failure test on Windows.
llvm-svn: 267736
2016-04-27 16:39:42 +00:00
Haojian Wu 5b759f82fa Don't search compilation database in explain-check, fixing buildbot test
failure.

llvm-svn: 267731
2016-04-27 16:09:34 +00:00
Benjamin Kramer cf4c6d860a Add missing dependency.
llvm-svn: 267721
2016-04-27 14:32:36 +00:00
Haojian Wu f875acbd77 [include-fixer] Add a find-all-symbols tool for include-fixer.
Summary:
The find-all-symbols tool generates a yaml symbol database for
include-fixer.

The symbol matcher is originally written by Xiaoyi Liu.

Reviewers: bkramer, djasper

Subscribers: cfe-commits, klimek, ioeric

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

llvm-svn: 267719
2016-04-27 14:27:05 +00:00
Benjamin Kramer f412e9029d Clean up the include fixer 'driver' a bit and make the database configurable.
Also add a test for it. The library is covered by unit tests, the driver
was not.

llvm-svn: 267718
2016-04-27 14:24:32 +00:00
Haojian Wu 68d2b881d2 Remove explain-config testcase that detect hard-coded check.
Remove it for now, we need to better way to figure out how to test it.

llvm-svn: 267711
2016-04-27 13:23:39 +00:00
Haojian Wu 20d4c20bca Fix a crash in cppcoreguidelines-pro-type-member-init when checking a type with a template parameter as a base class.
Summary: Fixed a crash in cppcoreguidelines-pro-type-member-init when encountering a type that uses one of its template parameters as a base when compiling for C++98.

Patch by Michael Miller!

Reviewers: aaron.ballman, alexfh, hokein

Subscribers: cfe-commits

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

llvm-svn: 267700
2016-04-27 12:17:04 +00:00
Alexander Kornienko 493db093be clang-tidy -list-checks should exit with non-zero code when no checks are enabled.
llvm-svn: 267697
2016-04-27 11:45:14 +00:00
Haojian Wu cd32384539 Don't search compilation database in explain-check test.
Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 267687
2016-04-27 10:22:31 +00:00
Haojian Wu 12e6b8f929 [ClangTidy] Add an 'explain-checks' option to diagnose where each checks comes from.
Reviewers: alexfh

Subscribers: cfe-commits

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

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

llvm-svn: 267592
2016-04-26 19:33:49 +00:00
Alexander Kornienko 1af58fc1e5 [clang-tidy] Added misc-move-const-arg docs.
llvm-svn: 267587
2016-04-26 18:48:59 +00:00