Changeset 31868da for src/CodeTools/DeclStats.cc
- Timestamp:
- Feb 28, 2017, 1:48:56 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- fd061ed3
- Parents:
- 356c62a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
r356c62a r31868da 130 130 std::unordered_set<std::string> seen_names; ///< Stores manglenames already seen to avoid double-counting 131 131 Stats total; 132 /// Count of expressions with (depth, fanout) 133 std::map<std::pair<unsigned, unsigned>, unsigned> exprs_by_fanout_at_depth; 132 134 133 135 /// Update arg pack stats based on a declaration list … … 179 181 analyze( stats, seen, params, fnTy->get_parameters() ); 180 182 analyze( stats, seen, returns, fnTy->get_returnVals() ); 183 } 184 185 void analyzeExpr( UntypedExpr *expr, unsigned depth ) { 186 auto& args = expr->get_args(); 187 unsigned fanout = args.size(); 188 ++exprs_by_fanout_at_depth[ std::make_pair(depth, fanout) ]; 189 for ( Expression* arg : args ) { 190 if ( UntypedExpr *uearg = dynamic_cast<UntypedExpr*>(arg) ) { 191 analyzeExpr( uearg, depth+1 ); 192 } 193 } 181 194 } 182 195 … … 217 230 } 218 231 232 virtual void visit( UntypedExpr *expr ) { 233 analyzeExpr( expr, 0 ); 234 } 235 219 236 private: 220 237 template<typename F> … … 297 314 printAllMap("n_distinct_types_" + name, [&extract](const Stats& stats) { return extract(stats).n_types; }); 298 315 printAllMap("%_new_types_in_" + name, [&extract](const Stats& stats) { return extract(stats).p_new; }); 316 } 317 318 void printPairMap( const std::string& name, 319 const std::map<std::pair<unsigned, unsigned>, unsigned>& map ) { 320 for ( const auto& entry : map ) { 321 const auto& key = entry.first; 322 std::cout << "\"" << name << "\"," << key.first << "," << key.second << "," 323 << entry.second << std::endl; 324 } 299 325 } 300 326 … … 322 348 printAllPack("assn_params", [](const Stats& stats) { return stats.assn_params; }); 323 349 printAllPack("assn_returns", [](const Stats& stats) { return stats.assn_returns; }); 350 std::cout << std::endl; 351 352 printPairMap("exprs_by_depth+fanout", exprs_by_fanout_at_depth); 324 353 } 325 354 };
Note: See TracChangeset
for help on using the changeset viewer.