summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/utils/Matchers.h
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] New checker performance-trivially-destructible-checkAnton Bikineev2019-11-011-0/+4
| | | | | | | | | | | | | Checks for types which can be made trivially-destructible by removing out-of-line defaulted destructor declarations. The check is motivated by the work on C++ garbage collector in Blink (rendering engine for Chrome), which strives to minimize destructors and improve runtime of sweeping phase. In the entire chromium codebase the check hits over 2000 times. Differential Revision: https://reviews.llvm.org/D69435
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy] White List Option for performance-unnecessary-value-param, ↵Adam Balogh2018-10-121-0/+7
| | | | | | | | | | | | | | performance-unnecessary-copy-initialization and performance-for-range-copy New option added to these three checks to be able to silence false positives on types that are intentionally passed by value or copied. Such types are e.g. intrusive reference counting pointer types like llvm::IntrusiveRefCntPtr. The new option is named WhiteListTypes and can contain a semicolon-separated list of names of these types. Regular expressions are allowed. Default is empty. Differential Revision: https://reviews.llvm.org/D52727 llvm-svn: 344340
* [clang-tidy] Implement type-based check for `gsl::owner`Jonas Toth2017-09-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check implements the typebased semantic of `gsl::owner`. Meaning, that - only `gsl::owner` is allowed to get `delete`d - `new` expression must be assigned to `gsl::owner` - function calls that expect `gsl::owner` as argument, must get either an owner or a newly created and recognized resource (in the moment only `new`ed memory) - assignment to `gsl::owner` must be either a resource or another owner - functions returning an `gsl::owner` are considered as factories, and their result must be assigned to an `gsl::owner` - classes that have an `gsl::owner`-member must declare a non-default destructor There are some problems that occur when typededuction is in place. For example `auto Var = function_that_returns_owner();` the type of `Var` will not be an `gsl::owner`. This case is catched, and explicitly noted. But cases like fully templated functions ``` template <typename T> void f(T t) { delete t; } // ... f(gsl::owner<int*>(new int(42))); ``` Will created false positive (the deletion is problematic), since the type deduction removes the wrapping `typeAlias`. Codereview in D36354 llvm-svn: 313067
* [clang-tidy] Revert Implement type-based check for gsl::ownerJonas Toth2017-09-121-4/+0
| | | | | | This should unbreak the buildbot for visual studio 2015 for now. llvm-svn: 313059
* [clang-tidy] Implement type-based check for `gsl::owner`Jonas Toth2017-09-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check implements the typebased semantic of `gsl::owner`. Meaning, that - only `gsl::owner` is allowed to get `delete`d - `new` expression must be assigned to `gsl::owner` - function calls that expect `gsl::owner` as argument, must get either an owner or a newly created and recognized resource (in the moment only `new`ed memory) - assignment to `gsl::owner` must be either a resource or another owner - functions returning an `gsl::owner` are considered as factories, and their result must be assigned to an `gsl::owner` - classes that have an `gsl::owner`-member must declare a non-default destructor There are some problems that occur when typededuction is in place. For example `auto Var = function_that_returns_owner();` the type of `Var` will not be an `gsl::owner`. This case is catched, and explicitly noted. But cases like fully templated functions ``` template <typename T> void f(T t) { delete t; } // ... f(gsl::owner<int*>(new int(42))); ``` Will created false positive (the deletion is problematic), since the type deduction removes the wrapping `typeAlias`. Please give your comments :) llvm-svn: 313043
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-4/+2
| | | | | | | | | | | | | | | | Summary: Ran clang-format on all .c/.cpp/.h files in clang-tools-extra. Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories. Reviewers: klimek, alexfh Subscribers: nemanjai Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D26329 llvm-svn: 286221
* [clang-tidy] Fixes to modernize-use-emplacePiotr Padlewski2016-07-291-2/+0
| | | | | | | | Not everything is valid, but it should works for 99.8% cases https://reviews.llvm.org/D22208 llvm-svn: 277097
* [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const ↵Felix Berger2016-07-011-0/+6
| | | | | | | | | | | | | | | | | | | | value parameter can be moved. Summary: Make check more useful in the following two cases: The parameter is passed by non-const value, has a non-deleted move constructor and is only referenced once in the function as argument to the type's copy constructor. The parameter is passed by non-const value, has a non-deleted move assignment operator and is only referenced once in the function as argument of the the type's copy assignment operator. In this case suggest a fix to move the parameter which avoids the unnecessary copy and is closest to what the user might have intended. Reviewers: alexfh, sbenza Subscribers: cfe-commits, Prazek Differential Revision: http://reviews.llvm.org/D20277 llvm-svn: 274380
* Remove ignoringImplicit from clang-tidy.Cong Liu2016-06-241-5/+0
| | | | llvm-svn: 273660
* [clang-tidy] Add modernize-use-emplacePiotr Padlewski2016-06-211-0/+2
| | | | | | | | | | Summary: Add check that replaces call of push_back to emplace_back Reviewers: hokein Differential Revision: http://reviews.llvm.org/D20964 llvm-svn: 273275
* [clang-tidy] Lift common matchers to utils namespaceEtienne Bergeron2016-05-171-0/+5
| | | | | | | | | | | | | | Summary: This patch is lifting matchers used by more than one checkers to the common namespace. Reviewers: aaron.ballman, alexfh Subscribers: aaron.ballman, cfe-commits Differential Revision: http://reviews.llvm.org/D19841 llvm-svn: 269804
* [clang-tidy] Cleanup namespace in utils folder.Etienne Bergeron2016-05-031-2/+2
| | | | | | | | | | | | | | Summary: This is a step forward cleaning up the namespaces in clang-tidy/utils. There is no behavior change. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19819 llvm-svn: 268356
* [clang-tidy] Cleanup some ast-matchers and lift some to utils.Etienne Bergeron2016-04-211-0/+12
| | | | | | | | | | | | | | | | Summary: Little cleanup to lift-out and to remove some frequently used ast-matchers. Some of theses matchers are candidates to be lifted to ASTMatchers.h. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19200 llvm-svn: 267003
* Complete support for C++ Core Guidelines Type.6: Always initialize a member ↵Alexander Kornienko2016-04-131-0/+5
| | | | | | | | | | | | | | | | 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
* Replace the custom AST matcher for nothrow functions with the canonical AST ↵Aaron Ballman2015-12-021-16/+0
| | | | | | matcher from r254516. llvm-svn: 254517
* Add a new checker, cert-err58-cpp, that checks for static or thread_local ↵Aaron Ballman2015-12-011-0/+16
| | | | | | | | objects that use a throwing constructor. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/ERR58-CPP.+Constructors+of+objects+with+static+or+thread+storage+duration+must+not+throw+exceptions llvm-svn: 254415
* Make isExpensiveToCopy() tri-state.Manuel Klimek2015-10-231-1/+3
| | | | | | This allows returning "don't know" for dependent types. llvm-svn: 251103
* Improved the misc-move-constructor-init check to identify arguments that are ↵Aaron Ballman2015-10-061-0/+28
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