Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- NaClBitcodeParser.h -----------------------------------*- C++ -*-===// | 1 //===- NaClBitcodeParser.h -----------------------------------*- C++ -*-===// |
| 2 // Low-level bitcode driver to parse PNaCl bitcode files. | 2 // Low-level bitcode driver to parse PNaCl bitcode files. |
| 3 // | 3 // |
| 4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
| 5 // | 5 // |
| 6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
| 7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 // | 10 // |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 NaClBitcodeParser Parser(BlockID, this); | 481 NaClBitcodeParser Parser(BlockID, this); |
| 482 return Parser.ParseThisBlock(); | 482 return Parser.ParseThisBlock(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 // Changes the stream to print errors to, and returns the old error stream. | 485 // Changes the stream to print errors to, and returns the old error stream. |
| 486 // There are two use cases: | 486 // There are two use cases: |
| 487 // 1) To change (from the default errs()) inside the constructor of the | 487 // 1) To change (from the default errs()) inside the constructor of the |
| 488 // derived class. In this context, it will be used for all error | 488 // derived class. In this context, it will be used for all error |
| 489 // messages for the derived class. | 489 // messages for the derived class. |
| 490 // 2) Temporarily modify it for a single error message. In this context, | 490 // 2) Temporarily modify it for a single error message. In this context, |
| 491 // the method Error() is overridden in the derived class, and | 491 // the method ErrorAt(ErrorLevel, Bit, Message) is overridden in |
| 492 // calls this method twice. Once before calling base method Error(), | 492 // the derived class, and calls this method twice. Once before |
| 493 // and followed by a second call to restore the default error stream. | 493 // calling base method Error(), and followed by a second call to |
|
jvoung (off chromium)
2015/03/09 18:50:23
Another mention of "base method Error()".
Probabl
Karl
2015/03/09 19:49:25
Done.
| |
| 494 // restore the default error stream. | |
| 494 raw_ostream &setErrStream(raw_ostream &Stream) { | 495 raw_ostream &setErrStream(raw_ostream &Stream) { |
| 495 raw_ostream &OldErrStream = *ErrStream; | 496 raw_ostream &OldErrStream = *ErrStream; |
| 496 ErrStream = &Stream; | 497 ErrStream = &Stream; |
| 497 return OldErrStream; | 498 return OldErrStream; |
| 498 } | 499 } |
| 499 | 500 |
| 500 // Called when an error occurs. BitPosition is the bit position the | 501 // Called when an error occurs. BitPosition is the bit position the |
| 501 // error was found, and Message is the error to report. Always | 502 // error was found, and Message is the error to report. Always |
| 502 // returns true (the error return value of Parse). | 503 // returns true (the error return value of Parse). Level is |
| 503 virtual bool ErrorAt(uint64_t BitPosition, const std::string &Message); | 504 // the severity of the error. |
| 505 virtual bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t BitPosition, | |
| 506 const std::string &Message); | |
| 507 | |
| 508 bool ErrorAt(uint64_t BitPosition, const std::string &Message) { | |
| 509 return ErrorAt(naclbitc::Error, BitPosition, Message); | |
| 510 } | |
| 504 | 511 |
| 505 // Called when an error occurs. Message is the error to | 512 // Called when an error occurs. Message is the error to |
| 506 // report. Always returns true (the error return value of Parse). | 513 // report. Always returns true (the error return value of Parse). |
| 507 bool Error(const std::string &Message) { | 514 bool Error(const std::string &Message) { |
| 508 return ErrorAt(Record.GetStartBit(), Message); | 515 return ErrorAt(Record.GetStartBit(), Message); |
| 509 } | 516 } |
| 510 | 517 |
| 511 // Called when a fatal error occurs. BitPosition is the bit position | 518 // Called when a fatal error occurs. BitPosition is the bit position |
| 512 // the error was found, and Message is the error to report. Does not | 519 // the error was found, and Message is the error to report. Does not |
| 513 // return. | 520 // return. |
| 514 LLVM_ATTRIBUTE_NORETURN | 521 LLVM_ATTRIBUTE_NORETURN |
| 515 virtual void FatalAt(uint64_t BitPosition, const std::string &Message); | 522 void FatalAt(uint64_t BitPosition, const std::string &Message) { |
| 523 ErrorAt(naclbitc::Fatal, BitPosition, Message); | |
| 524 llvm_unreachable("Fatal errors should not return"); | |
| 525 } | |
| 516 | 526 |
| 517 // Called when a fatal error occurs. Message is the error to | 527 // Called when a fatal error occurs. Message is the error to |
| 518 // report. Does not return. | 528 // report. Does not return. |
| 519 LLVM_ATTRIBUTE_NORETURN | 529 LLVM_ATTRIBUTE_NORETURN |
| 520 void Fatal(const std::string &Message) { | 530 void Fatal(const std::string &Message) { |
| 521 FatalAt(Record.GetStartBit(), Message); | 531 FatalAt(Record.GetStartBit(), Message); |
| 522 } | 532 } |
| 523 | 533 |
| 524 // Generates fatal generic error message. | 534 // Generates fatal generic error message. |
| 525 LLVM_ATTRIBUTE_NORETURN | 535 LLVM_ATTRIBUTE_NORETURN |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 bool ParseBlockInternal(); | 648 bool ParseBlockInternal(); |
| 639 | 649 |
| 640 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 650 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
| 641 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 651 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
| 642 | 652 |
| 643 }; | 653 }; |
| 644 | 654 |
| 645 } // namespace llvm | 655 } // namespace llvm |
| 646 | 656 |
| 647 #endif | 657 #endif |
| OLD | NEW |