Slides:
https://github.com/boostcon/cppnow_presentations_2017/blob/master/05-20-2017_saturday/clang_useful_building_useful_tools_with_llvm_and_clang_for_fun_and_profit__peter_goldsborough__cppnow_05-20-2017.pdfVideo:
https://www.youtube.com/watch?v=E6i8jmiy8MYThe talk will consist of two parts. The first will be a general overview of the LLVM and clang library infrastructure available for creating custom tools such as static analyzers or source-to-source transformation tools. I will explain the ecosystem of the LLVM and clang tooling environment and outline options, tradeoffs and examples of the different ways of creating a tool (e.g. the difference between creating a plugin vs. a LibTooling executable). I will then go further in depth about how clang represents C++ source code by means of an AST and ways of traversing the AST to look for certain points of interest, e.g. old-style for loops that could be converted to range-based loops, or braces that are indented in Allman instead of One-True-Brace-Style, which could be useful for any company with a style guide it wants to enforce at compile-time rather than on paper or in code-reviews.
For the second part, I will then branch out into the two common tasks one might want to perform with a custom-built tool: emitting warnings or errors (for static analysis), and transforming and emitting new code (source-to-source transformations, such as clang-tidy). For each use-case, I will walk through real code that shows how one might approach a simple task in each category.
At the end of the talk, I expect listeners to have a basic understanding of the LLVM/clang tooling environment and AST representation. However, most importantly, I expect people to take away knowledge they can take home or to their office and immediately build tools in no time at all that *genuinely* improve their workflow and productivity. This is not a "give a man a fish" talk. This is a "teach a man to fish" talk.