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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 // block with the given block ID, and then call's method | 461 // block with the given block ID, and then call's method |
462 // ParseThisBlock() to parse the corresponding block. Note: | 462 // ParseThisBlock() to parse the corresponding block. Note: |
463 // Each derived class should define it's own version of this | 463 // Each derived class should define it's own version of this |
464 // method, following the pattern below. | 464 // method, following the pattern below. |
465 virtual bool ParseBlock(unsigned BlockID) { | 465 virtual bool ParseBlock(unsigned BlockID) { |
466 // Default implementation just builds a parser that does nothing. | 466 // Default implementation just builds a parser that does nothing. |
467 NaClBitcodeParser Parser(BlockID, this); | 467 NaClBitcodeParser Parser(BlockID, this); |
468 return Parser.ParseThisBlock(); | 468 return Parser.ParseThisBlock(); |
469 } | 469 } |
470 | 470 |
471 // Changes the error stream to print errors to Stream. Warning: | 471 // Changes the stream to print errors to. There are two use cases: |
Jim Stichnoth
2015/01/22 17:26:13
Just to be clear for the short-of-attention-span,
Karl
2015/01/22 17:42:58
Done.
| |
472 // Stream must exist till the next call to setErrStream. Otherwise | 472 // 1) To change (from the default errs()) inside the constructor of the |
473 // it must exist for the entire lifetime of the bitcode parser. | 473 // derived class. In this context, it will be used for all error |
474 // Note: This err stream should be set immediately after | 474 // messages for the derived class. |
475 // construction. Assigning after nested bitcode parsers have been | 475 // 2) Temporarily modify it for a single error message. In this context, |
476 // built will not work. | 476 // the method Error() is overridden in the derived class, and |
477 void setErrStream(raw_ostream &Stream) { | 477 // calls this method twice. Once before calling base method Error(), |
478 // and followed by a second call to restore the default error stream. | |
479 raw_ostream *setErrStream(raw_ostream &Stream) { | |
Jim Stichnoth
2015/01/22 17:26:13
It seems a little odd to mix raw_ostream* and raw_
Karl
2015/01/22 17:42:58
Done.
| |
480 raw_ostream *OldErrStream = ErrStream; | |
478 ErrStream = &Stream; | 481 ErrStream = &Stream; |
482 return OldErrStream; | |
479 } | 483 } |
480 | 484 |
481 // Called when error occurs. Message is the error to report. Always | 485 // Called when error occurs. Message is the error to report. Always |
482 // returns true (the error return value of Parse). | 486 // returns true (the error return value of Parse). |
483 virtual bool Error(const std::string &Message) { | 487 virtual bool Error(const std::string &Message) { |
484 *ErrStream << "Error: " << Message << "\n"; | 488 *ErrStream << "Error: " << Message << "\n"; |
485 return true; | 489 return true; |
486 } | 490 } |
487 | 491 |
488 // Returns the number of bits in this block, including nested blocks. | 492 // Returns the number of bits in this block, including nested blocks. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
597 | 601 |
598 | 602 |
599 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 603 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
600 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; | 604 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; |
601 | 605 |
602 }; | 606 }; |
603 | 607 |
604 } // namespace llvm | 608 } // namespace llvm |
605 | 609 |
606 #endif | 610 #endif |
OLD | NEW |