Refactoring C++ Using LibTooling
summary
Shows how to build a real migration using clang LibTooling and clang-tidy: an AST-matcher based check finds assignments calling create_button(...) with five args and replaces them with create_button_x() plus inserted setPosition/setDimensions/setTitle calls using fix-it hints. Requires a compilation database and a clang-buildable codebase (Twitter poll: 150 people, 27% say their code doesn’t compile with clang). Covers lexer use for token/indent handling, emphasizes tests and Hyrum’s-law pitfalls, and demonstrates the check running and auto-applying fixes.
AI-written summary · about
chapters (31)
- 0:00Intro
- 0:15What is refactoring
- 1:46Automated refactoring
- 2:09Why automate
- 5:03Nonatomic API Migration
- 7:01UI Library Example
- 8:23Button Example
- 9:33What is LibTooling
- 10:31Can you compile with C
- 12:10Build system
- 13:59Easy migrations
- 15:11Hiram Slaw
- 16:10Quick Summary
- 17:47Why ClientID
- 19:32Getting Started
- 19:58Simple AST Matchers
- 21:39NoMeasures
- 23:30Narrowing Measures
- 25:26Building a Simple Matter
- 28:11Implementing the Check
- 29:59Matching Operators
- 34:26clang
- 36:24check
- 37:15get notes
- 38:45catark
- 39:13cosmetics
- 40:27binary
- 40:57code generation
- 41:59fixit migrations
- 43:23generate diagnostic
- 44:44run diagnostic
