Changes in src/SymTab/Validate.cc [09867ec:98538288]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r09867ec r98538288 64 64 #include "Common/UniqueName.h" // for UniqueName 65 65 #include "Common/utility.h" // for operator+, cloneAll, deleteAll 66 #include "CompilationState.h" // skip some passes in new-ast build67 66 #include "Concurrency/Keywords.h" // for applyKeywords 68 67 #include "FixFunction.h" // for FixFunction … … 271 270 }; 272 271 273 struct InitializerLength{272 struct ArrayLength : public WithIndexer { 274 273 /// for array types without an explicit length, compute the length and store it so that it 275 274 /// is known to the rest of the phases. For example, … … 282 281 283 282 void previsit( ObjectDecl * objDecl ); 284 };285 286 struct ArrayLength : public WithIndexer {287 static void computeLength( std::list< Declaration * > & translationUnit );288 289 283 void previsit( ArrayType * arrayType ); 290 284 }; … … 374 368 mutateAll( translationUnit, compoundliteral ); 375 369 }); 376 if (!useNewAST) { 377 Stats::Time::TimeBlock("Resolve With Expressions", [&]() { 378 ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables 379 }); 380 } 370 Stats::Time::TimeBlock("Resolve With Expressions", [&]() { 371 ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables 372 }); 381 373 } 382 374 { 383 375 Stats::Heap::newPass("validate-F"); 384 376 Stats::Time::BlockGuard guard("validate-F"); 385 if (!useNewAST) { 386 Stats::Time::TimeCall("Fix Object Type", 387 FixObjectType::fix, translationUnit); 388 } 389 Stats::Time::TimeCall("Initializer Length", 390 InitializerLength::computeLength, translationUnit); 391 if (!useNewAST) { 392 Stats::Time::TimeCall("Array Length", 393 ArrayLength::computeLength, translationUnit); 394 } 377 Stats::Time::TimeCall("Fix Object Type", 378 FixObjectType::fix, translationUnit); 379 Stats::Time::TimeCall("Array Length", 380 ArrayLength::computeLength, translationUnit); 395 381 Stats::Time::TimeCall("Find Special Declarations", 396 382 Validate::findSpecialDecls, translationUnit); 397 383 Stats::Time::TimeCall("Fix Label Address", 398 384 mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer); 399 if (!useNewAST) { 400 Stats::Time::TimeCall("Handle Attributes", 401 Validate::handleAttributes, translationUnit); 402 } 385 Stats::Time::TimeCall("Handle Attributes", 386 Validate::handleAttributes, translationUnit); 403 387 } 404 388 } … … 976 960 } 977 961 978 static bool isNonParameterAttribute( Attribute * attr ) {979 static const std::vector<std::string> bad_names = {980 "aligned", "__aligned__",981 };982 for ( auto name : bad_names ) {983 if ( name == attr->name ) {984 return true;985 }986 }987 return false;988 }989 990 962 Type * ReplaceTypedef::postmutate( TypeInstType * typeInst ) { 991 963 // instances of typedef types will come here. If it is an instance … … 996 968 ret->location = typeInst->location; 997 969 ret->get_qualifiers() |= typeInst->get_qualifiers(); 998 // GCC ignores certain attributes if they arrive by typedef, this mimics that. 999 if ( inFunctionType ) { 1000 ret->attributes.remove_if( isNonParameterAttribute ); 1001 } 1002 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 970 // attributes are not carried over from typedef to function parameters/return values 971 if ( ! inFunctionType ) { 972 ret->attributes.splice( ret->attributes.end(), typeInst->attributes ); 973 } else { 974 deleteAll( ret->attributes ); 975 ret->attributes.clear(); 976 } 1003 977 // place instance parameters on the typedef'd type 1004 978 if ( ! typeInst->parameters.empty() ) { … … 1341 1315 } 1342 1316 1343 void InitializerLength::computeLength( std::list< Declaration * > & translationUnit ) {1344 PassVisitor<InitializerLength> len;1345 acceptAll( translationUnit, len );1346 }1347 1348 1317 void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) { 1349 1318 PassVisitor<ArrayLength> len; … … 1351 1320 } 1352 1321 1353 void InitializerLength::previsit( ObjectDecl * objDecl ) {1322 void ArrayLength::previsit( ObjectDecl * objDecl ) { 1354 1323 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1355 1324 if ( at->dimension ) return; … … 1405 1374 /// Replaces enum types by int, and function/array types in function parameter and return 1406 1375 /// lists by appropriate pointers 1407 /*1408 1376 struct EnumAndPointerDecay_new { 1409 1377 const ast::EnumDecl * previsit( const ast::EnumDecl * enumDecl ) { … … 1456 1424 } 1457 1425 }; 1458 */1459 1426 1460 1427 /// expand assertions from a trait instance, performing appropriate type variable substitutions … … 1475 1442 } 1476 1443 1477 /*1478 1479 1444 /// Associates forward declarations of aggregates with their definitions 1480 1445 class LinkReferenceToTypes_new final … … 1543 1508 } 1544 1509 1545 void checkGenericParameters( const ast:: BaseInstType * inst ) {1510 void checkGenericParameters( const ast::ReferenceToType * inst ) { 1546 1511 for ( const ast::Expr * param : inst->params ) { 1547 1512 if ( ! dynamic_cast< const ast::TypeExpr * >( param ) ) { … … 1807 1772 static const node_t * forallFixer( 1808 1773 const CodeLocation & loc, const node_t * node, 1809 ast:: FunctionType::ForallList parent_t::* forallField1774 ast::ParameterizedType::ForallList parent_t::* forallField 1810 1775 ) { 1811 1776 for ( unsigned i = 0; i < (node->* forallField).size(); ++i ) { … … 1858 1823 } 1859 1824 }; 1860 */1861 1825 } // anonymous namespace 1862 1826 1863 /*1864 1827 const ast::Type * validateType( 1865 1828 const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab ) { 1866 //ast::Pass< EnumAndPointerDecay_new > epc;1829 ast::Pass< EnumAndPointerDecay_new > epc; 1867 1830 ast::Pass< LinkReferenceToTypes_new > lrt{ loc, symtab }; 1868 1831 ast::Pass< ForallPointerDecay_new > fpd{ loc }; 1869 1832 1870 return type->accept( lrt )->accept( fpd );1833 return type->accept( epc )->accept( lrt )->accept( fpd ); 1871 1834 } 1872 */1873 1835 1874 1836 } // namespace SymTab
Note:
See TracChangeset
for help on using the changeset viewer.