| Index: include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
|
| diff --git a/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h b/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
|
| index 8ff6460b6c67f70521e668def6f89e21b6819c1e..fa8575f7951d2d0b5a9ae71dd92889fa43aae1de 100644
|
| --- a/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
|
| +++ b/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
|
| @@ -672,9 +672,9 @@ class RecordTextFormatter : public TextFormatter {
|
| RecordTextFormatter(const RecordTextFormatter&) = delete;
|
| RecordTextFormatter &operator=(const RecordTextFormatter&) = delete;
|
| public:
|
| - /// The address write width used to print the number of
|
| - /// bytes in the record bit address, when printing records.
|
| - static const unsigned AddressWriteWidth = 8;
|
| + /// The address write width used to print a bit address, when
|
| + /// printing records.
|
| + static const unsigned AddressWriteWidth = 10;
|
|
|
| explicit RecordTextFormatter(ObjDumpStream *ObjDump);
|
|
|
| @@ -708,6 +708,9 @@ private:
|
| StartClusteringDirective StartCluster;
|
| // End clustering tokens.
|
| FinishClusteringDirective FinishCluster;
|
| +
|
| + // Generates an address label with padding to match AddressWriteWidth;
|
| + std::string getBitAddress(uint64_t Bit);
|
| };
|
|
|
| /// Implements a stream to print out bitcode records, assembly code,
|
| @@ -806,53 +809,40 @@ public:
|
| /// then returns the comments stream. In general, warnings will be
|
| /// printed after the next record, unless a call to Flush is made.
|
| raw_ostream &Warning() {
|
| - return Warning(LastKnownBit);
|
| + return WarningAt(LastKnownBit);
|
| }
|
|
|
| /// Prints "Warning(Bit/8:Bit%8): " onto the comments stream, and
|
| /// then returns the comments stream. In general, warnings will be
|
| /// printed after the next record, unless a call to Flush is made.
|
| - raw_ostream &Warning(uint64_t Bit) {
|
| + raw_ostream &WarningAt(uint64_t Bit) {
|
| LastKnownBit = Bit;
|
| - return PrintMessagePrefix("Warning", Bit);
|
| + return naclbitc::ErrorAt(Comments(), naclbitc::Warning, Bit);
|
| }
|
|
|
| - /// Prints "Error(Bit/8:Bit%8): " onto the comments stream, records
|
| - /// that an error has occurred, and then returns the comments
|
| - /// stream. In general errors will be printed after the next record,
|
| - /// unless a call to Flush is made.
|
| + /// Prints "Error(Bit/8:Bit%8): " onto the comments stream using the
|
| + /// last know bit position of the input. Then, it records that an
|
| + /// error has occurred and returns the comments stream. In general
|
| + /// errors will be printed after the next record, unless a call to
|
| + /// Flush is made.
|
| raw_ostream &Error() {
|
| - return Error(LastKnownBit);
|
| - }
|
| -
|
| - /// Prints "Error(Bit/8:Bit%8): " onto the comments stream, records
|
| - /// that an error has occurred, and then returns the comments
|
| - /// stream. In general errors will be printed after the next record,
|
| - /// unless a call to Flush is made.
|
| - raw_ostream &Error(uint64_t Bit);
|
| -
|
| - /// Write a fatal error message to the dump stream, and then
|
| - /// stop the executable. If any assembly, comments, or errors have
|
| - /// been buffered, they will be printed first.
|
| - LLVM_ATTRIBUTE_NORETURN
|
| - void Fatal(const std::string &Message) {
|
| - Fatal(LastKnownBit, Message);
|
| - }
|
| -
|
| - /// Write a fatal error message to the dump stream, and then
|
| - /// stop the executable. If any assembly, comments, or errors have
|
| - /// been buffered, they will be printed first. Associates fatal error
|
| - /// Message with the given Bit.
|
| - LLVM_ATTRIBUTE_NORETURN
|
| - void Fatal(uint64_t Bit, const std::string &Message);
|
| -
|
| - /// Write a fatal error message to the dump stream, and then
|
| - /// stop the executable. If any assembly, comments, or errors have
|
| - /// been buffered, they will be printed first, along with the given record.
|
| - LLVM_ATTRIBUTE_NORETURN
|
| - void Fatal(uint64_t Bit,
|
| - const llvm::NaClBitcodeRecordData &Record,
|
| - const std::string &Message);
|
| + return ErrorAt(LastKnownBit);
|
| + }
|
| +
|
| + /// Prints "Error(Bit/8:Bit%8): " onto the comments stream at the
|
| + /// given Bit position. Then, it records that an error has occurred
|
| + /// and returns the comments stream. In general errors will be
|
| + /// printed after the next record, unless a call to Flush is made.
|
| + raw_ostream &ErrorAt(uint64_t Bit) {
|
| + return ErrorAt(naclbitc::Error, Bit);
|
| + }
|
| +
|
| + /// Prints "Level(Bit/8:Bit%8): " onto the comments stream at the
|
| + /// given bit position and severity Level. Then, it records that an
|
| + /// error has occurred and then returns the comments stream. In
|
| + /// general errors will be printed after the next record, unless a
|
| + /// call to Flush is made.
|
| + raw_ostream &ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit);
|
|
|
| /// Dumps a record (at the given bit), along with all buffered assembly,
|
| /// comments, and errors, into the objdump stream.
|
| @@ -869,6 +859,11 @@ public:
|
| /// corresponding record, into the objdump stream.
|
| void Flush();
|
|
|
| + /// Flushes out the last record and/or error, and then stops
|
| + /// the executable. Should be called immediately after generating
|
| + /// the error message using ErrorAt(naclbitc::Fatal,...).
|
| + void FlushThenQuit();
|
| +
|
| /// Increments the record indent by one.
|
| void IncRecordIndent() {
|
| RecordFormatter.Inc();
|
| @@ -920,8 +915,7 @@ public:
|
| }
|
|
|
| /// Changes the internal state, to assume one is processing a record
|
| - /// at the given bit. Used by Error() and Fatal(Message) to fill in
|
| - /// the corresponding bit to associate with the error message.
|
| + /// at the given bit.
|
| void SetRecordBitAddress(uint64_t Bit) {
|
| LastKnownBit = Bit;
|
| }
|
| @@ -965,12 +959,6 @@ private:
|
| AssemblyBuffer.clear();
|
| MessageBuffer.clear();
|
| }
|
| -
|
| - // Returns the message stream with 'Label(Bit/8:Bit%8): '.
|
| - raw_ostream &PrintMessagePrefix(const char *Label, uint64_t Bit) {
|
| - return Comments() << Label << "(" << NaClBitstreamReader::getBitAddress(Bit)
|
| - << "): ";
|
| - }
|
| };
|
|
|
| }
|
|
|