Commit Graph

816 Commits

Author SHA1 Message Date
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
Chris Bieneman fc4fd529c8 NFC. Migrating clang-tools-extra to the cl::HideUnrelatedOptions API.
llvm-svn: 227388
2015-01-28 22:45:26 +00:00
Pete Cooper 1d2f63a4ef Updated tools to match r227345 which changed the getRegisteredOptions method
llvm-svn: 227372
2015-01-28 21:34:05 +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 a6354cae56 [clang-tidy] Small readability-container-size-empty cleanup
Utilized the hasEitherOperand instead of explicit anyOf.

http://reviews.llvm.org/D7142

Patch by Gábor Horváth!

llvm-svn: 226911
2015-01-23 14:43:06 +00:00
Alexander Kornienko bf87a8b714 Replace size call with empty call where appripriate in clang/tools/extra
This patch is the result of applying fixes of the ContainerSizeEmpty Clang-Tidy
checker which was committed recently.

http://reviews.llvm.org/D7085

Patch by Gábor Horváth!

llvm-svn: 226817
2015-01-22 13:14:29 +00:00
Alexander Kornienko 96e7b8b0c9 [clang-tidy] Use actual LangOptions.
llvm-svn: 226812
2015-01-22 12:40:47 +00:00
Alexander Kornienko febfd3453e [clang-tidy] Minor cleanups in readability-container-size-empty checker
* Removed an unused header
  * Simplified the custom ast_matchers

http://reviews.llvm.org/D7088

Patch by Gábor Horváth!

llvm-svn: 226810
2015-01-22 12:27:09 +00:00
Alexander Kornienko 9115a3af02 [clang-tidy] Make ClangTidyOptionsProvider::getOptions return by value.
Returning by reference limits possible implementations and doesn't bring any
benefits as all callers make copies of the returned value anyway.

llvm-svn: 226553
2015-01-20 09:48:51 +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
Hans Wennborg 859ea8056d docs/conf.py: bump version to 3.7
llvm-svn: 226015
2015-01-14 18:32:20 +00:00
Chandler Carruth 3cbd71c03b [cleanup] Re-sort the #include lines with llvm/utils/sort_includes.py
No functionality changed, this is just a mechanical cleanup to keep the
order of #include lines consistent across the project.

llvm-svn: 225976
2015-01-14 11:24:38 +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
Alexander Kornienko 284c249a63 Fixed a typo in a comment. NFC.
llvm-svn: 224581
2014-12-19 15:37:02 +00:00
Richard Smith 2cf124a9f3 Update to match clang r223913.
llvm-svn: 223914
2014-12-10 03:10:06 +00:00
Alexander Kornienko b0a9b70373 [clang-tidy] Fix a typo.
llvm-svn: 223777
2014-12-09 15:02:17 +00:00
Alexander Kornienko 423236bf0b [clang-tidy] Extended the example check, added a fix-it, etc.
llvm-svn: 223771
2014-12-09 12:43:09 +00:00
Daniel Jasper 4ecc8b30af clang-tidy: Add a basic python script to generate checks.
There are still a vast range of improvements that can be done to this,
but it seems like an ok initial version. Suggestions or patches are
highly welcome.

llvm-svn: 223766
2014-12-09 10:02:51 +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 d365731dd0 Make ArgumentsAdjuster an std::function (clang-tools-extra part of D6505).
Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

llvm-svn: 223249
2014-12-03 17:53:03 +00:00
Alexander Kornienko 5c423318c9 [clang-tidy] Update help messages and docs.
Fixed incorrect examples of configuration, clarified the usage of -dump-config.

llvm-svn: 223235
2014-12-03 14:03:03 +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
Richard Smith 4742353414 Update and simplify to match Clang r223095.
llvm-svn: 223098
2014-12-02 00:32:02 +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
David Blaikie 34318816e8 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
llvm-svn: 222336
2014-11-19 07:49:54 +00:00
David Blaikie 8e6cf9e579 Remove uses of StringMap::GetOrCreateValue in favor of stl-compatible API usage
llvm-svn: 222305
2014-11-19 03:05:07 +00:00
David Blaikie 206b15b2e4 Update for LLVM API change
llvm-svn: 222304
2014-11-19 03:04:29 +00:00
Alexander Kornienko b23eb5e3f7 [clang-tidy] Move the missing namespace comment warnings to the closing brace
Summary:
The google-readability-namespace-comments/llvm-namespace-comment
warnings are quite confusing when they appear at the beginning of a long
namespace and the closing brace is not in sight.

For convenience added notes pointing to the start of the namespace.

Reviewers: klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 222145
2014-11-17 17:32:32 +00:00
David Blaikie 0ee6800a31 Remove some redundant virtual on overridden functions
llvm-svn: 222027
2014-11-14 19:27:22 +00:00
Alexander Kornienko e553a93ba8 Regression test for the --serialize-diagnostics problem fixed in r221884.
llvm-svn: 221885
2014-11-13 13:09:16 +00:00
Alexander Kornienko e20ce07a2f [clang-tidy] google-readability-function: skip std::nullptr_t
Parameters of type std::nullptr_t can only have one value, so it doesn't make
sense to name them.

llvm-svn: 221340
2014-11-05 11:08:39 +00:00
Alexander Kornienko ddf9767a49 [clang-tidy] Don't print a message if there's no error.
llvm-svn: 221272
2014-11-04 15:25:22 +00:00
Rafael Espindola ecc2ebe846 Use findProgramByName. NFC.
llvm-svn: 221260
2014-11-04 12:48:22 +00:00
Alexander Kornienko 5eac3c6a44 [clang-tidy] Added -fix-errors option
Summary:
Added -fix-errors option to allow applying fixes when compiler errors
are present. Without this flag -fix would bail out if there are compiler errors.
This is needed to avoid applying wrong fixes if Clang fails to recover from
compilation errors correctly.

Reviewers: djasper, klimek

Reviewed By: klimek

Subscribers: curdeius, cfe-commits

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

llvm-svn: 221152
2014-11-03 14:06:31 +00:00
NAKAMURA Takumi 5f687a036f [CMake] clangApplyReplacement: Add clangAST in libdeps to appease msc builder.
clangApplyReplacements.lib(ApplyReplacements.cpp.obj) : error LNK2001: unresolved external symbol "private: void __thiscall clang::APValue::DestroyDataAndMakeUninit(void)" (?DestroyDataAndMakeUninit@APValue@clang@@AAEXXZ)

They are not seen in mingw dll build. Investigating.

llvm-svn: 220895
2014-10-30 03:22:32 +00:00
NAKAMURA Takumi 9f99a7a417 [CMake] Prune redundant libdeps.
llvm-svn: 220893
2014-10-30 01:37:44 +00:00
NAKAMURA Takumi dc872ed908 [CMake] Add dependencies on clangToolingCore.
llvm-svn: 220890
2014-10-30 00:44:01 +00:00