[PATCH] D87482: Fix clang Wrange-loop-analysis in BuildTree.cpp
Jeff Hemphill via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 10 14:17:46 PDT 2020
jthemphill created this revision.
jthemphill added a reviewer: eduucaldas.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jthemphill requested review of this revision.
Building on Mac OS with clang 12:
jhemphill at jhemphill-mbp build % clang --version
Apple clang version 12.0.0 (clang-1200.0.26.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
yields one warning:
/Users/jhemphill/oss/llvm-project/clang/lib/Tooling/Syntax/BuildTree.cpp:1126:22: warning: loop variable 'Arg' is always a copy because the range of type 'llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr *, clang::Stmt *> >' does not return a reference [-Wrange-loop-analysis]
for (const auto &Arg : Args) {
^
/Users/jhemphill/oss/llvm-project/clang/lib/Tooling/Syntax/BuildTree.cpp:1126:10: note: use non-reference type 'clang::Expr *'
for (const auto &Arg : Args) {
It appears that `Arg` is an `Expr*`, passed by value rather than by const reference.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87482
Files:
clang/lib/Tooling/Syntax/BuildTree.cpp
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===================================================================
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1123,7 +1123,7 @@
syntax::CallArguments *
buildCallArguments(CallExpr::arg_range ArgsAndDefaultArgs) {
auto Args = dropDefaultArgs(ArgsAndDefaultArgs);
- for (const auto &Arg : Args) {
+ for (auto *Arg : Args) {
Builder.markExprChild(Arg, syntax::NodeRole::ListElement);
const auto *DelimiterToken =
std::next(Builder.findToken(Arg->getEndLoc()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87482.291080.patch
Type: text/x-patch
Size: 594 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200910/d3977b42/attachment.bin>
More information about the cfe-commits
mailing list