Ratnesh Tiwari via llvm-dev
2018-Aug-10 11:09 UTC
[llvm-dev] Error facing in llvm command line argument
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>
Philip Pfaffe via llvm-dev
2018-Aug-10 13:51 UTC
[llvm-dev] Error facing in llvm command line argument
Hi Ratnesh, you can find the API documentation of llvm::Expected here: http://llvm.org/doxygen/classllvm_1_1Expected.html Cheers, Philip On Fri, Aug 10, 2018 at 1:09 PM Ratnesh Tiwari via llvm-dev < llvm-dev at lists.llvm.org> wrote:> 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; > } > > -------------------------------------------------------------------------------------------------------- > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180810/6e015f1e/attachment.html>