#include <string>
#include <utility>
-// FIXME: There are still remaining checks here that check for consistency
-// between `StructValue` and `AggregateStorageLocation`. Now that the redundancy
-// between these two classes has been eliminated, these checks aren't needed any
-// more, so remove them.
-
namespace {
using namespace clang;
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
});
}
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
});
}
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
});
}
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
});
}
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
+ cast<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env));
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
+ cast<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env));
const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
ASSERT_THAT(BazDecl, NotNull());
const auto *QuxLoc =
cast<AggregateStorageLocation>(ThisLoc->getChild(*QuxDecl));
- const auto *QuxVal = dyn_cast<StructValue>(Env.getValue(*QuxLoc));
- ASSERT_THAT(QuxVal, NotNull());
+ EXPECT_THAT(dyn_cast<StructValue>(Env.getValue(*QuxLoc)), NotNull());
- const auto *BazLoc =
- cast<ScalarStorageLocation>(QuxLoc->getChild(*BazDecl));
const auto *BazVal =
- cast<IntegerValue>(getFieldValue(QuxVal, *BazDecl, Env));
- EXPECT_EQ(Env.getValue(*BazLoc), BazVal);
+ cast<IntegerValue>(getFieldValue(QuxLoc, *BazDecl, Env));
const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux");
ASSERT_THAT(QuuxDecl, NotNull());
const auto *QuxLoc =
cast<AggregateStorageLocation>(ThisLoc->getChild(*QuxDecl));
- const auto *QuxVal = dyn_cast<StructValue>(Env.getValue(*QuxLoc));
- ASSERT_THAT(QuxVal, NotNull());
+ EXPECT_THAT(dyn_cast<StructValue>(Env.getValue(*QuxLoc)), NotNull());
- const auto *BazLoc =
- cast<ScalarStorageLocation>(QuxLoc->getChild(*BazDecl));
const auto *BazVal =
- cast<IntegerValue>(getFieldValue(QuxVal, *BazDecl, Env));
- EXPECT_EQ(Env.getValue(*BazLoc), BazVal);
+ cast<IntegerValue>(getFieldValue(QuxLoc, *BazDecl, Env));
const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux");
ASSERT_THAT(QuuxDecl, NotNull());
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
});
}
const auto *FooLoc =
cast<AggregateStorageLocation>(Env.getStorageLocation(*FooDecl));
- const auto *BarLoc =
- cast<ScalarStorageLocation>(FooLoc->getChild(*BarDecl));
-
- const auto *FooVal = cast<StructValue>(Env.getValue(*FooLoc));
- const auto *BarVal =
- cast<IntegerValue>(getFieldValue(FooVal, *BarDecl, Env));
- EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+ EXPECT_TRUE(isa<IntegerValue>(getFieldValue(FooLoc, *BarDecl, Env)));
},
LangStandard::lang_cxx14);
}
ASSERT_THAT(BazLoc, NotNull());
ASSERT_THAT(Env.getValue(*BazLoc), NotNull());
- const auto *BazVal = cast<StructValue>(Env.getValue(*BazLoc));
- const auto *FooValFromBazVal =
- cast<IntegerValue>(getFieldValue(BazVal, *FooDecl, Env));
- const auto *FooValFromBazLoc =
+ const auto *FooVal =
cast<IntegerValue>(getFieldValue(BazLoc, *FooDecl, Env));
- EXPECT_EQ(FooValFromBazLoc, FooValFromBazVal);
const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
ASSERT_THAT(BarDecl, NotNull());
const auto *BarLoc = Env.getStorageLocation(*BarDecl);
ASSERT_TRUE(isa_and_nonnull<ScalarStorageLocation>(BarLoc));
- EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazVal);
- EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazLoc);
+ EXPECT_EQ(Env.getValue(*BarLoc), FooVal);
});
}