Commit Graph

1134 Commits

Author SHA1 Message Date
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