Getting started

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting started

Phil King
Hi,

I'm new to clang and am looking for some pointers on getting started.

I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

Thanks

Phil

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Chad Rosier

On Feb 15, 2012, at 2:41 PM, Phil King wrote:

> Hi,
>
> I'm new to clang and am looking for some pointers on getting started.

See: http://llvm.org/docs/GettingStarted.html

> I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

See: http://llvm.org/docs/

> Thanks
>
> Phil
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Phil King
Hi Chad,

I should have mentioned that I've already looked at the documents on llvm.org/docs and clang.llvm.org/docs.

I've also seen the doxygen API documentation, but it's going to take a long time to get going using that on its own ;-)
 Phil.



----- Original Message -----
From: Chad Rosier <[hidden email]>
To: Phil King <[hidden email]>
Cc: "[hidden email]" <[hidden email]>
Sent: Wednesday, 15 February 2012, 22:50
Subject: Re: [cfe-dev] Getting started


On Feb 15, 2012, at 2:41 PM, Phil King wrote:

> Hi,
>
> I'm new to clang and am looking for some pointers on getting started.

See: http://llvm.org/docs/GettingStarted.html

> I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?

See: http://llvm.org/docs/

> Thanks
>
> Phil
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Chad Rosier
Phil,
You might also try grepping the mailing lists to see if you can find an answer.  Unfortunately, I don't have a specific answer to give you, but maybe someone else can offer some direction.  If this is going to be a research project, then it's inevitable that you'll have to work on the source.  That _is_ the definitive documentation.

 Chad


On Feb 15, 2012, at 3:06 PM, Phil King wrote:

> Hi Chad,
>
> I should have mentioned that I've already looked at the documents on llvm.org/docs and clang.llvm.org/docs.
>
> I've also seen the doxygen API documentation, but it's going to take a long time to get going using that on its own ;-)
>  Phil.
>
>
>
> ----- Original Message -----
> From: Chad Rosier <[hidden email]>
> To: Phil King <[hidden email]>
> Cc: "[hidden email]" <[hidden email]>
> Sent: Wednesday, 15 February 2012, 22:50
> Subject: Re: [cfe-dev] Getting started
>
>
> On Feb 15, 2012, at 2:41 PM, Phil King wrote:
>
>> Hi,
>>
>> I'm new to clang and am looking for some pointers on getting started.
>
> See: http://llvm.org/docs/GettingStarted.html
>
>> I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?
>
> See: http://llvm.org/docs/
>
>> Thanks
>>
>> Phil
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Edward Meewis
In reply to this post by Phil King
On 15-02-12 23:41, Phil King wrote:

> Hi,
>
> I'm new to clang and am looking for some pointers on getting started.
>
> I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?
>
> Thanks
>
> Phil
>
Hello Phil,

This maybe the blind leading the blind, but have you seen Douglas' talk
about libclang (http://llvm.org/devmtg/2011-11/index.html) and extending
clang the year before (http://llvm.org/devmtg/2010-11/)?

There's an example extracting function names in the example directory.
I'd also study c-index-test source, which does AST walking.

Hope that get you started, Ed.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Phil King
----- Original Message -----

From: Edward Meewis <[hidden email]>
To: [hidden email]
Cc:
Sent: Thursday, 16 February 2012, 0:30
Subject: Re: [cfe-dev] Getting started

On 15-02-12 23:41, Phil King wrote:

> Hi,
>
> I'm new to clang and am looking for some pointers on getting started.
>
> I want to be able to build a project against clang with the aim of adding code checking functionality for research purposes. Are there any examples / tutorials that show how to do this (e.g. getting and walking the AST representation of an expression )?
>
> Thanks
>
> Phil
>
Hello Phil,

This maybe the blind leading the blind, but have you seen Douglas' talk
about libclang (http://llvm.org/devmtg/2011-11/index.html) and extending
clang the year before (http://llvm.org/devmtg/2010-11/)?

There's an example extracting function names in the example directory.
I'd also study c-index-test source, which does AST walking.

Hope that get you started, Ed.

-------------------

Thanks Ed, I finished listening to his talk a few minutes before your message arrived !

Just trying to get a skeletal program to build at the moment... It looks like it's the way in I was after ;-)

Phil

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

David Chisnall
In reply to this post by Edward Meewis
On 16 Feb 2012, at 00:30, Edward Meewis wrote:

> This maybe the blind leading the blind, but have you seen Douglas' talk
> about libclang (http://llvm.org/devmtg/2011-11/index.html) and extending
> clang the year before (http://llvm.org/devmtg/2010-11/)?
>
> There's an example extracting function names in the example directory.
> I'd also study c-index-test source, which does AST walking.

If you want to build a code checking tool, then libclang is probably not the best thing for you.  It is designed for things like IDEs and does not expose the code flow analysis stuff that the static analyser uses.  Your best bet would probably be to look at the existing analysers.

David

-- Sent from my Cray X1
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Phil King
On 16 Feb 2012, at 12:10, David Chisnall <[hidden email]> wrote:

> If you want to build a code checking tool, then libclang is probably not the best thing for you.  It is designed for things like IDEs and does not expose the code flow analysis stuff that the static analyser uses.  Your best bet would probably be to look at the existing analysers.
>
> David

Thanks, I've had a look and that does look a better place to start.

Is there a "how to" for adding a new checker? I've added in a new cpp file and added it to cmakelists.txt, but it fails at compile time due a missing declaration in clang:ento. I think I just need to add something in to checkers.td - does it matter where ?

Phil.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Phil King
On 18 Feb 2012, at 00:28, Phil King <[hidden email]> wrote:

> On 16 Feb 2012, at 12:10, David Chisnall <[hidden email]> wrote:
>
>> If you want to build a code checking tool, then libclang is probably not the best thing for you.  It is designed for things like IDEs and does not expose the code flow analysis stuff that the static analyser uses.  Your best bet would probably be to look at the existing analysers.
>>
>> David
>
> Thanks, I've had a look and that does look a better place to start.
>
> Is there a "how to" for adding a new checker? I've added in a new cpp file and added it to cmakelists.txt, but it fails at compile time due a missing declaration in clang:ento. I think I just need to add something in to checkers.td - does it matter where

Found the answer at clang-analyser.llvm.org/checker_dev_manual.html

Phil.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev