Changeset d41280e for src/SymTab


Ignore:
Timestamp:
Feb 8, 2016, 10:07:42 AM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c44e622
Parents:
00ede9e (diff), bd85400 (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.
Message:

Merge branch 'master' into gc_noraii

Location:
src/SymTab
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    r00ede9e rd41280e  
    1818#include "SynTree/Type.h"
    1919#include "SynTree/Expression.h"
    20 #include "utility.h"
     20#include "Common/utility.h"
    2121
    2222namespace SymTab {
  • src/SymTab/IdTable.cc

    r00ede9e rd41280e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 17:04:02 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Oct 07 12:21:13 2015
    13 // Update Count     : 73
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Jan  8 22:59:23 2016
     13// Update Count     : 74
    1414//
    1515
     
    2121#include "Mangler.h"
    2222#include "IdTable.h"
    23 #include "SemanticError.h"
     23#include "Common/SemanticError.h"
    2424
    2525using std::string;
     
    5454                        manglename = name;
    5555                } else if ( LinkageSpec::isOverridable( decl->get_linkage() ) ) {
    56                         // mangle the name without including the appropriate suffix
    57                         // this will make it so that overridable routines are placed
    58                         // into the same "bucket" as their user defined versions.
     56                        // mangle the name without including the appropriate suffix, so overridable routines are placed into the
     57                        // same "bucket" as their user defined versions.
    5958                        manglename = Mangler::mangle( decl, false );
    6059                } else {
     
    7170                        std::stack< DeclEntry >& entry = it->second;
    7271                        if ( ! entry.empty() && entry.top().second == scopeLevel ) {
    73                                 // if we're giving the same name mangling to things of
    74                                 //  different types then there is something wrong
     72                                // if we're giving the same name mangling to things of different types then there is something wrong
    7573                                Declaration *old = entry.top().first;
    7674                                assert( (dynamic_cast<ObjectDecl*>( decl ) && dynamic_cast<ObjectDecl*>( old ) )
  • src/SymTab/ImplementationType.cc

    r00ede9e rd41280e  
    1919#include "SynTree/Visitor.h"
    2020#include "SymTab/Indexer.h"
    21 #include "utility.h"
     21#include "Common/utility.h"
    2222
    2323
  • src/SymTab/Indexer.cc

    r00ede9e rd41280e  
    2121#include "Indexer.h"
    2222#include <typeinfo>
    23 #include "utility.h"
     23#include "Common/utility.h"
    2424
    2525#define debugPrint(x) if ( doDebug ) { std::cout << x; }
     
    225225                        maybeAccept( alignofExpr->get_expr(), *this );
    226226                }
     227        }
     228
     229        void Indexer::visit( UntypedOffsetofExpr *offsetofExpr ) {
     230                acceptAllNewScope( offsetofExpr->get_results(), *this );
     231                maybeAccept( offsetofExpr->get_type(), *this );
     232        }
     233
     234        void Indexer::visit( OffsetofExpr *offsetofExpr ) {
     235                acceptAllNewScope( offsetofExpr->get_results(), *this );
     236                maybeAccept( offsetofExpr->get_type(), *this );
     237                maybeAccept( offsetofExpr->get_member(), *this );
    227238        }
    228239
  • src/SymTab/Indexer.h

    r00ede9e rd41280e  
    5555                virtual void visit( SizeofExpr *sizeofExpr );
    5656                virtual void visit( AlignofExpr *alignofExpr );
     57                virtual void visit( UntypedOffsetofExpr *offsetofExpr );
     58                virtual void visit( OffsetofExpr *offsetofExpr );
    5759                virtual void visit( AttrExpr *attrExpr );
    5860                virtual void visit( LogicalExpr *logicalExpr );
  • src/SymTab/Validate.cc

    r00ede9e rd41280e  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 15:34:05 2015
    13 // Update Count     : 218
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jan 27 22:03:12 2016
     13// Update Count     : 225
    1414//
    1515
     
    4949#include "FixFunction.h"
    5050// #include "ImplementationType.h"
    51 #include "utility.h"
    52 #include "UniqueName.h"
     51#include "Common/utility.h"
     52#include "Common/UniqueName.h"
    5353#include "AddVisit.h"
    5454#include "MakeLibCfa.h"
     
    585585        }
    586586
     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
    587597        //E ?=?(E volatile*, int),
    588598        //  ?=?(E _Atomic volatile*, int);
     
    653663
    654664                // 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)
    655666                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    656667                std::list< Expression* > structParams;  // List of matching parameters to put on types
    657668                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
     669                        isGeneric = true;
    658670                        TypeDecl *typeParam = (*param)->clone();
    659671                        assignType->get_forall().push_back( typeParam );
     
    661673                }
    662674
    663                 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
     675                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 );
    664676                assignType->get_returnVals().push_back( returnVal );
    665677
     
    691703                                if ( ArrayType *array = dynamic_cast< ArrayType * >( dwt->get_type() ) ) {
    692704                                        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() ) );
    693706                                } else {
    694707                                        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() ) );
    695709                                } // if
    696710                        } // if
    697711                } // for
    698                 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
     712                if ( ! isGeneric ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );
    699713
    700714                return assignDecl;
     
    705719
    706720                // 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)
    707722                std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters();
    708723                std::list< Expression* > unionParams;  // List of matching parameters to put on types
    709724                for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) {
     725                        isGeneric = true;
    710726                        TypeDecl *typeParam = (*param)->clone();
    711727                        assignType->get_forall().push_back( typeParam );
     
    713729                }
    714730
    715                 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
     731                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
    716732                assignType->get_returnVals().push_back( returnVal );
    717733
     
    727743                assignDecl->fixUniqueId();
    728744
    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 ) ) );
     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 ) ) );
    736749
    737750                return assignDecl;
Note: See TracChangeset for help on using the changeset viewer.