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