Changes in src/SymTab/Validate.cc [7e08acf:2bfc6b2]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r7e08acf r2bfc6b2 75 75 #include "SynTree/Visitor.h" // for Visitor 76 76 #include "Validate/HandleAttributes.h" // for handleAttributes 77 #include "Validate/FindSpecialDecls.h" // for FindSpecialDecls 77 78 78 79 class CompoundStmt; … … 287 288 }; 288 289 289 FunctionDecl * dereferenceOperator = nullptr;290 struct FindSpecialDeclarations final {291 void previsit( FunctionDecl * funcDecl );292 };293 294 290 void validate( std::list< Declaration * > &translationUnit, __attribute__((unused)) bool doDebug ) { 295 291 PassVisitor<EnumAndPointerDecay> epc; … … 298 294 PassVisitor<CompoundLiteral> compoundliteral; 299 295 PassVisitor<ValidateGenericParameters> genericParams; 300 PassVisitor<FindSpecialDeclarations> finder;301 296 PassVisitor<LabelAddressFixer> labelAddrFixer; 302 297 PassVisitor<HoistTypeDecls> hoistDecls; … … 325 320 FixObjectType::fix( translationUnit ); 326 321 ArrayLength::computeLength( translationUnit ); 327 acceptAll( translationUnit, finder ); // xxx - remove this pass soon322 Validate::findSpecialDecls( translationUnit ); 328 323 mutateAll( translationUnit, labelAddrFixer ); 329 324 Validate::handleAttributes( translationUnit ); … … 403 398 assert( aggr ); // TODO: need to handle forward declarations 404 399 for ( Declaration * member : aggr->members ) { 405 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 400 if ( StructInstType * inst = dynamic_cast< StructInstType * >( child ) ) { 401 if ( StructDecl * aggr = dynamic_cast< StructDecl * >( member ) ) { 402 if ( aggr->name == inst->name ) { 403 // TODO: is this case, and other non-TypeInstType cases, necessary? 404 return new StructInstType( qualType->get_qualifiers(), aggr ); 405 } 406 } 407 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( child ) ) { 408 if ( UnionDecl * aggr = dynamic_cast< UnionDecl * > ( member ) ) { 409 if ( aggr->name == inst->name ) { 410 return new UnionInstType( qualType->get_qualifiers(), aggr ); 411 } 412 } 413 } else if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( child ) ) { 414 if ( EnumDecl * aggr = dynamic_cast< EnumDecl * > ( member ) ) { 415 if ( aggr->name == inst->name ) { 416 return new EnumInstType( qualType->get_qualifiers(), aggr ); 417 } 418 } 419 } else if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 406 420 // name on the right is a typedef 407 421 if ( NamedTypeDecl * aggr = dynamic_cast< NamedTypeDecl * > ( member ) ) { … … 410 424 Type * ret = aggr->base->clone(); 411 425 ret->get_qualifiers() = qualType->get_qualifiers(); 412 TypeSubstitution sub = parent->genericSubstitution();413 sub.apply(ret);414 426 return ret; 415 427 } … … 884 896 if ( eliminator.pass.typedefNames.count( "size_t" ) ) { 885 897 // grab and remember declaration of size_t 886 SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();898 Validate::SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone(); 887 899 } else { 888 900 // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong 889 901 // eventually should have a warning for this case. 890 SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );902 Validate::SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ); 891 903 } 892 904 } … … 1276 1288 // need to resolve array dimensions early so that constructor code can correctly determine 1277 1289 // if a type is a VLA (and hence whether its elements need to be constructed) 1278 ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );1290 ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer ); 1279 1291 1280 1292 // must re-evaluate whether a type is a VLA, now that more information is available … … 1313 1325 return addrExpr; 1314 1326 } 1315 1316 void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {1317 if ( ! dereferenceOperator ) {1318 if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) {1319 FunctionType * ftype = funcDecl->get_functionType();1320 if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {1321 dereferenceOperator = funcDecl;1322 }1323 }1324 }1325 }1326 1327 } // namespace SymTab 1327 1328
Note:
See TracChangeset
for help on using the changeset viewer.