Commit Graph

358 Commits

Author SHA1 Message Date
Alexander Kornienko c5bc68e7ab [clang-tidy] Move google-readability-function check to readability-named-parameter.
Summary: The relevant style rule is going to be removed, thus the check is no longer needed in the Google module. Leaving the check in readability/ in case someone needs it.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 232431
2015-03-16 22:31:16 +00:00
Alexander Kornienko 57a5c6b56c Move remove-cstr-calls from a standalone executable to a clang-tidy check readability-redundant-string-cstr
http://reviews.llvm.org/D7318

Patch by Richard Thomson!

llvm-svn: 232338
2015-03-16 00:32:25 +00:00
Alexander Kornienko 1c4af5edf4 [clang-tidy] Fix false positives in the misc-static-assert check http://llvm.org/PR22880
The misc-static-assert check will not warn on assert(false), assert(False),
assert(FALSE); where false / False / FALSE are macros expanding to the false or
0 literals.

Also added corresponding test cases.

http://reviews.llvm.org/D8328

Patch by Szabolcs Sipos!

llvm-svn: 232306
2015-03-15 02:19:37 +00:00
Gabor Horvath 343832181b [clang-tidy] Static Analyzer checker configuration options pass-through.
Reviewed by: Alexander Kornienko

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

llvm-svn: 231941
2015-03-11 17:25:22 +00:00
Alexander Kornienko b2ddb8ac4d [clang-tidy] Fix assertion when a dependent expression is used in an assert.
llvm-svn: 231620
2015-03-09 02:27:57 +00:00
Alexander Kornienko ed07a255da [clang-tidy] Fix diag message in clang-tidy misc-uniqueptr-reset-release if right side is rvalue
http://reviews.llvm.org/D8071

Patch by Alexey Sokolov!

llvm-svn: 231365
2015-03-05 13:53:21 +00:00
Alexander Kornienko ad53695a09 [clang-tidy] Output more diagnostics in check_clang_tidy.sh
Print clang-tidy output and fixes applied.

llvm-svn: 231236
2015-03-04 12:07:50 +00:00
Filipe Cabecinhas 3be5b7fb43 Add -fexceptions for targets which need it
llvm-svn: 230994
2015-03-02 19:12:51 +00:00
Alexander Kornienko 1ca3b83255 [clang-tidy] Assert related checkers
This patch contains two assert related checkers. These checkers are the part of
those that is being open sourced by Ericsson
(http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-December/040520.html).

The checkers:

AssertSideEffect:
/// \brief Finds \c assert() with side effect.
///
/// The conition of \c assert() is evaluated only in debug builds so a condition
/// with side effect can cause different behaviour in debug / relesase builds.

StaticAssert:
/// \brief Replaces \c assert() with \c static_assert() if the condition is 
/// evaluatable at compile time.
///
/// The condition of \c static_assert() is evaluated at compile time which is
/// safer and more efficient.

http://reviews.llvm.org/D7375

Patch by Szabolcs Sipos!

llvm-svn: 230943
2015-03-02 10:46:43 +00:00
Alexander Kornienko dd836f238d [clang-tidy] Various improvements in misc-use-override
* Better error message when more than one of 'virtual', 'override' and 'final'
    is present ("X is/are redundant since the function is already declared Y").
  * Convert the messages to the style used in Clang diagnostics: lower case
    initial letter, no trailing period.
  * Don't run the check for files compiled in pre-C++11 mode
    (http://llvm.org/PR22638).

llvm-svn: 230765
2015-02-27 16:50:32 +00:00
Alexander Kornienko 6d02cc8d65 [clang-tidy] Correct spelling error in test file name. NFC.
Patch by Richard Thomson!
http://reviews.llvm.org/D7603

llvm-svn: 230491
2015-02-25 13:17:14 +00:00
Gabor Horvath ca0bbff3a7 [clang-tidy] Fixed a false positive case in misc-inaccurate-erase checker.
llvm-svn: 230483
2015-02-25 12:17:03 +00:00
Adrian Prantl 2be16291ff Revert "Add a missing target requirement."
This reverts commit 230430.

llvm-svn: 230455
2015-02-25 02:46:29 +00:00
Adrian Prantl beb52cfea0 Add a missing target requirement.
llvm-svn: 230430
2015-02-25 01:52:10 +00:00
John Thompson a5666cadbb Deleted module-map-checker, as it's been folded into modularize.
llvm-svn: 230014
2015-02-20 14:28:10 +00:00
John Thompson 8eb8d93672 Added module map coverage support, extracted from module-map-checker.
llvm-svn: 229869
2015-02-19 16:47:27 +00:00
John Thompson 41ede8e507 Fixed missing checkins.
llvm-svn: 229699
2015-02-18 17:08:00 +00:00
John Thompson 9cb7964641 Added support for extracting headers from module maps as a source for the header list.
llvm-svn: 229692
2015-02-18 16:14:32 +00:00
Gabor Horvath 21b76badeb [clang-tidy] Fixed two wrong fix-it cases in misc-inefficient-algorithm checker.
llvm-svn: 229552
2015-02-17 21:45:38 +00:00
NAKAMURA Takumi 43361ae42d clang-tools-extra/test/modularize/NoProblemsList.modularize: Unbreak test.
Don't expect the list were on the current directory.

llvm-svn: 228991
2015-02-13 00:28:21 +00:00
Gabor Horvath 0329519904 [clang-tidy] Fixed a false positive case in misc-inefficient-algorithm checker.
llvm-svn: 228945
2015-02-12 18:19:34 +00:00
John Thompson 97eac4089a Fix broken test in separate build tree.
llvm-svn: 228941
2015-02-12 17:52:28 +00:00
John Thompson 469bbc002a Added support for multiple header list files, as a precursor for when we need to load multiple module maps.
llvm-svn: 228935
2015-02-12 16:22:09 +00:00
John Thompson ecd3b04cd7 Added -block-check-header-list-only option. This is a work-around for private includes that purposefully get included inside blocks.
llvm-svn: 228846
2015-02-11 16:58:36 +00:00
John Thompson e0aa5fea15 Renamed module.map to module.modulemap.
llvm-svn: 228692
2015-02-10 14:29:16 +00:00
Gabor Horvath d4637fb433 [clang-tidy] Checker for inaccurate use of erase() method.
Algorithms like remove() does not actually remove any element from the
container but returns an iterator to the first redundant element at the end
of the container. These redundant elements must be removed using the
erase() method. This check warns when not all of the elements will be
removed due to using an inappropriate overload.

Reviewer: alexfh

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

llvm-svn: 228679
2015-02-10 09:14:26 +00:00
Samuel Benzaquen b5cbe0100f Verify assign operator signatures.
Summary: Warn when the return type of assign operators is not Class&.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 228583
2015-02-09 17:50:40 +00:00
Gabor Horvath 3880bee0ff [clang-tidy] Checker for inefficient use of algorithms on associative containers
Summary:
Associative containers implements some of the algorithms as methods which
should be preferred to the algorithms in the algorithm header. The methods
can take advantage of the order of the elements.

Reviewers: alexfh

Reviewed By: alexfh

Subscribers: cfe-commits

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

llvm-svn: 228505
2015-02-07 19:54:19 +00:00
Alexander Kornienko b6e1fde719 [clang-tidy] Don't ignore default set of checks when a config file is found.
Summary:
This makes clang-tidy merge the default set of checks with the one
provided in the configuration file instead of just using the checks from the
config file. This adds a way to modify the default set of checks while the
previous behavior required to always define the set of checks completely.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 228298
2015-02-05 14:50:17 +00:00
Alexander Kornienko dd2dad0d24 [clang-tidy] Detect dependent initializer_lists in google-explicit-constructor.
Summary:
Detect constructors taking a single std::initializer_list even when it
is instantiation-dependent.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 228289
2015-02-05 12:49:07 +00:00
Alexander Kornienko 78070fbae5 [clang-tidy] Fix some false positives in google-readability-casting
Summary:
Ignore C-style casts in extern "C" {} sections. Be more careful when
detecting redundant casts between typedefs to the same type - emit a more
specific warning and don't automatically fix them.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 227444
2015-01-29 15:17:13 +00:00
Alexander Kornienko e94b7c24c8 [clang-tidy] Use shrink_to_fit instead of copy and swap trick
The shrink_to_fit() method is more readable and more effective than
the copy and swap trick to reduce the capacity of a shrinkable container.
Note that, the shrink_to_fit() method is only available in C++11 and up.

Example:

std::vector<int>(v).swap(v); will be replaced with v.shrink_to_fit();

http://reviews.llvm.org/D7087

Patch by Gábor Horváth!

llvm-svn: 226912
2015-01-23 15:10:37 +00:00
Alexander Kornienko 4babd689f9 clang-tidy: 'size' call that could be replaced with 'empty' on STL containers
We are porting some of the checkers at a company we developed to the Clang Tidy
infrastructure. We would like to open source the checkers that may be useful
for the community as well. This patch is the first checker that is being ported
to Clang Tidy. We also added fix-it hints, and applied them to LLVM:
http://reviews.llvm.org/D6924

The code compiled and the unit tests are passed after the fixits was applied.

The documentation of the checker:

/// The emptiness of a container should be checked using the empty method
/// instead of the size method. It is not guaranteed that size is a
/// constant-time function, and it is generally more efficient and also shows
/// clearer intent to use empty. Furthermore some containers may implement the
/// empty method but not implement the size method. Using empty whenever
/// possible makes it easier to switch to another container in the future.

It also uses some custom ASTMatchers. In case you find them useful I can submit
them as separate patches to clang. I will apply your suggestions to this patch.

http://reviews.llvm.org/D6925

Patch by Gábor Horváth!

llvm-svn: 226172
2015-01-15 15:46:58 +00:00
Daniel Jasper 3b6018b9f6 clang-tidy: Add initial check for "Don't use else after return".
As per the LLVM coding standards:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

Initial version, probably still quite a bit to do until this is really
useful.

Review: http://reviews.llvm.org/D6927
llvm-svn: 226025
2015-01-14 19:37:54 +00:00
Daniel Jasper 0c7e93c128 Make LoopConvert work with containers that are used like arrays.
llvm-svn: 225629
2015-01-12 13:17:56 +00:00
Daniel Jasper 02c9153009 clang-tidy: [misc-use-override] Simplify regular expressions in test.
No functional changes.

llvm-svn: 225520
2015-01-09 14:10:15 +00:00
Daniel Jasper e73cfbf6ba clang-tidy: [misc-use-override] Fix 'override' insertion.
Before:
  void f() __attribute__((override unused))

After:
  void f() override __attribute__((unused))

llvm-svn: 225519
2015-01-09 13:56:35 +00:00
Nikola Smiljanic 76c21b5a27 Handle newlines on Windows correctly.
llvm-svn: 223750
2014-12-09 02:57:56 +00:00
Alexander Kornienko 980385095e [clang-tidy] google-runtime-int: Don't check C code.
llvm-svn: 223651
2014-12-08 11:17:25 +00:00
Alexander Kornienko bc0c423a46 [clang-tidy] Add clang-tidy check for unique_ptr's reset+release -> move
Replace x.reset(y.release()); with x = std::move(y);
If y is rvalue, replace with x = y; instead.

http://reviews.llvm.org/D6485

Patch by Alexey Sokolov!

llvm-svn: 223460
2014-12-05 11:59:05 +00:00
Alexander Kornienko 4cf0c18a5b [clang-tidy] Make a test independent of the default check set.
llvm-svn: 223232
2014-12-03 13:48:46 +00:00
Alexander Kornienko ad5074df0c [clang-tidy] google-explicit-constructor: don't match in template instantiations
This helps avoiding false positives related to the recently added
std::initializer_list<> handling.

llvm-svn: 222981
2014-11-30 19:41:41 +00:00
Alexander Kornienko 18bc3bf830 [clang-tidy] More tests for the google-explicit-constructor check
llvm-svn: 222924
2014-11-28 17:31:51 +00:00
Alexander Kornienko 15c5e6a597 [clang-tidy] Support initializer_list in google-explicit-constructor check
Summary:
According to the Google C++ Style Guide, constructors taking a single
std::initializer_list<> should not be marked explicit.

This change also changes the messages according to conventions used in Clang
diagnostics: no capitalization of the first letter, no trailing dot.

Reviewers: djasper

Reviewed By: djasper

Subscribers: curdeius, cfe-commits

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

llvm-svn: 222878
2014-11-27 11:11:47 +00:00
Daniel Jasper a3ec1a3267 clang-tidy: [misc-use-override] Add testcase with reversed attribute order
llvm-svn: 222755
2014-11-25 12:32:14 +00:00
Daniel Jasper 4525be4ebc clang-tidy: Add override before the first attribute.
Apparently attributes aren't sorted by source location.

llvm-svn: 222751
2014-11-25 10:45:23 +00:00
Alexander Kornienko b1f871cdcb [clang-tidy] Set google-readability-namespace-comments.ShortNamespaceLines to 10
This value is used in cpplint, so we'd better be consistent.

llvm-svn: 222431
2014-11-20 15:05:32 +00:00
Alexander Kornienko fc1dafba60 [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
This re-applies r222363 reverted in r222390 after compilation errors in our
out-of-tree clang-tidy tests were fixed.

llvm-svn: 222427
2014-11-20 12:05:51 +00:00
Hans Wennborg b4986e5a44 Revert r222363: "[clang-tidy] Count errors in ClangTidyDiagnosticConsumer"
This was causing clang-tidy invocations that would previously pass despite
source errors to fail.

llvm-svn: 222390
2014-11-19 22:02:11 +00:00
Alexander Kornienko efa443429d [clang-tidy] Count errors in ClangTidyDiagnosticConsumer
llvm-svn: 222363
2014-11-19 16:07:26 +00:00