Changeset 97dbc09 for src/SynTree


Ignore:
Timestamp:
Sep 27, 2017, 4:25:28 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
1189946
Parents:
c3b3799
git-author:
Rob Schluntz <rschlunt@…> (09/27/17 16:05:26)
git-committer:
Rob Schluntz <rschlunt@…> (09/27/17 16:25:28)
Message:

Replace parameter and return value references inside of function body during clone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/FunctionDecl.cc

    rc3b3799 r97dbc09  
    2626#include "Statement.h"           // for CompoundStmt
    2727#include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
     28#include "VarExprReplacer.h"
    2829
    2930extern bool translation_unit_nomain;
     
    3940FunctionDecl::FunctionDecl( const FunctionDecl &other )
    4041                : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
     42
     43        VarExprReplacer::DeclMap declMap;
     44        for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
     45                declMap[ std::get<0>(p) ] = std::get<1>(p);
     46        }
     47        for ( auto p : group_iterate( other.type->returnVals, type->returnVals ) ) {
     48                declMap[ std::get<0>(p) ] = std::get<1>(p);
     49        }
     50        if ( ! declMap.empty() ) {
     51                VarExprReplacer replacer( declMap );
     52                accept( replacer );
     53        }
    4154}
    4255
Note: See TracChangeset for help on using the changeset viewer.