A Visual Studio AddIn that lets users play with the Clang C/C++ compiler from within the VS IDE. Designed to translate MSVC C/C++ compiler options into arguments that Clang understands while retaining and executing the rest of the build pipeline.
Simply load a project and choose Rebuild from the Clang menu. If you’re lucky, you will end up with a functioning executable; if not, the plug-in verbosely spews the compiler output in a format compatible with the VS log window – double-click to jump to file locations, just as you would with the default compiler.
Using Clang you get the benefit of more descriptive and column-specific diagnostics, too. ClangVSx can dump the complete command line invocation, as well as the internal compiler-driver arguments.
Alongside the main menu additions, ClangVSx adds a context-menu to the editor that allows the developer to fire off Clang-specific tasks on the current source file.
It becomes trivial to bring up the LLVM bitcode representation of compiled source, or the output from the C/C++ preprocessor (a feature, I might add, that I wish Visual Studio had built-in itself, like CodeWarrior used to have)
A settings dialog controls which compiler package to target, along with various global settings and diagnotics outputs. You can also override the target-triple, if you fancy trying to compile projects for ARM or something.
It is not all plain sailing, however:
- Clang is not entirely MS/Win32 friendly – there are huge gaps in the MSVC C++ ABI support (as of writing), along with various core intrinsics not being available yet (
__debugbreak, for example)
- Compiling ATL/MFC apps is currently not trivial, or infact possible at all in most cases – there are a few critical incompatibilities with the afx headers in the Windows Platform SDK
There are a few patches applied to my local version of Clang that improve the success rate when compiling Win32 projects. I have a pre-built version of Clang 3.2 available here. The nature of the patches can be found on the GitHub page. If you just want to play about with the compiler and see what works, I would recommend using this prebuilt version.
The ClangVSx source code and built executables are available on GitHub.
Release notes and version information (ie. what works and what probably doesn’t) can also be found there.