Automatically detect your .clang-tidy file

Ionut Enache Ionut July 13, 2020

Constantly dealing with multiple C++ projects in Visual Studio is often challenging. In many cases, you need to adjust your helper tools to fully support each project manually. These actions can cost you a significant amount of time, and repeating the same steps doesn’t sound like a pleasant activity.

Clang Power Tools is built for automatization, and if you want to modernize your C++ code using Clang Tidy you can choose to use the predefined flags or a .clang-tidy file you created specifically for your project. For the next steps, we use the second method.

Detect .clang-tidy file

Using the quick commands from the Visual Studio toolbar, you have access to the main Clang Power Tools features, so let’s get started.

  1. Open Clang Power Tools Settings Menu.Clang Power Tools Toolbar
  2. Select the Tidy tab.
  3. Be sure you have the Detect .clang-tidy file option activated.Detect Clang Tidy File Settings Option

    💡 The option is On by default. In the current state, we are using the default configuration with the Use checks from option set on PredefinedChecks.

  4. Execute Clang Tidy/Clang Tidy-Fix command on a C++ file that has a corresponding .clang-tidy file.

    💡 The .clang-tidy file is automatically detected at runtime.

If you open the Tidy Settings tab again, you can see that the Use checks from option is now set on TidyFile.

Detected Clang Tidy File

Be sure you don’t miss our video tutorial about how to Automatically detect the .clang-tidy configuration file.

Conclusion

Now you are ready to jump on those C++ projects which have a .clang-tidy file without worrying about the configuration process. Clang Power Tools is a tool that is already configured out of the box.