Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```cpp
- static void D() { }
- static void Y() { D(); }
- static void X() { Y(); }
- static void C() { D(); X(); }
- static void B() { C(); }
- static void S() { D(); }
- static void P() { S(); }
- static void O() { P(); }
- static void N() { O(); }
- static void M() { N(); }
- static void G() { M(); }
- static void A() { B(); G(); }
- int main() {
- A();
- }
- ```
- easy step:
- ```
- $ clang++ -S -emit-llvm main1.cpp -o - | opt -analyze -dot-callgraph
- $ dot -Tpng -ocallgraph.png callgraph.dot
- ```
- filtered step:
- ```cpp
- #include <vector>
- struct A {
- A(int);
- void f(); // not defined, prevents inlining it!
- };
- int main() {
- std::vector<A> v;
- v.push_back(42);
- v[0].f();
- }
- ```
- two commands:
- ```
- $ clang++ -S -emit-llvm main1.cpp -o - |
- opt -analyze -std-link-opts -dot-callgraph
- $ cat callgraph.dot |
- c++filt |
- sed 's,>,\\>,g; s,-\\>,->,g; s,<,\\<,g' |
- gawk '/external node/{id=$1} $1 != id' |
- dot -Tpng -ocallgraph.png
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement