summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
authorShuai Wang <shuaiwang@google.com>2018-07-10 22:51:06 +0000
committerShuai Wang <shuaiwang@google.com>2018-07-10 22:51:06 +0000
commit0ed0febb3e58081edf1c69b62d28f72703a417f8 (patch)
treee10e9cc1c63427942dee33907784359fbcd28eb8 /clang-tools-extra/clang-tidy
parent3482871645efab6ea45b921f1ff4071f0825b76d (diff)
downloadbcm5719-llvm-0ed0febb3e58081edf1c69b62d28f72703a417f8.tar.gz
bcm5719-llvm-0ed0febb3e58081edf1c69b62d28f72703a417f8.zip
Use ExprMutationAnalyzer in performance-for-range-copy
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
Diffstat (limited to 'clang-tools-extra/clang-tidy')
-rw-r--r--clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
index 0b9dd2308c9..2358aacb214 100644
--- a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "ForRangeCopyCheck.h"
-#include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
#include "../utils/FixItHintUtils.h"
#include "../utils/TypeTraits.h"
@@ -79,8 +79,8 @@ bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
if (LoopVar.getType().isConstQualified() || !Expensive || !*Expensive)
return false;
- if (!utils::decl_ref_expr::isOnlyUsedAsConst(LoopVar, *ForRange.getBody(),
- Context))
+ if (utils::ExprMutationAnalyzer(ForRange.getBody(), &Context)
+ .isMutated(&LoopVar))
return false;
diag(LoopVar.getLocation(),
"loop variable is copied but only used as const reference; consider "
OpenPOWER on IntegriCloud