summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/cppcoreguidelines
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Cleaning namespaces to be more consistant across checkers.Etienne Bergeron2016-05-0218-5/+41
| | | | | | | | | | | | | | Summary: The goal of the patch is to bring checkers in their appropriate namespace. This path doesn't change any behavior. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19811 llvm-svn: 268264
* [clang-tidy] cppcoreguidelines-pro-type-member-init should not complain ↵Alexander Kornienko2016-04-281-0/+1
| | | | | | | | | | | | | | | | about static variables Summary: Variables with static storage duration are zero-initialized per [stmt.dcl]p4 and [basic.start.init]p2. Reviewers: sbenza, aaron.ballman Subscribers: michael_miller, flx, cfe-commits Differential Revision: http://reviews.llvm.org/D19672 llvm-svn: 267933
* Fix a crash in cppcoreguidelines-pro-type-member-init when checking a type ↵Haojian Wu2016-04-271-2/+6
| | | | | | | | | | | | | | | | with a template parameter as a base class. Summary: Fixed a crash in cppcoreguidelines-pro-type-member-init when encountering a type that uses one of its template parameters as a base when compiling for C++98. Patch by Michael Miller! Reviewers: aaron.ballman, alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19539 llvm-svn: 267700
* clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp: Use ↵NAKAMURA Takumi2016-04-231-1/+1
| | | | | | raw_string_ostream::str() to flush the buffer explicitly. llvm-svn: 267290
* Fix a crash in cppcoreguidelines-pro-type-member-init related to missing ↵Haojian Wu2016-04-201-6/+4
| | | | | | | | | | | | | | | | constructor bodies. Summary: Fixes a crash in cppcoreguidelines-pro-type-member-init when checking some record types with a constructor without a body. We now check to make sure the constructor has a body before looking for missing members and base initializers. Patch by Michael Miller! Reviewers: aaron.ballman, alexfh, hokein Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19270 llvm-svn: 266862
* [Clang-tidy] Fix extra semicolon warning in ↵Eugene Zelenko2016-04-191-2/+2
| | | | | | cppcoreguidelines/ProTypeMemberInitCheck.cpp. llvm-svn: 266795
* Complete support for C++ Core Guidelines Type.6: Always initialize a member ↵Alexander Kornienko2016-04-132-138/+355
| | | | | | | | | | | | | | | | variable. Summary: Added the remaining features needed to satisfy C++ Core Guideline Type.6: Always initialize a member variable to cppcoreguidelines-pro-type-member-init. The check now flags all default-constructed uses of record types without user-provided default constructors that would leave their memory in an undefined state. The check suggests value initializing them instead. Reviewers: flx, alexfh, aaron.ballman Subscribers: klimek, aaron.ballman, LegalizeAdulthood, cfe-commits Patch by Michael Miller! Differential Revision: http://reviews.llvm.org/D18584 llvm-svn: 266191
* [clang-tidy] cppcoreguidelines-interfaces-global-initAlexander Kornienko2016-04-084-0/+98
| | | | | | | | | | | | | | | | Summary: This check flags initializers of globals that access extern objects, and therefore can lead to order-of-initialization problems (this recommandation is part of CPP core guidelines). Note that this only checks half of the guideline for now (it does not enforce using constexpr functions). Reviewers: aaron.ballman, alexfh Subscribers: aaron.ballman, etienneb, Eugene.Zelenko, cfe-commits Patch by Clement Courbet! Differential Revision: http://reviews.llvm.org/D18649 llvm-svn: 265774
* Fix crashes from delayed template parsing code that assumed getBody() would ↵Aaron Ballman2016-03-221-2/+7
| | | | | | | | return non-null. Patch by Etienne Bergeron. llvm-svn: 264049
* [clang-tidy] Update check for API change in r263895.Benjamin Kramer2016-03-201-2/+4
| | | | | | | for range stmts now have split begin and ends, just apply OR to the condition. Should unbreak the build. llvm-svn: 263900
* [clang-tidy] ClangTidy check to flag uninitialized builtin and pointer fields.Felix Berger2016-02-154-0/+278
| | | | | | | | | | | | | | | | | | | | | Summary: This patch is a continuation of http://reviews.llvm.org/D10553 by Jonathan B Coe. The main additions are: 1. For C++11 the check suggests in-class field initialization as fix. This makes the fields future proof towards the addition of new constructors. 2 For older language versions the fields are added in the right position in the initializer list with more tests. 3. User documentation. Reviewers: alexfh, jbcoe Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16517 llvm-svn: 260873
* Remove autoconf supportChris Bieneman2016-01-261-12/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "Now I am become Death, the destroyer of worlds." -J. Robert Oppenheimer Reviewers: chandlerc, grosbach, bob.wilson, echristo Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D16475 llvm-svn: 258864
* [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-indexMatthias Gehre2015-12-134-0/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is http://reviews.llvm.org/D13746 but instead of including <array>, a stub is provided. This check flags all array subscriptions on static arrays and std::arrays that either have a non-compile-time-constant index or are out of bounds. Dynamic accesses into arrays are difficult for both tools and humans to validate as safe. array_view is a bounds-checked, safe type for accessing arrays of data. at() is another alternative that ensures single accesses are bounds-checked. If iterators are needed to access an array, use the iterators from an array_view constructed over the array. This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15030 llvm-svn: 255470
* [clang-tidy] cppcoreguidelines-pro-bounds-pointer-arithmetic: ignore ↵Matthias Gehre2015-11-261-5/+9
| | | | | | | | | | | | | | | | generated pointer arithmetic Summary: Inside a range-based for-loop over an array, the compiler generates pointer arithmetic (end = array + size). Don't flag this. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14582 llvm-svn: 254182
* Revert r253401, "[clang-tidy] add check ↵NAKAMURA Takumi2015-11-184-175/+0
| | | | | | | | cppcoreguidelines-pro-bounds-constant-array-index" cppcoreguidelines-pro-bounds-constant-array-index.cpp is failing in several hosts. llvm-svn: 253428
* [clang-tidy] add check cppcoreguidelines-pro-bounds-constant-array-indexMatthias Gehre2015-11-174-0/+175
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check flags all array subscriptions on static arrays and std::arrays that either have a non-compile-time-constant index or are out of bounds. Dynamic accesses into arrays are difficult for both tools and humans to validate as safe. array_view is a bounds-checked, safe type for accessing arrays of data. at() is another alternative that ensures single accesses are bounds-checked. If iterators are needed to access an array, use the iterators from an array_view constructed over the array. This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds2-only-index-into-arrays-using-constant-expressions Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13746 llvm-svn: 253401
* Fix bug 25362 "cppcoreguidelines-pro-bounds-array-to-pointer-decay does not ↵Matthias Gehre2015-11-172-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | consider const" Summary: The current matcher is implicitCastExpr(unless(hasParent(explicitCastExpr()))) but the AST in the bug is `-CXXStaticCastExpr 0x2bb64f8 <col:21, col:55> 'void *const *' static_cast<void *const *> <NoOp> `-ImplicitCastExpr 0x2bb64e0 <col:47> 'void *const *' <NoOp> `-ImplicitCastExpr 0x2bb64c8 <col:47> 'void **' <ArrayToPointerDecay> `-DeclRefExpr 0x2bb6458 <col:47> 'void *[2]' lvalue Var 0x2bb59d0 'addrlist' 'void *[2]' i.e. an ImplicitCastExpr (const cast) between decay and explicit cast. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14517 llvm-svn: 253399
* [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-castMatthias Gehre2015-11-084-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This check flags all use of c-style casts that perform a static_cast downcast, const_cast, or reinterpret_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. Note that a C-style (T)expression cast means to perform the first of the following that is possible: a const_cast, a static_cast, a static_cast followed by a const_cast, a reinterpret_cast, or a reinterpret_cast followed by a const_cast. This rule bans (T)expression only when used to perform an unsafe cast. This rule is part of the "Type safety" profile of the C++ Core Guidelines, see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type4-dont-use-c-style-texpression-casts-that-would-perform-a-static_cast-downcast-const_cast-or-reinterpret_cast. Reviewers: alexfh, sbenza, bkramer, aaron.ballman Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D14096 llvm-svn: 252425
* [clang-tidy] Add new check cppcoreguidelines-pro-bounds-array-to-pointer-decayMatthias Gehre2015-10-264-0/+98
| | | | | | | | | | | | | | | | | | | | 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 check cppcoreguidelines-pro-type-varargMatthias Gehre2015-10-214-4/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] add check cppcoreguidelines-pro-type-union-accessMatthias Gehre2015-10-164-0/+72
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [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
* 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-131-0/+3
| | | | | | cppcoreguidelines-c-copy-assignment-signature. llvm-svn: 250165
* [clang-tidy] new check cppcoreguidelines-pro-bounds-pointer-arithmeticMatthias Gehre2015-10-124-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | 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-124-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Test commitMatthias Gehre2015-10-111-0/+1
| | | | llvm-svn: 250002
* Fixing links and reformatting code; NFC.Aaron Ballman2015-10-074-8/+6
| | | | | | Patch by Marek Kurdej! llvm-svn: 249612
* Add checker for the C++ Core Guidelines: cppcoreguidelines-pro-type-const-cast.Aaron Ballman2015-10-074-0/+71
| | | | | | Patch by Matthias Gehre! llvm-svn: 249540
* Add a new module for the C++ Core Guidelines, and the first checker for ↵Aaron Ballman2015-10-065-0/+132
those guidelines: cppcoreguidelines-pro-type-reinterpret-cast. Patch by Matthias Gehre! llvm-svn: 249399
OpenPOWER on IntegriCloud