Developing the Clang Static Analyzer
Artem Dergachev, Apple
Developing the Clang Static Analyzer Artem Dergachev, Apple Clang - - PowerPoint PPT Presentation
Developing the Clang Static Analyzer Artem Dergachev, Apple Clang Static Analyzer Finds bugs at compile time by inspecting your source code Bugs it finds are more sophisticated than warnings or Clang-Tidy Clang Static Analyzer 1
Artem Dergachev, Apple
1 int foo(int x) { 2 int y = x; 3 if (y == 0) 4 return 24 / x; 5 return 0; 6 }
defend BS/MS/Ph.D. theses on it
https://youtu.be/kdxlsP5QVPw
🎄 Spooky! 🎄 Symbolic Execution 🎄 Dead, Undead, Zombie and Schrödinger Symbols,
The Reaper
🎄 Body Farms
🎄 Spooky!
Plain Source Code Abstract Syntax Tree Control Flow Graph Exploded Graph Path Diagnostics
x + y + z
x x + y y x + y + z z
x ? y : z x y x ? y : z z
x + y + z x + y y x z x x + y y x + y + z z
1 2 3 4 5 3 4 5 1 2
x y x ? y : z z x ? y : z y x z
1 2? 2?
the statement between Point1 and Point2 updates State1 to State2
Program State: Nothing Yet! Program State: Store: x -> 7 Statement: x = 7
Program State: Store: x -> 7 Program State: Store: x -> 7 Exprs: x + 5 -> 12 Statement: x + 5;
Program State: Exprs: x + 5 -> 12 Program State: Exprs: (x + 5) / 2 -> 6 Statement: (x + 5) / 2;
Program State: Nothing Yet! Program State: Exprs: x -> reg_$0<int x> Statement: x;
// example: int foo(int x) { return x; }
Path Explosion!
Program State: Exprs: x -> reg_$0<int x> Statement: if (x > 5) … Program State: Ranges: reg_$0<int x> <= 5 Program State: Ranges: reg_$0<int x> > 5
that may occur during the execution of the program.
by looking at exploded graph dumps and setting conditional breaks
utils/analyzer/exploded-graph-rewriter.py
with various flags to extract useful information from the dump.