[llvm] 99913ef - [OpenMP] set_bits iterator yields unsigned elements, no reference (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 29 09:09:26 PDT 2020
Author: Florian Hahn
Date: 2020-03-29T17:08:13+01:00
New Revision: 99913ef3d14fcbfc939d9547506b55ac76fd0c59
URL: https://github.com/llvm/llvm-project/commit/99913ef3d14fcbfc939d9547506b55ac76fd0c59
DIFF: https://github.com/llvm/llvm-project/commit/99913ef3d14fcbfc939d9547506b55ac76fd0c59.diff
LOG: [OpenMP] set_bits iterator yields unsigned elements, no reference (NFC).
BitVector::set_bits() returns an iterator range yielding unsinged
elements, which always will be copied while const & gives the impression
that there will be no copy. Newer version of clang complain:
warning: loop variable 'SetBitsIt' is always a copy because the range of type 'iterator_range<llvm::BitVector::const_set_bits_iterator>' (aka 'iterator_range<const_set_bits_iterator_impl<llvm::BitVector> >') does not return a reference [-Wrange-loop-analysis]
Reviewers: jdoerfert, rnk
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D77010
Added:
Modified:
llvm/lib/Frontend/OpenMP/OMPContext.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/OpenMP/OMPContext.cpp b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
index 505d4e978b12..dd3292ab776e 100644
--- a/llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -79,8 +79,8 @@ OMPContext::OMPContext(bool IsDeviceCompilation, Triple TargetTriple) {
LLVM_DEBUG({
dbgs() << "[" << DEBUG_TYPE
<< "] New OpenMP context with the following properties:\n";
- for (const auto &SetBitsIt : ActiveTraits.set_bits()) {
- TraitProperty Property = TraitProperty(SetBitsIt);
+ for (unsigned Bit : ActiveTraits.set_bits()) {
+ TraitProperty Property = TraitProperty(Bit);
dbgs() << "\t " << getOpenMPContextTraitPropertyFullName(Property)
<< "\n";
}
@@ -127,8 +127,8 @@ static bool isStrictSubset(const VariantMatchInfo &VMI0,
// relation is not required to be strict.
if (VMI0.RequiredTraits.count() >= VMI1.RequiredTraits.count())
return false;
- for (const auto &SetBitsIt : VMI0.RequiredTraits.set_bits())
- if (!VMI1.RequiredTraits.test(SetBitsIt))
+ for (unsigned Bit : VMI0.RequiredTraits.set_bits())
+ if (!VMI1.RequiredTraits.test(Bit))
return false;
if (!isSubset<TraitProperty>(VMI0.ConstructTraits, VMI1.ConstructTraits))
return false;
@@ -139,8 +139,8 @@ static int isVariantApplicableInContextHelper(
const VariantMatchInfo &VMI, const OMPContext &Ctx,
SmallVectorImpl<unsigned> *ConstructMatches) {
- for (const auto &SetBitsIt : VMI.RequiredTraits.set_bits()) {
- TraitProperty Property = TraitProperty(SetBitsIt);
+ for (unsigned Bit : VMI.RequiredTraits.set_bits()) {
+ TraitProperty Property = TraitProperty(Bit);
bool IsActiveTrait = Ctx.ActiveTraits.test(unsigned(Property));
if (!IsActiveTrait) {
@@ -191,8 +191,8 @@ static APInt getVariantMatchScore(const VariantMatchInfo &VMI,
APInt Score(64, 1);
unsigned NoConstructTraits = VMI.ConstructTraits.size();
- for (const auto &SetBitsIt : VMI.RequiredTraits.set_bits()) {
- TraitProperty Property = TraitProperty(SetBitsIt);
+ for (unsigned Bit : VMI.RequiredTraits.set_bits()) {
+ TraitProperty Property = TraitProperty(Bit);
// If there is a user score attached, use it.
if (VMI.ScoreMap.count(Property)) {
const APInt &UserScore = VMI.ScoreMap.lookup(Property);
More information about the llvm-commits
mailing list