[llvm-dev] Error facing in llvm command line argument
Ratnesh Tiwari via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 10 04:09:33 PDT 2018
Hi,
I was writing main.cpp file for command line argument . I am facing this
error:
error: ‘class llvm::Expected<std::unique_ptr<llvm::Module> >’ has no member
named ‘getError’
if (error_code ec = m.getError())
I do not which member does this expecting. Please suggest me steps. Here is
my source code.
------------------------------------------------------------
--------------------------------------
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <llvm/Support/Error.h>
#include <llvm/IRReader/IRReader.h>
using namespace llvm;
using namespace std;
static cl::opt<string> input(cl::Positional, cl::desc("Bitcode file"),
cl::Required);
int main(int argc, char** argv)
{
cl::ParseCommandLineOptions(argc, argv, "LLVM IR to Bytecode \n");
LLVMContext context;
ErrorOr<std::unique_ptr<MemoryBuffer>> mb =
MemoryBuffer::getFile(input);
if (error_code ec = mb.getError()) {
errs() << ec.message();
return -1;
}
Expected<std::unique_ptr<Module>>
m=parseBitcodeFile(mb->get()->getMemBufferRef(),
context);
if (error_code ec = m.getError())
{
errs() << "Error reading bitcode: " << ec.message() << "\n";
return -1;
}
return 0;
}
------------------------------------------------------------
--------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180810/5f6e2a2b/attachment.html>
More information about the llvm-dev
mailing list