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

Side by Side Diff: lib/Bitcode/NaCl/TestUtils/NaClBitcodeMunge.cpp

Issue 1310883003: Install notion of diagnostic handler into PNaCl bitcode readers. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix issues in patch set 2. Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 //===--- Bitcode/NaCl/TestUtils/NaClBitcodeMunge.cpp - Bitcode Munger -----===// 1 //===--- Bitcode/NaCl/TestUtils/NaClBitcodeMunge.cpp - Bitcode Munger -----===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Bitcode writer/munger implementation for testing. 10 // Bitcode writer/munger implementation for testing.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return cleanupTest(); 134 return cleanupTest();
135 } 135 }
136 136
137 bool NaClParseBitcodeMunger::runTest(const uint64_t Munges[], size_t MungesSize, 137 bool NaClParseBitcodeMunger::runTest(const uint64_t Munges[], size_t MungesSize,
138 bool VerboseErrors) { 138 bool VerboseErrors) {
139 bool AddHeader = true; 139 bool AddHeader = true;
140 if (!setupTest(Munges, MungesSize, AddHeader)) 140 if (!setupTest(Munges, MungesSize, AddHeader))
141 return cleanupTest(); 141 return cleanupTest();
142 142
143 LLVMContext &Context = getGlobalContext(); 143 LLVMContext &Context = getGlobalContext();
144
145 raw_ostream *VerboseStrm = VerboseErrors ? &getDumpStream() : nullptr;
146 ErrorOr<Module *> ModuleOrError = 144 ErrorOr<Module *> ModuleOrError =
147 NaClParseBitcodeFile(MungedInput->getMemBufferRef(), Context, 145 NaClParseBitcodeFile(MungedInput->getMemBufferRef(), Context,
148 VerboseStrm); 146 redirectNaClDiagnosticToStream(getDumpStream()));
149 if (ModuleOrError) { 147 if (ModuleOrError) {
150 if (VerboseErrors) 148 if (VerboseErrors)
151 getDumpStream() << "Successful parse!\n"; 149 getDumpStream() << "Successful parse!\n";
152 delete ModuleOrError.get(); 150 delete ModuleOrError.get();
153 } else { 151 } else {
154 Error() << ModuleOrError.getError().message() << "\n"; 152 Error() << ModuleOrError.getError().message() << "\n";
155 } 153 }
156 return cleanupTest(); 154 return cleanupTest();
157 } 155 }
158 156
159 bool NaClCompressMunger::runTest(const uint64_t Munges[], size_t MungesSize) { 157 bool NaClCompressMunger::runTest(const uint64_t Munges[], size_t MungesSize) {
160 bool AddHeader = true; 158 bool AddHeader = true;
161 if (!setupTest(Munges, MungesSize, AddHeader)) 159 if (!setupTest(Munges, MungesSize, AddHeader))
162 return cleanupTest(); 160 return cleanupTest();
163 161
164 NaClBitcodeCompressor Compressor; 162 NaClBitcodeCompressor Compressor;
165 if (!Compressor.compress(MungedInput.get(), getDumpStream())) 163 if (!Compressor.compress(MungedInput.get(), getDumpStream()))
166 Error() << "Unable to compress\n"; 164 Error() << "Unable to compress\n";
167 return cleanupTest(); 165 return cleanupTest();
168 } 166 }
OLDNEW
« no previous file with comments | « lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp ('k') | lib/Bitcode/NaCl/TestUtils/NaClBitcodeTextReader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698