summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] implement utility-function to add 'const' to variablesJonas Toth2020-01-031-7/+15
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch extends the already existing facility to add 'const' to variables to be more flexible and correct. The previous version did not consider pointers as value AND pointee. For future automatic introduction for const-correctness this shortcoming needs to be fixed. It always allows configuration where the 'const' token is inserted, either on the left side (if possible) or the right side. It adds many unit-tests to the utility-function that did not exist before, as the function was implicitly tested through clang-tidy checks. These tests were not changed, as the API is still compatible. Reviewers: aaron.ballman, hokein, alexfh, shuaiwang, lebedev.ri Reviewed By: aaron.ballman Subscribers: jdoerfert, mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54395
* 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-2/+12
| | | | | | | | | | | | | | 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
* [clangtidy] Remove old copy of ExprMutationAnalyzerShuai Wang2018-09-111-3/+2
| | | | | | | | | | | | | | | | | | Summary: This is 2/2 of moving ExprMutationAnalyzer from clangtidy to clang/Analysis. ExprMutationAnalyzer is moved to clang/Analysis in D51948. This diff migrates existing usages within clangtidy to point to the new location and remove the old copy of ExprMutationAnalyzer. Reviewers: george.karpenkov, JonasToth Reviewed By: george.karpenkov Subscribers: mgorny, a.sidorin, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D51950 llvm-svn: 342006
* [clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888Roman Lebedev2018-09-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I have hit this the rough way, while trying to use this in D51870. There is no particular point in storing the pointers, and moreover the pointers are assumed to be non-null, and that assumption is not enforced. If they are null, it won't be able to do anything good with them anyway. Initially i thought about simply adding asserts() that they are not null, but taking/storing references looks like even cleaner solution? Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38888 | PR38888 ]] Reviewers: JonasToth, shuaiwang, alexfh, george.karpenkov Reviewed By: shuaiwang Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51884 llvm-svn: 341854
* [clang-tidy] Omit cases where loop variable is not used in loop body inHaojian Wu2018-08-101-9/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | performance-for-range-copy check. Summary: The upstream change r336737 make the check too smart to fix the case where loop variable could be used as `const auto&`. But for the case below, changing to `const auto _` will introduce an unused complier warning. ``` for (auto _ : state) { // no references for _. } ``` This patch omit this case, and it is safe to do it as the case is very rare. Reviewers: ilya-biryukov, alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D50447 llvm-svn: 339415
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* Use ExprMutationAnalyzer in performance-for-range-copyShuai Wang2018-07-101-3/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This gives better coverage to the check as ExprMutationAnalyzer is more accurate comparing to isOnlyUsedAsConst. Majority of wins come from const usage of member field, e.g.: for (auto widget : container) { // copy of loop variable if (widget.type == BUTTON) { // const usage only recognized by ExprMutationAnalyzer // ... } } Reviewers: george.karpenkov Subscribers: a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D48854 llvm-svn: 336737
* [clang-tidy] Cleanup namespace in utils folder.Etienne Bergeron2016-05-031-7/+8
| | | | | | | | | | | | | | 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] Cleaning namespaces to be more consistant across checkers.Etienne Bergeron2016-05-021-2/+2
| | | | | | | | | | | | | | 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] Extend UnnecessaryCopyInitialization check to trigger on ↵Felix Berger2016-03-051-94/+8
| | | | | | | | | | | | | | | | non-const copies that can be safely converted to const references. Summary: Move code shared between UnnecessaryCopyInitialization and ForRangeCopyCheck into utilities files. Add more test cases for UnnecessaryCopyInitialization and disable fixes inside of macros. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17488 llvm-svn: 262781
* [clang-tidy] Only invoke ForRangeCopyCheck on expensive-to-copy types.Felix Berger2016-02-151-3/+6
| | | | | | | | | | | | | | Summary: Fix oversight not checking the value of the Optional<bool> returned by isExpensiveToCopy(). Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17064 llvm-svn: 260870
* [clang-tidy] ForRangeCopyCheck that warns on and fixes unnecessary copies of ↵Alexander Kornienko2016-01-291-0/+177
loop variables. Patch by Felix Berger! Differential revision: http://reviews.llvm.org/D13849 llvm-svn: 259199
OpenPOWER on IntegriCloud