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

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

Issue 865963002: Allow temporary overrides of error stream in NaClBitcodeParser. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Clean up code. Created 5 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
diff --git a/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h b/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
index f9c02f71ad9e09a0b73fad9fe7502a986a641436..3adc5fa76709f16f73fee41a36e1810736685729 100644
--- a/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
+++ b/include/llvm/Bitcode/NaCl/NaClBitcodeParser.h
@@ -468,14 +468,19 @@ public:
return Parser.ParseThisBlock();
}
- // Changes the error stream to print errors to Stream. Warning:
- // Stream must exist till the next call to setErrStream. Otherwise
- // it must exist for the entire lifetime of the bitcode parser.
- // Note: This err stream should be set immediately after
- // construction. Assigning after nested bitcode parsers have been
- // built will not work.
- void setErrStream(raw_ostream &Stream) {
+ // Changes the stream to print errors to, and returns the old error stream.
+ // There are two use cases:
+ // 1) To change (from the default errs()) inside the constructor of the
+ // derived class. In this context, it will be used for all error
+ // messages for the derived class.
+ // 2) Temporarily modify it for a single error message. In this context,
+ // the method Error() is overridden in the derived class, and
+ // calls this method twice. Once before calling base method Error(),
+ // and followed by a second call to restore the default error stream.
+ raw_ostream &setErrStream(raw_ostream &Stream) {
+ raw_ostream &OldErrStream = *ErrStream;
ErrStream = &Stream;
+ return OldErrStream;
}
// Called when error occurs. Message is the error to report. Always
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698