[cfe-dev] LibTooling question

Mario Schwalbe mario at se.inf.tu-dresden.de
Tue Jul 31 01:37:06 PDT 2012


-----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:

      -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.

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-----



More information about the cfe-dev mailing list