diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp --- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp @@ -27,11 +27,6 @@ #include #include -// 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; @@ -268,13 +263,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }); } @@ -317,13 +306,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }); } @@ -365,13 +348,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }); } @@ -1046,13 +1023,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }); } @@ -1150,9 +1121,8 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); + cast(getFieldValue(FooLoc, *BarDecl, Env)); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); @@ -1392,9 +1362,8 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *FooVal = cast(Env.getValue(*FooLoc)); const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); + cast(getFieldValue(FooLoc, *BarDecl, Env)); const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz"); ASSERT_THAT(BazDecl, NotNull()); @@ -1553,14 +1522,10 @@ const auto *QuxLoc = cast(ThisLoc->getChild(*QuxDecl)); - const auto *QuxVal = dyn_cast(Env.getValue(*QuxLoc)); - ASSERT_THAT(QuxVal, NotNull()); + EXPECT_THAT(dyn_cast(Env.getValue(*QuxLoc)), NotNull()); - const auto *BazLoc = - cast(QuxLoc->getChild(*BazDecl)); const auto *BazVal = - cast(getFieldValue(QuxVal, *BazDecl, Env)); - EXPECT_EQ(Env.getValue(*BazLoc), BazVal); + cast(getFieldValue(QuxLoc, *BazDecl, Env)); const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); @@ -1628,14 +1593,10 @@ const auto *QuxLoc = cast(ThisLoc->getChild(*QuxDecl)); - const auto *QuxVal = dyn_cast(Env.getValue(*QuxLoc)); - ASSERT_THAT(QuxVal, NotNull()); + EXPECT_THAT(dyn_cast(Env.getValue(*QuxLoc)), NotNull()); - const auto *BazLoc = - cast(QuxLoc->getChild(*BazDecl)); const auto *BazVal = - cast(getFieldValue(QuxVal, *BazDecl, Env)); - EXPECT_EQ(Env.getValue(*BazLoc), BazVal); + cast(getFieldValue(QuxLoc, *BazDecl, Env)); const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux"); ASSERT_THAT(QuuxDecl, NotNull()); @@ -1915,13 +1876,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }); } @@ -1954,13 +1909,7 @@ const auto *FooLoc = cast(Env.getStorageLocation(*FooDecl)); - const auto *BarLoc = - cast(FooLoc->getChild(*BarDecl)); - - const auto *FooVal = cast(Env.getValue(*FooLoc)); - const auto *BarVal = - cast(getFieldValue(FooVal, *BarDecl, Env)); - EXPECT_EQ(Env.getValue(*BarLoc), BarVal); + EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env))); }, LangStandard::lang_cxx14); } @@ -2973,20 +2922,15 @@ ASSERT_THAT(BazLoc, NotNull()); ASSERT_THAT(Env.getValue(*BazLoc), NotNull()); - const auto *BazVal = cast(Env.getValue(*BazLoc)); - const auto *FooValFromBazVal = - cast(getFieldValue(BazVal, *FooDecl, Env)); - const auto *FooValFromBazLoc = + const auto *FooVal = cast(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(BarLoc)); - EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazVal); - EXPECT_EQ(Env.getValue(*BarLoc), FooValFromBazLoc); + EXPECT_EQ(Env.getValue(*BarLoc), FooVal); }); }