[cfe-dev] How to make clang compile any other language ? I want it to support ACSL (specification language of C).)

Mahesha HS mahesha.llvm at gmail.com
Wed Jul 17 23:49:54 PDT 2013


1. You have to spend considerable amount of time playing with Clang (for
that matter with any software) in order to know its internals.

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.

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.

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.


On Thu, Jul 18, 2013 at 11:24 AM, surbhi singh
<surbhi.chauhan011 at gmail.com>wrote:

> Hie Everyone.
> I want to to produce LLVM-IR for ACSL programs using CLANG. I am new to
> 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
> 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 :
>
> /* Program verification examples from the book "Software Foundations"
>    http://www.cis.upenn.edu/~bcpierce/sf/
>
>    Example: Reduce to Zero
> */
> int reduce_to_zero (int x)/*
>   @requires { x >= 0 }
>   @ensures { result = 0 }
> */{
>     while (x != 0) {
>         /*
>           @invariant { x >= 0 }
>           @variant { x }
>         */
>         x = x - 1;
>     }
>     return x;}
>
>
> 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.
> This is one of the programs for which I want to produce LLVM-IR.
> I had studied internal manual on clang but din't find it much useful as
> 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.
> 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.
> This is a part of my academic research work(B.Tech) on compilers which I
> might continue further as I like this part.
> Please help me with this as I am seriously interested in working with
> clang.
> Thanks in advance.
> Surbhi
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>


-- 
mahesha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130718/52febda3/attachment.html>


More information about the cfe-dev mailing list