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

Side by Side Diff: lib/Bitcode/NaCl/TestUtils/NaClBitcodeMungeWriter.cpp

Issue 1150183010: Add error recovery for abbreviations outside blocks in bitcode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Add test case. Created 5 years, 6 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 | unittests/Bitcode/NaClMungeWriteErrorTests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- NaClBitcodeMungeWriter.cpp - Write munged bitcode --------*- C++ -*-===// 1 //===- NaClBitcodeMungeWriter.cpp - Write munged bitcode --------*- C++ -*-===//
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 // Implements method NaClMungedBitcode.write(), which writes out a munged 10 // Implements method NaClMungedBitcode.write(), which writes out a munged
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 << "Uses illegal abbreviation index in define abbreviation record: " 397 << "Uses illegal abbreviation index in define abbreviation record: "
398 << Record << "\n"; 398 << Record << "\n";
399 if (!Flags.getTryToRecover()) 399 if (!Flags.getTryToRecover())
400 return false; 400 return false;
401 } 401 }
402 NaClBitCodeAbbrev *Abbrev = buildAbbrev(Record); 402 NaClBitCodeAbbrev *Abbrev = buildAbbrev(Record);
403 if (Abbrev == nullptr) { 403 if (Abbrev == nullptr) {
404 markCurrentBlockWithOmittedAbbreviations(); 404 markCurrentBlockWithOmittedAbbreviations();
405 return Flags.getTryToRecover(); 405 return Flags.getTryToRecover();
406 } 406 }
407 if (atOutermostScope()) {
408 RecoverableError() << "Abbreviation definition not in block: "
409 << Record << "\n";
410 return Flags.getTryToRecover();
411 }
407 if (getCurWriteBlockID() == naclbitc::BLOCKINFO_BLOCK_ID) { 412 if (getCurWriteBlockID() == naclbitc::BLOCKINFO_BLOCK_ID) {
408 Writer.EmitBlockInfoAbbrev(SetBID, Abbrev); 413 Writer.EmitBlockInfoAbbrev(SetBID, Abbrev);
409 } else { 414 } else {
410 Writer.EmitAbbrev(Abbrev); 415 Writer.EmitAbbrev(Abbrev);
411 } 416 }
412 break; 417 break;
413 } 418 }
414 case naclbitc::BLK_CODE_HEADER: 419 case naclbitc::BLK_CODE_HEADER:
415 // Note: There is no abbreviation index here. Ignore. 420 // Note: There is no abbreviation index here. Ignore.
416 for (uint64_t Value : Record.Values) 421 for (uint64_t Value : Record.Values)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 NaClWriteHeader(Writer, true); 604 NaClWriteHeader(Writer, true);
600 } 605 }
601 for (const NaClBitcodeAbbrevRecord &Record : *this) { 606 for (const NaClBitcodeAbbrevRecord &Record : *this) {
602 if (!State.emitRecord(Writer, Record)) 607 if (!State.emitRecord(Writer, Record))
603 break; 608 break;
604 } 609 }
605 bool RecoverSilently = 610 bool RecoverSilently =
606 State.Results.NumErrors > 0 && !Flags.getTryToRecover(); 611 State.Results.NumErrors > 0 && !Flags.getTryToRecover();
607 return State.finish(Writer, RecoverSilently); 612 return State.finish(Writer, RecoverSilently);
608 } 613 }
OLDNEW
« no previous file with comments | « no previous file | unittests/Bitcode/NaClMungeWriteErrorTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698