diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-07-05 14:21:36 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-07-05 14:21:36 +0000 | 
| commit | 1a82d4c088707c791c792f6822f611b47a12bdfe (patch) | |
| tree | 7c411f9b5d807f7f204fdd16965d8925a82b6d18 /unittests/Transforms/Utils/Cloning.cpp | |
| parent | 3a0822f094b578157263e04114075ad7df81db41 (diff) | |
Notes
Diffstat (limited to 'unittests/Transforms/Utils/Cloning.cpp')
| -rw-r--r-- | unittests/Transforms/Utils/Cloning.cpp | 35 | 
1 files changed, 35 insertions, 0 deletions
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index 18d3ca6267535..e2671499e812a 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -415,4 +415,39 @@ TEST_F(CloneFunc, DebugIntrinsics) {    }  } +class CloneModule : public ::testing::Test { +protected: +  void SetUp() override { +    SetupModule(); +    CreateOldModule(); +    CreateNewModule(); +  } + +  void SetupModule() { OldM = new Module("", C); } + +  void CreateOldModule() { +    IRBuilder<> IBuilder(C); + +    auto *FuncType = FunctionType::get(Type::getVoidTy(C), false); +    auto *PersFn = Function::Create(FuncType, GlobalValue::ExternalLinkage, +                                    "persfn", OldM); +    auto *F = +        Function::Create(FuncType, GlobalValue::PrivateLinkage, "f", OldM); +    F->setPersonalityFn(PersFn); +    auto *Entry = BasicBlock::Create(C, "", F); +    IBuilder.SetInsertPoint(Entry); +    IBuilder.CreateRetVoid(); +  } + +  void CreateNewModule() { NewM = llvm::CloneModule(OldM); } + +  LLVMContext C; +  Module *OldM; +  Module *NewM; +}; + +TEST_F(CloneModule, Verify) { +  EXPECT_FALSE(verifyModule(*NewM)); +} +  }  | 
