Changeset 58fe85a for src/SymTab/Validate.cc
- Timestamp:
- Jan 7, 2021, 3:27:00 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2b4daf2, 64aeca0
- Parents:
- 3c64c668 (diff), eef8dfb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r3c64c668 r58fe85a 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 build 66 67 #include "Concurrency/Keywords.h" // for applyKeywords 67 68 #include "FixFunction.h" // for FixFunction … … 270 271 }; 271 272 272 struct ArrayLength : public WithIndexer{273 struct InitializerLength { 273 274 /// for array types without an explicit length, compute the length and store it so that it 274 275 /// is known to the rest of the phases. For example, … … 281 282 282 283 void previsit( ObjectDecl * objDecl ); 284 }; 285 286 struct ArrayLength : public WithIndexer { 287 static void computeLength( std::list< Declaration * > & translationUnit ); 288 283 289 void previsit( ArrayType * arrayType ); 284 290 }; … … 368 374 mutateAll( translationUnit, compoundliteral ); 369 375 }); 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 }); 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 } 373 381 } 374 382 { 375 383 Stats::Heap::newPass("validate-F"); 376 384 Stats::Time::BlockGuard guard("validate-F"); 377 Stats::Time::TimeCall("Fix Object Type", 378 FixObjectType::fix, translationUnit); 379 Stats::Time::TimeCall("Array Length", 380 ArrayLength::computeLength, translationUnit); 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 } 381 395 Stats::Time::TimeCall("Find Special Declarations", 382 396 Validate::findSpecialDecls, translationUnit); 383 397 Stats::Time::TimeCall("Fix Label Address", 384 398 mutateAll<LabelAddressFixer>, translationUnit, labelAddrFixer); 385 Stats::Time::TimeCall("Handle Attributes", 386 Validate::handleAttributes, translationUnit); 399 if (!useNewAST) { 400 Stats::Time::TimeCall("Handle Attributes", 401 Validate::handleAttributes, translationUnit); 402 } 387 403 } 388 404 } … … 960 976 } 961 977 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 962 990 Type * ReplaceTypedef::postmutate( TypeInstType * typeInst ) { 963 991 // instances of typedef types will come here. If it is an instance … … 968 996 ret->location = typeInst->location; 969 997 ret->get_qualifiers() |= typeInst->get_qualifiers(); 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 } 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 ); 977 1003 // place instance parameters on the typedef'd type 978 1004 if ( ! typeInst->parameters.empty() ) { … … 1315 1341 } 1316 1342 1343 void InitializerLength::computeLength( std::list< Declaration * > & translationUnit ) { 1344 PassVisitor<InitializerLength> len; 1345 acceptAll( translationUnit, len ); 1346 } 1347 1317 1348 void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) { 1318 1349 PassVisitor<ArrayLength> len; … … 1320 1351 } 1321 1352 1322 void ArrayLength::previsit( ObjectDecl * objDecl ) {1353 void InitializerLength::previsit( ObjectDecl * objDecl ) { 1323 1354 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->type ) ) { 1324 1355 if ( at->dimension ) return; … … 1374 1405 /// Replaces enum types by int, and function/array types in function parameter and return 1375 1406 /// lists by appropriate pointers 1407 /* 1376 1408 struct EnumAndPointerDecay_new { 1377 1409 const ast::EnumDecl * previsit( const ast::EnumDecl * enumDecl ) { … … 1424 1456 } 1425 1457 }; 1458 */ 1426 1459 1427 1460 /// expand assertions from a trait instance, performing appropriate type variable substitutions … … 1442 1475 } 1443 1476 1477 /* 1478 1444 1479 /// Associates forward declarations of aggregates with their definitions 1445 1480 class LinkReferenceToTypes_new final … … 1508 1543 } 1509 1544 1510 void checkGenericParameters( const ast:: ReferenceToType * inst ) {1545 void checkGenericParameters( const ast::BaseInstType * inst ) { 1511 1546 for ( const ast::Expr * param : inst->params ) { 1512 1547 if ( ! dynamic_cast< const ast::TypeExpr * >( param ) ) { … … 1772 1807 static const node_t * forallFixer( 1773 1808 const CodeLocation & loc, const node_t * node, 1774 ast:: ParameterizedType::ForallList parent_t::* forallField1809 ast::FunctionType::ForallList parent_t::* forallField 1775 1810 ) { 1776 1811 for ( unsigned i = 0; i < (node->* forallField).size(); ++i ) { … … 1823 1858 } 1824 1859 }; 1860 */ 1825 1861 } // anonymous namespace 1826 1862 1863 /* 1827 1864 const ast::Type * validateType( 1828 1865 const CodeLocation & loc, const ast::Type * type, const ast::SymbolTable & symtab ) { 1829 ast::Pass< EnumAndPointerDecay_new > epc;1866 // ast::Pass< EnumAndPointerDecay_new > epc; 1830 1867 ast::Pass< LinkReferenceToTypes_new > lrt{ loc, symtab }; 1831 1868 ast::Pass< ForallPointerDecay_new > fpd{ loc }; 1832 1869 1833 return type->accept( epc )->accept(lrt )->accept( fpd );1870 return type->accept( lrt )->accept( fpd ); 1834 1871 } 1872 */ 1835 1873 1836 1874 } // namespace SymTab
Note:
See TracChangeset
for help on using the changeset viewer.