Hi,
I am doing a project involving checking a called specific function’s argument. Suppose that the function is int f(const char* str)
.
When I am analyzing such a snippet:
f("hello")
, then compiled by Clang, I will have the “hello” as a Constant Array in the IR code. My goal is to call APIs of LLVM to get the “hello” from IR code.
Now suppose the I got the llvm::Function* fn
from some Module
, so I can get the access the ArgumentList
by iterator const_arg_iterator it
.
However, the iterator now I got is of type llvm::ilist_iterator<const llvm::Argument>::const_iterator
. When I am trying to cast it into ``llvm::ilist_iterator::const_iterator`, it can’t success. But if I get the raw pointer out of it, the program will simply crash.
While Argument
inherits Value
, ConstantArray
inherits Value
as well. But how should I cast one into another? It is worth nothing that, hen I used getType()->getTypeID()
, it is ConstantArrayVal
, and that seems to be the right direction.
Thanks for any help!
- Zhen