Note: the extension only seems to work in VS2019 if VS2017 is also installed (https://llvm.org/PR42290). VS2019 users may want to look at Clang/LLVM Support in Visual Studio instead.
This extension allows clang to be used as a drop in replacement for the standard Visual Studio compiler in existing C and C++ projects. Simply go to Project -> Settings -> General, choose "llvm" as the toolchain, and you are ready to go!
Note that you will need to install LLVM separately. If you want to use a custom built version of LLVM that you have not installed, a property page is added to the project settings UI to allow you to choose an explicit clang binary.
Since clang is a drop-in replacement for MSVC, all compiler options and projects settings that you've selected (with a couple of exceptions) should "just work".
Exceptions:
- You may need to disable precompiled headers
- MSVC LTCG and PGO are incompatible with clang. As such, you will need to disable these options.
- Clang does not support some of the most obscure options of cl. You will get a warning or error if you try to make use of them.
Update History
8/30/2018:
- LLD is now supported! You can choose to enable either LLD, clang-cl, or both.
- Based on user feedback, project settings are added that enable you to specify additional compiler / linker options only when the LLVM version of the corresponding tool is in use. This is helpful if you switch back and forth between toolchains.
- Removed the warnings about several ignored compiler options.
- Due to the structure of a VC project file and the nature of the changes required to get the options working, it's possible that a vcxproj that was set to use this toolchain on an earlier version will not smoothly transition. If that happens, set each value in the LLVM page to a different value (to force it to be dirty), then save, then set the values back to the original values again. Hopefully this is the last time this will happen.