Changeset 6215a5c for src/CodeTools/DeclStats.cc
- Timestamp:
- Feb 6, 2017, 11:37:38 AM (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:
- 0c82fec4
- Parents:
- 7a560c1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
r7a560c1 r6215a5c 22 22 23 23 #include "Common/VectorMap.h" 24 #include "GenPoly/GenPoly.h" 24 25 #include "Parser/LinkageSpec.h" 25 26 #include "SynTree/Declaration.h" … … 39 40 /// Count of declarations with each number of return types 40 41 VectorMap<unsigned> by_returns; 41 42 Stats() : n_decls(0), mono_decls(0), poly_decls(0), by_name() {} 42 /// Count of declarations with each number of polymorphic parameters 43 VectorMap<unsigned> n_poly_params; 44 /// Count of declarations with each number of polymorphic return types 45 VectorMap<unsigned> n_poly_returns; 46 47 Stats() : n_decls(0), mono_decls(0), poly_decls(0), by_name(), by_params(), by_returns(), n_poly_params(), n_poly_returns() {} 43 48 44 49 Stats& operator+= (const Stats& o) { … … 61 66 } 62 67 68 n_poly_params.reserve( o.n_poly_params.size() ); 69 for ( unsigned i = 0; i < o.n_poly_params.size(); ++i ) { 70 n_poly_params[i] += o.n_poly_params[i]; 71 } 72 73 n_poly_returns.reserve( o.n_poly_returns.size() ); 74 for ( unsigned i = 0; i < o.n_poly_returns.size(); ++i ) { 75 n_poly_returns[i] += o.n_poly_returns[i]; 76 } 77 63 78 return *this; 64 79 } … … 86 101 87 102 unsigned n_params = 0; 88 for ( auto pdecl : fnTy->get_parameters() ) { n_params += pdecl->get_type()->size(); } 103 unsigned n_poly_params = 0; 104 for ( auto pdecl : fnTy->get_parameters() ) { 105 n_params += pdecl->get_type()->size(); 106 if ( GenPoly::hasPolyBase( pdecl->get_type() ) ) ++n_poly_params; 107 } 89 108 ++stats.by_params.at( n_params ); 109 ++stats.n_poly_params.at( n_poly_params ); 90 110 91 111 unsigned n_returns = 0; 92 for ( auto rdecl : fnTy->get_returnVals() ) { n_returns += rdecl->get_type()->size(); } 112 unsigned n_poly_returns = 0; 113 for ( auto rdecl : fnTy->get_returnVals() ) { 114 n_returns += rdecl->get_type()->size(); 115 if ( GenPoly::hasPolyBase( rdecl->get_type() ) ) ++n_poly_returns; 116 } 93 117 ++stats.by_returns.at( n_returns ); 118 ++stats.n_poly_returns.at( n_poly_returns ); 94 119 } 95 120 … … 156 181 157 182 printAllHisto("overloads", [](const Stats& stats) { return stats.by_name; }); 183 printAllMap("n_poly_params", [](const Stats& stats) { return stats.n_poly_params; }); 158 184 printAllMap("n_params", [](const Stats& stats) { return stats.by_params; }); 185 printAllMap("n_poly_returns", [](const Stats& stats) { return stats.n_poly_returns; }); 159 186 printAllMap("n_returns", [](const Stats& stats) { return stats.by_returns; }); 160 187 }
Note: See TracChangeset
for help on using the changeset viewer.