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

Unified Diff: src/PNaClTranslator.cpp

Issue 800883006: Add ability to test parsing of bitcode records in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix issues in last patch set. Created 5 years, 11 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
« no previous file with comments | « src/PNaClTranslator.h ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index ac4c6976477ec5e1dbb8a1d6a380924a06db2227..4156c91841de6f6fd3faf6e9ec5b52cd2d86b4fe 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -37,12 +37,6 @@
namespace {
using namespace llvm;
-// TODO(kschimpf) Remove error recovery once implementation complete.
-static cl::opt<bool> AllowErrorRecovery(
- "allow-pnacl-reader-error-recovery",
- cl::desc("Allow error recovery when reading PNaCl bitcode."),
- cl::init(false));
-
// Models elements in the list of types defined in the types block.
// These elements can be undefined, a (simple) type, or a function type
// signature. Note that an extended type is undefined on construction.
@@ -440,7 +434,7 @@ bool TopLevelParser::Error(const std::string &Message) {
ErrorStatus = true;
++NumErrors;
NaClBitcodeParser::Error(Message);
- if (!AllowErrorRecovery)
+ if (!Translator.getFlags().AllowErrorRecovery)
report_fatal_error("Unable to continue");
return true;
}
@@ -612,10 +606,11 @@ bool BlockParserBaseClass::Error(const std::string &Message) {
StrBuf << "(" << format("%" PRIu64 ":%u", (Bit / 8),
static_cast<unsigned>(Bit % 8)) << ") ";
// Note: If dump routines have been turned off, the error messages
- // will not be readable. Hence, replace with simple error.
- if (ALLOW_DUMP)
+ // will not be readable. Hence, replace with simple error. We also
+ // use the simple form for unit tests.
+ if (ALLOW_DUMP && !getFlags().GenerateUnitTestMessages) {
StrBuf << Message;
- else {
+ } else {
StrBuf << "Invalid " << getBlockName() << " record: <" << Record.GetCode();
for (const uint64_t Val : Record.GetValues()) {
StrBuf << " " << Val;
@@ -2967,6 +2962,11 @@ void PNaClTranslator::translate(const std::string &IRFilename) {
}
std::unique_ptr<MemoryBuffer> MemBuf(ErrOrFile.get().release());
+ translateBuffer(IRFilename, MemBuf.get());
+}
+
+void PNaClTranslator::translateBuffer(const std::string &IRFilename,
+ MemoryBuffer *MemBuf) {
if (MemBuf->getBufferSize() % 4 != 0) {
errs() << IRFilename
<< ": Bitcode stream should be a multiple of 4 bytes in length.\n";
« no previous file with comments | « src/PNaClTranslator.h ('k') | src/llvm2ice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698