aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/IR/MetadataTest.cpp')
-rw-r--r--llvm/unittests/IR/MetadataTest.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index 0c73aaa..a755dfa 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -1045,52 +1045,51 @@ TEST_F(DILocationTest, cloneTemporary) {
}
TEST_F(DILocationTest, discriminatorEncoding) {
- EXPECT_EQ(0U, DILocation::encodeDiscriminator(0, 0, 0).getValue());
+ EXPECT_EQ(0U, DILocation::encodeDiscriminator(0, 0, 0).value());
// Encode base discriminator as a component: lsb is 0, then the value.
// The other components are all absent, so we leave all the other bits 0.
- EXPECT_EQ(2U, DILocation::encodeDiscriminator(1, 0, 0).getValue());
+ EXPECT_EQ(2U, DILocation::encodeDiscriminator(1, 0, 0).value());
// Base discriminator component is empty, so lsb is 1. Next component is not
// empty, so its lsb is 0, then its value (1). Next component is empty.
// So the bit pattern is 101.
- EXPECT_EQ(5U, DILocation::encodeDiscriminator(0, 1, 0).getValue());
+ EXPECT_EQ(5U, DILocation::encodeDiscriminator(0, 1, 0).value());
// First 2 components are empty, so the bit pattern is 11. Then the
// next component - ending up with 1011.
- EXPECT_EQ(0xbU, DILocation::encodeDiscriminator(0, 0, 1).getValue());
+ EXPECT_EQ(0xbU, DILocation::encodeDiscriminator(0, 0, 1).value());
// The bit pattern for the first 2 components is 11. The next bit is 0,
// because the last component is not empty. We have 29 bits usable for
// encoding, but we cap it at 12 bits uniformously for all components. We
// encode the last component over 14 bits.
- EXPECT_EQ(0xfffbU, DILocation::encodeDiscriminator(0, 0, 0xfff).getValue());
+ EXPECT_EQ(0xfffbU, DILocation::encodeDiscriminator(0, 0, 0xfff).value());
- EXPECT_EQ(0x102U, DILocation::encodeDiscriminator(1, 1, 0).getValue());
+ EXPECT_EQ(0x102U, DILocation::encodeDiscriminator(1, 1, 0).value());
- EXPECT_EQ(0x13eU, DILocation::encodeDiscriminator(0x1f, 1, 0).getValue());
+ EXPECT_EQ(0x13eU, DILocation::encodeDiscriminator(0x1f, 1, 0).value());
- EXPECT_EQ(0x87feU, DILocation::encodeDiscriminator(0x1ff, 1, 0).getValue());
+ EXPECT_EQ(0x87feU, DILocation::encodeDiscriminator(0x1ff, 1, 0).value());
- EXPECT_EQ(0x1f3eU, DILocation::encodeDiscriminator(0x1f, 0x1f, 0).getValue());
+ EXPECT_EQ(0x1f3eU, DILocation::encodeDiscriminator(0x1f, 0x1f, 0).value());
- EXPECT_EQ(0x3ff3eU,
- DILocation::encodeDiscriminator(0x1f, 0x1ff, 0).getValue());
+ EXPECT_EQ(0x3ff3eU, DILocation::encodeDiscriminator(0x1f, 0x1ff, 0).value());
EXPECT_EQ(0x1ff87feU,
- DILocation::encodeDiscriminator(0x1ff, 0x1ff, 0).getValue());
+ DILocation::encodeDiscriminator(0x1ff, 0x1ff, 0).value());
EXPECT_EQ(0xfff9f3eU,
- DILocation::encodeDiscriminator(0x1f, 0x1f, 0xfff).getValue());
+ DILocation::encodeDiscriminator(0x1f, 0x1f, 0xfff).value());
EXPECT_EQ(0xffc3ff3eU,
- DILocation::encodeDiscriminator(0x1f, 0x1ff, 0x1ff).getValue());
+ DILocation::encodeDiscriminator(0x1f, 0x1ff, 0x1ff).value());
EXPECT_EQ(0xffcf87feU,
- DILocation::encodeDiscriminator(0x1ff, 0x1f, 0x1ff).getValue());
+ DILocation::encodeDiscriminator(0x1ff, 0x1f, 0x1ff).value());
EXPECT_EQ(0xe1ff87feU,
- DILocation::encodeDiscriminator(0x1ff, 0x1ff, 7).getValue());
+ DILocation::encodeDiscriminator(0x1ff, 0x1ff, 7).value());
}
TEST_F(DILocationTest, discriminatorEncodingNegativeTests) {
@@ -1113,36 +1112,36 @@ TEST_F(DILocationTest, discriminatorSpecialCases) {
EXPECT_EQ(0U, L1->getBaseDiscriminator());
EXPECT_EQ(1U, L1->getDuplicationFactor());
- EXPECT_EQ(L1, L1->cloneWithBaseDiscriminator(0).getValue());
- EXPECT_EQ(L1, L1->cloneByMultiplyingDuplicationFactor(0).getValue());
- EXPECT_EQ(L1, L1->cloneByMultiplyingDuplicationFactor(1).getValue());
+ EXPECT_EQ(L1, L1->cloneWithBaseDiscriminator(0).value());
+ EXPECT_EQ(L1, L1->cloneByMultiplyingDuplicationFactor(0).value());
+ EXPECT_EQ(L1, L1->cloneByMultiplyingDuplicationFactor(1).value());
- auto L2 = L1->cloneWithBaseDiscriminator(1).getValue();
+ auto L2 = L1->cloneWithBaseDiscriminator(1).value();
EXPECT_EQ(0U, L1->getBaseDiscriminator());
EXPECT_EQ(1U, L1->getDuplicationFactor());
EXPECT_EQ(1U, L2->getBaseDiscriminator());
EXPECT_EQ(1U, L2->getDuplicationFactor());
- auto L3 = L2->cloneByMultiplyingDuplicationFactor(2).getValue();
+ auto L3 = L2->cloneByMultiplyingDuplicationFactor(2).value();
EXPECT_EQ(1U, L3->getBaseDiscriminator());
EXPECT_EQ(2U, L3->getDuplicationFactor());
- EXPECT_EQ(L2, L2->cloneByMultiplyingDuplicationFactor(1).getValue());
+ EXPECT_EQ(L2, L2->cloneByMultiplyingDuplicationFactor(1).value());
- auto L4 = L3->cloneByMultiplyingDuplicationFactor(4).getValue();
+ auto L4 = L3->cloneByMultiplyingDuplicationFactor(4).value();
EXPECT_EQ(1U, L4->getBaseDiscriminator());
EXPECT_EQ(8U, L4->getDuplicationFactor());
- auto L5 = L4->cloneWithBaseDiscriminator(2).getValue();
+ auto L5 = L4->cloneWithBaseDiscriminator(2).value();
EXPECT_EQ(2U, L5->getBaseDiscriminator());
EXPECT_EQ(8U, L5->getDuplicationFactor());
// Check extreme cases
- auto L6 = L1->cloneWithBaseDiscriminator(0xfff).getValue();
+ auto L6 = L1->cloneWithBaseDiscriminator(0xfff).value();
EXPECT_EQ(0xfffU, L6->getBaseDiscriminator());
EXPECT_EQ(0xfffU, L6->cloneByMultiplyingDuplicationFactor(0xfff)
- .getValue()
+ .value()
->getDuplicationFactor());
// Check we return None for unencodable cases.
@@ -2933,22 +2932,24 @@ TEST_F(DIExpressionTest, createFragmentExpression) {
#define EXPECT_VALID_FRAGMENT(Offset, Size, ...) \
do { \
uint64_t Elements[] = {__VA_ARGS__}; \
- DIExpression* Expression = DIExpression::get(Context, Elements); \
- EXPECT_TRUE(DIExpression::createFragmentExpression( \
- Expression, Offset, Size).hasValue()); \
+ DIExpression *Expression = DIExpression::get(Context, Elements); \
+ EXPECT_TRUE( \
+ DIExpression::createFragmentExpression(Expression, Offset, Size) \
+ .has_value()); \
} while (false)
#define EXPECT_INVALID_FRAGMENT(Offset, Size, ...) \
do { \
uint64_t Elements[] = {__VA_ARGS__}; \
- DIExpression* Expression = DIExpression::get(Context, Elements); \
- EXPECT_FALSE(DIExpression::createFragmentExpression( \
- Expression, Offset, Size).hasValue()); \
+ DIExpression *Expression = DIExpression::get(Context, Elements); \
+ EXPECT_FALSE( \
+ DIExpression::createFragmentExpression(Expression, Offset, Size) \
+ .has_value()); \
} while (false)
// createFragmentExpression adds correct ops.
Optional<DIExpression*> R = DIExpression::createFragmentExpression(
DIExpression::get(Context, {}), 0, 32);
- EXPECT_EQ(R.hasValue(), true);
+ EXPECT_EQ(R.has_value(), true);
EXPECT_EQ(3u, (*R)->getNumElements());
EXPECT_EQ(dwarf::DW_OP_LLVM_fragment, (*R)->getElement(0));
EXPECT_EQ(0u, (*R)->getElement(1));
@@ -3455,20 +3456,20 @@ TEST_F(FunctionAttachmentTest, Verifier) {
TEST_F(FunctionAttachmentTest, RealEntryCount) {
Function *F = getFunction("foo");
- EXPECT_FALSE(F->getEntryCount().hasValue());
+ EXPECT_FALSE(F->getEntryCount().has_value());
F->setEntryCount(12304, Function::PCT_Real);
auto Count = F->getEntryCount();
- EXPECT_TRUE(Count.hasValue());
+ EXPECT_TRUE(Count.has_value());
EXPECT_EQ(12304u, Count->getCount());
EXPECT_EQ(Function::PCT_Real, Count->getType());
}
TEST_F(FunctionAttachmentTest, SyntheticEntryCount) {
Function *F = getFunction("bar");
- EXPECT_FALSE(F->getEntryCount().hasValue());
+ EXPECT_FALSE(F->getEntryCount().has_value());
F->setEntryCount(123, Function::PCT_Synthetic);
auto Count = F->getEntryCount(true /*allow synthetic*/);
- EXPECT_TRUE(Count.hasValue());
+ EXPECT_TRUE(Count.has_value());
EXPECT_EQ(123u, Count->getCount());
EXPECT_EQ(Function::PCT_Synthetic, Count->getType());
}