As I stated in the title. I want to run custom clang tool on the translation unit while the compilation process is running. I want to take over this translation process and do a static analysis when it runs. I know that it is possible to perform static analysis using the libTooling library, but I want it to happen inside the compiler during the compilation process.
Asked
Active
Viewed 160 times
1
-
What have you tried so far? – Kyle Williamson May 14 '19 at 19:40
-
1So far I've managed to compile libTooling examples with few custom modifications. To be honest I'm quite new in the clang world but I'm pretty impressed with it's capability. I was thinking about modifying compiler itself since all the sources are available. I also read that clang allows something called plugins which can be loaded into the compiler executable. But when you run this plugin it's just this plugin that's being run. Did anyone ever tried something like this? Is it feasible? – fskoras May 14 '19 at 20:20
-
Can you, please, clarify on what do you mean by _during the compilation process_? Do you mean that you don't want to have a separate tool that compiles your source and a compiler itself that does the same thing? If that's the case, it's still possible to do it using *libTooling* as it gives you access to all of the clang's internals. It might be a better approach as the migration from one clang version to another would be easier. – Valeriy Savchenko Jun 03 '19 at 09:43
-
@ValeriySavchenko This is exactly what I am aiming for. How would you achieve this using libTooling? – fskoras Jun 06 '19 at 17:20
-
libTooling gives you the access to all of the Clang's internal header files and the ability to link against whatever component of Clang/LLVM. I guess the best way to go is to study how SA and clang itself are implemented using those components and replicate a hybrid in your own tool. – Valeriy Savchenko Jun 06 '19 at 18:58