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

Unified Diff: include/llvm/Bitcode/NaCl/NaClObjDumpStream.h

Issue 932953002: Fix the NaCl bitstream reader to report fatal errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Merge with master 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
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitstreamReader.h ('k') | lib/Bitcode/NaCl/Analysis/NaClObjDump.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
diff --git a/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h b/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
index f75a6c7f9394ee250b84b7844adf211cf492a215..8ff6460b6c67f70521e668def6f89e21b6819c1e 100644
--- a/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
+++ b/include/llvm/Bitcode/NaCl/NaClObjDumpStream.h
@@ -669,6 +669,8 @@ static int32_t ABBREV_INDEX_NOT_SPECIFIED = -1;
/// The formatter used for dumping records in ObjDumpStream.
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.
@@ -686,22 +688,10 @@ public:
/// Returns text corresponding to an empty label column.
std::string GetEmptyLabelColumn();
- // Converts the given start bit to the corresponding address to
- // print. That is, generate "Bit/8:Bit%8" value.
- static std::string RecordAddress(uint64_t Bit, unsigned MinByteWidth);
-
- // Returns the record address (when printing records) associated with
- // the given bit.
- static std::string RecordAddress(uint64_t Bit) {
- return RecordAddress(Bit, AddressWriteWidth);
- }
-
protected:
void WriteLineIndents() override;
private:
- // The object dumper this formatter is associated with.
- ObjDumpStream *ObjDump;
// The address label associated with the current line.
std::string Label;
// The open brace '<' for a record.
@@ -844,6 +834,7 @@ public:
/// 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);
}
@@ -852,11 +843,13 @@ public:
/// 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);
@@ -907,12 +900,6 @@ public:
return DumpAssembly;
}
- /// Changes the default assumption that bit addresses start
- /// at index 0.
- void SetStartOffset(uint64_t Offset) {
- StartOffset = Offset;
- }
-
/// Changes the maximum number of errors allowed.
void SetMaxErrors(unsigned NewMax) {
MaxErrors = NewMax;
@@ -939,18 +926,6 @@ public:
LastKnownBit = Bit;
}
- // Converts the given start bit to the corresponding address to
- // print. That is, generate "Bit/8:Bit%8" value.
- std::string ObjDumpAddress(uint64_t Bit, unsigned MinByteWidth=1) {
- return RecordFormatter.RecordAddress(Bit + StartOffset, MinByteWidth);
- }
-
- // Returns the record address (when printing records) associated with
- // the given bit.
- std::string RecordAddress(uint64_t Bit) {
- return RecordFormatter.RecordAddress(Bit + StartOffset);
- }
-
private:
// The stream to dump to.
raw_ostream &Stream;
@@ -964,9 +939,6 @@ private:
unsigned MaxErrors;
// The number of columns available to print bitcode records.
unsigned RecordWidth;
- // The number of bits to add to the record bit address, to correct
- // the record bit address passed to the write routines.
- uint64_t StartOffset;
// The buffer for assembly to be printed during the next write.
std::string AssemblyBuffer;
// The stream to buffer assembly into the assembly buffer.
@@ -996,7 +968,8 @@ private:
// Returns the message stream with 'Label(Bit/8:Bit%8): '.
raw_ostream &PrintMessagePrefix(const char *Label, uint64_t Bit) {
- return Comments() << Label << "(" << ObjDumpAddress(Bit) << "): ";
+ return Comments() << Label << "(" << NaClBitstreamReader::getBitAddress(Bit)
+ << "): ";
}
};
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitstreamReader.h ('k') | lib/Bitcode/NaCl/Analysis/NaClObjDump.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698