Changes in src/SymTab/Validate.cc [4ef7506:d3b7937]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r4ef7506 rd3b7937 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Fri Dec 18 15:34:05 201513 // Update Count : 2 1811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jan 27 22:03:12 2016 13 // Update Count : 225 14 14 // 15 15 … … 49 49 #include "FixFunction.h" 50 50 // #include "ImplementationType.h" 51 #include " utility.h"52 #include " UniqueName.h"51 #include "Common/utility.h" 52 #include "Common/UniqueName.h" 53 53 #include "AddVisit.h" 54 54 #include "MakeLibCfa.h" … … 585 585 } 586 586 587 template< typename OutputIterator >588 void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, UnionInstType *unionType, OutputIterator out ) {589 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) );590 copy->get_args().push_back( new VariableExpr( dstParam ) );591 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) );592 copy->get_args().push_back( new SizeofExpr( unionType ) );593 594 *out++ = new ExprStmt( noLabels, copy );595 }596 597 587 //E ?=?(E volatile*, int), 598 588 // ?=?(E _Atomic volatile*, int); … … 663 653 664 654 // Make function polymorphic in same parameters as generic struct, if applicable 665 bool isGeneric = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union)666 655 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 667 656 std::list< Expression* > structParams; // List of matching parameters to put on types 668 657 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 669 isGeneric = true;670 658 TypeDecl *typeParam = (*param)->clone(); 671 659 assignType->get_forall().push_back( typeParam ); … … 673 661 } 674 662 675 ObjectDecl *returnVal = new ObjectDecl( " _ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );663 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 ); 676 664 assignType->get_returnVals().push_back( returnVal ); 677 665 … … 703 691 if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) { 704 692 makeArrayAssignment( srcParam, dstParam, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) ); 705 if ( isGeneric ) makeArrayAssignment( srcParam, returnVal, dwt, array, back_inserter( assignDecl->get_statements()->get_kids() ) );706 693 } else { 707 694 makeScalarAssignment( srcParam, dstParam, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) ); 708 if ( isGeneric ) makeScalarAssignment( srcParam, returnVal, dwt, back_inserter( assignDecl->get_statements()->get_kids() ) );709 695 } // if 710 696 } // if 711 697 } // for 712 if ( ! isGeneric )assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );698 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 713 699 714 700 return assignDecl; … … 719 705 720 706 // Make function polymorphic in same parameters as generic union, if applicable 721 bool isGeneric = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)722 707 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 723 708 std::list< Expression* > unionParams; // List of matching parameters to put on types 724 709 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 725 isGeneric = true;726 710 TypeDecl *typeParam = (*param)->clone(); 727 711 assignType->get_forall().push_back( typeParam ); … … 729 713 } 730 714 731 ObjectDecl *returnVal = new ObjectDecl( " _ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );715 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 ); 732 716 assignType->get_returnVals().push_back( returnVal ); 733 717 … … 743 727 assignDecl->fixUniqueId(); 744 728 745 makeUnionFieldsAssignment( srcParam, dstParam, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) ); 746 if ( isGeneric ) makeUnionFieldsAssignment( srcParam, returnVal, cloneWithParams( refType, unionParams ), back_inserter( assignDecl->get_statements()->get_kids() ) ); 747 748 if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 729 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) ); 730 copy->get_args().push_back( new VariableExpr( dstParam ) ); 731 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) ); 732 copy->get_args().push_back( new SizeofExpr( cloneWithParams( refType, unionParams ) ) ); 733 734 assignDecl->get_statements()->get_kids().push_back( new ExprStmt( noLabels, copy ) ); 735 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 749 736 750 737 return assignDecl;
Note:
See TracChangeset
for help on using the changeset viewer.