summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decayMatthias Gehre2015-10-267-0/+149
| | | | | | | | | | | | | | | | | | | | Summary: This check flags all array to pointer decays. Pointers should not be used as arrays. array_view is a bounds-checked, safe alternative to using pointers to access arrays. This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds3-no-array-to-pointer-decay Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13640 llvm-svn: 251358
* clang-tidy/add_new_check.py: Adapt to use %check_clang_tidy in testsMatthias Gehre2015-10-261-1/+1
| | | | | | | | | | | | Summary: Adapt clang-tidy/add_new_check.py according to commit r251010 "Add %check_clang_tidy and %clang_tidy_diff" Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14049 llvm-svn: 251355
* Drop dead return after llvm_unreachable. NFC.Benjamin Kramer2015-10-261-1/+0
| | | | llvm-svn: 251279
* assert(false) -> llvm_unreachable.Benjamin Kramer2015-10-251-1/+1
| | | | llvm-svn: 251265
* [clang-tidy] Add return value for non-assert builds.Daniel Jasper2015-10-251-0/+1
| | | | llvm-svn: 251262
* [clang-tidy] Another fix for failing buildbots regarding signedness of charPiotr Dziwinski2015-10-252-10/+10
| | | | | | | | | I totally forgot that char can be defined as unsigned on some platforms. Now I made explicit mention of signed type where necessary in tests. Also fixed '//RUN: ' header of cxx98 test to correct format. llvm-svn: 251244
* [clang-tidy] Fix for build bots not liking #include <cstddef>Piotr Dziwinski2015-10-252-2/+8
| | | | llvm-svn: 251239
* [clang-tidy] Add check readability-implicit-bool-castPiotr Dziwinski2015-10-259-0/+1101
| | | | | | | | | | | | | | | | | | | | | Summary: This is another check that I ported to clang-tidy from colobot-lint tool. As previously discussed on cfe-dev mailing list, this is one of those checks that I think is general and useful enough for contribution to clang-tidy. This patch contains implementation of check taken from colobot-lint, but it is extended a great deal, including FixIt hints for automated refactoring, exhaustive testcases, and user documentation. Reviewers: sbenza, aaron.ballman, alexfh Subscribers: Eugene.Zelenko Differential Revision: http://reviews.llvm.org/D13635 llvm-svn: 251235
* Test commitPiotr Dziwinski2015-10-241-2/+2
| | | | llvm-svn: 251204
* Make isExpensiveToCopy() tri-state.Manuel Klimek2015-10-234-9/+8
| | | | | | This allows returning "don't know" for dependent types. llvm-svn: 251103
* Switch check_clang_tidy to argparse and add a -resource-dir argument.Manuel Klimek2015-10-2236-44/+55
| | | | | | | -resource-dir can be used to inject non-standard resource dirs via the lit site config. llvm-svn: 251021
* Don't use "auto" on loops over fundamental types in modernize-loop-convert.Angel Garcia Gomez2015-10-227-115/+166
| | | | | | | | | | | | Summary: using "auto" on a loop that iterates over ints is kind of an overkill. Use the real type name instead. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13982 llvm-svn: 251015
* Correctly print the type in modernize-make-unique.Angel Garcia Gomez2015-10-222-2/+14
| | | | | | | | | | | | Summary: Take into account the current LangOptions the check has to add back the template argument. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13983 llvm-svn: 251013
* Add %check_clang_tidy and %clang_tidy_diff.Manuel Klimek2015-10-2282-82/+91
| | | | | | | | | | With this, site specific lit configs can inject parameters into the test scripts if they need site specific parameters. Next up: enable check_clang_tidy to take a resource dir to enable non-standard locations for builtin includes. llvm-svn: 251010
* Make string constants in the modernize module static.Angel Garcia Gomez2015-10-223-18/+18
| | | | | | | | | | | | Summary: Add static to global variables, if they are not in an anonymous namespace. Reviewers: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13975 llvm-svn: 251005
* clang-tools-extra/test/clang-tidy/cppcoreguidelines-pro-type-vararg.cpp: ↵NAKAMURA Takumi2015-10-221-1/+1
| | | | | | Tweak not to depend on out-of-tree header <cstdarg>. llvm-svn: 250986
* clang-tools-extra/test/clang-tidy/modernize-use-default.cpp: Appease MS mode.NAKAMURA Takumi2015-10-221-1/+1
| | | | llvm-svn: 250983
* [clang-tidy] add check cppcoreguidelines-pro-type-varargMatthias Gehre2015-10-217-4/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check flags all calls to c-style vararg functions and all use of va_list, va_start and va_arg. Passing to varargs assumes the correct type will be read. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right. This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type8-avoid-reading-from-varargs-or-passing-vararg-arguments-prefer-variadic-template-parameters-instead This commits also reverts "[clang-tidy] add cert's VariadicFunctionDefCheck as cppcoreguidelines-pro-type-vararg-def" because that check makes the SFINAE use of vararg functions impossible. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13787 llvm-svn: 250939
* Add modernize-use-default check to clang-tidy.Angel Garcia Gomez2015-10-217-3/+284
| | | | | | | | | | | | | | | | | | | Summary: Add a check that replaces empty bodies of special member functions with '= default;'. For now, it is only implemented for the default constructor and the destructor, which are the easier cases. The copy-constructor and the copy-assignment operator cases will be implemented later. I applied this check to the llvm code base and found 627 warnings (385 in llvm, 9 in compiler-rt, 220 in clang and 13 in clang-tools-extra). Applying the fixes didn't break any build or test, it only caused a -Wpedantic warning in lib/Target/Mips/MipsOptionRecord.h:33 becaused it replaced virtual ~MipsOptionRecord(){}; to virtual ~MipsOptionRecord()= default;; Reviewers: klimek Subscribers: george.burgess.iv, Eugene.Zelenko, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13871 llvm-svn: 250897
* Revert "Apply modernize-use-default to clang-tools-extra."David Blaikie2015-10-2010-13/+13
| | | | | | | | | Breaks the build in GCC 4.7.2 (see http://lab.llvm.org:8011/builders/perf-x86_64-penryn-O3 for example) This reverts commit r250824. llvm-svn: 250862
* Apply modernize-use-default to clang-tools-extra.Angel Garcia Gomez2015-10-2010-13/+13
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: klimek Subscribers: alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13889 llvm-svn: 250824
* Added check uniqueptr-delete-release to replace "delete x.release()" with "x ↵Samuel Benzaquen2015-10-197-0/+185
| | | | | | | | | | = nullptr" Reviewers: alexfh Differential Revision: http://reviews.llvm.org/D13179 llvm-svn: 250742
* Make a bunch of static arrays const.Craig Topper2015-10-1811-39/+44
| | | | llvm-svn: 250641
* [clang-tidy] add check cppcoreguidelines-pro-type-union-accessMatthias Gehre2015-10-167-0/+123
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This check flags all access to members of unions. Passing unions as a whole is not flagged. Reading from a union member assumes that member was the last one written, and writing to a union member assumes another member with a nontrivial destructor had its destructor called. This is fragile because it cannot generally be enforced to be safe in the language and so relies on programmer discipline to get it right. This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type7-avoid-accessing-members-of-raw-unions-prefer-variant-instead Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13784 llvm-svn: 250537
* Replacements in different files do not overlap.Angel Garcia Gomez2015-10-163-16/+41
| | | | | | | | | | | | Summary: Prevent clang-tidy from discarding fixes that are in different files but happen to have the same file offset. Reviewers: klimek, bkramer Subscribers: bkramer, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13810 llvm-svn: 250523
* Empty undefined static variable -> local variable.Benjamin Kramer2015-10-161-1/+1
| | | | | | Resolves a -Wundefined-internal warning from clang. llvm-svn: 250510
* Fix overlapping replacements in clang-tidy.Angel Garcia Gomez2015-10-163-71/+221
| | | | | | | | | | | | Summary: Prevent clang-tidy from applying fixes to errors that overlap with other errors' fixes, with one exception: if one fix is completely contained inside another one, then we can apply the big one. Reviewers: bkramer, klimek Subscribers: djasper, cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13516 llvm-svn: 250509
* [clang-tidy] add cert's VariadicFunctionDefCheck as ↵Matthias Gehre2015-10-152-0/+4
| | | | | | | | | | | | | | | | | 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 llvm-svn: 250468
* Use __SIZE_TYPE__ to fix buildbot failures.Angel Garcia Gomez2015-10-141-1/+1
| | | | | | | | | | | | Summary: Use __SIZE_TYPE__ to fix buildbot failures. Reviewers: klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13720 llvm-svn: 250288
* Prevent modernize-use-auto from emitting a warning when 'auto' was already ↵Angel Garcia Gomez2015-10-142-0/+8
| | | | | | | | | | | | | | 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 llvm-svn: 250284
* Support every kind of initialization.Angel Garcia Gomez2015-10-142-20/+118
| | | | | | | | | | | | 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 llvm-svn: 250283
* Exposing an existing checker under the name cert-err61-cpp, as it ↵Aaron Ballman2015-10-131-0/+3
| | | | | | corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR61-CPP.+Catch+exceptions+by+lvalue+reference llvm-svn: 250221
* Updating the documentation for the ↵Aaron Ballman2015-10-131-2/+13
| | | | | | | | readability-inconsistent-declaration-parameter-name checker. Patch by Piotr Dziwinski. llvm-svn: 250194
* Appeasing build bots by linking in the proper libraries.Aaron Ballman2015-10-131-0/+1
| | | | llvm-svn: 250166
* Expose the clang-tidy misc-assign-operator-signature checker as ↵Aaron Ballman2015-10-133-6/+15
| | | | | | cppcoreguidelines-c-copy-assignment-signature. llvm-svn: 250165
* [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmeticMatthias Gehre2015-10-127-0/+189
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcastMatthias Gehre2015-10-127-0/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Added documentation for misc-throw-by-value-catch-by-reference.Aaron Ballman2015-10-122-0/+12
| | | | | | Patch by Tobias Langner. llvm-svn: 250034
* Test commitMatthias Gehre2015-10-111-0/+1
| | | | llvm-svn: 250002
* [clang-tidy] Python script for easy check renamePiotr Zegar2015-10-111-0/+93
| | | | | | | | | | | | | | | 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
* Explicitly enable -fcxx-exceptions for this test to appease Windows build bots.Aaron Ballman2015-10-091-1/+1
| | | | llvm-svn: 249905
* Add a new checker that tests whether a throw expression throws by value, and ↵Aaron Ballman2015-10-095-0/+368
| | | | | | | | whether a catch statement catches by reference. Patch by Tobias Langner! llvm-svn: 249899
* Adding a checker (cert-err52-cpp) that detects use of setjmp or longjmp in ↵Aaron Ballman2015-10-087-0/+157
| | | | | | C++ code. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=1834 llvm-svn: 249727
* Fixing links and reformatting code; NFC.Aaron Ballman2015-10-076-13/+11
| | | | | | Patch by Marek Kurdej! llvm-svn: 249612
* Loosening the restriction on variadic function definitions so that extern ↵Aaron Ballman2015-10-072-3/+12
| | | | | | "C" function definitions are permissible. llvm-svn: 249555
* Add checker for the C++ Core Guidelines: cppcoreguidelines-pro-type-const-cast.Aaron Ballman2015-10-077-0/+87
| | | | | | Patch by Matthias Gehre! llvm-svn: 249540
* [VFS] Switch clang-tidy tests to use an in-memory fs.Benjamin Kramer2015-10-071-4/+8
| | | | | | | Again, this is both cleaner and completely removes any depedency on the host file system. llvm-svn: 249526
* Change the write modes to "binary" so that line endings do not get munged on ↵Aaron Ballman2015-10-061-7/+7
| | | | | | Windows. Otherwise, when this script is run, all files created on Windows have CRLF instead of LF line endings. llvm-svn: 249444
* Attempting to appease the CMake build bots after r249429.Aaron Ballman2015-10-061-0/+1
| | | | llvm-svn: 249430
* Improved the misc-move-constructor-init check to identify arguments that are ↵Aaron Ballman2015-10-0612-92/+368
| | | | | | | | 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
OpenPOWER on IntegriCloud