[cfe-dev] LibTooling question

Manuel Klimek klimek at google.com
Wed Aug 1 06:45:05 PDT 2012


On Tue, Jul 31, 2012 at 10:37 AM, Mario Schwalbe
<mario at se.inf.tu-dresden.de> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi CLANGers,
>
> I've been playing with Clang's LibTooling classes closely following
> the tutorial at http://clang.llvm.org/docs/LibTooling.html in order
> to make use of clang as a frontend in our project.
>
> However, I might need some assistence:
>
> 1. Include headers: Using the ClangTool class (like the example suggests)
>    it cannot find its own headers. The documentation states:
>
>    "Clang tools need their builtin headers and search for them the same
>     way clang does. Thus, the default location to look for builtin headers
>     is in a path $(dirname /path/to/tool)/../lib/clang/3.2/include relative
>     to the tool binary."
>
>    But apparently the passed pseudo argv[0] is clang-tool, and, hence, the
>    invocation contains:

That should only be the case if you use runToolOnCode, and not if you
use ClangTool.

Does the code live somewhere you can point me to?

>       -resource-dir ../lib/clang/3.1
>       -internal-isystem ../lib/clang/3.1/include
>
>    on Linux. (Windows seems to work.) It this intended behaviour?
>    How can I set those paths? clang itself works. The ToolInvocation class
>    as well, if I pass a reasonable path as argv[0].
>
> 2. I finally managed to run a SyntaxOnlyAction as well as PrintPreprocessedAction.
>    But how can I compile a module to LLVM IR?
>
> 3. And is it possible to access the generated result (LLVM IR or preprocessed
>    source code) without first writing to disk and re-reading.

Regarding code generation I'm not sure :) The tooling is definitely
built mainly with parsing in mind. I've looped in Nick for some
comments on what might be necessary to get your use case working...

Cheers,
/Manuel

>
> Thanks in advance,
> Mario
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJQF5kiAAoJEDv0fP6GapNt1j8IAInVS4J2446fYTpxJF+uUjSe
> mV3rte0PyZ/fS1+70LfH+etjjiP0PMhrvLKIvU5HazMZ2cn7ZpXJXqopXQS/orcx
> hzwTrYzRehfVOzv0ykW0XwI5yKqaOg+SKZtyevBSMMY7go+x7CXZQw9rNncetI7L
> e4ITyzQmjQd/Tal9OdWpDu2uB9Ma79QBmDYEm035jt/twcEDATK91ZFgP5MSaCXQ
> DPwWMZhG01vkR5uoBCQX4gVeLXlMrJJtaSM21ZNv1jZ4cfJdqMqoVTh7wZ/VKL1t
> jzvP0AyIWEg6VxI18do15KE2B7TKSzq2vBpK0w7lgKbADS8qOZiQH+YzWHE+Ahk=
> =PvUf
> -----END PGP SIGNATURE-----
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list