This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Use an explicit copy in a range-based for
ClosedPublic

Authored by Mordante on Nov 9 2019, 9:18 AM.

Details

Summary

The std::pair<const clang::ValueDecl *, llvm::ArrayRef<clang::OMPClauseMappableExprCommon::MappableComponent>>
type will be copied in a range-based for loop. Make the copy explicit to
avoid the -Wrange-loop-analysis warning.

This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall.

Diff Detail

Event Timeline

Mordante created this revision.Nov 9 2019, 9:18 AM

Why do we get the warnings with references?

OMPMappableExprListClause::const_component_lists_iterator::operator*() returns an object and not a reference to an object.
-Wrange-loop-analysis warns to make it more visible the object is a copy and not a reference.

ABataev accepted this revision.Nov 11 2019, 7:15 AM

LG, thanks!

This revision is now accepted and ready to land.Nov 11 2019, 7:15 AM
This revision was automatically updated to reflect the committed changes.