Page MenuHomePhabricator

Fix clang Wrange-loop-analysis in BuildTree.cpp

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



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.Thu, Sep 10, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Sep 10, 2:17 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
jthemphill requested review of this revision.Thu, Sep 10, 2:17 PM
gribozavr2 accepted this revision.Thu, Sep 10, 2:29 PM
This revision is now accepted and ready to land.Thu, Sep 10, 2:29 PM
eduucaldas accepted this revision.Thu, Sep 10, 11:49 PM

Will someone come by and land this?

This revision was landed with ongoing or failed builds.Fri, Sep 11, 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!