3

My ultimate goal is to do a one-off automated modernization of some code and apply our identifier capitalization rules that are expressed in .clang-tidy. Being able to repeat this over time would be nice. We use Visual Studio 2015, CMake 3.13, and I've installed LLVM 9 to get clang-tidy.

I'm fine with running clang-tidy on the command line, or from CMake, or Visual Studio, but I need help for any of those.

For running on the command line I need a compile_commands.json file from CMake, but passing -DCMAKE_EXPORT_COMPILE_COMMANDS=ON will not create one. I've heard this does not work for CMake Visual Studio generators. I tried a Ninja generator with "cmake .. -G Ninja" but I got errors. I'm not familiar with Ninja and don't know if is expected to just work. I also don't know whether the compile_commands.json file that it generates would be relevant if I'm really building with Visual Studio 2015. What is the most accepted way to generate this file on my platform?

I have access to Visual Studio 2019, 16.4, which has built-in clang-tidy support, but the blog says that this doesn't apply fixes, which is my main goal here.

Ionut Enache
  • 461
  • 8
  • 22
All The Rage
  • 743
  • 5
  • 24

1 Answers1

2

The way I did this was via Clang Power Tools - it's an extension for Visual Studio that integrates clang-tidy and can apply fixes.

It also helped me in getting my codebase compileable by clang (necessary precondition for clang-tidy) as it provides basic clang compilation (just syntax, no output).

pablo285
  • 2,460
  • 4
  • 14
  • 38