[clang] e10df77 - Fix clang Wrange-loop-analysis in BuildTree.cpp
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 16:10:16 PDT 2020
Author: Dmitri Gribenko
Date: 2020-09-12T01:07:54+02:00
New Revision: e10df779f097e3a1fb02d901117ce71a5dd9dda2
URL: https://github.com/llvm/llvm-project/commit/e10df779f097e3a1fb02d901117ce71a5dd9dda2
DIFF: https://github.com/llvm/llvm-project/commit/e10df779f097e3a1fb02d901117ce71a5dd9dda2.diff
LOG: Fix clang Wrange-loop-analysis in BuildTree.cpp
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.
Reviewed By: eduucaldas, gribozavr2
Differential Revision: https://reviews.llvm.org/D87482
Added:
Modified:
clang/lib/Tooling/Syntax/BuildTree.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index dab1457fbdba..3e0573ac4ffc 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1126,7 +1126,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor<BuildTreeVisitor> {
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()));
More information about the cfe-commits
mailing list