forked from OSchip/llvm-project
Make mlir::Value's bool conversion operator explicit
This still allows `if (value)` while requiring an explicit cast when not in a boolean context. This means things like `std::set<Value>` will no longer compile. Differential Revision: https://reviews.llvm.org/D80497
This commit is contained in:
parent
3873d0b3d8
commit
a9b5edc5e2
|
@ -303,7 +303,7 @@ struct StructuredIndexed {
|
|||
"MemRef, RankedTensor or Vector expected");
|
||||
}
|
||||
|
||||
bool hasValue() const { return value; }
|
||||
bool hasValue() const { return (bool)value; }
|
||||
Value getValue() const {
|
||||
assert(value && "StructuredIndexed Value not set.");
|
||||
return value;
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
return U(ownerAndKind);
|
||||
}
|
||||
|
||||
operator bool() const { return ownerAndKind.getPointer(); }
|
||||
explicit operator bool() const { return ownerAndKind.getPointer(); }
|
||||
bool operator==(const Value &other) const {
|
||||
return ownerAndKind == other.ownerAndKind;
|
||||
}
|
||||
|
|
|
@ -281,7 +281,8 @@ LogicalResult NDTransferOpHelper<TransferReadOp>::doReplace() {
|
|||
}
|
||||
});
|
||||
|
||||
assert((!options.unroll ^ result) && "Expected resulting Value iff unroll");
|
||||
assert((!options.unroll ^ (bool)result) &&
|
||||
"Expected resulting Value iff unroll");
|
||||
if (!result)
|
||||
result = std_load(vector_type_cast(MemRefType::get({}, vectorType), alloc));
|
||||
rewriter.replaceOp(op, result);
|
||||
|
|
|
@ -3542,14 +3542,14 @@ ParseResult OperationParser::finalize() {
|
|||
// Check for any forward references that are left. If we find any, error
|
||||
// out.
|
||||
if (!forwardRefPlaceholders.empty()) {
|
||||
SmallVector<std::pair<const char *, Value>, 4> errors;
|
||||
SmallVector<const char *, 4> errors;
|
||||
// Iteration over the map isn't deterministic, so sort by source location.
|
||||
for (auto entry : forwardRefPlaceholders)
|
||||
errors.push_back({entry.second.getPointer(), entry.first});
|
||||
errors.push_back(entry.second.getPointer());
|
||||
llvm::array_pod_sort(errors.begin(), errors.end());
|
||||
|
||||
for (auto entry : errors) {
|
||||
auto loc = SMLoc::getFromPointer(entry.first);
|
||||
auto loc = SMLoc::getFromPointer(entry);
|
||||
emitError(loc, "use of undeclared SSA value name");
|
||||
}
|
||||
return failure();
|
||||
|
|
Loading…
Reference in New Issue