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