#define LLVM_ADT_STLEXTRAS_H
#include "llvm/Support/Compiler.h"
+#include <algorithm> // for std::all_of
#include <cassert>
#include <cstddef> // for std::size_t
#include <cstdlib> // for qsort
C.clear();
}
+/// Provide wrappers to std::all_of which take ranges instead of having to pass
+/// being/end explicitly.
+template<typename R, class UnaryPredicate>
+bool all_of(R &&Range, UnaryPredicate &&P) {
+ return std::all_of(Range.begin(), Range.end(),
+ std::forward<UnaryPredicate>(P));
+}
+
//===----------------------------------------------------------------------===//
// Extra additions to <memory>
//===----------------------------------------------------------------------===//
/// hasLoopInvariantOperands - Return true if all the operands of the
/// specified instruction are loop invariant.
bool Loop::hasLoopInvariantOperands(const Instruction *I) const {
- for (auto &Op : I->operands())
- if (!isLoopInvariant(Op))
- return false;
-
- return true;
+ return all_of(I->operands(), [this](Value *V) { return isLoopInvariant(V); });
}
/// makeLoopInvariant - If the given value is an instruciton inside of the