Use a SmallVector instead of an ArrayRef to materialize a temporary local array

This pattern is error prone and unfortunately none of the sanitizer is catching
it at the moment.

Fixes tensorflow/mlir#192

Closes tensorflow/mlir#193

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/mlir/pull/193 from joker-eph:fix_array_ref 8092252e64c426c6a8a790b7638f847bea4818b1
PiperOrigin-RevId: 275280201
This commit is contained in:
Mehdi Amini 2019-10-17 09:58:58 -07:00 committed by A. Unique TensorFlower
parent 23d21af65c
commit 6ebc7318b0
1 changed files with 1 additions and 1 deletions

View File

@ -142,7 +142,7 @@ static LogicalResult verifyAllReduce(gpu::AllReduce allReduce) {
return allReduce.emitError(
"expected either an op attribute or a non-empty body");
if (allReduce.op()) {
ArrayRef<StringRef> supportedOps{"add", "mul"};
SmallVector<StringRef, 2> supportedOps{"add", "mul"};
if (!llvm::is_contained(supportedOps, *allReduce.op()))
return allReduce.emitError("op \"") << *allReduce.op() << "\" is invalid";
}