Changeset bf2438c for src/CodeTools
- Timestamp:
- Jul 11, 2017, 3:06:40 PM (7 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:
- fcab269
- Parents:
- fab6ded
- Location:
- src/CodeTools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeTools/DeclStats.cc
rfab6ded rbf2438c 16 16 #include "DeclStats.h" 17 17 18 #include <iostream> 19 #include <map> 20 #include <sstream> 21 #include <string> 22 #include <unordered_map> 23 #include <unordered_set> 24 25 #include "Common/VectorMap.h" 26 #include "GenPoly/GenPoly.h" 27 #include "Parser/LinkageSpec.h" 28 #include "SynTree/Declaration.h" 29 #include "SynTree/Visitor.h" 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/SemanticError.h" // for SemanticError 26 #include "Common/VectorMap.h" // for VectorMap 27 #include "GenPoly/GenPoly.h" // for hasPolyBase 28 #include "Parser/LinkageSpec.h" // for ::NoOfSpecs, Spec 29 #include "SynTree/Declaration.h" // for FunctionDecl, TypeDecl, Declaration 30 #include "SynTree/Expression.h" // for UntypedExpr, Expression 31 #include "SynTree/Statement.h" // for CompoundStmt 32 #include "SynTree/Type.h" // for Type, FunctionType, PointerType 33 #include "SynTree/Visitor.h" // for maybeAccept, Visitor, acceptAll 30 34 31 35 namespace CodeTools { 32 36 33 37 class DeclStats : public Visitor { 34 38 template<typename T> … … 75 79 sum(n_types, o.n_types); 76 80 sum(p_new, o.p_new); 77 81 78 82 return *this; 79 83 } 80 84 }; 81 85 82 86 struct Stats { 83 87 unsigned n_decls; ///< Total number of declarations … … 98 102 /// Stats for the return list 99 103 ArgPackStats returns; 100 104 101 105 /// Count of declarations with each number of assertions 102 106 std::map<unsigned, unsigned> n_assns; … … 105 109 /// Stats for the assertions' return types 106 110 ArgPackStats assn_returns; 107 111 108 112 Stats() : n_decls(0), n_type_params(), by_name(), basic_type_names(), compound_type_names(), basic_type_decls(), compound_type_decls(), params(), returns(), n_assns(), assn_params(), assn_returns() {} 109 113 … … 122 126 sum( assn_params, o.assn_params ); 123 127 sum( assn_returns, o.assn_returns ); 124 128 125 129 return *this; 126 130 } … … 144 148 145 149 n += dt->size(); 146 150 147 151 std::stringstream ss; 148 152 dt->print( ss ); … … 176 180 ++pstats.n_types.at( types.size() ); 177 181 } 178 182 179 183 void analyzeFunc( FunctionType* fnTy, Stats& stats, ArgPackStats& params, ArgPackStats& returns ) { 180 184 std::unordered_set<std::string> seen; … … 186 190 auto& args = expr->get_args(); 187 191 unsigned fanout = args.size(); 188 192 189 193 ++exprs_by_fanout_at_depth[ std::make_pair(depth, fanout) ]; 190 194 for ( Expression* arg : args ) { … … 205 209 return; 206 210 } 207 211 208 212 Stats& stats = for_linkage[ decl->get_linkage() ]; 209 213 … … 323 327 } 324 328 325 void printPairMap( const std::string& name, 329 void printPairMap( const std::string& name, 326 330 const std::map<std::pair<unsigned, unsigned>, unsigned>& map ) { 327 331 for ( const auto& entry : map ) { 328 332 const auto& key = entry.first; 329 std::cout << "\"" << name << "\"," << key.first << "," << key.second << "," 333 std::cout << "\"" << name << "\"," << key.first << "," << key.second << "," 330 334 << entry.second << std::endl; 331 335 } 332 336 } 333 337 334 338 public: 335 339 void print() { … … 366 370 stats.print(); 367 371 } 368 372 369 373 } // namespace CodeTools 370 374 -
src/CodeTools/DeclStats.h
rfab6ded rbf2438c 17 17 #define DECLSTATS_H 18 18 19 #include "SynTree/SynTree.h" 19 #include <list> // for list 20 21 class Declaration; 20 22 21 23 namespace CodeTools { -
src/CodeTools/TrackLoc.cc
rfab6ded rbf2438c 16 16 #include "TrackLoc.h" 17 17 18 #include <cstdlib> 18 #include <cstdlib> // for size_t, exit, EXIT_FAILURE 19 #include <iostream> // for operator<<, ostream, basic_ostream 20 #include <iterator> // for back_inserter, inserter 21 #include <stack> // for stack 22 #include <string> // for operator<<, string 23 #include <typeindex> // for type_index 19 24 20 #include <iostream> 21 #include <sstream> 22 #include <stack> 23 #include <string> 24 #include <typeindex> 25 #include "Common/PassVisitor.h" // for PassVisitor 26 #include "Common/PassVisitor.impl.h" // for acceptAll 27 #include "Common/SemanticError.h" // for SemanticError 28 #include "Common/utility.h" // for CodeLocation 29 #include "SynTree/BaseSyntaxNode.h" // for BaseSyntaxNode 30 #include "SynTree/Mutator.h" // for mutateAll 31 #include "SynTree/Visitor.h" // for acceptAll 25 32 26 #include "Common/utility.h" 27 #include "Common/PassVisitor.h" 28 #include "Common/VectorMap.h" 29 #include "GenPoly/GenPoly.h" 30 #include "Parser/LinkageSpec.h" 31 #include "SynTree/Declaration.h" 32 #include "SynTree/Initializer.h" 33 class Declaration; 33 34 34 35 namespace CodeTools { -
src/CodeTools/TrackLoc.h
rfab6ded rbf2438c 17 17 #define TRACKLOC_H 18 18 19 #include "SynTree/SynTree.h" 19 #include <cstddef> // for size_t 20 #include <list> // for list 21 22 class Declaration; 20 23 21 24 namespace CodeTools {
Note: See TracChangeset
for help on using the changeset viewer.