Commit Graph

1081 Commits

Author SHA1 Message Date
Alexander Kornienko 7532d3e93d [clang-tidy] Add misc-sizeof-container check to find sizeof() uses on stl
containers.

Summary:
sizeof(some_std_string) is likely to be an error. This check finds this
pattern and suggests using .size() instead.

Reviewers: djasper, klimek, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 247297
2015-09-10 16:37:46 +00:00
Alexander Kornienko 3285f1b850 [clang-tidy] add_new_check.py improvements: add doc file, refer it from .h
+ some console logging and minor cleanups.

llvm-svn: 247282
2015-09-10 13:56:39 +00:00
Alexander Kornienko a24501b2e1 [clang-tidy] Renamed tests files to be closer to the check names.
llvm-svn: 247266
2015-09-10 10:58:38 +00:00
Alexander Kornienko 11d4d6446e [clang-tidy] Add inconsistent declaration parameter name check
This is first of series of patches, porting code from my project colobot-lint,
as I mentioned recently in cfe-dev mailing list.

This patch adds a new check in readability module:
readability-inconsistent-declaration-parameter-name. I also added appropriate
testcases and documentation.

I chose readability module, as it seems it is the best place for it.

I think I followed the rules of LLVM coding guideline, but I may have missed
something, as I usually use other code formatting style.

http://reviews.llvm.org/D12462

Patch by Piotr Dziwinski!

llvm-svn: 247261
2015-09-10 10:07:11 +00:00
Alexander Kornienko f4e8b92ff5 Add a deprecation notice to the clang-modernize documentation.
Summary:
Add a deprecation notice to the clang-modernize documentation. Remove
the reference to the external JIRA tracker.

Reviewers: revane, klimek

Subscribers: cfe-commits

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

llvm-svn: 247258
2015-09-10 09:42:01 +00:00
Alexander Kornienko ffc277989b [clang-tidy] Fix PR22785.
Fix http://llvm.org/PR22785. Bug 22785 - readability-braces-around-statements
doesn't work well with macros.

http://reviews.llvm.org/D12729

Patch by Marek Kurdej!

llvm-svn: 247163
2015-09-09 17:06:09 +00:00
Alexander Kornienko d3e098140f [clang-tidy] Automatically redirect to the new page.
llvm-svn: 247153
2015-09-09 15:23:39 +00:00
Alexander Kornienko 16bb65431c Add a redirection page to unbreak external links.
Apparently, there are some links to http://clang.llvm.org/extra/clang-tidy.html
in the wild. It's better to keep them working.

llvm-svn: 247007
2015-09-08 12:26:32 +00:00
Alexander Kornienko 3f1153869f [clang-tidy] Fix run-clang-tidy.py.
Do not add "-*" to the list of checks. Make consistent the list of enabled
checks and the checks in use. Moreover, removing "-*" makes the behaviour
consistent with clang-tidy and allows user to use .clang-tidy configuration...

http://reviews.llvm.org/D12687

Patch by Marek Kurdej!

llvm-svn: 247002
2015-09-08 10:31:36 +00:00
Alexander Kornienko d96d89f6e5 [clang-tidy] Updated docs.
llvm-svn: 246996
2015-09-08 09:44:04 +00:00
Angel Garcia Gomez d930ef76ea Avoid using rvalue references with trivially copyable types.
Summary:
When the dereference operator returns a value that is trivially
copyable (like a pointer), copy it. After this change, modernize-loop-convert
check can be applied to the whole llvm source code without breaking any build
or test.

Reviewers: alexfh, klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 246989
2015-09-08 09:01:21 +00:00
Angel Garcia Gomez bd0ec69e0a Avoid repeated replacements on loop-convert check.
Summary: The InitListExpr subtree is visited twice, this caused the check to do multiple replacements. Added a set to avoid it.

Reviewers: klimek, alexfh

Subscribers: cfe-commits, alexfh

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

llvm-svn: 246879
2015-09-04 21:37:05 +00:00
Alexander Kornienko 13f0bb8b3a [clang-tidy] Fix llvm-include-order check on Windows.
IncludeDirectives struct used a StringRef that pointed to a stack variable
(SmallString<128> FilenameBuffer from PPDirectives.cpp:1513).

http://reviews.llvm.org/D12632

Patch by Marek Kurdej!

llvm-svn: 246856
2015-09-04 15:46:51 +00:00
Alexander Kornienko c0ebfbe5e1 [clang-tidy] Fix add_new_check.py.
This fixes the case where the check should be added at the end of
the list of checks in CMakeLists.txt of the corresponding module.
Before it was added after LINK_LIBS line.

http://reviews.llvm.org/D12629

Patch by Marek Kurdej!

llvm-svn: 246854
2015-09-04 14:56:57 +00:00
Angel Garcia Gomez 8d01772dae Two more fixes to loop convert.
Summary: Ensure that the alias has the same type than the loop variable. Now it works with lambda captures.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 246762
2015-09-03 12:28:11 +00:00
Aaron Ballman d428e203a0 Updating the code owners list.
llvm-svn: 246698
2015-09-02 20:00:41 +00:00
Aaron Ballman ec3e5d6fd8 Disable clang-tidy Google checkers when not compiling in C++ mode. None of the checkers require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.
llvm-svn: 246663
2015-09-02 16:20:42 +00:00
Aaron Ballman 1f1b067036 Disable clang-tidy readability checkers when not compiling in C++ mode. None of the checkers require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.
llvm-svn: 246661
2015-09-02 16:05:21 +00:00
Aaron Ballman 01cee3a7bd Move some more functionality into the AST consumer creation factory function, before registering matchers with the MatchFinder object. This allows us to set the language options for the ClangTidyContext object appropriately so that they can be used from registerMatchers(), and more closely models the way the clang-tidy tool works.
llvm-svn: 246660
2015-09-02 16:04:15 +00:00
Angel Garcia Gomez 8475466860 Fix loop-convert crash.
Summary: loop-convert no longer crashes when calling a member function using a member pointer which is a member of another record.

Reviewers: alexfh, klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 246655
2015-09-02 14:25:08 +00:00
Alexander Kornienko 84745524b3 [clang-tidy] Updated the check name in the doc.
llvm-svn: 246643
2015-09-02 12:01:51 +00:00
Angel Garcia Gomez e6035de11e Fix use-auto-check.
Summary: Fix a bug where use-auto check would crash when the definition of a type is in the same statement than its instantiation with new.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 246638
2015-09-02 10:20:00 +00:00
Yaron Keren 95e6d9ebbd Add \n to the regex in clang-tidy-diff.py in order to fix http://llvm.org/PR24637,
git usecase for multiple files diff.

llvm-svn: 246575
2015-09-01 19:08:17 +00:00
Angel Garcia Gomez 692cbb5bb0 Fix several corner cases for loop-convert check.
Summary: Reduced the amount of wrong conversions of this check.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 246550
2015-09-01 15:05:15 +00:00
Aaron Ballman c0dc76c251 Allow the static assert clang-tidy checker to run over C code.
llvm-svn: 246495
2015-08-31 21:54:42 +00:00
Aaron Ballman f444177d00 Help the clang-tidy helper script to understand C files better.
llvm-svn: 246494
2015-08-31 21:53:55 +00:00
Aaron Ballman bf89109013 Using an early return as it is more clear; NFC.
llvm-svn: 246447
2015-08-31 15:28:57 +00:00
Alexander Kornienko 54f3657448 [clang-tidy] misc-assert-side-effect: support assert macros defined through other macros
llvm-svn: 246446
2015-08-31 14:47:14 +00:00
Aaron Ballman a96b33b1b1 Using an early return as it is more clear; NFC.
llvm-svn: 246444
2015-08-31 14:23:21 +00:00
Alexander Kornienko 0ed6c478a4 [clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"
These checks are focusing on migrating the code from C++98/03 to C++11, so they
belong to the modernize module.

llvm-svn: 246437
2015-08-31 13:17:43 +00:00
Aaron Ballman ed5e4ef853 Updated to make use of the AST matcher instead of a custom matcher; NFC.
llvm-svn: 246325
2015-08-28 19:40:30 +00:00
Aaron Ballman 327e97bb37 Disable clang-tidy misc checkers when not compiling in C++ mode. Many of the checkers do not require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct.
llvm-svn: 246318
2015-08-28 19:27:19 +00:00
Aaron Ballman 8b0583ef1b Disable several more clang-tidy modernize checkers when not compiling in C++ mode. Loop conversion would make recommendations for C code, so added a test to ensure that does not happen. The pass by value, use auto and replace auto_ptr checkers would not make recommendations for C code, and are disabled for performance reasons, but do not require an extra test.
llvm-svn: 246310
2015-08-28 17:58:10 +00:00
Aaron Ballman f36a425eba Reapplying r246209, which exposed language options to the checkers. This time disable UseNullptrCheck when not compiling in C++ mode, but still allow in C++11 mode since it's likely the user wishes to modernize their code.
llvm-svn: 246298
2015-08-28 13:20:46 +00:00
Alexander Kornienko f0fa8a80a3 [clang-tidy] Documented the reason to run the test in C++98 mode.
llvm-svn: 246238
2015-08-27 23:43:39 +00:00
Aaron Ballman 46c9ae3578 Reverting r246209 while I investigate a build bot failure: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/30516
llvm-svn: 246224
2015-08-27 22:19:50 +00:00
Aaron Ballman ed916fa458 Expose language options to the checkers; disable UseNullptrCheck when not compiling in C++11 mode.
llvm-svn: 246209
2015-08-27 21:17:47 +00:00
Alexander Kornienko aabfadef84 [clang-tidy] Move clang-tidy docs to a separate directory. Create doc files for checks
The doc files for checks have been generated from the corresponding header files
using the docs/clang-tidy/tools/dump_check_docs.py script. Committing the script
as well, but the intention is to move all the user-facing docs from header files
to the rST files and add links to .h files appropriately.

llvm-svn: 246173
2015-08-27 18:10:07 +00:00
Alexander Kornienko 2588cb93af [clang-tidy] Renamed a test file to <check-name>.cpp.
llvm-svn: 246170
2015-08-27 18:03:37 +00:00
Alexander Kornienko f8ed0a8d35 [clang-tidy] Update docs for clang-tidy checks. NFC
Changes mostly address formatting and unification of the style. Use
MarkDown style for inline code snippets and lists. Added some text
for a few checks.

The idea is to move most of the documentation out to separate rST files and have
implementation files refer to the corresponding documentation files.

llvm-svn: 246169
2015-08-27 18:01:58 +00:00
Angel Garcia Gomez 8409e88fde Fix another LoopConvert fail.
Summary: Prevent LoopConvert from taking as alias anything that comes from a random member function call.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 246039
2015-08-26 17:08:24 +00:00
Angel Garcia Gomez 446fe8d62c LoopConvert no longer take as alias references to other containers.
Summary: Fix a bug where modernize-loop-convert check would take as alias a reference to other containers. Add the pertinent test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 246034
2015-08-26 14:51:11 +00:00
Angel Garcia Gomez 06d010cae3 Avoid LoopConvertCheck replacements in template instantiations.
Summary: Prevent LoopConvertCheck from doing replacements in template instantiations, and add a test.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 245942
2015-08-25 15:44:00 +00:00
Angel Garcia Gomez 190167104c Add replace-auto_ptr check.
Summary: Migrate replace-auto_ptr check from clang-modernize to modernize module in clang-tidy.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 245933
2015-08-25 13:03:43 +00:00
Angel Garcia Gomez df21015903 Tests no longer need the 'REQUIRES: SHELL' line.
Summary: Update python script, so that it doesn't print that line in new tests.

Reviewers: alexfh

Subscribers: klimek, cfe-commits

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

llvm-svn: 245926
2015-08-25 08:39:34 +00:00
Angel Garcia Gomez 5b9d33a5a1 [clang-tidy] Migrate UseAuto from clang-modernize to clang-tidy.
http://reviews.llvm.org/D12231

llvm-svn: 245703
2015-08-21 15:08:51 +00:00
Angel Garcia Gomez 485f38756d Test commit!
llvm-svn: 245701
2015-08-21 13:55:16 +00:00
Alexander Kornienko 36c8e56493 [clang-tidy] Remove check_clang_tidy.sh that has been replaced with check_clang_tidy.py.
llvm-svn: 245699
2015-08-21 12:41:14 +00:00
Yaron Keren 2ecb118a1d Make test EOL tolerant by moving the symbol ot the first line
before any EOL changes the byte offset count and enable it on Windows.

llvm-svn: 245688
2015-08-21 10:46:46 +00:00
Yaron Keren 92660a2cdd Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.
llvm-svn: 245683
2015-08-21 09:27:24 +00:00