Explicitly construct ArrayRef in AttributeTest.cpp

Some compilers find initializer list constructors from boolean literals
ambiguous between ArrayRef<bool> and ArrayRef<Attribute>.  Call the
ArrayRef<bool> constructor explicitly to disambiguate.

PiperOrigin-RevId: 253224859
This commit is contained in:
Alex Zinenko 2019-06-14 07:28:41 -07:00 committed by Mehdi Amini
parent ee6f84aebd
commit b582338f62
1 changed files with 8 additions and 4 deletions

View File

@ -43,19 +43,23 @@ TEST(DenseSplatTest, BoolSplat) {
// Check that splat is automatically detected for boolean values. // Check that splat is automatically detected for boolean values.
/// True. /// True.
DenseElementsAttr trueSplat = DenseElementsAttr::get(shape, true); DenseElementsAttr trueSplat =
DenseElementsAttr::get(shape, llvm::ArrayRef<bool>(true));
EXPECT_TRUE(trueSplat.isSplat()); EXPECT_TRUE(trueSplat.isSplat());
/// False. /// False.
DenseElementsAttr falseSplat = DenseElementsAttr::get(shape, false); DenseElementsAttr falseSplat =
DenseElementsAttr::get(shape, llvm::ArrayRef<bool>(false));
EXPECT_TRUE(falseSplat.isSplat()); EXPECT_TRUE(falseSplat.isSplat());
EXPECT_NE(falseSplat, trueSplat); EXPECT_NE(falseSplat, trueSplat);
/// Detect and handle splat within 8 elements (bool values are bit-packed). /// Detect and handle splat within 8 elements (bool values are bit-packed).
/// True. /// True.
auto detectedSplat = DenseElementsAttr::get(shape, {true, true, true, true}); auto detectedSplat = DenseElementsAttr::get(
shape, llvm::ArrayRef<bool>({true, true, true, true}));
EXPECT_EQ(detectedSplat, trueSplat); EXPECT_EQ(detectedSplat, trueSplat);
/// False. /// False.
detectedSplat = DenseElementsAttr::get(shape, {false, false, false, false}); detectedSplat = DenseElementsAttr::get(
shape, llvm::ArrayRef<bool>({false, false, false, false}));
EXPECT_EQ(detectedSplat, falseSplat); EXPECT_EQ(detectedSplat, falseSplat);
} }