Abid Malik via llvm-dev
2020-Jan-14 19:22 UTC
[llvm-dev] error: incomplete type 'llvm::CallInst' named in nested name specifier
Hello, I am trying to write a pass. Here is a short and simplified version of it bool MyPass:: runOnFunction( Function &F){ errs() << "Visiting function " << F.getName(); errs() << "\n"; for (auto &BB : F) { for (auto &II : BB) { if (CallInst *c = dyn_cast <CallInst> (&II)){ } } } return false; // We did not change anything in the IR } The code is straight forward and very much in line with the examples LLVM pass on the web. However, when I compile it, I am getting the following error. In file included from MyPass.cpp:1: In file included from /home/amalik/LLVM/llvm-8.0.0.src/include/llvm/Pass.h:365: In file included from /home/amalik/LLVM/llvm_install/include/llvm/PassSupport.h:26: In file included from /home/amalik/LLVM/llvm_install/include/llvm/PassRegistry.h:23: In file included from /home/amalik/LLVM/llvm_install/include/llvm/Support/CBindingWrapping.h:18: /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:59:12: error: incomplete type 'llvm::CallInst' named in nested name specifier return To::classof(&Val); ^~~~ /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:107:32: note: in instantiation of member function 'llvm::isa_impl<llvm::CallInst, llvm::Instruction, void>::doit' requested here return isa_impl<To, From>::doit(*Val); ^ /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:133:36: note: in instantiation of member function 'llvm::isa_impl_cl<llvm::CallInst, const llvm::Instruction *>::doit' requested here return isa_impl_cl<To,FromTy>::doit(Val); ^ /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:124:56: note: in instantiation of member function 'llvm::isa_impl_wrap<llvm::CallInst, const llvm::Instruction *, const llvm::Instruction *>::doit' requested here typename simplify_type<SimpleFrom>::SimpleType>::doit( ^ /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:144:70: note: in instantiation of member function 'llvm::isa_impl_wrap<llvm::CallInst, llvm::Instruction *const, const llvm::Instruction *>::doit' requested here typename simplify_type<const Y>::SimpleType>::doit(Val); ^ /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:334:10: note: in instantiation of function template specialization 'llvm::isa<llvm::CallInst, llvm::Instruction *>' requested here return isa<X>(Val) ? cast<X>(Val) : nullptr; ^ DummyPass.cpp:30:21: note: in instantiation of function template specialization 'llvm::dyn_cast<llvm::CallInst, llvm::Instruction>' requested here if (CallInst *c = dyn_cast <CallInst> (&II)){ ^ /home/amalik/LLVM/llvm_install/include/llvm/IR/BasicBlock.h:35:7: note: forward declaration of 'llvm::CallInst' class CallInst; ^ 1 error generated ------> Thanks, -- Abid M. Malik ****************************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200114/316192b9/attachment.html>
Tim Northover via llvm-dev
2020-Jan-14 19:26 UTC
[llvm-dev] error: incomplete type 'llvm::CallInst' named in nested name specifier
On Tue, 14 Jan 2020 at 19:22, Abid Malik via llvm-dev <llvm-dev at lists.llvm.org> wrote:> However, when I compile it, I am getting the following error. > > /home/amalik/LLVM/llvm_install/include/llvm/Support/Casting.h:59:12: error: incomplete type 'llvm::CallInst' named in nested name > [...] ^ > /home/amalik/LLVM/llvm_install/include/llvm/IR/BasicBlock.h:35:7: note: forward declaration of 'llvm::CallInst' > class CallInst;Looks like you forgot to include the header that defined CallInst. You need that to be able to do most things with it, including (as you've discovered) an RTTI-based cast. In this case the header is "llvm/IR/Instructions.h". Cheers. Tim.