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 clang++ -fsyntax-only.


Does Clang Power Tools supportclang-format ?

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?

Yes. Download and install Clang for Windows (LLVM pre-built binary)
Eg. LLVM-8.0.0-win64

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 %PATH%.


What versions of LLVM are supported by Clang Power Tools?

We tested Clang Power Tools with LLVM 4.0.x , 5.0.x , 6.0.x , 7.0.x and 8.0.x


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 -I and -isystem to pass include directories to clang, with the following defaults:

  • include directories passed using -isystem
  • additional include directories passed using -I

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:
clang.llvm.org/extra/clang-tidy/checks/list


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?

After performing clang-tidy on a source file opened in the VS editor, you can Undo the tidy changes (atomically) by hitting Ctrl+Z


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:
clang-analyzer.llvm.org/available_checks


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 ->

  1. Select Start external program, enter “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe”
  2. In Command Line Arguments, add “/rootsuffix Exp”
  3. Start an instance (F5) and you will be able to set breakpoints etc.

Can't find your answer?

You can always write us or open an issue on GitHub .