[llvm-dev] Error: ‘class llvm::PassManager<llvm::Module>’ has no member named ‘add’
Ratnesh Tiwari via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 13 11:49:10 PDT 2018
Hi, I am begineer to llvm, implementing a main.cpp from
https://github.com/davidar/lljvm/blob/master/backend/main.cpp
A) : When I am declaring a command:
* PassManager PM*
* PM.add(new DataLayout td)*
It shows error:
>
*error: missing template arguments before ‘PM’*
* PassManager PM;*
^
>*main_test.cpp:48:2: error: ‘PM’ was not declared in this scope*
* PM.add(new DataLayout(td));*
Keeping in mind the above error, I changed the code as:
*PassManager<Module> PM*
*PM.add(new DataLayout td)*
I dont know, whether the above change is the correct one or not. But the
error is changed to:
>*error: ‘class llvm::PassManager<llvm::Module>’ has no member named ‘add’*
* PM.add(new DataLayout(td));*
Here is mine source code:
-----------------------------------------------
#include "backened.h"
#include <iostream>
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/IR/Function.h"
#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/IR/PassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/DataLayout.h"
#include <llvm/Transforms/Scalar.h>
#include "llvm/IR/LegacyPassManager.h"
using namespace llvm;
using namespace std;
static cl::opt<string> input(cl::Positional, cl::desc("Bitcode
File.."),cl::Required);
static cl::opt<string> classname("classname",cl::desc("Binary name of the
generated class..."));
int main(int argc, char** argv)
{
cl::ParseCommandLineOptions(argc, argv, "Hi..");
LLVMContext context;
ErrorOr<unique_ptr<MemoryBuffer>> mb =
MemoryBuffer::getFile(input);
if(error_code ec = mb.getError())
{
errs() << ec.message();
return 1;
}
Expected<unique_ptr<Module>> m =
parseBitcodeFile(mb->get()->getMemBufferRef(),context);
if(error_code ec= errorToErrorCode(m.takeError()) )
{
PassManager<Module> PM;
DataLayout td("e-p:32:32:32"
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
"-f32:32:32-f64:64:64");
PM.add(new DataLayout(td));
return 0;
}
------------------------------------------
B) Also suggest me , whether I am implemented a correct way "*DataLayout td
("e-p:32:32:32......")" *and "*new DataLayout td" *in the place of
TargetData.h as I found that TargeyData.h is not found in newer version of
llvm. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180814/beb36a31/attachment.html>
More information about the llvm-dev
mailing list