1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[PM] Teach PreservedAnalyses to have an allInSet static factory

function template to simplify building a quick object with a set marked
as preserved.

llvm-svn: 307493
This commit is contained in:
Chandler Carruth 2017-07-09 07:23:27 +00:00
parent 8652178bc5
commit 36d470ca31
2 changed files with 15 additions and 0 deletions

View File

@ -162,6 +162,14 @@ public:
return PA; return PA;
} }
/// \brief Construct a preserved analyses object with a single preserved set.
template <typename AnalysisSetT>
static PreservedAnalyses allInSet() {
PreservedAnalyses PA;
PA.preserveSet<AnalysisSetT>();
return PA;
}
/// Mark an analysis as preserved. /// Mark an analysis as preserved.
template <typename AnalysisT> void preserve() { preserve(AnalysisT::ID()); } template <typename AnalysisT> void preserve() { preserve(AnalysisT::ID()); }

View File

@ -210,6 +210,13 @@ TEST(PreservedAnalysesTest, Basic) {
EXPECT_FALSE(PAC.preserved()); EXPECT_FALSE(PAC.preserved());
EXPECT_FALSE(PAC.preservedSet<AllAnalysesOn<Function>>()); EXPECT_FALSE(PAC.preservedSet<AllAnalysesOn<Function>>());
} }
auto PA5 = PreservedAnalyses::allInSet<AllAnalysesOn<Function>>();
{
auto PAC = PA5.getChecker<TestFunctionAnalysis>();
EXPECT_FALSE(PAC.preserved());
EXPECT_TRUE(PAC.preservedSet<AllAnalysesOn<Function>>());
EXPECT_FALSE(PAC.preservedSet<AllAnalysesOn<Module>>());
}
} }
TEST(PreservedAnalysesTest, Preserve) { TEST(PreservedAnalysesTest, Preserve) {