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

Side by Side Diff: include/llvm/Bitcode/NaCl/NaClBitcodeParser.h

Issue 986453002: Additional clean ups on errors in bitcode parsing. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix nits. Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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
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 Error() is overridden in the derived class, and
jvoung (off chromium) 2015/03/06 22:30:27 Error() is no longer overridden (changed at some p
Karl 2015/03/06 22:54:20 Fixed to refer to the right method.
492 // calls this method twice. Once before calling base method Error(), 492 // calls this method twice. Once before calling base method Error(),
493 // and followed by a second call to restore the default error stream. 493 // and followed by a second call to restore the default error stream.
494 raw_ostream &setErrStream(raw_ostream &Stream) { 494 raw_ostream &setErrStream(raw_ostream &Stream) {
495 raw_ostream &OldErrStream = *ErrStream; 495 raw_ostream &OldErrStream = *ErrStream;
496 ErrStream = &Stream; 496 ErrStream = &Stream;
497 return OldErrStream; 497 return OldErrStream;
498 } 498 }
499 499
500 // Called when an error occurs. BitPosition is the bit position the 500 // Called when an error occurs. BitPosition is the bit position the
501 // error was found, and Message is the error to report. Always 501 // error was found, and Message is the error to report. Always
502 // returns true (the error return value of Parse). 502 // returns true (the error return value of Parse). Level is
503 virtual bool ErrorAt(uint64_t BitPosition, const std::string &Message); 503 // the severity of the error.
504 virtual bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t BitPosition,
505 const std::string &Message);
506
507 bool ErrorAt(uint64_t BitPosition, const std::string &Message) {
508 return ErrorAt(naclbitc::Error, BitPosition, Message);
509 }
504 510
505 // Called when an error occurs. Message is the error to 511 // Called when an error occurs. Message is the error to
506 // report. Always returns true (the error return value of Parse). 512 // report. Always returns true (the error return value of Parse).
507 bool Error(const std::string &Message) { 513 bool Error(const std::string &Message) {
508 return ErrorAt(Record.GetStartBit(), Message); 514 return ErrorAt(Record.GetStartBit(), Message);
509 } 515 }
510 516
511 // Called when a fatal error occurs. BitPosition is the bit position 517 // 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 518 // the error was found, and Message is the error to report. Does not
513 // return. 519 // return.
514 LLVM_ATTRIBUTE_NORETURN 520 LLVM_ATTRIBUTE_NORETURN
515 virtual void FatalAt(uint64_t BitPosition, const std::string &Message); 521 void FatalAt(uint64_t BitPosition, const std::string &Message) {
522 ErrorAt(naclbitc::Fatal, BitPosition, Message);
523 llvm_unreachable("Fatal errors should not return");
524 }
516 525
517 // Called when a fatal error occurs. Message is the error to 526 // Called when a fatal error occurs. Message is the error to
518 // report. Does not return. 527 // report. Does not return.
519 LLVM_ATTRIBUTE_NORETURN 528 LLVM_ATTRIBUTE_NORETURN
520 void Fatal(const std::string &Message) { 529 void Fatal(const std::string &Message) {
521 FatalAt(Record.GetStartBit(), Message); 530 FatalAt(Record.GetStartBit(), Message);
522 } 531 }
523 532
524 // Generates fatal generic error message. 533 // Generates fatal generic error message.
525 LLVM_ATTRIBUTE_NORETURN 534 LLVM_ATTRIBUTE_NORETURN
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 bool ParseBlockInternal(); 647 bool ParseBlockInternal();
639 648
640 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; 649 void operator=(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION;
641 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION; 650 NaClBitcodeParser(const NaClBitcodeParser &Parser) LLVM_DELETED_FUNCTION;
642 651
643 }; 652 };
644 653
645 } // namespace llvm 654 } // namespace llvm
646 655
647 #endif 656 #endif
OLDNEW
« no previous file with comments | « no previous file | include/llvm/Bitcode/NaCl/NaClBitstreamReader.h » ('j') | include/llvm/Bitcode/NaCl/NaClBitstreamReader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698