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

Side by Side Diff: lib/Bitcode/NaCl/Analysis/NaClObjDump.cpp

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 //===-- NaClObjDump.cpp - Dump PNaCl bitcode contents ---------------------===// 1 //===-- NaClObjDump.cpp - Dump PNaCl bitcode contents ---------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
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 #include "llvm/ADT/STLExtras.h" 10 #include "llvm/ADT/STLExtras.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // Be sure to flush any remaining errors. 582 // Be sure to flush any remaining errors.
583 ObjDump.Flush(); 583 ObjDump.Flush();
584 } 584 }
585 585
586 // Returns the number of errors that were sent to the ObjDump. 586 // Returns the number of errors that were sent to the ObjDump.
587 unsigned GetNumErrors() { 587 unsigned GetNumErrors() {
588 return ObjDump.GetNumErrors(); 588 return ObjDump.GetNumErrors();
589 } 589 }
590 590
591 /// Generates an error with the given message. 591 /// Generates an error with the given message.
592 bool ErrorAt(uint64_t Bit, const std::string &Message) final { 592 bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit,
593 // Use local error routine so that all errors are treated uniformly. 593 const std::string &Message) final {
594 ObjDump.Error(Bit) << Message << "\n"; 594 if (Level == naclbitc::Fatal)
jvoung (off chromium) 2015/03/06 22:30:28 How come Fatal is called out specially?
Karl 2015/03/06 22:54:20 Under the new scheme, within a bitcode parser, all
jvoung (off chromium) 2015/03/07 00:04:35 I think if (a) only this method needs to worry abo
Karl 2015/03/09 18:10:54 Ok. I was able to clean things up and remove both
595 ObjDump.FatalAt(Bit, Message);
596 else
597 ObjDump.ErrorAt(Level, Bit) << Message << "\n";
595 return true; 598 return true;
596 } 599 }
597 600
598 /// Flushes out objdump and then exits with fatal error.
599 LLVM_ATTRIBUTE_NORETURN
600 void Fatal() {
601 NaClBitcodeParser::Fatal();
602 }
603
604 /// Flushes out objdump and then exits with fatal error, using
605 /// the given message.
606 LLVM_ATTRIBUTE_NORETURN
607 void FatalAt(uint64_t Bit, const std::string &Message) final {
608 ObjDump.Fatal(Bit, Message);
609 }
610
611 /// Parses the top-level module block. 601 /// Parses the top-level module block.
612 bool ParseBlock(unsigned BlockID) override; 602 bool ParseBlock(unsigned BlockID) override;
613 603
614 /// Installs the given type to the next available type index. 604 /// Installs the given type to the next available type index.
615 void InstallType(Type *Ty) { 605 void InstallType(Type *Ty) {
616 TypeIdType.push_back(Ty); 606 TypeIdType.push_back(Ty);
617 } 607 }
618 608
619 /// Returns the type associated with the given type index. 609 /// Returns the type associated with the given type index.
620 Type *GetType(uint32_t Index) { 610 Type *GetType(uint32_t Index) {
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 } 1348 }
1359 1349
1360 raw_ostream &Errors() { 1350 raw_ostream &Errors() {
1361 return Context->Errors(); 1351 return Context->Errors();
1362 } 1352 }
1363 1353
1364 raw_ostream &Warnings() { 1354 raw_ostream &Warnings() {
1365 return Context->Warnings(); 1355 return Context->Warnings();
1366 } 1356 }
1367 1357
1368 void Fatal() { 1358 bool ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit,
1369 return Context->Fatal(); 1359 const std::string &Message) final {
1370 } 1360 return Context->ErrorAt(Level, Bit, Message);
1371
1372 void FatalAt(uint64_t Bit, const std::string &Message) override {
1373 return Context->FatalAt(Bit, Message);
1374 } 1361 }
1375 1362
1376 const std::string &GetAssemblyIndent() const { 1363 const std::string &GetAssemblyIndent() const {
1377 return Context->GetAssemblyIndent(); 1364 return Context->GetAssemblyIndent();
1378 } 1365 }
1379 1366
1380 unsigned GetAssemblyNumTabs() const { 1367 unsigned GetAssemblyNumTabs() const {
1381 return Context->GetAssemblyNumTabs(); 1368 return Context->GetAssemblyNumTabs();
1382 } 1369 }
1383 1370
(...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after
3572 ObjDump.Error() << "Expected 1 top level block in bitcode: Found:" 3559 ObjDump.Error() << "Expected 1 top level block in bitcode: Found:"
3573 << NumBlocksRead << "\n"; 3560 << NumBlocksRead << "\n";
3574 ErrorsFound = true; 3561 ErrorsFound = true;
3575 } 3562 }
3576 3563
3577 ObjDump.Flush(); 3564 ObjDump.Flush();
3578 return ErrorsFound || Parser.GetNumErrors() > 0; 3565 return ErrorsFound || Parser.GetNumErrors() > 0;
3579 } 3566 }
3580 3567
3581 } 3568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698