Commit Graph

1266 Commits

Author SHA1 Message Date
Aaron Ballman af0159bafb Updating the documentation for the readability-inconsistent-declaration-parameter-name checker.
Patch by Piotr Dziwinski.

llvm-svn: 250194
2015-10-13 18:13:10 +00:00
Aaron Ballman d8e52d65f1 Appeasing build bots by linking in the proper libraries.
llvm-svn: 250166
2015-10-13 15:42:06 +00:00
Aaron Ballman 17b6feef69 Expose the clang-tidy misc-assign-operator-signature checker as cppcoreguidelines-c-copy-assignment-signature.
llvm-svn: 250165
2015-10-13 15:24:33 +00:00
Matthias Gehre dc48412c93 [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmetic
Summary:
This check flags all usage of pointer arithmetic, because it could lead
to an
invalid pointer.
Subtraction of two pointers is not flagged by this check.

Pointers should only refer to single objects, and pointer arithmetic is
fragile and easy to get wrong. array_view is a bounds-checked, safe type
for accessing arrays of data.

This rule is part of the "Bounds safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds1-dont-use-pointer-arithmetic-use-array_view-instead

Depends on D13313

Subscribers: cfe-commits

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

llvm-svn: 250116
2015-10-12 21:53:19 +00:00
Matthias Gehre a704d4bb27 [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast
Summary:
This check flags all usages of static_cast, where a base class is casted
to a derived class.
In those cases, a fixit is provided to convert the cast to a
dynamic_cast.

Use of these casts can violate type safety and cause the program to
access a variable that is actually of type X to be accessed as if it
were of an unrelated type Z.

This rule is part of the "Type safety" profile of the C++ Core
Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type2-dont-use-static_cast-downcasts-use-dynamic_cast-instead

Depends on D13313

Reviewers: alexfh, sbenza, bkramer, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 250098
2015-10-12 20:46:53 +00:00
Aaron Ballman 20c1971db3 Added documentation for misc-throw-by-value-catch-by-reference.
Patch by Tobias Langner.

llvm-svn: 250034
2015-10-12 12:57:55 +00:00
Matthias Gehre 36489cd39b Test commit
llvm-svn: 250002
2015-10-11 22:55:29 +00:00
Piotr Zegar 2e5bbce75f [clang-tidy] Python script for easy check rename
Summary:
Script can rename check that is in same module - I found it useful.

Diff generated in root directory of clang-tools-extra project.

Reviewers: sbenza, aaron.ballman, alexfh

Subscribers: mgehre, xazax.hun, cfe-commits

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

llvm-svn: 249970
2015-10-11 07:58:34 +00:00
Aaron Ballman f6e237e606 Explicitly enable -fcxx-exceptions for this test to appease Windows build bots.
llvm-svn: 249905
2015-10-09 21:15:00 +00:00
Aaron Ballman fd78cc88cf Add a new checker that tests whether a throw expression throws by value, and whether a catch statement catches by reference.
Patch by Tobias Langner!

llvm-svn: 249899
2015-10-09 20:42:44 +00:00
Aaron Ballman e4b1765a0f Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834
llvm-svn: 249727
2015-10-08 19:54:43 +00:00
Aaron Ballman 9ec7c3c72e Fixing links and reformatting code; NFC.
Patch by Marek Kurdej!

llvm-svn: 249612
2015-10-07 20:33:36 +00:00
Aaron Ballman fd3a3b3f29 Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.
llvm-svn: 249555
2015-10-07 15:14:10 +00:00
Aaron Ballman 0bf129823a Add checker for the C++ Core Guidelines: cppcoreguidelines-pro-type-const-cast.
Patch by Matthias Gehre!

llvm-svn: 249540
2015-10-07 12:24:57 +00:00
Benjamin Kramer ac8517c2bf [VFS] Switch clang-tidy tests to use an in-memory fs.
Again, this is both cleaner and completely removes any depedency on the
host file system.

llvm-svn: 249526
2015-10-07 08:35:23 +00:00
Aaron Ballman 017bfee456 Change the write modes to "binary" so that line endings do not get munged on Windows. Otherwise, when this script is run, all files created on Windows have CRLF instead of LF line endings.
llvm-svn: 249444
2015-10-06 19:11:12 +00:00
Aaron Ballman b92b47c6ff Attempting to appease the CMake build bots after r249429.
llvm-svn: 249430
2015-10-06 16:32:50 +00:00
Aaron Ballman fc4e042bf5 Improved the misc-move-constructor-init check to identify arguments that are passed by value but copy assigned to class data members when the non-deleted move constructor is a better fit.
Patch by Felix Berger!

llvm-svn: 249429
2015-10-06 16:27:03 +00:00
Angel Garcia Gomez 32af5bc51a Create interfaces and tests for the overlapping replacements fix in clang-tidy.
Summary: No changes in clang-tidy yet.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 249402
2015-10-06 13:52:51 +00:00
Aaron Ballman aaa4080d21 Add a new module for the C++ Core Guidelines, and the first checker for those guidelines: cppcoreguidelines-pro-type-reinterpret-cast.
Patch by Matthias Gehre!

llvm-svn: 249399
2015-10-06 13:31:00 +00:00
Aaron Ballman 46bc30472b Adding a checker (cert-dcl50-cpp) that detects the definition of a C-style variadic function in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function
llvm-svn: 249343
2015-10-05 20:08:59 +00:00
Angel Garcia Gomez b9f3059509 Use better mocks in modernize-make-unique, and fix matcher.
Summary: Add the second template argument to the unique_ptr mock, and update the matcher so that it only matches against cases where the second argument is the default.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 249305
2015-10-05 12:20:17 +00:00
Angel Garcia Gomez 199e5232b3 Document a bug in loop-convert and fix one of its subcases.
Summary: Now that we prioritize copying trivial types over using const-references where possible, I found some cases where, after the transformation, the loop was using the address of the local copy instead of the original object.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 249300
2015-10-05 11:15:39 +00:00
Angel Garcia Gomez c50b9fbb84 Fix bug in modernize-use-nullptr.
Summary:
https://llvm.org/bugs/show_bug.cgi?id=24960

modernize-use-nullptr would hit an assertion in some cases involving macros and initializer lists, due to finding a node with more than one parent (the two forms of the initializer list).

However, this doesn't mean that the replacement is incorrect, so instead of just rejecting this case I tried to find a way to make it work. Looking at the semantic form of the InitListExpr made sense to me (looking at both forms results in false negatives) but I am not sure of the things that we can miss by skipping the syntactic form.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

llvm-svn: 249291
2015-10-05 08:40:13 +00:00
Craig Topper 8f70a9f892 SourceRanges are small and trivially copyable, don't them by reference. NFC
llvm-svn: 249258
2015-10-04 04:53:37 +00:00
Yaron Keren 8b563665c3 Replace double negation of !FileID.isInvalid() with FileID.isValid().
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228.

llvm-svn: 249235
2015-10-03 10:46:20 +00:00
Aaron Ballman b91d64c6cc Taking a stab at fixing failing build bots that use make. Unfortunately, the build logs do not point to much useful information for tracking this down, such as:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/31782/steps/compile/logs/stdio

llvm-svn: 249136
2015-10-02 14:28:44 +00:00
Aaron Ballman 67e06ddb51 Hopefully rectifying a build bot issue with:
http://bb.pgr.jp/builders/i686-mingw32-RA-on-linux/builds/2833/steps/build_llvmclang/logs/stdio

Also, drive-by comment fix in a makefile.

llvm-svn: 249133
2015-10-02 14:01:55 +00:00
Aaron Ballman ea2f90c96b Adding a new clang-tidy module to house CERT-specific checkers, and map existing checkers to CERT secure coding rules and recommendations for both C (https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard) and C++ (https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637).
llvm-svn: 249130
2015-10-02 13:27:19 +00:00
Angel Garcia Gomez 88d204442b Handle trailing underscores on modernize-loop-convert variable namer.
Summary: https://llvm.org/bugs/show_bug.cgi?id=24961.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

llvm-svn: 249127
2015-10-02 13:20:11 +00:00
NAKAMURA Takumi 0ed0740c7e Fix the *unchecked* commit.
llvm-svn: 249100
2015-10-01 23:50:06 +00:00
Chris Bieneman 261d3ea0f8 [CMake] Don't include the test directories if CLANG_INCLUDE_TESTS is Off
This matches Clang's behavior.

llvm-svn: 249048
2015-10-01 18:16:56 +00:00
Angel Garcia Gomez 05ca3ec7d0 Update clang-tidy documentation.
Summary:
Improve modernize-use-auto documentation (https://llvm.org/bugs/show_bug.cgi?id=24962).
Add documentation for modernize-make-unique.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

llvm-svn: 249017
2015-10-01 14:50:40 +00:00
Angel Garcia Gomez 90bf895aa3 Prevent loop-convert from leaving empty lines after removing an alias declaration.
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=17716.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

llvm-svn: 249006
2015-10-01 13:08:21 +00:00
Alexander Kornienko eef2c237a5 [clang-tidy] fix add_new_check.py
Before this check, I would get the following error:

Updating ./misc/CMakeLists.txt...
Creating ./misc/NoReinterpret_castCheck.h...
Creating ./misc/NoReinterpret_castCheck.cpp...
Updating ./misc/MiscTidyModule.cpp...
Creating ../test/clang-tidy/misc-no-reinterpret_cast.cpp...
Creating ../docs/clang-tidy/checks/misc-no-reinterpret_cast.rst...
Traceback (most recent call last):

File "./add_new_check.py", line 271, in <module>
  main()
File "./add_new_check.py", line 267, in main
  update_checks_list(module_path)
File "./add_new_check.py", line 220, in update_checks_list
  os.listdir('docs/clang-tidy/checks')))
OSError: [Errno 2] No such file or directory: 'docs/clang-tidy/checks'

Patch by Matthias Gehre!

Differential revision: http://reviews.llvm.org/D13272

llvm-svn: 248997
2015-10-01 09:23:20 +00:00
Alexander Kornienko 30c423b1e3 [clang-tidy] Implement FixitHints for identifier references in IdentifierNamingCheck
This diff requires http://reviews.llvm.org/D13079 to be applied first. I wasn't sure about how to make patch series in Phabricator, and I wanted to keep the two separate for clarity.

It looks like that most cases can be supported with this patch. I'm not totally sure about the actual coverage though. I think that the matchers are very generic, but I'm still not totally fluent with the AST.

Patch by Beren Minor!

Differential revision: http://reviews.llvm.org/D13081

llvm-svn: 248996
2015-10-01 09:19:40 +00:00
Angel Garcia Gomez 2bfb7cbddb Add support for 'cbegin()' and 'cend()' on modernize-loop-convert.
Summary:
This fixes https://llvm.org/bugs/show_bug.cgi?id=22196 .

Also add a non-trivially copyable type to fix some tests that were meant to be about using const-refs, but were changed in r248438.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 248994
2015-10-01 08:57:11 +00:00
Aaron Ballman 8db15e4a4d Adding a checker (misc-non-copyable-objects) that detects situations where a non-copyable C type is being dereferenced, such as FILE or pthread_mutex_t. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FIO38-C.+Do+not+copy+a+FILE+object
llvm-svn: 248907
2015-09-30 14:09:38 +00:00
Alexander Kornienko 87e1da6205 [clang-tidy] Added missing check lines, made the checking stricter.
llvm-svn: 248899
2015-09-30 13:32:42 +00:00
Alexander Kornienko 08023c696d [clang-tidy] Fix an assertion in the readability-braces-around-statements check.
llvm-svn: 248895
2015-09-30 12:48:42 +00:00
Alexander Kornienko 42e651fa43 [clang-tidy] Better diagnostic in tests when clang-tidy fails.
llvm-svn: 248886
2015-09-30 10:41:53 +00:00
Aaron Ballman 0f28d62a12 Some of the build bots are unhappy about the overload of the global operator new() because it was accidentally marked noexcept instead of noexcept(false). This should correct those bots.
llvm-svn: 248797
2015-09-29 14:26:00 +00:00
Aaron Ballman 5edd83de91 Silencing bot failures a more creative and definitive way.
llvm-svn: 248794
2015-09-29 13:38:00 +00:00
Aaron Ballman 872c95c26f Hopefully silencing some built bot warnings. Note, this should be unsigned long instead of unsigned int, but then *other* builds start to fail because of duplicate redefinitions of size_t.
llvm-svn: 248792
2015-09-29 13:20:26 +00:00
Aaron Ballman de34985caa Adding a checker (misc-new-delete-overloads) that detects mismatched overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope
llvm-svn: 248791
2015-09-29 13:12:21 +00:00
Angel Garcia Gomez 26fd0e8b62 Create modernize-make-unique check.
Summary: create a check that replaces 'std::unique_ptr<type>(new type(args...))' with 'std::make_unique<type>(args...)'. It was on the list of "Ideas for new Tools". It needs to be tested more carefully, but first I wanted to know if you think it is worth the effort.

Reviewers: klimek

Subscribers: cfe-commits

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

llvm-svn: 248785
2015-09-29 09:36:41 +00:00
Aaron Ballman 176a1a3931 Fixing a sphinx warning.
llvm-svn: 248729
2015-09-28 19:27:37 +00:00
Guillaume Papin 68b591079a [clang-tidy] add option to specify build path
Summary:
compile_commands.json is usually generated in the build directory.
Projects like LLVM/Clang enforce out-of-source builds.
This option allow allow such projects to work out of the box, without
moving the compilation database manually.

The naming of the option is similar to the one use by other tools:

    clang-{check,modernize,query,rename,tidy} -p=<build_path> <...>

Reviewers: alexfh

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

llvm-svn: 248723
2015-09-28 17:53:04 +00:00
Manuel Klimek 55dc5df59f Install clang-query by default.
It is already installed by the autotools build, and it is useful for
developers who are not working on LLVM/Clang itself.

llvm-svn: 248710
2015-09-28 13:26:39 +00:00
Alexander Kornienko 3d77768e2a [clang-tidy] Code factorization and cleanup in IdentifierNamingCheck
This is to level the ground a little bit, in preparation for the changes in http://reviews.llvm.org/D13081.

Code factorization replaces all insertions to NamingCheckFailures map with a unique addUsage function that does the job.
There is also no more difference between the declaration and the references to a given identifier, both cases are treated as ranges in the Usage vector. There is also a check to avoid duplicated ranges to be inserted, which sometimes triggered erroneous replacements.

References can now also be added before the declaration of the identifier is actually found; this looks to be the case for example when a templated class uses its parameters to specialize its templated base class.

Patch by Beren Minor!

Differential revision: http://reviews.llvm.org/D13079

llvm-svn: 248700
2015-09-28 08:59:12 +00:00
Alexander Kornienko 501e6cd283 [clang-tidy] Removed a stray empty line in the docs.
llvm-svn: 248699
2015-09-28 08:52:55 +00:00
Alexander Kornienko 91b53846f7 [clang-tidy] Updated misc-unused-raii documentation.
llvm-svn: 248594
2015-09-25 17:50:11 +00:00
Angel Garcia Gomez 8535c6c278 Add NamingStyle option to modernize-loop-convert.
Summary: Add an option to specify wich style must be followed when choosing the new index name.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 248517
2015-09-24 17:02:19 +00:00
Angel Garcia Gomez bd432b2d04 Remove dangling parenthesis.
Summary: Remove parenthesis surrounding the new loop index.

Reviewers: klimek

Subscribers: cfe-commits, klimek

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

llvm-svn: 248507
2015-09-24 15:29:46 +00:00
Angel Garcia Gomez aed6dde955 Solve comment on rL248418.
Summary: Solve comment on rL248418.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 248489
2015-09-24 13:26:28 +00:00
Manuel Klimek a88ce501fe Use simpler interface for getting the pointee type for a node.
llvm-svn: 248449
2015-09-24 00:16:38 +00:00
Manuel Klimek b457b68f8d Fix loop-convert for trivially copyable types.
Previously, we would rewrite:
void f(const vector<int> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
to
  for (const auto &elem : v) {

Now we rewrite it to:
  for (auto elem : v) {
(and similarly for iterator based loops).

llvm-svn: 248438
2015-09-23 22:28:14 +00:00
Manuel Klimek 143b644238 Fix loop-convert for const references to containers.
Previously we would use a non-const loop variable in the range-based
loop for:
void f(const std::vector<int> &v) {
  for (size_t i = 0; i < v.size(); ++i) {
Now we use const auto&.

Note that we'll also want to use a copy at least for simple types.

llvm-svn: 248418
2015-09-23 18:40:47 +00:00
Daniel Jasper f631191305 misc-unused-parameter: Ignore lambda static invokers.
llvm-svn: 248252
2015-09-22 09:20:20 +00:00
Angel Garcia Gomez 415af0184c Replace references to "transform" with references to "check" where neccessary in the documentation.
Summary: Replace references to "transform" with references to "check" where neccessary in the documentation.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 248153
2015-09-21 12:53:30 +00:00
Alexander Kornienko 3e748fbd17 [clang-tidy] Fixed formatting of headings in the docs.
llvm-svn: 248151
2015-09-21 12:13:27 +00:00
Angel Garcia Gomez f41a631b50 Refactor LoopConvertCheck.
Summary: Reorder the code in a more logical and understandable way.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

llvm-svn: 248144
2015-09-21 09:32:59 +00:00
Craig Topper 18929c5069 Pass SourceLocation by value instead of by const reference since its just a 32-bit integer. NFC
llvm-svn: 248139
2015-09-21 01:33:03 +00:00
NAKAMURA Takumi e677e2f545 clang-tools-extra: Appease PR24881. [-Wdocumentation]
\returns doesn't accept \li, but \parblock \li.

llvm-svn: 248080
2015-09-19 02:21:28 +00:00
Angel Garcia Gomez b22084e113 Update clang-tidy documentation.
Summary: Update documentation of the modernize module with clang-modernize's documentation.

Subscribers: cfe-commits, klimek, alexfh

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

llvm-svn: 247987
2015-09-18 14:08:57 +00:00
Alexander Kornienko 8221ab3499 [clang-tidy] install helper scripts
Scripts are installed in same location as clang-fromat ones, so I think will be good idea to not create dedicated directory.

I checked this patch on my own build on RHEL 6.

Please check it in if it's OK, because I don't have SVN write access.

I think will be good idea to backport this patch to 3.7 release branch.

Probably same should be done for configure build.

Patch by Eugene Zelenko!

Differential revision: http://reviews.llvm.org/D12700

llvm-svn: 247890
2015-09-17 14:37:26 +00:00
Angel Garcia Gomez 387dc0b019 Add a test to modernize-loop-convert.
Summary: Add the test about replacements in several arguments of the same macro call, now that the problem has been fixed.

Reviewers: alexfh

Subscribers: cfe-commits, klimek

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

llvm-svn: 247889
2015-09-17 14:25:39 +00:00
Aaron Ballman b9ea09c445 Refactors AST matching code to use the new AST matcher names. This patch correlates to r247885 which performs the AST matcher rename in Clang.
llvm-svn: 247886
2015-09-17 13:31:25 +00:00
Alexander Kornienko c7a6b40d10 [clang-tidy] Ignore spaces in -checks=
llvm-svn: 247812
2015-09-16 16:16:53 +00:00
Alexander Kornienko 4d48e1e85b [clang-tidy] google-runtime-int: made the matcher more restricting, added a test for a false positive
This should be NFC.

llvm-svn: 247806
2015-09-16 15:08:46 +00:00
Alexander Kornienko f63f9e3d6a [clang-tidy] Make google-runtime-int configurable.
llvm-svn: 247803
2015-09-16 14:36:22 +00:00
Alexander Kornienko 63b0573a2c [clang-tidy] Added a style guide link.
llvm-svn: 247798
2015-09-16 13:54:16 +00:00
Alexander Kornienko be50698bfc [clang-tidy] Improve the help text for -dump-config.
llvm-svn: 247792
2015-09-16 13:21:57 +00:00
NAKAMURA Takumi e74d042ca6 Remove garbage. The issue was fixed in r246856.
llvm-svn: 247689
2015-09-15 14:01:09 +00:00
Alexander Kornienko 1395253bf3 [clang-tidy] Update check name in the comment. NFC.
llvm-svn: 247682
2015-09-15 13:13:48 +00:00
Alexander Kornienko 64aa388efa [clang-tidy] updated misc-sizeof-container docs.
llvm-svn: 247580
2015-09-14 16:56:57 +00:00
Alexander Kornienko 6ae0a630b8 [clang-tidy] misc-sizeof-container: remove fix-it hints
This turned out to be a rather noisy check, so automated fixes will only do
harm. Remove them completely.

llvm-svn: 247578
2015-09-14 16:51:52 +00:00
Alexander Kornienko 4cd7ad9727 [clang-tidy] misc-sizeof-container: whitelist std::array
llvm-svn: 247559
2015-09-14 13:55:29 +00:00
NAKAMURA Takumi fdaefe533b Prune CRLF.
llvm-svn: 247541
2015-09-14 11:13:39 +00:00
Marek Kurdej 099227a270 Test commit.
llvm-svn: 247536
2015-09-14 08:05:12 +00:00
Alexander Kornienko 541de378ce [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.
It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.

llvm-svn: 247489
2015-09-11 22:54:44 +00:00
Alexander Kornienko 2681e7dcd0 [clang-tidy] Fix minor issues in the testing script.
llvm-svn: 247485
2015-09-11 22:38:26 +00:00
Angel Garcia Gomez bb9ca54bbe Another patch for modernize-loop-convert.
Summary:
1. Avoid converting loops that iterate over the size of a container and don't use its elements, as this would result in an unused-result warning.
2. Never capture the elements by value on lambdas, thus avoiding doing unnecessary copies and errors with non-copyable types.
3. The 'const auto &' instead of 'auto &' substitution on const containers now works on arrays and pseudoarrays as well.
4. The error about multiple replacements in the same macro call is now documented in the tests (not solved though).
5. Due to [1], I had to add a dummy usage of the range element (like "(void) *It;" or similars) on the tests that had empty loops.
6. I removed the braces from the CHECK comments. I think that there is no need for them, and they confuse vim.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

llvm-svn: 247399
2015-09-11 10:02:07 +00:00
NAKAMURA Takumi d7df405580 clang-tidy/misc-sizeof-container.cpp: Add explicit triple.
For targeting LLP64, like Windows x86, size_t is not unsigned long.

  tools/clang/tools/extra/test/clang-tidy/Output/misc-sizeof-container.cpp.tmp.cpp:33:12: error: target of using declaration conflicts with declaration already in scope [clang-diagnostic-error]
  using std::size_t;
             ^

llvm-svn: 247394
2015-09-11 08:16:30 +00:00
NAKAMURA Takumi c3115d1c28 clang-tidy/readability-inconsistent-declaration-parameter-name.cpp: Appease MS-incompatibility [-fno-delayed-template-parsing]
llvm-svn: 247393
2015-09-11 08:16:22 +00:00
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
Aaron Ballman 7fc9feac3e Change the test to use the new python script instead of the more verbose RUN line.
llvm-svn: 245600
2015-08-20 19:21:07 +00:00
Alexander Kornienko 8e9110c160 [clang-tidy] Mention check_clang_tidy.py instead of check_clang_tidy.sh in the docs.
llvm-svn: 245587
2015-08-20 18:16:13 +00:00
Alexander Kornienko a7970eb424 [clang-tidy] Use check_clang_tidy.py instead of check_clang_tidy.sh by default.
llvm-svn: 245586
2015-08-20 18:11:13 +00:00
Alexander Kornienko 43556bb7f0 [clang-tidy] Use a python script instead of a shell script to run clang-tidy tests.
Summary:
Add check_clang_tidy.py script that is functionally identical to the
check_clang_tidy.py, but should also be functional on windows.

I've verified that the script works on linux. Would be nice if folks using
Windows could test the patch before I break windows bots ;)

Reviewers: chapuni, aaron.ballman

Subscribers: cfe-commits

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

llvm-svn: 245583
2015-08-20 17:58:07 +00:00
Aaron Ballman 9392ced263 Add a new clang-tidy check (misc-move-constructor-init) that diagnoses move constructor initializations that call copy constructors instead of move constructors.
llvm-svn: 245571
2015-08-20 15:52:52 +00:00
NAKAMURA Takumi ae6b329c8f Tweak clang-tidy-diff.py to pass JSON argument correctly to clang-tidy on win32 arg parser.
- Single quotation is not recognized.
  - Use """ to pass a double quotation.

It also reverts r211831.

llvm-svn: 245567
2015-08-20 15:04:46 +00:00
NAKAMURA Takumi 1544a819b7 Tweak clang-tools-extra/test/clang-tidy/file-filter.cpp to pass on win32.
FIXME: "-I %S/Inputs/file-filter/system/.." must be redundant.
On Win32, file-filter/system\system-header1.h precedes file-filter\header*.h due to code order between '/' and '\\'.

We should remove such a tweak to introduce the *right* path canonicalization.

Posix:
  file-filter/header*.h
  file-filter/system/system-header1.h

Win32:
  file-filter/system\system-header1.h
  file-filter\header*.h

Win32, tweaked:
  file-filter/system/..\header*.h
  file-filter/system\system-header1.h

It had been disabled since r220837.

llvm-svn: 245566
2015-08-20 15:04:39 +00:00
NAKAMURA Takumi ba598b5581 clang-tools-extra/test/lit.cfg: Prune an obsolete feature, python27. Now we requires python>=2.7.
clang-tools-extra/test/clang-tidy/clang-tidy-diff.cpp was the only user.

llvm-svn: 245565
2015-08-20 15:04:32 +00:00
Alexander Kornienko 74a44d9133 [clang-tidy] Fix bug in modernize-loop-convert check.
http://reviews.llvm.org/D12186

Patch by Angel Garcia!

llvm-svn: 245561
2015-08-20 13:18:23 +00:00
Benjamin Kramer e09303808a [clang-tidy] Fold the meat of the UseNullPtrCheck into an anonymous namespace.
While convenient, RecursiveASTVisitor generates a ridiculous amount of dead
template code. Making it not visible from the outside lets the compiler
eliminate some of it, shrinking clang-tidy by ~140k.

llvm-svn: 245548
2015-08-20 09:47:06 +00:00
Alexander Kornienko 20ce95f294 [clang-tidy] Add back a test with a custom NULL macro. Remove redundant default.
llvm-svn: 245533
2015-08-20 01:44:14 +00:00
Alexander Kornienko 0777b3cffe [clang-tidy] Fix use-after-free in UseNullptrCheck.
llvm-svn: 245524
2015-08-19 23:57:34 +00:00
Alexander Kornienko 87d89d2be1 [clang-tidy] Work around failure in Darwin.
llvm-svn: 245517
2015-08-19 23:03:23 +00:00
Alexander Kornienko 1b7bf7a2a7 [clang-tidy] Add modernize-use-nullptr check, attempt 2.
This patch re-applies r245434 and r245471 reverted in r245493, and changes the
way custom null macros are configured. The test for custom null macros is
temporarily excluded and will be committed separately to reduce chances of
breakages.

Initial patches by Angel Garcia.

llvm-svn: 245511
2015-08-19 22:21:37 +00:00
Daniel Jasper 8d90e533ea Remove empty destructors added in r245500. I got confused by my
YouCompleteMe setup which apparently doesn't find the base classes and
thus doesn't understand that there is an implicit virtual destructor.

llvm-svn: 245510
2015-08-19 22:04:55 +00:00