Transforms: Update unit tests to use verifyModule()

Since I'm slowly gutting `DISubprogram` and `DICompileUnit`, update the
`CloneFunc` unit tests to call `verifyModule()` (where the checks are
moving to).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233602 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-03-30 21:35:14 +00:00
parent 494ae8db19
commit 7f3757eb9b

View File

@ -22,6 +22,7 @@
#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h" #include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using namespace llvm; using namespace llvm;
@ -297,15 +298,17 @@ TEST_F(CloneFunc, NewFunctionCreated) {
// Test that a new subprogram entry was added and is pointing to the new // Test that a new subprogram entry was added and is pointing to the new
// function, while the original subprogram still points to the old one. // function, while the original subprogram still points to the old one.
TEST_F(CloneFunc, Subprogram) { TEST_F(CloneFunc, Subprogram) {
EXPECT_FALSE(verifyModule(*M));
unsigned SubprogramCount = Finder->subprogram_count(); unsigned SubprogramCount = Finder->subprogram_count();
EXPECT_EQ(2U, SubprogramCount); EXPECT_EQ(2U, SubprogramCount);
auto Iter = Finder->subprograms().begin(); auto Iter = Finder->subprograms().begin();
DISubprogram Sub1(*Iter); DISubprogram Sub1(*Iter);
EXPECT_TRUE(Sub1.Verify()); EXPECT_TRUE(Sub1.isSubprogram());
Iter++; Iter++;
DISubprogram Sub2(*Iter); DISubprogram Sub2(*Iter);
EXPECT_TRUE(Sub2.Verify()); EXPECT_TRUE(Sub2.isSubprogram());
EXPECT_TRUE((Sub1.getFunction() == OldFunc && Sub2.getFunction() == NewFunc) EXPECT_TRUE((Sub1.getFunction() == OldFunc && Sub2.getFunction() == NewFunc)
|| (Sub1.getFunction() == NewFunc && Sub2.getFunction() == OldFunc)); || (Sub1.getFunction() == NewFunc && Sub2.getFunction() == OldFunc));
@ -314,14 +317,16 @@ TEST_F(CloneFunc, Subprogram) {
// Test that the new subprogram entry was not added to the CU which doesn't // Test that the new subprogram entry was not added to the CU which doesn't
// contain the old subprogram entry. // contain the old subprogram entry.
TEST_F(CloneFunc, SubprogramInRightCU) { TEST_F(CloneFunc, SubprogramInRightCU) {
EXPECT_FALSE(verifyModule(*M));
EXPECT_EQ(2U, Finder->compile_unit_count()); EXPECT_EQ(2U, Finder->compile_unit_count());
auto Iter = Finder->compile_units().begin(); auto Iter = Finder->compile_units().begin();
DICompileUnit CU1(*Iter); DICompileUnit CU1(*Iter);
EXPECT_TRUE(CU1.Verify()); EXPECT_TRUE(CU1.isCompileUnit());
Iter++; Iter++;
DICompileUnit CU2(*Iter); DICompileUnit CU2(*Iter);
EXPECT_TRUE(CU2.Verify()); EXPECT_TRUE(CU2.isCompileUnit());
EXPECT_TRUE(CU1.getSubprograms().getNumElements() == 0 EXPECT_TRUE(CU1.getSubprograms().getNumElements() == 0
|| CU2.getSubprograms().getNumElements() == 0); || CU2.getSubprograms().getNumElements() == 0);
} }
@ -329,6 +334,8 @@ TEST_F(CloneFunc, SubprogramInRightCU) {
// Test that instructions in the old function still belong to it in the // Test that instructions in the old function still belong to it in the
// metadata, while instruction in the new function belong to the new one. // metadata, while instruction in the new function belong to the new one.
TEST_F(CloneFunc, InstructionOwnership) { TEST_F(CloneFunc, InstructionOwnership) {
EXPECT_FALSE(verifyModule(*M));
inst_iterator OldIter = inst_begin(OldFunc); inst_iterator OldIter = inst_begin(OldFunc);
inst_iterator OldEnd = inst_end(OldFunc); inst_iterator OldEnd = inst_end(OldFunc);
inst_iterator NewIter = inst_begin(NewFunc); inst_iterator NewIter = inst_begin(NewFunc);
@ -350,8 +357,8 @@ TEST_F(CloneFunc, InstructionOwnership) {
// But that they belong to different functions // But that they belong to different functions
DISubprogram OldSubprogram(OldDL.getScope()); DISubprogram OldSubprogram(OldDL.getScope());
DISubprogram NewSubprogram(NewDL.getScope()); DISubprogram NewSubprogram(NewDL.getScope());
EXPECT_TRUE(OldSubprogram.Verify()); EXPECT_TRUE(OldSubprogram.isSubprogram());
EXPECT_TRUE(NewSubprogram.Verify()); EXPECT_TRUE(NewSubprogram.isSubprogram());
EXPECT_EQ(OldFunc, OldSubprogram.getFunction()); EXPECT_EQ(OldFunc, OldSubprogram.getFunction());
EXPECT_EQ(NewFunc, NewSubprogram.getFunction()); EXPECT_EQ(NewFunc, NewSubprogram.getFunction());
} }
@ -366,6 +373,8 @@ TEST_F(CloneFunc, InstructionOwnership) {
// Test that the arguments for debug intrinsics in the new function were // Test that the arguments for debug intrinsics in the new function were
// properly cloned // properly cloned
TEST_F(CloneFunc, DebugIntrinsics) { TEST_F(CloneFunc, DebugIntrinsics) {
EXPECT_FALSE(verifyModule(*M));
inst_iterator OldIter = inst_begin(OldFunc); inst_iterator OldIter = inst_begin(OldFunc);
inst_iterator OldEnd = inst_end(OldFunc); inst_iterator OldEnd = inst_end(OldFunc);
inst_iterator NewIter = inst_begin(NewFunc); inst_iterator NewIter = inst_begin(NewFunc);