Changes in src/InitTweak/InitTweak.cc [1ba88a0:dcd73d1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/InitTweak.cc
r1ba88a0 rdcd73d1 23 23 }; 24 24 25 class InitDepthChecker : public Visitor { 26 public: 27 bool depthOkay = true; 28 Type * type; 29 int curDepth = 0, maxDepth = 0; 30 InitDepthChecker( Type * type ) : type( type ) { 31 Type * t = type; 32 while ( ArrayType * at = dynamic_cast< ArrayType * >( t ) ) { 33 maxDepth++; 34 t = at->get_base(); 35 } 36 maxDepth++; 37 } 38 virtual void visit( ListInit * listInit ) { 39 curDepth++; 40 if ( curDepth > maxDepth ) depthOkay = false; 41 Visitor::visit( listInit ); 42 curDepth--; 43 } 44 }; 45 25 46 class InitFlattener : public Visitor { 26 47 public: … … 53 74 maybeAccept( init, finder ); 54 75 return finder.hasDesignations; 76 } 77 78 bool checkInitDepth( ObjectDecl * objDecl ) { 79 InitDepthChecker checker( objDecl->get_type() ); 80 maybeAccept( objDecl->get_init(), checker ); 81 return checker.depthOkay; 55 82 } 56 83
Note:
See TracChangeset
for help on using the changeset viewer.