Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: unittests/Bitcode/NaClBitReaderTest.cpp

Issue 940243003: PNaCl localmod mods in LLVM to 223109 (local files only) (Closed)
Patch Set: xx Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/pnacl-llc/pnacl-llc.cpp ('K') | « tools/pnacl-thaw/pnacl-thaw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unittests/Bitcode/NaClBitReaderTest.cpp
diff --git a/unittests/Bitcode/NaClBitReaderTest.cpp b/unittests/Bitcode/NaClBitReaderTest.cpp
index cf719ffce231eccf970817d3b0839fdf620aed39..b0a28f57b083f0c03d6de21cb68fd8706931a8a1 100644
--- a/unittests/Bitcode/NaClBitReaderTest.cpp
+++ b/unittests/Bitcode/NaClBitReaderTest.cpp
@@ -16,19 +16,20 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
#include "llvm/PassManager.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/MemoryBuffer.h"
#include "gtest/gtest.h"
namespace llvm {
namespace {
-static Module *makeLLVMModule() {
- Module* Mod = new Module("test-mem", getGlobalContext());
+static std::unique_ptr<Module> makeLLVMModule() {
+ std::unique_ptr<Module> Mod(new Module("test-mem", getGlobalContext()));
FunctionType* FuncTy =
FunctionType::get(Type::getVoidTy(Mod->getContext()), false);
Function* Func = Function::Create(FuncTy,GlobalValue::ExternalLinkage,
- "func", Mod);
+ "func", Mod.get());
BasicBlock* Entry = BasicBlock::Create(Mod->getContext(), "entry", Func);
new UnreachableInst(Mod->getContext(), Entry);
@@ -40,7 +41,7 @@ static Module *makeLLVMModule() {
}
static void writeModuleToBuffer(SmallVectorImpl<char> &Buffer) {
- std::unique_ptr<Module> Mod(makeLLVMModule());
+ std::unique_ptr<Module> Mod = makeLLVMModule();
raw_svector_ostream OS(Buffer);
NaClWriteBitcodeToFile(Mod.get(), OS);
}
@@ -49,16 +50,15 @@ static void writeModuleToBuffer(SmallVectorImpl<char> &Buffer) {
TEST(NaClBitReaderTest, MaterializeSimpleModule) {
SmallString<1024> Mem;
writeModuleToBuffer(Mem);
- MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
+ std::unique_ptr<MemoryBuffer> Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
ErrorOr<Module *> ModuleOrErr =
- getNaClLazyBitcodeModule(Buffer, getGlobalContext());
+ getNaClLazyBitcodeModule(std::move(Buffer), getGlobalContext());
EXPECT_EQ(true, bool(ModuleOrErr));
// Do something with the module just to make sure it was built.
- std::unique_ptr<Module> m(ModuleOrErr.get());
- EXPECT_NE((Module *)nullptr, m.get());
- PassManager passes;
- passes.add(createVerifierPass());
- passes.run(*m);
+ std::unique_ptr<Module> M(ModuleOrErr.get());
+ EXPECT_NE((Module *)nullptr, M.get());
+ M->getFunction("func")->materialize();
+ EXPECT_FALSE(verifyModule(*M, &dbgs()));
}
// Test that we catch bad stuff at the end of a bitcode file.
@@ -66,9 +66,9 @@ TEST(NaClBitReaderTest, BadDataAfterModule) {
SmallString<1024> Mem;
writeModuleToBuffer(Mem);
Mem.append("more"); // Length must be divisible by 4!
- MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
+ std::unique_ptr<MemoryBuffer> Buffer = MemoryBuffer::getMemBuffer(Mem.str(), "test", false);
ErrorOr<Module *> ModuleOrErr =
- getNaClLazyBitcodeModule(Buffer, getGlobalContext());
+ getNaClLazyBitcodeModule(std::move(Buffer), getGlobalContext());
EXPECT_EQ(false, bool(ModuleOrErr));
std::string BadMessage("Invalid data after module");
EXPECT_EQ(BadMessage, ModuleOrErr.getError().message());
« tools/pnacl-llc/pnacl-llc.cpp ('K') | « tools/pnacl-thaw/pnacl-thaw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698