summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ExecutionEngine/JIT/JITTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-08-19 16:58:54 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-08-19 16:58:54 +0000
commit11c07d7eec2889be194e1662277542af2c9359df (patch)
treecf10f6375d086cd35dc910d75cba0497bb53ce8a /llvm/unittests/ExecutionEngine/JIT/JITTest.cpp
parent38f556d96d564fbd0fa9f76b5bd049338698b053 (diff)
downloadbcm5719-llvm-11c07d7eec2889be194e1662277542af2c9359df.tar.gz
bcm5719-llvm-11c07d7eec2889be194e1662277542af2c9359df.zip
Modernize the .ll parsing interface.
* Use StringRef instead of std::string& * Return a std::unique_ptr<Module> instead of taking an optional module to write to (was not really used). * Use current comment style. * Use current naming convention. llvm-svn: 215989
Diffstat (limited to 'llvm/unittests/ExecutionEngine/JIT/JITTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/JIT/JITTest.cpp18
1 files changed, 8 insertions, 10 deletions
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;
}
OpenPOWER on IntegriCloud