Lifetime analysis for everyone
summary
Clang implements Herb Sutter–inspired lifetime checks that run as fast, statement-local diagnostics and ship as clang 10 default, with the same rules available in MSVC. The checks track owners vs non-owning pointers (string_view, span, iterators), flag returns or local initializations that point into temporaries, and found ~20 lifetime-fix commits in LLVM with about half preventable; on tested projects the warnings produce no false positives. A more powerful -Wlifetime experimental flow‑sensitive branch adds annotations and inference for inter-statement bugs.
AI-written summary · about
chapters (20)
- 0:00Intro
- 0:32Object lifetimes
- 2:42String lifetimes
- 4:34Subobjects
- 6:13Rangebased
- 7:26Ternary operators
- 9:42Summary
- 11:01Do we make mistakes
- 16:53Practice
- 19:42Sanitizer
- 23:13Behind the curtain
- 36:49Flow sensitive analysis
- 40:42Owner invalidation
- 43:20New features
- 45:34Can the analysis read my mind
- 48:38Conclusion
- 50:08Statement local analysis
- 52:26False positives
- 55:10Release branch
- 56:51Wrap up
related talks
01h 08mImplementing the C++ Core Guidelines’ Lifetime Safety Profile in Clang
51mCode Analysis ++
57mC++ MythBusters Strike 2
22mWriting safe and secure code
58mAn (In-)Complete Guide to C++ Object Lifetimes
54mA look at C++ through the glasses of a language tool
01h 32mClosing Keynote: C++ Development Tools: Past, Present and Future
24mRefactoring Legacy Codebases with LibTooling
