[cfe-dev] Fwd: I need help on how to build and run clang programs

Jonathan Roelofs via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 25 07:39:21 PDT 2016


Please keep the mailing list cc'd in your replies.


On 3/25/16 3:43 AM, Rukayat Erinfolami wrote:
> Thanks a lot.
>
>  From what I read, in order to use a clang program to analyze a cpp
> code, I will first need to generate a .so file which I can use in a way
> like this - $ clang -Xclang -load -Xclang
> build/skeleton/*libSkeletonPass.so* something.c.

Ah, then this is what you're looking for:

http://clang.llvm.org/docs/ClangPlugins.html

The source for the example on that page is here:

https://github.com/llvm-mirror/clang/tree/master/examples/PrintFunctionNames


>
> I also want to ask if there is a specific format to write a clang
> program. Like in writing a Java program, I know that I can take the
> following steps:

Clang is /just/ a C/C++/ObjC/ObjC++ compiler. If you're familiar with 
development in any of those languages, then clang is more or less just a 
drop-in replacement for gcc.

>
> 1. I can write all my program in the method main.
> 2. Or I can have some methods and then call them in the method main.
> 3. I can also use global variables and so on.
>
> Thank you very much.
>
> On Thu, Mar 24, 2016 at 4:43 PM, Jonathan Roelofs
> <jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>> wrote:
>
>
>     Oops. Sent it to the wrong list.
>
>
>
>     -------- Forwarded Message --------
>     Subject: Fwd: I need help on how to build and run clang programs
>     Date: Thu, 24 Mar 2016 10:42:05 -0600
>     From: Jonathan Roelofs <jonathan at codesourcery.com
>     <mailto:jonathan at codesourcery.com>>
>     Organization: CodeSourcery / Mentor Embedded
>     To: erinfolamiayomide at gmail.com <mailto:erinfolamiayomide at gmail.com>
>     CC: cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu> Developers
>     <cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>>
>
>
>
>
>         -------- Forwarded Message --------
>         Subject: I need help on how to build and run clang programs
>         Date: Thu, 24 Mar 2016 03:32:01 -0700
>         From: erinfolamiayomide at gmail.com
>         <mailto:erinfolamiayomide at gmail.com>
>         To: jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>
>
>         I am very new to Clang. I want to write a clang program that
>         helps me
>         print all the methods including constructor of a c++ code. I am
>
>
>     Have a look at clang::ASTFrontendAction and clang::ASTConsumer.
>
>         having problem identifying the right location to place my files,
>         what
>         exactly the cmakeList.txt should contain and also how to build the
>
>
>     It helps to look at other CMakeLists.txt files in the source tree are
>     doing. Usually copy+paste+modify does the trick.
>
>         clang code to generate a .so file.
>
>
>     Can you elaborate what you're trying to do here?
>
>
>         I need help, please.
>
>         Thank you.
>
>         _____________________________________ Sent from
>         http://clang-developers.42468.n3.nabble.com
>
>
>
>
>
>
>
>
>

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-dev mailing list