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

Side by Side Diff: lib/IRReader/IRReader.cpp

Issue 770853002: Fix error reporting in the PNaCl bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix nits. Created 6 years 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 //===---- IRReader.cpp - Reader for LLVM IR files -------------------------===// 1 //===---- IRReader.cpp - Reader for LLVM IR files -------------------------===//
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/IRReader/IRReader.h" 10 #include "llvm/IRReader/IRReader.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // @LOCALMOD-BEGIN 101 // @LOCALMOD-BEGIN
102 Module *llvm::NaClParseIR(MemoryBuffer *Buffer, 102 Module *llvm::NaClParseIR(MemoryBuffer *Buffer,
103 NaClFileFormat Format, 103 NaClFileFormat Format,
104 SMDiagnostic &Err, 104 SMDiagnostic &Err,
105 LLVMContext &Context) { 105 LLVMContext &Context) {
106 NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, 106 NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName,
107 TimePassesIsEnabled); 107 TimePassesIsEnabled);
108 if ((Format == PNaClFormat) && 108 if ((Format == PNaClFormat) &&
109 isNaClBitcode((const unsigned char *)Buffer->getBufferStart(), 109 isNaClBitcode((const unsigned char *)Buffer->getBufferStart(),
110 (const unsigned char *)Buffer->getBufferEnd())) { 110 (const unsigned char *)Buffer->getBufferEnd())) {
111 std::string ErrMsg; 111 ErrorOr<Module *> MOrErr =
jvoung (off chromium) 2014/12/01 23:23:50 "ModuleOrError" to be consistent with ParseIR() ?
JF 2014/12/02 00:49:04 Upstream uses MOrErr, so I'd keep that.
Karl 2014/12/03 18:32:10 Since our local version uses ModuleOrError, will m
112 Module *M = NaClParseBitcodeFile(Buffer, Context, &ErrMsg); 112 NaClParseBitcodeFile(Buffer, Context, /*VerboseErrors=*/false);
jvoung (off chromium) 2014/12/01 23:23:50 how do you decide between setting VerboseErrors to
Karl 2014/12/03 18:32:10 Good point. Adding as argument so that calling too
113 if (M == 0) 113 if (std::error_code EC = MOrErr.getError())
114 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, 114 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
115 ErrMsg); 115 EC.message());
116 // ParseBitcodeFile does not take ownership of the Buffer. 116 // ParseBitcodeFile does not take ownership of the Buffer.
117 return M; 117 return MOrErr.get();
118 } else if (Format == LLVMFormat) { 118 } else if (Format == LLVMFormat) {
119 if (isBitcode((const unsigned char *)Buffer->getBufferStart(), 119 if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
120 (const unsigned char *)Buffer->getBufferEnd())) { 120 (const unsigned char *)Buffer->getBufferEnd())) {
121 ErrorOr<Module *> MOrErr = parseBitcodeFile(Buffer, Context); 121 ErrorOr<Module *> MOrErr = parseBitcodeFile(Buffer, Context);
122 if (std::error_code EC = MOrErr.getError()) 122 if (std::error_code EC = MOrErr.getError())
123 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error, 123 Err = SMDiagnostic(Buffer->getBufferIdentifier(), SourceMgr::DK_Error,
124 EC.message()); 124 EC.message());
125 // ParseBitcodeFile does not take ownership of the Buffer. 125 // ParseBitcodeFile does not take ownership of the Buffer.
126 return MOrErr.get(); 126 return MOrErr.get();
127 } 127 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 Diag.print(nullptr, os, false); 171 Diag.print(nullptr, os, false);
172 os.flush(); 172 os.flush();
173 173
174 *OutMessage = strdup(buf.c_str()); 174 *OutMessage = strdup(buf.c_str());
175 } 175 }
176 return 1; 176 return 1;
177 } 177 }
178 178
179 return 0; 179 return 0;
180 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698