Changeset c4c8571 for src


Ignore:
Timestamp:
Jul 28, 2022, 12:04:25 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
32d1383, d0fcc82
Parents:
3f95dab (diff), 2af1943 (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

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r3f95dab rc4c8571  
    143143        FunctionDecl( const CodeLocation & loc, const std::string & name, std::vector<ptr<TypeDecl>>&& forall,
    144144                std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
    145                 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
     145                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall,
    146146                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false);
    147147
     
    149149                std::vector<ptr<TypeDecl>>&& forall, std::vector<ptr<DeclWithType>>&& assertions,
    150150                std::vector<ptr<DeclWithType>>&& params, std::vector<ptr<DeclWithType>>&& returns,
    151                 CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C,
     151                CompoundStmt * stmts, Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::Cforall,
    152152                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {}, bool isVarArgs = false);
    153153
  • src/GenPoly/SpecializeNew.cpp

    r3f95dab rc4c8571  
    230230        if ( auto tuple = type.as<ast::TupleType>() ) {
    231231                std::vector<ast::ptr<ast::Expr>> exprs;
    232                 for ( const ast::Type * t : *tuple ) {
     232                for ( const ast::ptr<ast::Type> & t : *tuple ) {
    233233                        exprs.push_back( structureArg( location, t, begin, end ) );
    234234                }
     
    248248                        if (typeMap.count(typeInst->base)) {
    249249                                ast::TypeInstType * newInst = mutate(typeInst);
    250                                 newInst->expr_id = typeMap[typeInst->base].first;
    251                                 newInst->formal_usage = typeMap[typeInst->base].second;
     250                                auto const & pair = typeMap[typeInst->base];
     251                                newInst->expr_id = pair.first;
     252                                newInst->formal_usage = pair.second;
    252253                                return newInst;
    253254                        }
     
    462463        if ( specialized != expr->arg ) {
    463464                // Assume that the specialization incorporates the cast.
    464                 std::cerr << expr <<std::endl;
    465465                return specialized;
    466466        } else {
  • src/InitTweak/InitTweak.cc

    r3f95dab rc4c8571  
    2727#include "AST/Stmt.hpp"
    2828#include "AST/Type.hpp"
     29#include "CodeGen/OperatorTable.h" // for isConstructor, isDestructor, isCto...
    2930#include "Common/PassVisitor.h"
    3031#include "Common/SemanticError.h"  // for SemanticError
     
    770771                        std::list< Expression * > callExprs;
    771772                        collectCtorDtorCalls( stmt, callExprs );
    772                         // if ( callExprs.empty() ) return false; // xxx - do I still need this check?
    773773                        return std::all_of( callExprs.begin(), callExprs.end(), pred);
    774774                }
     
    901901                        } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) {
    902902                                return varExpr->get_var()->get_name();
    903                         }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
     903                        } else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
    904904                                return funcName( castExpr->get_arg() );
    905905                        } else if ( MemberExpr * memberExpr = dynamic_cast< MemberExpr * >( func ) ) {
     
    923923                        } else if ( const ast::VariableExpr * varExpr = dynamic_cast< const ast::VariableExpr * >( func ) ) {
    924924                                return varExpr->var->name;
    925                         }       else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) {
     925                        } else if ( const ast::CastExpr * castExpr = dynamic_cast< const ast::CastExpr * >( func ) ) {
    926926                                return funcName( castExpr->arg );
    927927                        } else if ( const ast::MemberExpr * memberExpr = dynamic_cast< const ast::MemberExpr * >( func ) ) {
     
    991991
    992992        Type * isPointerType( Type * type ) {
    993                 if ( getPointerBase( type ) ) return type;
    994                 else return nullptr;
     993                return getPointerBase( type ) ? type : nullptr;
    995994        }
    996995
     
    10141013                                src = new AddressExpr( src );
    10151014                        }
    1016                         // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
    10171015                }
    10181016                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
     
    11671165        }
    11681166
    1169         bool isConstructor( const std::string & str ) { return str == "?{}"; }
    1170         bool isDestructor( const std::string & str ) { return str == "^?{}"; }
    1171         bool isAssignment( const std::string & str ) { return str == "?=?"; }
    1172         bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); }
    1173         bool isCtorDtorAssign( const std::string & str ) { return isCtorDtor( str ) || isAssignment( str ); }
    1174 
    11751167        const FunctionDecl * isCopyFunction( const Declaration * decl, const std::string & fname ) {
    11761168                const FunctionDecl * function = dynamic_cast< const FunctionDecl * >( decl );
     
    11921184
    11931185bool isAssignment( const ast::FunctionDecl * decl ) {
    1194         return isAssignment( decl->name ) && isCopyFunction( decl );
     1186        return CodeGen::isAssignment( decl->name ) && isCopyFunction( decl );
    11951187}
    11961188
    11971189bool isDestructor( const ast::FunctionDecl * decl ) {
    1198         return isDestructor( decl->name );
     1190        return CodeGen::isDestructor( decl->name );
    11991191}
    12001192
    12011193bool isDefaultConstructor( const ast::FunctionDecl * decl ) {
    1202         return isConstructor( decl->name ) && 1 == decl->params.size();
     1194        return CodeGen::isConstructor( decl->name ) && 1 == decl->params.size();
    12031195}
    12041196
    12051197bool isCopyConstructor( const ast::FunctionDecl * decl ) {
    1206         return isConstructor( decl->name ) && 2 == decl->params.size();
     1198        return CodeGen::isConstructor( decl->name ) && 2 == decl->params.size();
    12071199}
    12081200
     
    12221214        }
    12231215        const FunctionDecl * isDestructor( const Declaration * decl ) {
    1224                 if ( isDestructor( decl->name ) ) {
     1216                if ( CodeGen::isDestructor( decl->name ) ) {
    12251217                        return dynamic_cast< const FunctionDecl * >( decl );
    12261218                }
     
    12281220        }
    12291221        const FunctionDecl * isDefaultConstructor( const Declaration * decl ) {
    1230                 if ( isConstructor( decl->name ) ) {
     1222                if ( CodeGen::isConstructor( decl->name ) ) {
    12311223                        if ( const FunctionDecl * func = dynamic_cast< const FunctionDecl * >( decl ) ) {
    12321224                                if ( func->type->parameters.size() == 1 ) {
  • src/SymTab/Autogen.cc

    r3f95dab rc4c8571  
    258258        }
    259259
    260         ///
     260        /// Given type T, generate type of default ctor/dtor, i.e. function type void (*) (T &).
    261261        ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic) {
    262262                std::vector<ast::ptr<ast::TypeDecl>> typeParams;
    263263                if (maybePolymorphic) typeParams = getGenericParams(paramType);
    264264                auto dstParam = new ast::ObjectDecl(loc, "_dst", new ast::ReferenceType(paramType), nullptr, {}, ast::Linkage::Cforall);
    265                 return new ast::FunctionDecl(loc, fname, std::move(typeParams), {dstParam}, {}, new ast::CompoundStmt(loc));
     265                return new ast::FunctionDecl(loc, fname, std::move(typeParams), {dstParam}, {}, new ast::CompoundStmt(loc), {}, ast::Linkage::Cforall);
    266266        }
    267267
Note: See TracChangeset for help on using the changeset viewer.