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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 864383002: Fix the PNaCl translator to lock the dump stream when printing errors. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the PNaCl bitcode file to Ice, to machine code 10 // This file implements the PNaCl bitcode file to Ice, to machine code
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 TopLevelParser(const TopLevelParser &) = delete; 158 TopLevelParser(const TopLevelParser &) = delete;
159 TopLevelParser &operator=(const TopLevelParser &) = delete; 159 TopLevelParser &operator=(const TopLevelParser &) = delete;
160 160
161 public: 161 public:
162 typedef std::vector<Ice::FunctionDeclaration *> FunctionDeclarationListType; 162 typedef std::vector<Ice::FunctionDeclaration *> FunctionDeclarationListType;
163 163
164 TopLevelParser(Ice::Translator &Translator, NaClBitcodeHeader &Header, 164 TopLevelParser(Ice::Translator &Translator, NaClBitcodeHeader &Header,
165 NaClBitstreamCursor &Cursor, bool &ErrorStatus) 165 NaClBitstreamCursor &Cursor, bool &ErrorStatus)
166 : NaClBitcodeParser(Cursor), Translator(Translator), Header(Header), 166 : NaClBitcodeParser(Cursor), Translator(Translator), Header(Header),
167 ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0), 167 ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0),
168 NumFunctionBlocks(0), BlockParser(nullptr) { 168 NumFunctionBlocks(0), BlockParser(nullptr) {}
169 // Note: This gives the reader uncontrolled access to the dump
170 // stream, which it can then use without locking. TODO(kschimpf):
171 // Consider reworking the LLVM side to use e.g. a callback for
172 // errors.
173 Ice::OstreamLocker L(Translator.getContext());
174 setErrStream(Translator.getContext()->getStrDump());
175 }
176 169
177 ~TopLevelParser() override {} 170 ~TopLevelParser() override {}
178 171
179 Ice::Translator &getTranslator() { return Translator; } 172 Ice::Translator &getTranslator() { return Translator; }
180 173
181 void setBlockParser(BlockParserBaseClass *NewBlockParser) { 174 void setBlockParser(BlockParserBaseClass *NewBlockParser) {
182 BlockParser = NewBlockParser; 175 BlockParser = NewBlockParser;
183 } 176 }
184 177
185 // Generates error with given Message. Always returns true. 178 // Generates error with given Message. Always returns true.
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 Ice::VariableDeclaration *reportGetGlobalVariableByIDError(unsigned Index); 423 Ice::VariableDeclaration *reportGetGlobalVariableByIDError(unsigned Index);
431 424
432 // Reports that there is no corresponding ICE type for LLVMTy, and 425 // Reports that there is no corresponding ICE type for LLVMTy, and
433 // returns ICE::IceType_void. 426 // returns ICE::IceType_void.
434 Ice::Type convertToIceTypeError(Type *LLVMTy); 427 Ice::Type convertToIceTypeError(Type *LLVMTy);
435 }; 428 };
436 429
437 bool TopLevelParser::Error(const std::string &Message) { 430 bool TopLevelParser::Error(const std::string &Message) {
438 ErrorStatus = true; 431 ErrorStatus = true;
439 ++NumErrors; 432 ++NumErrors;
433 Ice::GlobalContext *Context = Translator.getContext();
434 Ice::OstreamLocker L(Context);
435 raw_ostream *OldErrStream = setErrStream(Context->getStrDump());
440 NaClBitcodeParser::Error(Message); 436 NaClBitcodeParser::Error(Message);
437 setErrStream(*OldErrStream);
441 if (!Translator.getFlags().AllowErrorRecovery) 438 if (!Translator.getFlags().AllowErrorRecovery)
442 report_fatal_error("Unable to continue"); 439 report_fatal_error("Unable to continue");
443 return true; 440 return true;
444 } 441 }
445 442
446 void TopLevelParser::reportBadTypeIDAs(unsigned ID, const ExtendedType *Ty, 443 void TopLevelParser::reportBadTypeIDAs(unsigned ID, const ExtendedType *Ty,
447 ExtendedType::TypeKind WantedType) { 444 ExtendedType::TypeKind WantedType) {
448 std::string Buffer; 445 std::string Buffer;
449 raw_string_ostream StrBuf(Buffer); 446 raw_string_ostream StrBuf(Buffer);
450 if (Ty == nullptr) { 447 if (Ty == nullptr) {
(...skipping 2551 matching lines...) Expand 10 before | Expand all | Expand 10 after
3002 2999
3003 if (TopLevelBlocks != 1) { 3000 if (TopLevelBlocks != 1) {
3004 errs() << IRFilename 3001 errs() << IRFilename
3005 << ": Contains more than one module. Found: " << TopLevelBlocks 3002 << ": Contains more than one module. Found: " << TopLevelBlocks
3006 << "\n"; 3003 << "\n";
3007 ErrorStatus = true; 3004 ErrorStatus = true;
3008 } 3005 }
3009 } 3006 }
3010 3007
3011 } // end of namespace Ice 3008 } // end of namespace Ice
OLDNEW
« 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