Вопрос

I have downloaded LLVM 3.1 and build it successfully. My requirement is to add some few debugging lines in a C++ source code files. I have coded module using CLANG 3.1. But CLANG reports a lot of AST error which gcc does not. Note my code compiles fine with gcc compiler. Further my C++ program has a lot of #include statements. LLVM expects the same to be available in a path and fails at different level again.

Это было полезно?

Решение

Clang has a new library named libTooling to ease writing source-to-source tools with clang. I suggest you check it out. The most complete example of using it is clang-format, which reformats arbitrary C++ code according to a set of formatting guidelines. It demonstrates how to rewrite C++ code at the source-level while preserving all the semantics. It shouldn't be hard to hack it to add insertion of certain statements at certain places.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top