| 107 | } // end anonymous namespace |
| 108 | |
| 109 | void FunctionPointerAnalysis::run() { |
| 110 | ar::Bundle* bundle = _ctx.bundle; |
| 111 | |
| 112 | // Setup a progress logger |
| 113 | std::unique_ptr< ProgressLogger > progress = |
| 114 | make_progress_logger(_ctx.opts.progress, |
| 115 | LogLevel::Info, |
| 116 | /* num_tasks = */ |
| 117 | std::count_if(bundle->global_begin(), |
| 118 | bundle->global_end(), |
| 119 | [](ar::GlobalVariable* gv) { |
| 120 | return gv->is_definition(); |
| 121 | }) + |
| 122 | std::count_if(bundle->function_begin(), |
| 123 | bundle->function_end(), |
| 124 | [](ar::Function* fun) { |
| 125 | return fun->is_definition(); |
| 126 | }) + |
| 127 | 1); |
| 128 | ScopeLogger scope(*progress); |
| 129 | |
| 130 | log::debug("Generating pointer constraints"); |
| 131 | PointerConstraints constraints(bundle->data_layout()); |
| 132 | PointerConstraintsGenerator< EmptyCodeInvariants > visitor(_ctx, |
| 133 | constraints, |
| 134 | nullptr); |
| 135 | |
| 136 | for (auto it = bundle->global_begin(), et = bundle->global_end(); it != et; |
| 137 | ++it) { |
| 138 | ar::GlobalVariable* gv = *it; |
| 139 | if (gv->is_definition()) { |
| 140 | progress->start_task( |
| 141 | "Generating pointer constraints for initializer of global variable " |
| 142 | "'" + |
| 143 | demangle(gv->name()) + "'"); |
| 144 | visitor.process_global_var_def(gv, EmptyCodeInvariants()); |
| 145 | } else { |
| 146 | visitor.process_global_var_decl(gv); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | for (auto it = bundle->function_begin(), et = bundle->function_end(); |
| 151 | it != et; |
| 152 | ++it) { |
| 153 | ar::Function* fun = *it; |
| 154 | if (fun->is_definition()) { |
| 155 | progress->start_task("Generating pointer constraints for function '" + |
| 156 | demangle(fun->name()) + "'"); |
| 157 | visitor.process_function_def(fun, EmptyCodeInvariants()); |
| 158 | } else { |
| 159 | visitor.process_function_decl(fun); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | log::debug("Solving pointer constraints"); |
| 164 | progress->start_task("Solving pointer constraints"); |
| 165 | constraints.solve(); |
| 166 |
nothing calls this directly
no test coverage detected