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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 // Default implementation just builds a parser that does nothing. | 480 // Default implementation just builds a parser that does nothing. |
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. |
491 // the method Error() is overridden in the derived class, and | |
492 // calls this method twice. Once before calling base method Error(), | |
493 // and followed by a second call to restore the default error stream. | |
494 raw_ostream &setErrStream(raw_ostream &Stream) { | 491 raw_ostream &setErrStream(raw_ostream &Stream) { |
495 raw_ostream &OldErrStream = *ErrStream; | 492 raw_ostream &OldErrStream = *ErrStream; |
496 ErrStream = &Stream; | 493 ErrStream = &Stream; |
497 return OldErrStream; | 494 return OldErrStream; |
498 } | 495 } |
499 | 496 |
500 // Called when an error occurs. BitPosition is the bit position the | 497 // Called when an error occurs. BitPosition is the bit position the |
501 // error was found, and Message is the error to report. Always | 498 // error was found, and Message is the error to report. Always |
502 // returns true (the error return value of Parse). | 499 // returns true (the error return value of Parse). Level is |
503 virtual bool ErrorAt(uint64_t BitPosition, const std::string &Message); | 500 // the severity of the error. |
| 501 virtual bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t BitPosition, |
| 502 const std::string &Message); |
| 503 |
| 504 bool ErrorAt(uint64_t BitPosition, const std::string &Message) { |
| 505 return ErrorAt(naclbitc::Error, BitPosition, Message); |
| 506 } |
504 | 507 |
505 // Called when an error occurs. Message is the error to | 508 // Called when an error occurs. Message is the error to |
506 // report. Always returns true (the error return value of Parse). | 509 // report. Always returns true (the error return value of Parse). |
507 bool Error(const std::string &Message) { | 510 bool Error(const std::string &Message) { |
508 return ErrorAt(Record.GetStartBit(), Message); | 511 return ErrorAt(Record.GetStartBit(), Message); |
509 } | 512 } |
510 | 513 |
511 // Called when a fatal error occurs. BitPosition is the bit position | 514 // 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 | 515 // the error was found, and Message is the error to report. Does not |
513 // return. | 516 // return. |
514 LLVM_ATTRIBUTE_NORETURN | 517 LLVM_ATTRIBUTE_NORETURN |
515 virtual void FatalAt(uint64_t BitPosition, const std::string &Message); | 518 void FatalAt(uint64_t BitPosition, const std::string &Message) { |
| 519 ErrorAt(naclbitc::Fatal, BitPosition, Message); |
| 520 llvm_unreachable("Fatal errors should not return"); |
| 521 } |
516 | 522 |
517 // Called when a fatal error occurs. Message is the error to | 523 // Called when a fatal error occurs. Message is the error to |
518 // report. Does not return. | 524 // report. Does not return. |
519 LLVM_ATTRIBUTE_NORETURN | 525 LLVM_ATTRIBUTE_NORETURN |
520 void Fatal(const std::string &Message) { | 526 void Fatal(const std::string &Message) { |
521 FatalAt(Record.GetStartBit(), Message); | 527 FatalAt(Record.GetStartBit(), Message); |
522 } | 528 } |
523 | 529 |
524 // Generates fatal generic error message. | 530 // Generates fatal generic error message. |
525 LLVM_ATTRIBUTE_NORETURN | 531 LLVM_ATTRIBUTE_NORETURN |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 bool ParseBlockInternal(); | 644 bool ParseBlockInternal(); |
639 | 645 |
640 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 646 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
641 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 647 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
642 | 648 |
643 }; | 649 }; |
644 | 650 |
645 } // namespace llvm | 651 } // namespace llvm |
646 | 652 |
647 #endif | 653 #endif |
OLD | NEW |