projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[X86][Haswell][SchedModel] Add architecture specific scheduling models.
[oota-llvm.git]
/
lib
/
AsmParser
/
Parser.cpp
diff --git
a/lib/AsmParser/Parser.cpp
b/lib/AsmParser/Parser.cpp
index ef9328a0b1c34297b02d9809b2fcaa51524dc22b..4cc94cb270d9af3cd2ef738671b3f5673a1e6093 100644
(file)
--- a/
lib/AsmParser/Parser.cpp
+++ b/
lib/AsmParser/Parser.cpp
@@
-21,41
+21,40
@@
#include <system_error>
using namespace llvm;
#include <system_error>
using namespace llvm;
-Module *llvm::ParseAssembly(MemoryBuffer *F,
- Module *M,
- SMDiagnostic &Err,
- LLVMContext &Context) {
+Module *llvm::ParseAssembly(std::unique_ptr<MemoryBuffer> F, Module *M,
+ SMDiagnostic &Err, LLVMContext &Context) {
SourceMgr SM;
SourceMgr SM;
- SM.AddNewSourceBuffer(F, SMLoc());
+ MemoryBuffer *Buf = F.get();
+ SM.AddNewSourceBuffer(F.release(), SMLoc());
// If we are parsing into an existing module, do it.
if (M)
// If we are parsing into an existing module, do it.
if (M)
- return LLParser(
F
, SM, Err, M).Run() ? nullptr : M;
+ return LLParser(
Buf
, SM, Err, M).Run() ? nullptr : M;
// Otherwise create a new module.
// Otherwise create a new module.
- std::unique_ptr<Module> M2(new Module(
F
->getBufferIdentifier(), Context));
- if (LLParser(
F
, SM, Err, M2.get()).Run())
+ std::unique_ptr<Module> M2(new Module(
Buf
->getBufferIdentifier(), Context));
+ if (LLParser(
Buf
, SM, Err, M2.get()).Run())
return nullptr;
return M2.release();
}
Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
LLVMContext &Context) {
return nullptr;
return M2.release();
}
Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
LLVMContext &Context) {
- std::unique_ptr<MemoryBuffer> File;
- if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
+ ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
+ MemoryBuffer::getFileOrSTDIN(Filename);
+ if (std::error_code EC = FileOrErr.getError()) {
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
- "Could not open input file: " +
ec
.message());
+ "Could not open input file: " +
EC
.message());
return nullptr;
}
return nullptr;
}
- return ParseAssembly(
File.release(
), nullptr, Err, Context);
+ return ParseAssembly(
std::move(FileOrErr.get()
), nullptr, Err, Context);
}
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
SMDiagnostic &Err, LLVMContext &Context) {
MemoryBuffer *F =
}
Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
SMDiagnostic &Err, LLVMContext &Context) {
MemoryBuffer *F =
- MemoryBuffer::getMemBuffer(StringRef(AsmString, strlen(AsmString)),
- "<string>");
+ MemoryBuffer::getMemBuffer(StringRef(AsmString), "<string>");
- return ParseAssembly(
F
, M, Err, Context);
+ return ParseAssembly(
std::unique_ptr<MemoryBuffer>(F)
, M, Err, Context);
}
}