Bringing Clang-tidy Magic to Visual Studio C++ Developers

Speaker: Victor Ciura

Audience level: Intermediate

category

"A 14 year old code base under active development, 2.5 million lines of C++ code, a few brave nerds, two powerful tools and one hot summer...", or "How we managed to clang-tidy our whole code base, while maintaining our monthly release cycle". Did I mention that we're a Windows-only dev team using Visual C++ ? That's right, we're going to continue using both Visual Studio (2017) and Clang tools on the side, to modernize and improve our code quality.

It's been a treacherous journey bringing the clang-tidy magic to Visual Studio C++ developers and I want to share with you some of the most exciting experiences my team and I had along the way and a few things we've learned that you may take with you on your next "travels". A few months back, we decided to hop on the clang-tidy train and set out to modernize our aging code base and find hidden bugs along the way with clang-tidy static analyzer. The hard part was getting all our code to compile with clang, using the correct project settings (extracted from Visual Studio). After that, clang-tidy was a breeze to use and we immediately integrated it in our workflow.

I still cannot believe the code transformations we were able to do with its 'modernize' and 'readability' modules and some of the subtle latent bugs we found and fixed with its static analyzer and CppCoreGuidelines checks. Luckily, we took a lot of pictures and kept a detailed travel log, to share this fruitful journey with you, now. We'll also share some tools we developed, to help you with this workflow: automation tips & configs (Jenkins, MSBuild), open-source PowerShell scripts (clang-tidy on Visual Studio projects) and a free Visual Studio extension (Clang Power Tools).