diff options
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/Analysis/CFGTest.cpp | 10 | ||||
-rw-r--r-- | llvm/unittests/Analysis/LazyCallGraphTest.cpp | 8 | ||||
-rw-r--r-- | llvm/unittests/Bitcode/BitReaderTest.cpp | 8 | ||||
-rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/JITTest.cpp | 18 | ||||
-rw-r--r-- | llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp | 3 | ||||
-rw-r--r-- | llvm/unittests/IR/DominatorTreeTest.cpp | 7 | ||||
-rw-r--r-- | llvm/unittests/IR/PassManagerTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/UseTest.cpp | 4 | ||||
-rw-r--r-- | llvm/unittests/IR/UserTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/ValueTest.cpp | 2 |
10 files changed, 26 insertions, 38 deletions
diff --git a/llvm/unittests/Analysis/CFGTest.cpp b/llvm/unittests/Analysis/CFGTest.cpp index ac5e71061d8..dba9d4991ec 100644 --- a/llvm/unittests/Analysis/CFGTest.cpp +++ b/llvm/unittests/Analysis/CFGTest.cpp @@ -30,20 +30,16 @@ namespace { class IsPotentiallyReachableTest : public testing::Test { protected: void ParseAssembly(const char *Assembly) { - M.reset(new Module("Module", getGlobalContext())); - SMDiagnostic Error; - bool Parsed = ParseAssemblyString(Assembly, M.get(), - Error, M->getContext()) == M.get(); + M = parseAssemblyString(Assembly, Error, getGlobalContext()); std::string errMsg; raw_string_ostream os(errMsg); Error.print("", os); - if (!Parsed) { - // A failure here means that the test itself is buggy. + // A failure here means that the test itself is buggy. + if (!M) report_fatal_error(os.str().c_str()); - } Function *F = M->getFunction("test"); if (F == nullptr) diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp index d7c70453c9b..5f73d83f092 100644 --- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp +++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp @@ -22,18 +22,16 @@ using namespace llvm; namespace { std::unique_ptr<Module> parseAssembly(const char *Assembly) { - auto M = make_unique<Module>("Module", getGlobalContext()); - SMDiagnostic Error; - bool Parsed = - ParseAssemblyString(Assembly, M.get(), Error, M->getContext()) == M.get(); + std::unique_ptr<Module> M = + parseAssemblyString(Assembly, Error, getGlobalContext()); std::string ErrMsg; raw_string_ostream OS(ErrMsg); Error.print("", OS); // A failure here means that the test itself is buggy. - if (!Parsed) + if (!M) report_fatal_error(OS.str().c_str()); return M; diff --git a/llvm/unittests/Bitcode/BitReaderTest.cpp b/llvm/unittests/Bitcode/BitReaderTest.cpp index 8331527437b..adc8851f279 100644 --- a/llvm/unittests/Bitcode/BitReaderTest.cpp +++ b/llvm/unittests/Bitcode/BitReaderTest.cpp @@ -26,18 +26,16 @@ using namespace llvm; namespace { std::unique_ptr<Module> parseAssembly(const char *Assembly) { - auto M = make_unique<Module>("Module", getGlobalContext()); - SMDiagnostic Error; - bool Parsed = - ParseAssemblyString(Assembly, M.get(), Error, M->getContext()) == M.get(); + std::unique_ptr<Module> M = + parseAssemblyString(Assembly, Error, getGlobalContext()); std::string ErrMsg; raw_string_ostream OS(ErrMsg); Error.print("", OS); // A failure here means that the test itself is buggy. - if (!Parsed) + if (!M) report_fatal_error(OS.str().c_str()); return M; diff --git a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp index 6110cb59747..4ba54b1d486 100644 --- a/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp +++ b/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp @@ -166,15 +166,14 @@ public: } }; -bool LoadAssemblyInto(Module *M, const char *assembly) { +std::unique_ptr<Module> loadAssembly(LLVMContext &C, const char *Assembly) { SMDiagnostic Error; - bool success = - nullptr != ParseAssemblyString(assembly, M, Error, M->getContext()); + std::unique_ptr<Module> M = parseAssemblyString(Assembly, Error, C); std::string errMsg; raw_string_ostream os(errMsg); Error.print("", os); - EXPECT_TRUE(success) << os.str(); - return success; + EXPECT_TRUE((bool)M) << os.str(); + return M; } class JITTest : public testing::Test { @@ -200,7 +199,7 @@ class JITTest : public testing::Test { } void LoadAssembly(const char *assembly) { - LoadAssemblyInto(M, assembly); + M = loadAssembly(Context, assembly).release(); } LLVMContext Context; @@ -615,14 +614,13 @@ TEST_F(JITTest, EscapedLazyStubStillCallable) { // Converts the LLVM assembly to bitcode and returns it in a std::string. An // empty string indicates an error. std::string AssembleToBitcode(LLVMContext &Context, const char *Assembly) { - Module TempModule("TempModule", Context); - if (!LoadAssemblyInto(&TempModule, Assembly)) { + std::unique_ptr<Module> TempModule = loadAssembly(Context, Assembly); + if (!TempModule) return ""; - } std::string Result; raw_string_ostream OS(Result); - WriteBitcodeToFile(&TempModule, OS); + WriteBitcodeToFile(TempModule.get(), OS); OS.flush(); return Result; } diff --git a/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp b/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp index 73acc6b1186..ceed7e826ad 100644 --- a/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp +++ b/llvm/unittests/ExecutionEngine/JIT/MultiJITTest.cpp @@ -27,8 +27,7 @@ namespace { std::unique_ptr<Module> loadAssembly(LLVMContext &Context, const char *Assembly) { SMDiagnostic Error; - std::unique_ptr<Module> Ret( - ParseAssemblyString(Assembly, nullptr, Error, Context)); + std::unique_ptr<Module> Ret = parseAssemblyString(Assembly, Error, Context); std::string errMsg; raw_string_ostream os(errMsg); Error.print("", os); diff --git a/llvm/unittests/IR/DominatorTreeTest.cpp b/llvm/unittests/IR/DominatorTreeTest.cpp index ab43d1c91fc..6c43d6fe7c7 100644 --- a/llvm/unittests/IR/DominatorTreeTest.cpp +++ b/llvm/unittests/IR/DominatorTreeTest.cpp @@ -186,8 +186,7 @@ namespace llvm { }; char DPass::ID = 0; - - Module* makeLLVMModule(DPass *P) { + std::unique_ptr<Module> makeLLVMModule(DPass *P) { const char *ModuleStrig = "declare i32 @g()\n" \ "define void @f(i32 %x) {\n" \ @@ -213,12 +212,12 @@ namespace llvm { "}\n"; LLVMContext &C = getGlobalContext(); SMDiagnostic Err; - return ParseAssemblyString(ModuleStrig, nullptr, Err, C); + return parseAssemblyString(ModuleStrig, Err, C); } TEST(DominatorTree, Unreachable) { DPass *P = new DPass(); - std::unique_ptr<Module> M(makeLLVMModule(P)); + std::unique_ptr<Module> M = makeLLVMModule(P); PassManager Passes; Passes.add(P); Passes.run(*M); diff --git a/llvm/unittests/IR/PassManagerTest.cpp b/llvm/unittests/IR/PassManagerTest.cpp index 25037a773cf..d493156a343 100644 --- a/llvm/unittests/IR/PassManagerTest.cpp +++ b/llvm/unittests/IR/PassManagerTest.cpp @@ -168,7 +168,7 @@ struct TestInvalidationFunctionPass { Module *parseIR(const char *IR) { LLVMContext &C = getGlobalContext(); SMDiagnostic Err; - return ParseAssemblyString(IR, nullptr, Err, C); + return parseAssemblyString(IR, Err, C).release(); } class PassManagerTest : public ::testing::Test { diff --git a/llvm/unittests/IR/UseTest.cpp b/llvm/unittests/IR/UseTest.cpp index fa73fe77bd3..3f33ca6a368 100644 --- a/llvm/unittests/IR/UseTest.cpp +++ b/llvm/unittests/IR/UseTest.cpp @@ -38,7 +38,7 @@ TEST(UseTest, sort) { "}\n"; SMDiagnostic Err; char vnbuf[8]; - Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C); Function *F = M->getFunction("f"); ASSERT_TRUE(F); ASSERT_TRUE(F->arg_begin() != F->arg_end()); @@ -83,7 +83,7 @@ TEST(UseTest, reverse) { "}\n"; SMDiagnostic Err; char vnbuf[8]; - Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C); Function *F = M->getFunction("f"); ASSERT_TRUE(F); ASSERT_TRUE(F->arg_begin() != F->arg_end()); diff --git a/llvm/unittests/IR/UserTest.cpp b/llvm/unittests/IR/UserTest.cpp index eb07e824d8b..5572424d19c 100644 --- a/llvm/unittests/IR/UserTest.cpp +++ b/llvm/unittests/IR/UserTest.cpp @@ -65,7 +65,7 @@ TEST(UserTest, ValueOpIteration) { " ret void\n" "}\n"; SMDiagnostic Err; - Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C); Function *F = M->getFunction("f"); BasicBlock &ExitBB = F->back(); diff --git a/llvm/unittests/IR/ValueTest.cpp b/llvm/unittests/IR/ValueTest.cpp index 61e44a908d4..dc5794b46d2 100644 --- a/llvm/unittests/IR/ValueTest.cpp +++ b/llvm/unittests/IR/ValueTest.cpp @@ -34,7 +34,7 @@ TEST(ValueTest, UsedInBasicBlock) { " ret void\n" "}\n"; SMDiagnostic Err; - Module *M = ParseAssemblyString(ModuleString, nullptr, Err, C); + std::unique_ptr<Module> M = parseAssemblyString(ModuleString, Err, C); Function *F = M->getFunction("f"); |