diff options
author | Rumeet Dhindsa <rdhindsa@google.com> | 2020-03-10 10:59:26 -0700 |
---|---|---|
committer | Rumeet Dhindsa <rdhindsa@google.com> | 2020-03-10 10:59:26 -0700 |
commit | 57a2eaf3c1aa1a08e9b474b873064e075c52daef (patch) | |
tree | 1148ef779729a5cee1a973d70e9ca89fb0fbce3a /clang/unittests/Serialization/InMemoryModuleCacheTest.cpp | |
parent | 66945b62f42f0911a328a354cbc7db40b05b76eb (diff) | |
download | llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.zip llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.tar.gz llvm-57a2eaf3c1aa1a08e9b474b873064e075c52daef.tar.bz2 |
Revert "[modules] Do not cache invalid state for modules that we attempted to load."
As per comment on https://reviews.llvm.org/D72860, it is suggested to
revert this change in the meantime, since it has introduced regression.
This reverts commit 83f4c3af021cd5322ea10fd1c4e839874c1dae49.
Diffstat (limited to 'clang/unittests/Serialization/InMemoryModuleCacheTest.cpp')
-rw-r--r-- | clang/unittests/Serialization/InMemoryModuleCacheTest.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp b/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp index 7a5a3d4..ed5e153 100644 --- a/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp +++ b/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp @@ -24,11 +24,12 @@ std::unique_ptr<MemoryBuffer> getBuffer(int I) { TEST(InMemoryModuleCacheTest, initialState) { InMemoryModuleCache Cache; - EXPECT_EQ(nullptr, Cache.lookupPCM("B")); + EXPECT_EQ(InMemoryModuleCache::Unknown, Cache.getPCMState("B")); EXPECT_FALSE(Cache.isPCMFinal("B")); + EXPECT_FALSE(Cache.shouldBuildPCM("B")); #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST - EXPECT_DEATH(Cache.tryToRemovePCM("B"), "PCM to remove is unknown"); + EXPECT_DEATH(Cache.tryToDropPCM("B"), "PCM to remove is unknown"); EXPECT_DEATH(Cache.finalizePCM("B"), "PCM to finalize is unknown"); #endif } @@ -39,33 +40,37 @@ TEST(InMemoryModuleCacheTest, addPCM) { InMemoryModuleCache Cache; EXPECT_EQ(RawB, &Cache.addPCM("B", std::move(B))); + EXPECT_EQ(InMemoryModuleCache::Tentative, Cache.getPCMState("B")); EXPECT_EQ(RawB, Cache.lookupPCM("B")); EXPECT_FALSE(Cache.isPCMFinal("B")); + EXPECT_FALSE(Cache.shouldBuildPCM("B")); #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM"); - EXPECT_DEATH(Cache.addFinalPCM("B", getBuffer(2)), - "Already has a non-final PCM"); + EXPECT_DEATH(Cache.addBuiltPCM("B", getBuffer(2)), + "Trying to override tentative PCM"); #endif } -TEST(InMemoryModuleCacheTest, addFinalPCM) { +TEST(InMemoryModuleCacheTest, addBuiltPCM) { auto B = getBuffer(1); auto *RawB = B.get(); InMemoryModuleCache Cache; - EXPECT_EQ(RawB, &Cache.addFinalPCM("B", std::move(B))); + EXPECT_EQ(RawB, &Cache.addBuiltPCM("B", std::move(B))); + EXPECT_EQ(InMemoryModuleCache::Final, Cache.getPCMState("B")); EXPECT_EQ(RawB, Cache.lookupPCM("B")); EXPECT_TRUE(Cache.isPCMFinal("B")); + EXPECT_FALSE(Cache.shouldBuildPCM("B")); #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM"); - EXPECT_DEATH(Cache.addFinalPCM("B", getBuffer(2)), + EXPECT_DEATH(Cache.addBuiltPCM("B", getBuffer(2)), "Trying to override finalized PCM"); #endif } -TEST(InMemoryModuleCacheTest, tryToRemovePCM) { +TEST(InMemoryModuleCacheTest, tryToDropPCM) { auto B1 = getBuffer(1); auto B2 = getBuffer(2); auto *RawB1 = B1.get(); @@ -73,22 +78,27 @@ TEST(InMemoryModuleCacheTest, tryToRemovePCM) { ASSERT_NE(RawB1, RawB2); InMemoryModuleCache Cache; + EXPECT_EQ(InMemoryModuleCache::Unknown, Cache.getPCMState("B")); EXPECT_EQ(RawB1, &Cache.addPCM("B", std::move(B1))); - EXPECT_FALSE(Cache.tryToRemovePCM("B")); + EXPECT_FALSE(Cache.tryToDropPCM("B")); EXPECT_EQ(nullptr, Cache.lookupPCM("B")); + EXPECT_EQ(InMemoryModuleCache::ToBuild, Cache.getPCMState("B")); EXPECT_FALSE(Cache.isPCMFinal("B")); + EXPECT_TRUE(Cache.shouldBuildPCM("B")); #if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST - EXPECT_DEATH(Cache.tryToRemovePCM("B"), "PCM to remove is unknown"); - EXPECT_DEATH(Cache.finalizePCM("B"), "PCM to finalize is unknown"); + EXPECT_DEATH(Cache.addPCM("B", getBuffer(2)), "Already has a PCM"); + EXPECT_DEATH(Cache.tryToDropPCM("B"), + "PCM to remove is scheduled to be built"); + EXPECT_DEATH(Cache.finalizePCM("B"), "Trying to finalize a dropped PCM"); #endif // Add a new one. - EXPECT_EQ(RawB2, &Cache.addFinalPCM("B", std::move(B2))); + EXPECT_EQ(RawB2, &Cache.addBuiltPCM("B", std::move(B2))); EXPECT_TRUE(Cache.isPCMFinal("B")); // Can try to drop again, but this should error and do nothing. - EXPECT_TRUE(Cache.tryToRemovePCM("B")); + EXPECT_TRUE(Cache.tryToDropPCM("B")); EXPECT_EQ(RawB2, Cache.lookupPCM("B")); } @@ -97,10 +107,12 @@ TEST(InMemoryModuleCacheTest, finalizePCM) { auto *RawB = B.get(); InMemoryModuleCache Cache; + EXPECT_EQ(InMemoryModuleCache::Unknown, Cache.getPCMState("B")); EXPECT_EQ(RawB, &Cache.addPCM("B", std::move(B))); // Call finalize. Cache.finalizePCM("B"); + EXPECT_EQ(InMemoryModuleCache::Final, Cache.getPCMState("B")); EXPECT_TRUE(Cache.isPCMFinal("B")); } |