[LLVMdev] get source-level function signature?
Lewis Burns
lewisurn at gmail.com
Fri Nov 8 15:20:17 PST 2013
Hi,
I want to get source-level function signature by using metadata and
debug info descriptors, but it seems that the return type is only
available if it's a primitive type. For example, for the following code:
int *foo(struct ST *s) {
return &s[1].Z.B[5][13];
}
I get empty string as the return type when I use the getReturnTypeName()
function of DISubprogram. However, if I change the return type to "int"
and the corresponding code, I get the "int" type.
I took a look at the implementation of the function, which is the following:
/// getReturnTypeName - Subprogram return types are encoded either as
/// DIType or as DICompositeType.
StringRef getReturnTypeName() const {
DICompositeType DCT(getFieldAs<DICompositeType>(7));
if (DCT.Verify()) {
DIArray A = DCT.getTypeArray();
DIType T(A.getElement(0));
return T.getName();
}
DIType T(getFieldAs<DIType>(7));
return T.getName();
}
I also tried to get the types of parameters by changing the index of
A.getElement() and noticed the same issue, namely, the types seem to
work only with primitive types like "int."
My questions are:
(1) Is it possible to get source-level function signature by using
metadata? For example, for the function
int* convert(unsigned *u)
{
return (int*) u;
}
I'd like to get its type as "(unsigned int *) -> int*" not the llvm
type: (i32*) -> i32*.
(2) When the above function is declared as
extern int* convert(unsigned *u);
Can I still get the source-level signature? It seems to me that the list
of subprograms in the compile unit metadata only contains functions
defined in the unit.
My examples use pointers, but in general I'd like to get any derived or
composite types.
Thanks very much,
Lewis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131108/c2603233/attachment.html>
More information about the llvm-dev
mailing list