Frequently Asked Questions
Does Clang Power Tools generate object files when running the Compile command?
No. Clang Power Tools performs only the following operations: lexical analysis, preprocessing, parsing, and semantic analysis (syntax-directed translation), by invoking
Does Clang Power Tools support
Yes. Starting with version 3.0 Clang Power Tools VS extension has built-in support for clang-format
Auto-format source file on save, configurable style options, file extension rules, etc.
What Clang/LLVM tools are supported by Clang Power Tools workflows?
clang++- Clang compile (syntax-only)
clang-tidy- Clang Tidy (checks, auto-fixes, modernizing code, static analysis)
clang-format- source code formating (auto format on save)
Do I need to install LLVM for Clang Power Tools to work?
We will automatically load clang from the default installation path "C:\Program Files\LLVM".
If you prefer to use a different location you must manually add the bin folder to
What versions of LLVM are supported by Clang Power Tools?
We tested Clang Power Tools with LLVM
Can I share Clang Power Tools configuration options across my team?
Yes, there is support for that, using the
cpt.config file. It enables automatic configuration of any script parameter that is supported by
clang-build.ps1. Place it anywhere in the project parent directories hierarchy and it will be automatically picked up.
cpt.config is version-control friendly, it enables all team members to seamlessly use the same Clang Power Tools configuration options, from both Visual Studio and the console.
Have a look at the sample cpt.config in the Github repository.
How to deal with warnings from system/third-party headers?
Until v2.6, we’ve used the
%INCLUDE% environment variable for setting clang include directories. That was equivalent to using
-isystem for each directory.
Unfortunately, this caused headers included relative to those include directories to be ignored when running compiling/tidying because they were treated as system headers.
Having this brought to our attention, going forward we will use
-isystem to pass include directories to clang, with the following defaults:
- include directories passed using
- additional include directories passed using
Q: What does this mean?
A: You’ll most likely see new warnings when compiling or tidying your code-base.
Q: Will my build fail?
A: Only if you have specified
-Werror (treat warnings as errors).
Q: What should I do?
A: - Make sure to include third party library dependencies via the Include directories project option. Additional include directories should point only to code you can modernize.
- Resolve remaining warnings related to your code.
Q: Can I use ClangPowerTools using the old behavior?
A: Yes. We’ve added, for compatibility reasons, a UI option that allows clang to treat additional includes as system headers. Keep in mind this means we will potentially miss some of your headers when calling clang.
You may want to use this option if using
-Werror (treating warnings as errors) until you’ve reorganized your includes, since any new warnings will break your build.
Q: What about the continuous integration script (clang-build.ps1)?
A: You can specify the
-treat-sai switch and it will have the old behavior.
Did you know you can automatically run Clang compile on the current source file after each MSVC compilation?
This option was a real game changer for our team, because developers often broke CI build pipelines (Clang build).
Scenario: Developer compiles code in Visual Studio (
/W4 /WX ) ✔️ … push commit … CI build pipeline … broken Clang build 🔥
After enabling this option (from Settings), developers immediately see when they compile a source file from VS if it also works in Clang. Each successful MSVC compile is automatically followed by a Clang compile.
Where can I see detailed information about clang-tidy checks?
A list of available checks that
clang-tidy can perform:
Did you know you can auto tidy code on save?
There is a setting (off by default) that enables automatic
clang-tidy (fix) when the current source file is saved.
Did you know you can UNDO all the changes performed by clang-tidy?
clang-tidy on a source file opened in the VS editor, you can Undo the tidy changes (atomically) by hitting
How can I use Clang Static Analyzer?
Clang Static Analyzer was included into
clang-tidy some time ago. As a result, you can use Clang Power Tools to run all static analyzer checks from Clang. Check our extension settings panel, in the Tidy sub-section, scroll to see and ENABLE all the checks starting with: “clang-analyzer-”
More details here:
Does Clang Power Tools support automatic checking of CppCoreGuidelines?
Yes. By leveraging
clang-tidy support for checking CppCoreGuidelines. You can use the
cppcoreguidelines-* filter from Clang Power Tools settings, to select CppCoreGuidelines from the available clang-tidy checks.
If I want to use a .clang-tidy file, where do I put that configuration file on the file system?
clang-tidy searches for the config file starting from the given/input source file directory, going up … until it finds a .clang-tidy file (stops at drive root). This is the standard clang-tidy lookup mechanism.
FYI, Clang Power Tools has a setting related to this workflow:
VS Options > Clang Power Tools > Tidy > Options > Use checks from: (combo-box)
How do I configure options for specific clang-tidy checks?
Configuration options for specific clang-tidy checks can be specified via the
.clang-tidy configuration file. Eg.:
Checks: '-*,some-check' WarningsAsErrors: '' HeaderFilterRegex: '.*' FormatStyle: none CheckOptions: - key: some-check.SomeOption value: 'some value' ...
I found a bug, How can I debug the Clang Power Tools extension?
Clone the Clang Power Tools repository, open the Solution file and build the project. Right click the project and do Properties -> Debug ->
- Select Start external program, enter “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe”
- In Command Line Arguments, add “/rootsuffix Exp”
- Start an instance (F5) and you will be able to set breakpoints etc.