This is an archive of the discontinued LLVM Phabricator instance.

Fix clang Wrange-loop-analysis in BuildTree.cpp
ClosedPublic

Authored by jthemphill on Sep 10 2020, 2:17 PM.

Details

Summary

Building on Mac OS with clang 12:

jhemphill@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.

Diff Detail

Event Timeline

jthemphill created this revision.Sep 10 2020, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2020, 2:17 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jthemphill requested review of this revision.Sep 10 2020, 2:17 PM
gribozavr2 accepted this revision.Sep 10 2020, 2:29 PM
This revision is now accepted and ready to land.Sep 10 2020, 2:29 PM
eduucaldas accepted this revision.Sep 10 2020, 11:49 PM

Will someone come by and land this?

This revision was landed with ongoing or failed builds.Sep 11 2020, 4:10 PM
This revision was automatically updated to reflect the committed changes.

Sorry, I didn't realize you don't have commit access. Pushed this patch to git, thanks for the contribution!