<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,<br>
</p>
<p>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:<br>
</p>
<font face="Courier New, Courier, monospace">int *foo(struct ST *s)
{</font><br>
<font face="Courier New, Courier, monospace"> return
&s[1].Z.B[5][13];</font><br>
<font face="Courier New, Courier, monospace">}</font>
<p>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.<br>
</p>
<p>I took a look at the implementation of the function, which is the
following:<br>
</p>
<p><font face="Courier New, Courier, monospace"> ///
getReturnTypeName - Subprogram return types are encoded either
as<br>
/// DIType or as DICompositeType.<br>
StringRef getReturnTypeName() const {<br>
DICompositeType DCT(getFieldAs<DICompositeType>(7));<br>
if (DCT.Verify()) {<br>
DIArray A = DCT.getTypeArray();<br>
DIType T(A.getElement(0));<br>
return T.getName();<br>
}<br>
DIType T(getFieldAs<DIType>(7));<br>
return T.getName();<br>
}<br>
</font><br>
</p>
<p>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."<br>
</p>
<p>My questions are:<br>
</p>
<p>(1) Is it possible to get source-level function signature by
using metadata? For example, for the function<br>
</p>
<p><font face="Courier New, Courier, monospace">int*
convert(unsigned *u)<br>
{<br>
return (int*) u;<br>
}</font></p>
<p>I'd like to get its type as "(unsigned int *) -> int*" not the
llvm type: (i32*) -> i32*.<br>
</p>
<p>(2) When the above function is declared as<br>
</p>
<p><font face="Courier New, Courier, monospace">extern int*
convert(unsigned *u);<br>
</font></p>
<p>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.<br>
</p>
My examples use pointers, but in general I'd like to get any derived
or composite types.<br>
<br>
Thanks very much,<br>
Lewis<br>
<br>
</body>
</html>