<br>Hi Sebastian,<br><br>Thanks for the response.<br><br>I already did this :<br><br>
I cast the entire annotated expression to Value*. Then, in order to avoid ugly things like getAsString(), I check if <code>V->getValueID() == Value::ConstantArrayVal</code> in order to cast it to <code>ConstantArray</code>. Because it contains only array[0], I cast array0>getOperand(0) to <code>ConstantStruct</code>. Therefore, from <code>ConstantStruct</code> you can get all the four operands. Now, as a TODO, is only to get the names of @f, @str from every field.<br>
<br>But right now I have only a small step to do. ConstantStruct->getOperand(0) gives me   i8* bitcast (i32* @f to i8*)  . Do you know how I can get the name @f from this? I cannot convert it again to ConstantStruct and follow the same procedure, it will give me a segfault. <br>
<br>Thank you again. Your advice was very helpful :)<br><br><br><div class="gmail_quote">On Fri, Mar 1, 2013 at 9:22 AM, Sebastian Dreßler <span dir="ltr"><<a href="mailto:dressler@zib.de" target="_blank">dressler@zib.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<div><br>
On 02/28/2013 03:55 PM, Alexandru Ionut Diaconescu wrote:<br>
> Hi Sebastian,<br>
><br>
> I think I am very close to get the annotation, but I need to parse a<br>
> Value*, which is of type  {[1 x { i8*, i8*, i8*, i32 }]. In one of those<br>
> fields is the variable that I'm interested into and the string keeping the<br>
> annotation. But I don't know how to parse .... use_begin() gives me the<br>
> same Value*....do you know how I can parse inside the element?<br>
><br>
<br>
</div>This is an Array Type (<a href="http://llvm.org/docs/LangRef.html#array-type" target="_blank">http://llvm.org/docs/LangRef.html#array-type</a>)<br>
which contains a struct. I assume, that you could cast to ConstantArray<br>
which is a Value and then use getOperand(0) and cast its result to<br>
ConstantStruct, like I've done in the sample code. Then you have the<br>
struct and you can traverse it further.<br>
<br>
<br>
Cheers,<br>
Sebastian<br>
<div><div><br>
> Thank you :) !<br>
><br>
><br>
><br>
><br>
><br>
> On Wed, Feb 27, 2013 at 4:44 PM, Alexandru Ionut Diaconescu <<br>
> <a href="mailto:alexandruionutdiaconescu@gmail.com" target="_blank">alexandruionutdiaconescu@gmail.com</a>> wrote:<br>
><br>
>> Hi Sebastian,<br>
>><br>
>> Thank you for the dummy file. I will try to understand and use it. I guess<br>
>> I have some problems with C++11. If I cannot solve by simple "parsing" my<br>
>> code for @llvm.global.annotations, I will ask you again.<br>
>><br>
>> Cheers,<br>
>> Alex<br>
>><br>
>><br>
>> On Wed, Feb 27, 2013 at 4:34 PM, Sebastian Dreßler <<a href="mailto:dressler@zib.de" target="_blank">dressler@zib.de</a>>wrote:<br>
>><br>
>>> Hi Alexandru,<br>
>>><br>
>>> On 02/27/2013 04:20 PM, Alexandru Ionut Diaconescu wrote:<br>
>>>> [...]<br>
>>>> Do you have a larger piece of code (maybe you have some dummy/test<br>
>>>> examples) from your previous work with annotations? It would be very<br>
>>> useful<br>
>>>> :D<br>
>>>><br>
>>><br>
>>> I've attached an example. But please be aware of:<br>
>>><br>
>>> 1. It uses C++11 and cast (previously I simply replaced cast<> with<br>
>>> dynamic_cast<> which does not seem to work everywhere, so sorry for that).<br>
>>><br>
>>> 2. assert is not used in the style as it should be used, so pleas do not<br>
>>> adopt this style.<br>
>>><br>
>>><br>
>>> If some things are still unclear, keep asking ;)<br>
>>><br>
>>> Cheers,<br>
>>> Sebastian<br>
>>><br>
>>><br>
>>> --<br>
>>> Mit freundlichen Grüßen / Kind regards<br>
>>><br>
>>> Sebastian Dreßler<br>
>>><br>
>>> Zuse Institute Berlin (ZIB)<br>
>>> Takustraße 7<br>
>>> D-14195 Berlin-Dahlem<br>
>>> Germany<br>
>>><br>
>>> <a href="mailto:dressler@zib.de" target="_blank">dressler@zib.de</a><br>
>>> Phone: <a href="tel:%2B49%2030%2084185-261" value="+493084185261" target="_blank">+49 30 84185-261</a><br>
>>><br>
>>> <a href="http://www.zib.de/" target="_blank">http://www.zib.de/</a><br>
>>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Best regards,<br>
>> Alexandru Ionut Diaconescu<br>
>><br>
><br>
><br>
><br>
<br>
<br>
--<br>
Mit freundlichen Grüßen / Kind regards<br>
<br>
Sebastian Dreßler<br>
<br>
Zuse Institute Berlin (ZIB)<br>
Takustraße 7<br>
D-14195 Berlin-Dahlem<br>
Germany<br>
<br>
<a href="mailto:dressler@zib.de" target="_blank">dressler@zib.de</a><br>
Phone: <a href="tel:%2B49%2030%2084185-261" value="+493084185261" target="_blank">+49 30 84185-261</a><br>
<br>
<a href="http://www.zib.de/" target="_blank">http://www.zib.de/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font style="color:rgb(153,153,153)">Best regards,</font><br style="color:rgb(153,153,153)">
<font style="color:rgb(153,153,153)">Alexandru Ionut Diaconescu</font><br>