Matthias Gehre
722d8490b9
[clang-tidy] add cert's VariadicFunctionDefCheck as cppcoreguidelines-pro-type-vararg-def
...
Summary:
Import the cert check for variadic function definitions into
cppcoreguidelines module to check part of
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead
Reviewers: alexfh, sbenza, bkramer, aaron.ballman
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D13785
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250468 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-15 22:40:45 +00:00
Angel Garcia Gomez
26123d013c
Use __SIZE_TYPE__ to fix buildbot failures.
...
Summary: Use __SIZE_TYPE__ to fix buildbot failures.
Reviewers: klimek
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D13720
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250288 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 10:30:32 +00:00
Angel Garcia Gomez
c3f968272f
Prevent modernize-use-auto from emitting a warning when 'auto' was already being used.
...
Summary: This fixes https://llvm.org/bugs/show_bug.cgi?id=25082 .
Reviewers: bkramer, klimek
Subscribers: cfe-commits, alexfh
Differential Revision: http://reviews.llvm.org/D13504
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250284 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 09:29:55 +00:00
Angel Garcia Gomez
5b943fc586
Support every kind of initialization.
...
Summary: modernize-make-unique now correctly supports the different kinds of list initialization.
Reviewers: klimek
Subscribers: cfe-commits, alexfh
Differential Revision: http://reviews.llvm.org/D13590
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250283 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-14 09:22:32 +00:00
Aaron Ballman
2a1e897cb3
Exposing an existing checker under the name cert-err61-cpp, as it corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR61-CPP.+Catch+exceptions+by+lvalue+reference
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250221 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 20:42:41 +00:00
Aaron Ballman
46286b135f
Updating the documentation for the readability-inconsistent-declaration-parameter-name checker.
...
Patch by Piotr Dziwinski.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250194 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 18:13:10 +00:00
Aaron Ballman
3d9368067c
Appeasing build bots by linking in the proper libraries.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250166 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 15:42:06 +00:00
Aaron Ballman
f535df4313
Expose the clang-tidy misc-assign-operator-signature checker as cppcoreguidelines-c-copy-assignment-signature.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250165 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 15:24:33 +00:00
Matthias Gehre
3105766d1d
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250116 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12 21:53:19 +00:00
Matthias Gehre
d07f76b209
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250098 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12 20:46:53 +00:00
Aaron Ballman
ff24fcc9fd
Added documentation for misc-throw-by-value-catch-by-reference.
...
Patch by Tobias Langner.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250034 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-12 12:57:55 +00:00
Matthias Gehre
31bffa336e
Test commit
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@250002 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-11 22:55:29 +00:00
Piotr Zegar
2f99922fc7
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249970 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-11 07:58:34 +00:00
Aaron Ballman
bfae702f9f
Explicitly enable -fcxx-exceptions for this test to appease Windows build bots.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249905 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 21:15:00 +00:00
Aaron Ballman
7819030d5a
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!
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 20:42:44 +00:00
Aaron Ballman
52781d8060
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
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249727 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 19:54:43 +00:00
Aaron Ballman
e815e70c6a
Fixing links and reformatting code; NFC.
...
Patch by Marek Kurdej!
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249612 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 20:33:36 +00:00
Aaron Ballman
08ae890c8b
Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 15:14:10 +00:00
Aaron Ballman
fa0bfc95a3
Add checker for the C++ Core Guidelines: cppcoreguidelines-pro-type-const-cast.
...
Patch by Matthias Gehre!
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249540 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 12:24:57 +00:00
Benjamin Kramer
3246d60aae
[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.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249526 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-07 08:35:23 +00:00
Aaron Ballman
3d6a247886
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.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 19:11:12 +00:00
Aaron Ballman
18de751e20
Attempting to appease the CMake build bots after r249429.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249430 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 16:32:50 +00:00
Aaron Ballman
5c40d3f5af
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!
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249429 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 16:27:03 +00:00
Angel Garcia Gomez
c4d6a6f1ef
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249402 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 13:52:51 +00:00
Aaron Ballman
d2ec07d917
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!
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249399 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 13:31:00 +00:00
Aaron Ballman
fcf78a42ad
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
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249343 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 20:08:59 +00:00
Angel Garcia Gomez
bc522ba6ce
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249305 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 12:20:17 +00:00
Angel Garcia Gomez
c820163ebb
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249300 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 11:15:39 +00:00
Angel Garcia Gomez
e294083dce
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 08:40:13 +00:00
Craig Topper
237f33a3cf
SourceRanges are small and trivially copyable, don't them by reference. NFC
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249258 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-04 04:53:37 +00:00
Yaron Keren
0004769e2a
Replace double negation of !FileID.isInvalid() with FileID.isValid().
...
+couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-03 10:46:20 +00:00
Aaron Ballman
65af29576f
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249136 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 14:28:44 +00:00
Aaron Ballman
c7847605a6
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.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249133 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 14:01:55 +00:00
Aaron Ballman
40646627cf
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 ).
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249130 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 13:27:19 +00:00
Angel Garcia Gomez
2c5fed3800
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249127 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 13:20:11 +00:00
NAKAMURA Takumi
3dc8dbe628
Fix the *unchecked* commit.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249100 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 23:50:06 +00:00
Chris Bieneman
b2049c67f3
[CMake] Don't include the test directories if CLANG_INCLUDE_TESTS is Off
...
This matches Clang's behavior.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249048 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 18:16:56 +00:00
Angel Garcia Gomez
d16c266727
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249017 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 14:50:40 +00:00
Angel Garcia Gomez
914d6af0ea
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@249006 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 13:08:21 +00:00
Alexander Kornienko
6ca8fa5c16
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248997 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 09:23:20 +00:00
Alexander Kornienko
da72ce1a7a
[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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248996 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 09:19:40 +00:00
Angel Garcia Gomez
4c33686a42
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
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248994 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 08:57:11 +00:00
Aaron Ballman
31ab7f0dc9
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
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248907 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 14:09:38 +00:00
Alexander Kornienko
3534791046
[clang-tidy] Added missing check lines, made the checking stricter.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248899 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 13:32:42 +00:00
Alexander Kornienko
5726ddb8af
[clang-tidy] Fix an assertion in the readability-braces-around-statements check.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248895 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 12:48:42 +00:00
Alexander Kornienko
8a772cdfc8
[clang-tidy] Better diagnostic in tests when clang-tidy fails.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248886 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-30 10:41:53 +00:00
Aaron Ballman
8c7e0deeae
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.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248797 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 14:26:00 +00:00
Aaron Ballman
cb1ea4a031
Silencing bot failures a more creative and definitive way.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248794 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:38:00 +00:00
Aaron Ballman
91c3260b19
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.
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248792 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:20:26 +00:00
Aaron Ballman
2c2b89e115
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
...
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@248791 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29 13:12:21 +00:00