- Timestamp:
- Jun 28, 2018, 3:27:34 PM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- a12c81f3
- Parents:
- afcb0a3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rafcb0a3 r69918cea 214 214 }; 215 215 216 struct EliminateTypedef { 217 /// removes TypedefDecls from the AST 218 static void eliminateTypedef( std::list< Declaration * > &translationUnit ); 219 220 template<typename AggDecl> 221 void handleAggregate( AggDecl *aggregateDecl ); 222 223 void previsit( StructDecl * aggregateDecl ); 224 void previsit( UnionDecl * aggregateDecl ); 225 void previsit( CompoundStmt * compoundStmt ); 226 }; 227 216 228 struct VerifyCtorDtorAssign { 217 229 /// ensure that constructors, destructors, and assignment have at least one … … 277 289 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions 278 290 HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order 291 EliminateTypedef::eliminateTypedef( translationUnit ); // 279 292 acceptAll( translationUnit, genericParams ); // check as early as possible - can't happen before LinkReferenceToTypes 280 293 VerifyCtorDtorAssign::verify( translationUnit ); // must happen before autogen, because autogen examines existing ctor/dtors … … 399 412 } 400 413 414 415 bool isTypedef( Declaration *decl ) { 416 return dynamic_cast< TypedefDecl * >( decl ); 417 } 418 419 void EliminateTypedef::eliminateTypedef( std::list< Declaration * > &translationUnit ) { 420 PassVisitor<EliminateTypedef> eliminator; 421 acceptAll( translationUnit, eliminator ); 422 filter( translationUnit, isTypedef, true ); 423 } 424 425 template< typename AggDecl > 426 void EliminateTypedef::handleAggregate( AggDecl *aggregateDecl ) { 427 filter( aggregateDecl->members, isTypedef, true ); 428 } 429 430 void EliminateTypedef::previsit( StructDecl * aggregateDecl ) { 431 handleAggregate( aggregateDecl ); 432 } 433 434 void EliminateTypedef::previsit( UnionDecl * aggregateDecl ) { 435 handleAggregate( aggregateDecl ); 436 } 437 438 void EliminateTypedef::previsit( CompoundStmt * compoundStmt ) { 439 // remove and delete decl stmts 440 filter( compoundStmt->kids, [](Statement * stmt) { 441 if ( DeclStmt *declStmt = dynamic_cast< DeclStmt * >( stmt ) ) { 442 if ( dynamic_cast< TypedefDecl * >( declStmt->decl ) ) { 443 return true; 444 } // if 445 } // if 446 return false; 447 }, true); 448 } 401 449 402 450 void EnumAndPointerDecay::previsit( EnumDecl *enumDecl ) {
Note: See TracChangeset
for help on using the changeset viewer.