Commit 17b1a133 by Karl Schimpf

Apply LLVM clean ups for errors when bitcode parsing.

Fixes error reporting to match that of CL https://codereview.chromium.org/986453002 BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/980393004
parent cd912149
...@@ -179,7 +179,8 @@ public: ...@@ -179,7 +179,8 @@ public:
/// Generates error with given Message, occurring at BitPosition /// Generates error with given Message, occurring at BitPosition
/// within the bitcode file. Always returns true. /// within the bitcode file. Always returns true.
bool ErrorAt(uint64_t BitPosition, const std::string &Message) final; bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t BitPosition,
const std::string &Message) final;
/// Generates error message with respect to the current block parser. /// Generates error message with respect to the current block parser.
bool BlockError(const std::string &Message); bool BlockError(const std::string &Message);
...@@ -500,15 +501,17 @@ private: ...@@ -500,15 +501,17 @@ private:
Ice::Type convertToIceTypeError(Type *LLVMTy); Ice::Type convertToIceTypeError(Type *LLVMTy);
}; };
bool TopLevelParser::ErrorAt(uint64_t Bit, const std::string &Message) { bool TopLevelParser::ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit,
const std::string &Message) {
ErrorStatus.assign(Ice::EC_Bitcode); ErrorStatus.assign(Ice::EC_Bitcode);
++NumErrors; ++NumErrors;
Ice::GlobalContext *Context = Translator.getContext(); Ice::GlobalContext *Context = Translator.getContext();
Ice::OstreamLocker L(Context); Ice::OstreamLocker L(Context);
raw_ostream &OldErrStream = setErrStream(Context->getStrDump()); raw_ostream &OldErrStream = setErrStream(Context->getStrDump());
NaClBitcodeParser::ErrorAt(Bit, Message); NaClBitcodeParser::ErrorAt(Level, Bit, Message);
setErrStream(OldErrStream); setErrStream(OldErrStream);
if (!Translator.getFlags().getAllowErrorRecovery()) if (Level >= naclbitc::Error
&& !Translator.getFlags().getAllowErrorRecovery())
Fatal(); Fatal();
return true; return true;
} }
...@@ -586,7 +589,8 @@ public: ...@@ -586,7 +589,8 @@ public:
} }
// Generates an error Message with the Bit address prefixed to it. // Generates an error Message with the Bit address prefixed to it.
bool ErrorAt(uint64_t Bit, const std::string &Message) final; bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit,
const std::string &Message) final;
protected: protected:
// The context parser that contains the decoded state. // The context parser that contains the decoded state.
...@@ -673,7 +677,8 @@ bool TopLevelParser::BlockError(const std::string &Message) { ...@@ -673,7 +677,8 @@ bool TopLevelParser::BlockError(const std::string &Message) {
} }
// Generates an error Message with the bit address prefixed to it. // Generates an error Message with the bit address prefixed to it.
bool BlockParserBaseClass::ErrorAt(uint64_t Bit, const std::string &Message) { bool BlockParserBaseClass::ErrorAt(
naclbitc::ErrorLevel Level, uint64_t Bit, const std::string &Message) {
std::string Buffer; std::string Buffer;
raw_string_ostream StrBuf(Buffer); raw_string_ostream StrBuf(Buffer);
// Note: If dump routines have been turned off, the error messages // Note: If dump routines have been turned off, the error messages
...@@ -688,7 +693,7 @@ bool BlockParserBaseClass::ErrorAt(uint64_t Bit, const std::string &Message) { ...@@ -688,7 +693,7 @@ bool BlockParserBaseClass::ErrorAt(uint64_t Bit, const std::string &Message) {
} else { } else {
StrBuf << Message; StrBuf << Message;
} }
return Context->ErrorAt(Bit, StrBuf.str()); return Context->ErrorAt(Level, Bit, StrBuf.str());
} }
void BlockParserBaseClass::ReportRecordSizeError(unsigned ExpectedSize, void BlockParserBaseClass::ReportRecordSizeError(unsigned ExpectedSize,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment