Ignore:
Timestamp:
Oct 29, 2019, 4:01:24 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
773db65, 9421f3d8
Parents:
7951100 (diff), 8364209 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r7951100 rb067d9b  
    2424#include <vector>                  // for vector
    2525
     26#include "AST/Decl.hpp"
    2627#include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign
    2728#include "Common/PassVisitor.h"    // for PassVisitor
     
    4142
    4243namespace SymTab {
    43         Type * SizeType = 0;
    44 
    4544        /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
    4645        struct FuncData {
    47                 typedef FunctionType * (*TypeGen)( Type * );
     46                typedef FunctionType * (*TypeGen)( Type *, bool );
    4847                FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {}
    4948                std::string fname;
     
    211210        }
    212211
     212        bool isUnnamedBitfield( const ast::ObjectDecl * obj ) {
     213                return obj && obj->name.empty() && obj->bitfieldWidth;
     214        }
     215
    213216        /// inserts a forward declaration for functionDecl into declsToAdd
    214217        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
     
    231234
    232235        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    233         FunctionType * genDefaultType( Type * paramType ) {
    234                 const auto & typeParams = getGenericParams( paramType );
     236        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
    235237                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    236                 cloneAll( typeParams, ftype->forall );
     238                if ( maybePolymorphic ) {
     239                        // only copy in
     240                        const auto & typeParams = getGenericParams( paramType );
     241                        cloneAll( typeParams, ftype->forall );
     242                }
    237243                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    238244                ftype->parameters.push_back( dstParam );
     
    241247
    242248        /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
    243         FunctionType * genCopyType( Type * paramType ) {
    244                 FunctionType *ftype = genDefaultType( paramType );
     249        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
     250                FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
    245251                ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    246252                ftype->parameters.push_back( srcParam );
     
    249255
    250256        /// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
    251         FunctionType * genAssignType( Type * paramType ) {
    252                 FunctionType *ftype = genCopyType( paramType );
     257        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
     258                FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
    253259                ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    254260                ftype->returnVals.push_back( returnVal );
     
    308314                for ( const FuncData & d : data ) {
    309315                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    310                         FunctionType * ftype = d.genType( type );
     316                        FunctionType * ftype = d.genType( type, true );
    311317
    312318                        // destructor for concurrent type must be mutex
     
    387393
    388394        void StructFuncGenerator::makeMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool forward ) {
    389                 InitTweak::InitExpander srcParam( src );
     395                InitTweak::InitExpander_old srcParam( src );
    390396
    391397                // assign to destination
Note: See TracChangeset for help on using the changeset viewer.