source: src/CodeTools/DeclStats.cc@ 1b0184b

Last change on this file since 1b0184b was 52a5262e, checked in by Andrew Beach <ajbeach@…>, 2 years ago

TypeVarMap is now a subtype instead of an alias to remove the redundent constructor argument. Various bits of box pass clean-up.

  • Property mode set to 100644
File size: 22.4 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// DeclStats.cc --
8//
9// Author : Aaron Moss
10// Created On : Wed Jan 31 16:40:00 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Dec 13 23:39:33 2019
13// Update Count : 2
14//
15
16#include "DeclStats.h"
17
18#include <iostream> // for operator<<, basic_ostream, cout
19#include <map> // for map
20#include <string> // for string, operator+, operator<<, cha...
21#include <unordered_map> // for unordered_map
22#include <unordered_set> // for unordered_set
23#include <utility> // for pair, make_pair
24
25#include "Common/PassVisitor.h"
26#include "Common/VectorMap.h" // for VectorMap
27#include "SynTree/LinkageSpec.h" // for ::NoOfSpecs, Spec
28#include "SynTree/Declaration.h" // for FunctionDecl, TypeDecl, Declaration
29#include "SynTree/Expression.h" // for UntypedExpr, Expression
30#include "SynTree/Statement.h" // for CompoundStmt
31#include "SynTree/Type.h" // for Type, FunctionType, PointerType
32#include "SynTree/Visitor.h" // for maybeAccept, Visitor, acceptAll
33
34namespace CodeTools {
35
36 struct DeclStats : public WithShortCircuiting {
37 template<typename T>
38 static void sum(T& a, const T& b) { a += b; }
39
40 static void sum(VectorMap<unsigned>& a, const VectorMap<unsigned>& b) {
41 a.reserve( b.size() );
42 for ( unsigned i = 0; i < b.size(); ++i ) {
43 a[i] += b[i];
44 }
45 }
46
47 template<typename K>
48 static void sum(std::map<K, unsigned>& a, const std::map<K, unsigned>& b) {
49 for ( const auto& entry : b ) {
50 a[ entry.first ] += entry.second;
51 }
52 }
53
54 template<typename K>
55 static void sum(std::unordered_map<K, unsigned>& a, const std::unordered_map<K, unsigned>& b) {
56 for ( const auto& entry : b ) {
57 a[ entry.first ] += entry.second;
58 }
59 }
60
61 struct ArgPackStats {
62 VectorMap<unsigned> n; ///< Count of decls with each number of elements
63 VectorMap<unsigned> n_basic; ///< Count of decls with each number of basic type elements
64 VectorMap<unsigned> n_generic; ///< Count of decls with each number of generic type elements
65 VectorMap<unsigned> n_poly; ///< Count of decls with each number of polymorphic elements
66 VectorMap<unsigned> n_compound; ///< Count of decls with each number of non-generic compound types
67 std::map<unsigned, unsigned> p_basic; ///< Count of decls with each percentage of basic type elements
68 std::map<unsigned, unsigned> p_generic; ///< Count of decls with each percentage of generic type elements
69 std::map<unsigned, unsigned> p_poly; ///< Count of decls with each percentage of polymorphic elements
70 std::map<unsigned, unsigned> p_compound; ///< Count of decls with each percentage of non-generic compound type elements
71 VectorMap<unsigned> n_types; ///< Count of decls with each number of distinct types in the pack
72 /// Count of decls with each percentage of new types in lists.
73 /// Types used in the parameter list that recur in the return list are not considered to be new.
74 std::map<unsigned, unsigned> p_new;
75
76 ArgPackStats& operator+= (const ArgPackStats& o) {
77 sum(n, o.n);
78 sum(n_basic, o.n_basic);
79 sum(n_generic, o.n_generic);
80 sum(n_poly, o.n_poly);
81 sum(n_compound, o.n_compound);
82 sum(p_basic, o.p_basic);
83 sum(p_generic, o.p_generic);
84 sum(p_poly, o.p_poly);
85 sum(p_compound, o.p_compound);
86 sum(n_types, o.n_types);
87 sum(p_new, o.p_new);
88
89 return *this;
90 }
91 };
92
93 struct Stats {
94 unsigned n_decls; ///< Total number of declarations
95 /// Count of declarations with each number of assertion parameters
96 VectorMap<unsigned> n_type_params;
97 /// Count of generic types with each number of type parameters
98 VectorMap<unsigned> n_generic_params;
99 /// Count of maximum nesting depth of types
100 VectorMap<unsigned> n_generic_nesting;
101 /// Count of declarations with each name
102 std::unordered_map<std::string, unsigned> by_name;
103 /// Count of uses of each basic type
104 std::unordered_map<std::string, unsigned> basic_type_names;
105 /// Count of uses of each generic type name (includes "*", "[]", "(*)", "[,]")
106 std::unordered_map<std::string, unsigned> generic_type_names;
107 /// Count of uses of each non-generic aggregate type
108 std::unordered_map<std::string, unsigned> compound_type_names;
109 /// Count of decls using each basic type
110 std::unordered_map<std::string, unsigned> basic_type_decls;
111 /// Count of decls using each generic type (includes "*", "[]", "(*)", "[,]")
112 std::unordered_map<std::string, unsigned> generic_type_decls;
113 /// Count of decls using each compound type
114 std::unordered_map<std::string, unsigned> compound_type_decls;
115 /// Stats for the parameter list
116 ArgPackStats params;
117 /// Stats for the return list
118 ArgPackStats returns;
119
120 /// Count of declarations with each number of assertions
121 std::map<unsigned, unsigned> n_assns;
122 /// Stats for the assertions' parameters
123 ArgPackStats assn_params;
124 /// Stats for the assertions' return types
125 ArgPackStats assn_returns;
126
127 Stats() : n_decls(0), n_type_params(), n_generic_params(), n_generic_nesting(),
128 by_name(), basic_type_names(), generic_type_names(), compound_type_names(),
129 basic_type_decls(), generic_type_decls(), compound_type_decls(), params(),
130 returns(), n_assns(), assn_params(), assn_returns() {}
131
132 public:
133 Stats& operator+= (const Stats& o) {
134 sum( n_decls, o.n_decls );
135 sum( n_type_params, o.n_type_params );
136 sum( n_generic_params, o.n_generic_params );
137 sum( n_generic_nesting, o.n_generic_nesting );
138 sum( by_name, o.by_name );
139 sum( basic_type_names, o.basic_type_names );
140 sum( generic_type_names, o.generic_type_names );
141 sum( compound_type_names, o.compound_type_names );
142 sum( basic_type_decls, o.basic_type_decls );
143 sum( generic_type_decls, o.generic_type_decls );
144 sum( compound_type_decls, o.compound_type_decls );
145 sum( params, o.params );
146 sum( returns, o.returns );
147 sum( n_assns, o.n_assns );
148 sum( assn_params, o.assn_params );
149 sum( assn_returns, o.assn_returns );
150
151 return *this;
152 }
153 };
154
155 /// number of counting bins for linkages
156 static const unsigned n_named_specs = 8;
157 /// Mapping function from linkage to bin.
158 static unsigned linkage_index( LinkageSpec::Spec spec ) {
159 switch ( spec ) {
160 case LinkageSpec::Intrinsic: return 0;
161 case LinkageSpec::C: return 1;
162 case LinkageSpec::Cforall: return 2;
163 case LinkageSpec::AutoGen: return 3;
164 case LinkageSpec::Compiler: return 4;
165 case LinkageSpec::BuiltinCFA: return 5;
166 case LinkageSpec::BuiltinC: return 6;
167 default: return 7;
168 }
169 }
170
171 Stats for_linkage[n_named_specs]; ///< Stores separate stats per linkage
172 std::unordered_set<std::string> seen_names; ///< Stores manglenames already seen to avoid double-counting
173 Stats total;
174 /// Count of expressions with (depth, fanout)
175 std::map<std::pair<unsigned, unsigned>, unsigned> exprs_by_fanout_at_depth;
176
177 void countType( const std::string& name, unsigned& n, std::unordered_map<std::string,
178 unsigned>& names, std::unordered_map<std::string, unsigned>& decls,
179 std::unordered_set<std::string>& elSeen ) {
180 ++n;
181 ++names[ name ];
182 if ( elSeen.insert( name ).second ) { ++decls[ name ]; }
183 }
184
185 void update_max( unsigned& max, unsigned crnt ) {
186 if ( crnt > max ) max = crnt;
187 }
188
189 void analyzeSubtype( Type* ty, Stats& stats, std::unordered_set<std::string>& elSeen,
190 unsigned& n_poly, bool& seen_poly, unsigned& max_depth, unsigned depth ) {
191 unsigned x;
192 analyzeType( ty, stats, elSeen, x, x, n_poly, x, seen_poly, max_depth, depth + 1 );
193 }
194
195 void analyzeSubtypes( std::list<DeclarationWithType*>& tys, Stats& stats,
196 std::unordered_set<std::string>& elSeen, unsigned& n_poly, bool& seen_poly,
197 unsigned& max_depth, unsigned depth, unsigned& n_subs ) {
198 for ( DeclarationWithType* dwt : tys ) {
199 Type* ty = dwt->get_type();
200 n_subs += (unsigned)( dynamic_cast<VoidType*>(ty) != nullptr );
201 analyzeSubtype( ty, stats, elSeen, n_poly, seen_poly, max_depth, depth );
202 }
203 }
204
205 void analyzeSubtypes( std::list<Expression*>& tys, Stats& stats,
206 std::unordered_set<std::string>& elSeen, unsigned& n_poly, bool& seen_poly,
207 unsigned& max_depth, unsigned depth ) {
208 for ( Expression* expr : tys ) {
209 TypeExpr* texpr = dynamic_cast<TypeExpr*>(expr);
210 if ( ! texpr ) continue;
211 Type* ty = texpr->get_type();
212 analyzeSubtype( ty, stats, elSeen, n_poly, seen_poly, max_depth, depth );
213 }
214 }
215
216 void analyzeSubtypes( std::list<Type*>& tys, Stats& stats,
217 std::unordered_set<std::string>& elSeen, unsigned& n_poly, bool& seen_poly,
218 unsigned& max_depth, unsigned depth ) {
219 for ( Type* ty : tys ) {
220 analyzeSubtype( ty, stats, elSeen, n_poly, seen_poly, max_depth, depth );
221 }
222 }
223
224 void analyzeType( Type* ty, Stats& stats, std::unordered_set<std::string>& elSeen,
225 unsigned& n_basic, unsigned& n_generic, unsigned& n_poly, unsigned& n_agg,
226 bool& seen_poly, unsigned& max_depth, unsigned depth = 0 ) {
227 if ( BasicType* bt = dynamic_cast<BasicType*>(ty) ) {
228 std::string name = BasicType::typeNames[ bt->get_kind() ];
229 countType( name, n_basic, stats.basic_type_names, stats.basic_type_decls, elSeen );
230 update_max( max_depth, depth );
231 } else if ( PointerType* pt = dynamic_cast<PointerType*>(ty) ) {
232 std::string name = "*";
233 countType(
234 name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
235 analyzeSubtype(
236 pt->get_base(), stats, elSeen, n_poly, seen_poly, max_depth, depth );
237 ++stats.n_generic_params.at( 1 );
238 } else if ( ArrayType* at = dynamic_cast<ArrayType*>(ty) ) {
239 std::string name = "[]";
240 countType(
241 name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
242 analyzeSubtype(
243 at->get_base(), stats, elSeen, n_poly, seen_poly, max_depth, depth );
244 ++stats.n_generic_params.at( 1 );
245 } else if ( ReferenceType* rt = dynamic_cast<ReferenceType*>(ty) ) {
246 std::string name = "&";
247 countType(
248 name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
249 analyzeSubtype(
250 rt->get_base(), stats, elSeen, n_poly, seen_poly, max_depth, depth );
251 ++stats.n_generic_params.at( 1 );
252 } else if ( FunctionType* ft = dynamic_cast<FunctionType*>(ty) ) {
253 std::string name = "(*)";
254 countType(
255 name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
256 unsigned n_subs = 0;
257 analyzeSubtypes(
258 ft->get_returnVals(), stats, elSeen, n_poly, seen_poly, max_depth, depth,
259 n_subs );
260 analyzeSubtypes(
261 ft->get_parameters(), stats, elSeen, n_poly, seen_poly, max_depth, depth,
262 n_subs );
263 ++stats.n_generic_params.at( n_subs );
264 } else if ( TypeInstType* vt = dynamic_cast<TypeInstType*>(ty) ) {
265 if ( ! seen_poly ) {
266 ++n_poly;
267 seen_poly = true;
268 }
269 countType(
270 vt->get_name(), n_agg, stats.compound_type_names, stats.compound_type_decls,
271 elSeen );
272 update_max( max_depth, depth );
273 } else if ( ReferenceToType* st = dynamic_cast<ReferenceToType*>(ty) ) {
274 std::list<Expression*>& params = st->get_parameters();
275 if ( params.empty() ) {
276 countType(
277 st->get_name(), n_agg, stats.compound_type_names,
278 stats.compound_type_decls, elSeen );
279 update_max( max_depth, depth );
280 } else {
281 countType(
282 st->get_name(), n_generic, stats.generic_type_names,
283 stats.generic_type_decls, elSeen);
284 analyzeSubtypes( params, stats, elSeen, n_poly, seen_poly, max_depth, depth );
285 ++stats.n_generic_params.at( params.size() );
286 }
287 } else if ( TupleType* tt = dynamic_cast<TupleType*>(ty) ) {
288 std::string name = "[,]";
289 countType(
290 name, n_generic, stats.generic_type_names, stats.generic_type_decls, elSeen);
291 analyzeSubtypes(
292 tt->get_types(), stats, elSeen, n_poly, seen_poly, max_depth, depth );
293 ++stats.n_generic_params.at( tt->size() );
294 } else if ( dynamic_cast<VarArgsType*>(ty) ) {
295 std::string name = "...";
296 countType(
297 name, n_agg, stats.compound_type_names, stats.compound_type_decls, elSeen );
298 update_max( max_depth, depth );
299 } else if ( dynamic_cast<ZeroType*>(ty) ) {
300 std::string name = "0";
301 countType( name, n_basic, stats.basic_type_names, stats.basic_type_decls, elSeen );
302 update_max( max_depth, depth );
303 } else if ( dynamic_cast<OneType*>(ty) ) {
304 std::string name = "1";
305 countType( name, n_basic, stats.basic_type_names, stats.basic_type_decls, elSeen );
306 update_max( max_depth, depth );
307 }
308 }
309
310 /// Update arg pack stats based on a declaration list
311 void analyze( Stats& stats, std::unordered_set<std::string>& seen,
312 std::unordered_set<std::string>& elSeen, ArgPackStats& pstats,
313 std::list<DeclarationWithType*>& decls ) {
314 std::unordered_set<std::string> types;
315 unsigned n = 0; ///< number of args/returns
316 unsigned n_basic = 0; ///< number of basic types
317 unsigned n_generic = 0; ///< number of generic types (includes "*", "&", "[]", "(*)", "[,]")
318 unsigned n_poly = 0; ///< number of polymorphic types
319 unsigned n_agg = 0; ///< number of non-generic aggregate types
320 unsigned n_new = 0; ///< number of new types
321
322 for ( auto decl : decls ) {
323 Type* dt = decl->get_type();
324
325 n += dt->size();
326
327 std::stringstream ss;
328 dt->print( ss );
329 types.insert( ss.str() );
330 if ( seen.insert( ss.str() ).second ) { ++n_new; }
331
332 bool seen_poly = false;
333 unsigned max_depth = 0;
334 analyzeType(
335 dt, stats, elSeen, n_basic, n_generic, n_poly, n_agg, seen_poly, max_depth );
336 ++stats.n_generic_nesting.at( max_depth );
337 }
338
339 ++pstats.n.at( n );
340 ++pstats.n_basic.at( n_basic );
341 ++pstats.n_generic.at( n_generic );
342 ++pstats.n_poly.at( n_poly );
343 ++pstats.n_compound.at( n_agg );
344 if ( n > 0 ) {
345 ++pstats.p_basic[ n_basic*100/n ];
346 ++pstats.p_generic[ n_generic*100/n ];
347 ++pstats.p_poly[ n_poly*100/n ];
348 ++pstats.p_compound[ n_agg*100/n ];
349 if ( n > 1 ) ++pstats.p_new[ (n_new-1)*100/(n-1) ];
350 }
351 ++pstats.n_types.at( types.size() );
352 }
353
354 void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) {
355 std::unordered_set<std::string> seen;
356 std::unordered_set<std::string> elSeen;
357 analyze( stats, seen, elSeen, params, fnTy->get_parameters() );
358 analyze( stats, seen, elSeen, returns, fnTy->get_returnVals() );
359 }
360
361 void analyzeExpr( UntypedExpr *expr, unsigned depth ) {
362 auto& args = expr->get_args();
363 unsigned fanout = args.size();
364
365 ++exprs_by_fanout_at_depth[ std::make_pair(depth, fanout) ];
366 for ( Expression* arg : args ) {
367 if ( UntypedExpr *uearg = dynamic_cast<UntypedExpr*>(arg) ) {
368 analyzeExpr( uearg, depth+1 );
369 }
370 }
371 }
372
373 public:
374 void previsit( FunctionDecl *decl ) {
375 // skip if already seen declaration for this function
376 const std::string& mangleName = decl->get_mangleName().empty() ? decl->name : decl->get_mangleName();
377 if ( seen_names.insert( mangleName ).second ) {
378 Stats& stats = for_linkage[ linkage_index( decl->linkage ) ];
379
380 ++stats.n_decls;
381 FunctionType* fnTy = decl->type;
382 const Type::ForallList& forall = fnTy->forall;
383 ++stats.n_type_params.at( forall.size() );
384 unsigned n_assns = 0;
385 for ( TypeDecl* fdecl : forall ) {
386 n_assns += fdecl->assertions.size();
387 for ( DeclarationWithType* assn : fdecl->assertions ) {
388 FunctionType *assnTy = nullptr;
389 if ( ObjectDecl *assnObj = dynamic_cast<ObjectDecl*>(assn) ) {
390 if ( PointerType *ptrTy = dynamic_cast<PointerType*>(assnObj->get_type()) ) {
391 assnTy = dynamic_cast<FunctionType*>(ptrTy->base);
392 } else assnTy = dynamic_cast<FunctionType*>(assnObj->get_type());
393 } else if ( FunctionDecl *assnDecl = dynamic_cast<FunctionDecl*>(assn) ) {
394 assnTy = assnDecl->type;
395 }
396 if ( assnTy ) analyzeFunc( assnTy, stats, stats.assn_params, stats.assn_returns );
397 }
398 }
399 ++stats.n_assns[ n_assns ];
400 ++stats.by_name[ decl->name ];
401 analyzeFunc( fnTy, stats, stats.params, stats.returns );
402 }
403 }
404
405 void previsit( UntypedExpr *expr ) {
406 visit_children = false;
407 analyzeExpr( expr, 0 );
408 }
409
410 private:
411 template<typename F>
412 void printAll( const std::string& name, F extract ) {
413 std::cout << "\"" << name << "\",";
414 for ( const auto& stats : for_linkage ) {
415 std::cout << "," << extract(stats);
416 }
417 std::cout << "," << extract(total) << std::endl;
418 }
419
420 template<typename F>
421 void printAllMap( const std::string& name, F extract ) {
422 for ( const auto& entry : extract(total) ) {
423 const auto& key = entry.first;
424 std::cout << "\"" << name << "\"," << key;
425 for ( const auto& stats : for_linkage ) {
426 const auto& map = extract(stats);
427 auto it = map.find( key );
428 if ( it == map.end() ) std::cout << ",0";
429 else std::cout << "," << it->second;
430 }
431 std::cout << "," << entry.second << std::endl;
432 }
433 }
434
435 template<typename F>
436 void printAllHisto( const std::string& name, F extract ) {
437 VectorMap<unsigned> histos[n_named_specs];
438 VectorMap<unsigned> thisto;
439
440 for ( const auto& entry : extract(total) ) { ++thisto.at( entry.second ); }
441
442 for ( unsigned i = 0; i < n_named_specs; ++i ) {
443 // can't be a higher count in one of the sub-histograms than the total
444 histos[i].reserve( thisto.size() );
445
446 for ( const auto& entry : extract(for_linkage[i]) ) { ++histos[i][entry.second]; }
447 }
448
449 for ( unsigned i = 0; i < thisto.size(); ++i ) {
450 std::cout << "\"" << name << "\"," << i;
451 for ( const auto& histo : histos ) {
452 std::cout << "," << histo[i];
453 }
454 std::cout << "," << thisto[i] << std::endl;
455 }
456 }
457
458 template<typename F>
459 void printAllSparseHisto( const std::string& name, F extract ) {
460 std::map<unsigned, unsigned> histos[n_named_specs];
461 std::map<unsigned, unsigned> thisto;
462
463 for ( const auto& entry : extract(total) ) { ++thisto[ entry.second ]; }
464
465 for ( unsigned i = 0; i < n_named_specs; ++i ) {
466 for ( const auto& entry : extract(for_linkage[i]) ) { ++histos[i][entry.second]; }
467 }
468
469 for ( const auto& entry : thisto ) {
470 const auto& key = entry.first;
471 std::cout << "\"" << name << "\"," << key;
472 for ( unsigned i = 0; i < n_named_specs; ++i ) {
473 auto it = histos[i].find( key );
474 if ( it == histos[i].end() ) std::cout << ",0";
475 else std::cout << "," << it->second;
476 }
477 std::cout << "," << entry.second << std::endl;
478 }
479 }
480
481 template<typename F>
482 void printAllPack( const std::string& name, F extract ) {
483 printAllMap("n_basic_" + name, [&extract](const Stats& stats) { return extract(stats).n_basic; });
484 printAllMap("n_generic_" + name, [&extract](const Stats& stats) { return extract(stats).n_generic; });
485 printAllMap("n_poly_" + name, [&extract](const Stats& stats) { return extract(stats).n_poly; });
486 printAllMap("n_compound_" + name, [&extract](const Stats& stats) { return extract(stats).n_compound; });
487 printAllMap("n_" + name, [&extract](const Stats& stats) { return extract(stats).n; });
488 printAllMap("%_basic_" + name, [&extract](const Stats& stats) { return extract(stats).p_basic; });
489 printAllMap("%_generic_" + name, [&extract](const Stats& stats) { return extract(stats).p_generic; });
490 printAllMap("%_poly_" + name, [&extract](const Stats& stats) { return extract(stats).p_poly; });
491 printAllMap("%_compound_" + name, [&extract](const Stats& stats) { return extract(stats).p_compound; });
492 printAllMap("n_distinct_types_" + name, [&extract](const Stats& stats) { return extract(stats).n_types; });
493 printAllMap("%_new_types_in_" + name, [&extract](const Stats& stats) { return extract(stats).p_new; });
494 }
495
496 void printPairMap( const std::string& name,
497 const std::map<std::pair<unsigned, unsigned>, unsigned>& map ) {
498 for ( const auto& entry : map ) {
499 const auto& key = entry.first;
500 std::cout << "\"" << name << "\"," << key.first << "," << key.second << ","
501 << entry.second << std::endl;
502 }
503 }
504
505 public:
506 void print() {
507 for ( auto& stats : for_linkage ) {
508 total += stats;
509 }
510
511 std::cout << ",,\"intrinsic\",\"Cforall\",\"C\",\"autogen\",\"compiler\",\"builtinCFA\",\"builtinC\",\"other\",\"TOTAL\"" << std::endl;
512
513 printAllMap("n_type_params", [](const Stats& stats) { return stats.n_type_params; });
514 printAllMap("n_generic_params", [](const Stats& stats) { return stats.n_generic_params; });
515 printAllMap("n_generic_nesting", [](const Stats& stats) { return stats.n_generic_nesting; });
516 printAll("n_decls", [](const Stats& stats) { return stats.n_decls; });
517 printAll("unique_names", [](const Stats& stats) { return stats.by_name.size(); });
518 printAllSparseHisto("overloads", [](const Stats& stats) { return stats.by_name; });
519 printAll("basic_type_names", [](const Stats& stats) { return stats.basic_type_names.size(); });
520 printAllSparseHisto("basic_type_uses", [](const Stats& stats) { return stats.basic_type_names; });
521 printAllSparseHisto("decls_using_basic_type", [](const Stats& stats) { return stats.basic_type_decls; });
522 printAll("generic_type_names", [](const Stats& stats) { return stats.generic_type_names.size(); });
523 printAllSparseHisto("generic_type_uses", [](const Stats& stats) { return stats.generic_type_names; });
524 printAllSparseHisto("decls_using_generic_type", [](const Stats& stats) { return stats.generic_type_decls; });
525 printAll("compound_type_names", [](const Stats& stats) { return stats.compound_type_names.size(); });
526 printAllSparseHisto("compound_type_uses", [](const Stats& stats) { return stats.compound_type_names; });
527 printAllSparseHisto("decls_using_compound_type", [](const Stats& stats) { return stats.compound_type_decls; });
528 printAllPack("params", [](const Stats& stats) { return stats.params; });
529 printAllPack("returns", [](const Stats& stats) { return stats.returns; });
530 printAllMap("n_assns", [](const Stats& stats) { return stats.n_assns; });
531 printAllPack("assn_params", [](const Stats& stats) { return stats.assn_params; });
532 printAllPack("assn_returns", [](const Stats& stats) { return stats.assn_returns; });
533 std::cout << std::endl;
534
535 printPairMap("exprs_by_depth+fanout", exprs_by_fanout_at_depth);
536 }
537 };
538
539 void printDeclStats( std::list< Declaration * > &translationUnit ) {
540 PassVisitor<DeclStats> stats;
541 acceptAll( translationUnit, stats );
542 stats.pass.print();
543 }
544
545} // namespace CodeTools
546
547// Local Variables: //
548// tab-width: 4 //
549// mode: c++ //
550// compile-command: "make install" //
551// End: //
Note: See TracBrowser for help on using the repository browser.