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

Unified Diff: src/PNaClTranslator.cpp

Issue 512933006: LLVM 3.5 merge: Subzero (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rebase Created 6 years, 3 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 | « src/IceTranslator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 35108ccc560410fcb01575c3b3b65144b50c883e..488a4f174159b60d12f470884b4e8342b1b4bef9 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -12,7 +12,6 @@
//
//===----------------------------------------------------------------------===//
-#include "PNaClTranslator.h"
#include "IceCfg.h"
#include "IceCfgNode.h"
#include "IceClFlags.h"
@@ -29,13 +28,13 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ValueHandle.h"
-#include <vector>
#include <cassert>
+#include <vector>
using namespace llvm;
@@ -66,13 +65,12 @@ public:
setErrStream(Translator.getContext()->getStrDump());
}
- virtual ~TopLevelParser() {}
- LLVM_OVERRIDE;
+ ~TopLevelParser() override {}
Ice::Translator &getTranslator() { return Translator; }
// Generates error with given Message. Always returns true.
- virtual bool Error(const std::string &Message) LLVM_OVERRIDE {
+ bool Error(const std::string &Message) override {
ErrorStatus = true;
++NumErrors;
NaClBitcodeParser::Error(Message);
@@ -253,7 +251,7 @@ private:
// The translator associated with the parser.
Ice::Translator &Translator;
// The parsed module.
- OwningPtr<Module> Mod;
+ std::unique_ptr<Module> Mod;
// The data layout to use.
DataLayout DL;
// The bitcode header.
@@ -281,7 +279,7 @@ private:
// references to global variable addresses.
Type *GlobalVarPlaceHolderType;
- virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE;
+ bool ParseBlock(unsigned BlockID) override;
/// Reports that type ID is undefined, and then returns
/// the void type.
@@ -339,7 +337,7 @@ public:
BlockParserBaseClass(unsigned BlockID, TopLevelParser *Context)
: NaClBitcodeParser(BlockID, Context), Context(Context) {}
- virtual ~BlockParserBaseClass() LLVM_OVERRIDE {}
+ ~BlockParserBaseClass() override {}
protected:
// The context parser that contains the decoded state.
@@ -356,7 +354,7 @@ protected:
const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); }
// Generates an error Message with the bit address prefixed to it.
- virtual bool Error(const std::string &Message) LLVM_OVERRIDE {
+ bool Error(const std::string &Message) override {
uint64_t Bit = Record.GetStartBit() + Context->getHeaderSize() * 8;
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
@@ -367,11 +365,11 @@ protected:
// Default implementation. Reports that block is unknown and skips
// its contents.
- virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE;
+ bool ParseBlock(unsigned BlockID) override;
// Default implementation. Reports that the record is not
// understood.
- virtual void ProcessRecord() LLVM_OVERRIDE;
+ void ProcessRecord() override;
// Checks if the size of the record is Size. Return true if valid.
// Otherwise generates an error and returns false.
@@ -465,14 +463,14 @@ public:
TypesParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser), NextTypeId(0) {}
- ~TypesParser() LLVM_OVERRIDE {}
+ ~TypesParser() override {}
private:
// The type ID that will be associated with the next type defining
// record in the types block.
unsigned NextTypeId;
- virtual void ProcessRecord() LLVM_OVERRIDE;
+ void ProcessRecord() override;
};
void TypesParser::ProcessRecord() {
@@ -565,7 +563,7 @@ public:
NextGlobalID = Context->getNumFunctionIDs();
}
- virtual ~GlobalsParser() LLVM_OVERRIDE {}
+ ~GlobalsParser() override {}
private:
// Holds the sequence of initializers for the global.
@@ -584,7 +582,7 @@ private:
// The index of the next global variable.
unsigned NextGlobalID;
- virtual void ExitBlock() LLVM_OVERRIDE {
+ void ExitBlock() override {
verifyNoMissingInitializers();
unsigned NumIDs = Context->getNumGlobalValueIDs();
if (NextGlobalID < NumIDs) {
@@ -598,7 +596,7 @@ private:
BlockParserBaseClass::ExitBlock();
}
- virtual void ProcessRecord() LLVM_OVERRIDE;
+ void ProcessRecord() override;
// Checks if the number of initializers needed is the same as the
// number found in the bitcode file. If different, and error message
@@ -773,7 +771,7 @@ public:
ValuesymtabParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser) {}
- virtual ~ValuesymtabParser() LLVM_OVERRIDE {}
+ ~ValuesymtabParser() override {}
protected:
typedef SmallString<128> StringType;
@@ -786,7 +784,7 @@ protected:
private:
- virtual void ProcessRecord() LLVM_OVERRIDE;
+ void ProcessRecord() override;
void ConvertToString(StringType &ConvertedName) {
const NaClBitcodeRecord::RecordVector &Values = Record.GetValues();
@@ -853,7 +851,7 @@ public:
}
}
- ~FunctionParser() LLVM_OVERRIDE;
+ ~FunctionParser() override;
// Set the next constant ID to the given constant C.
void setNextConstantID(Ice::Constant *C) {
@@ -2388,13 +2386,14 @@ bool TopLevelParser::ParseBlock(unsigned BlockID) {
namespace Ice {
void PNaClTranslator::translate(const std::string &IRFilename) {
- OwningPtr<MemoryBuffer> MemBuf;
- if (error_code ec =
- MemoryBuffer::getFileOrSTDIN(IRFilename.c_str(), MemBuf)) {
- errs() << "Error reading '" << IRFilename << "': " << ec.message() << "\n";
+ ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile =
+ MemoryBuffer::getFileOrSTDIN(IRFilename);
+ if (std::error_code EC = ErrOrFile.getError()) {
+ errs() << "Error reading '" << IRFilename << "': " << EC.message() << "\n";
ErrorStatus = true;
return;
}
+ std::unique_ptr<MemoryBuffer> MemBuf(ErrOrFile.get().release());
if (MemBuf->getBufferSize() % 4 != 0) {
errs() << IRFilename
« no previous file with comments | « src/IceTranslator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698