<div dir="ltr"><div><div><div>1. You have to spend considerable amount of time playing with Clang (for that matter with any software) in order to know its internals.<br><br></div>2. Based on my understanding of your previous mail, as a first step, it looks like, you have to preserve comments in the original C program which Clang preprocessor probably throws away.<br>
<br></div>3. Then, probably you have to come-up with a mechanism to parse comments, to represent them as AST nodes, and further processing of these ASTs as per your requirements.<br><br></div>4. In my opinion, it could involve considerable amount work to tune Clang before it accepts your ASCL programs. Being said that, I am not an expert in Clang. Please consider other's opinion.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 18, 2013 at 11:24 AM, surbhi singh <span dir="ltr"><<a href="mailto:surbhi.chauhan011@gmail.com" target="_blank">surbhi.chauhan011@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div> Hie Everyone.<br>I want to to produce LLVM-IR for ACSL programs using CLANG. I am new to<br>CLANG and don't know much about it. What I am looking for is how to learn about architecture of CLANG so that I can make changes in its source code so as to make it support for my ACSL constructs. This language is a specification language<br>
of C. The specifications of the program are written in annotated comments. I want to produce LLVM-IR for such type of code using clang. For this I think I have to add some code in the existing source code of clang. So, what I want to know is learn about clang so as to know what changes to make in it and where. I am writing one simple ACSL program :<br>
<br><pre style="word-break:normal!important;word-wrap:normal!important;white-space:pre!important"><span>/* Program verification examples from the book "Software Foundations"
<a href="http://www.cis.upenn.edu/~bcpierce/sf/" target="_blank">http://www.cis.upenn.edu/~bcpierce/sf/</a>
Example: Reduce to Zero
*/</span><span>
</span><span>int</span><span> reduce_to_zero </span><span>(</span><span>int</span><span> x</span><span>)</span><span>
</span><span>/*
@requires { x >= 0 }
@ensures { result = 0 }<br></span><span>*/</span><span>
</span><span>{</span><span>
</span><span>while</span><span> </span><span>(</span><span>x </span><span>!=</span><span> </span><span>0</span><span>)</span><span> </span><span>{</span><span>
</span><span>/*
@invariant { x >= 0 }
@variant { x }
*/</span><span>
x </span><span>=</span><span> x </span><span>-</span><span> </span><span>1</span><span>;</span><span>
</span><span>}</span><span>
</span><span>return</span><span> x</span><span>;</span><span>
</span><span>}</span><br></pre><br>The "requires" annotation ensures that the caller of the function reduce_to_zero() has value of the parameter >= 0 and the "ensures" annotation ensures that the function reduce_to_zero() has result = 0 before it ends its execution. <br>
This is one of the programs for which I want to produce LLVM-IR.<br>I had studied internal manual on clang but din't find it much useful as<br>concerned to my work. I was reading the documentation of clang but I don't think its a great start for beginner's like me.<br>
I had done a course on compiler design as part of my academics and know the basics of lexing, parsing, semantic analysis and compiler architecture. Apart from this, this is my first practical experience with compilers.<br>
This is a part of my academic research work(B.Tech) on compilers which I might continue further as I like this part.<br>Please help me with this as I am seriously interested in working with clang.<br></div>Thanks in advance.<span class="HOEnZb"><font color="#888888"><br>
</font></span></div><span class="HOEnZb"><font color="#888888">Surbhi<br></font></span></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div>mahesha</div>
</div>