Changes in src/Validate/Autogen.cpp [8913de4:20737104]
- File:
-
- 1 edited
-
src/Validate/Autogen.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/Autogen.cpp
r8913de4 r20737104 25 25 26 26 #include "AST/Attribute.hpp" 27 #include "AST/Copy.hpp"28 27 #include "AST/Create.hpp" 29 28 #include "AST/Decl.hpp" … … 40 39 #include "InitTweak/GenInit.h" // for fixReturnStatements 41 40 #include "InitTweak/InitTweak.h" // for isAssignment, isCopyConstructor 42 #include "SymTab/GenImplicitCall.hpp" // for genImplicitCall43 41 #include "SymTab/Mangler.h" // for Mangler 44 42 #include "CompilationState.h" 43 44 // TODO: The other new ast function should be moved over to this file. 45 #include "SymTab/Autogen.h" 45 46 46 47 namespace Validate { … … 93 94 94 95 const CodeLocation& getLocation() const { return getDecl()->location; } 95 ast::FunctionDecl * genProto( std::string&& name,96 ast::FunctionDecl * genProto( const std::string& name, 96 97 std::vector<ast::ptr<ast::DeclWithType>>&& params, 97 98 std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const; … … 334 335 } 335 336 336 void replaceAll( std::vector<ast::ptr<ast::DeclWithType>> & dwts,337 const ast::DeclReplacer::TypeMap & map ) {338 for ( auto & dwt : dwts ) {339 dwt = strict_dynamic_cast<const ast::DeclWithType *>(340 ast::DeclReplacer::replace( dwt, map ) );341 }342 }343 344 337 /// Generates a basic prototype function declaration. 345 ast::FunctionDecl * FuncGenerator::genProto( std::string&& name,338 ast::FunctionDecl * FuncGenerator::genProto( const std::string& name, 346 339 std::vector<ast::ptr<ast::DeclWithType>>&& params, 347 340 std::vector<ast::ptr<ast::DeclWithType>>&& returns ) const { … … 349 342 // Handle generic prameters and assertions, if any. 350 343 auto const & old_type_params = getGenericParams( type ); 351 ast::DeclReplacer::TypeMap oldToNew;352 344 std::vector<ast::ptr<ast::TypeDecl>> type_params; 353 345 std::vector<ast::ptr<ast::DeclWithType>> assertions; 354 346 for ( auto & old_param : old_type_params ) { 355 347 ast::TypeDecl * decl = ast::deepCopy( old_param ); 356 decl->init = nullptr; 357 splice( assertions, decl->assertions ); 358 oldToNew.emplace( std::make_pair( old_param, decl ) ); 348 for ( auto assertion : decl->assertions ) { 349 assertions.push_back( assertion ); 350 } 351 decl->assertions.clear(); 359 352 type_params.push_back( decl ); 360 353 } 361 replaceAll( params, oldToNew );362 replaceAll( returns, oldToNew );363 replaceAll( assertions, oldToNew );354 // TODO: The values in params and returns still may point at the old 355 // generic params, that does not appear to be an issue but perhaps it 356 // should be addressed. 364 357 365 358 ast::FunctionDecl * decl = new ast::FunctionDecl( 366 359 // Auto-generated routines use the type declaration's location. 367 360 getLocation(), 368 std::move( name ),361 name, 369 362 std::move( type_params ), 370 363 std::move( assertions ), … … 430 423 for ( unsigned int index = 0 ; index < fields ; ++index ) { 431 424 auto member = aggr->members[index].strict_as<ast::DeclWithType>(); 432 if ( ast::isUnnamedBitfield(425 if ( SymTab::isUnnamedBitfield( 433 426 dynamic_cast<const ast::ObjectDecl *>( member ) ) ) { 434 427 if ( index == fields - 1 ) { … … 606 599 // Not sure why it could be null. 607 600 // Don't make a function for a parameter that is an unnamed bitfield. 608 if ( nullptr == field || ast::isUnnamedBitfield( field ) ) {601 if ( nullptr == field || SymTab::isUnnamedBitfield( field ) ) { 609 602 continue; 610 603 // Matching Parameter: Initialize the field by copy.
Note:
See TracChangeset
for help on using the changeset viewer.