C++ Insights - See your code through a compiler's eyes
Uses LLVM/Clang, Ninja and LLD to build.
C++ Insights is a tool based on clang that transforms your source code into the source code seen by the compiler.
The aim is to make things visible, which normally and intentionally happen behind the scenes. It’s about the magic the compiler does to make things work. Or looking through a compiler’s classes.
Suppose you have this code:
In fact this code looks like this by your compiler:
Installation and Use
C++ Insights is available online, but if you want to build and install it on your system, there are some details. You will need the following construction tools:
- LLVM/clang++, it only compiles with it.
- lld , this is the most important of all, C++ Insights reports parameters to the linker that GNU ld is not supported. 😞
Example in Ubuntu:
Then just clone and build with the following command:
If you can’t, try this:
Note that the linker and the compiler are informed via parameter to CMake, if you want to reinforce it, run the commands before
export CXX=$(which clang++)and for the linker:
env LD=$ (which lld).
You can still try with
cmake -G "Unix Makefiles" ..plus the other parameters above.
I thought about compiling with these “closed loop” tools… Anyway, good luck compiling, you’ll need it!
If you managed to compile and install it, the use is very simple, for example to analyze a code:
If you were NOT able to compile and install, relax! You can use it online at:
I’m sure it’s a lot easier! 😃
For more information, also visit GitHub: