Changeset 3d97b78


Ignore:
Timestamp:
Mar 1, 2018, 6:12:05 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
507e7a2
Parents:
2701c91 (diff), 244b934 (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 plg2:software/cfa/cfa-cc

Files:
2 added
2 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    r2701c91 r3d97b78  
    22772277}
    22782278
    2279 
     2279//--------------------------------------------------------------------------
     2280// TupleType
    22802281template< typename pass_type >
    22812282void PassVisitor< pass_type >::visit( TupleType * node ) {
    2282         VISIT_BODY( node );
    2283 }
    2284 
     2283        VISIT_START( node );
     2284
     2285        maybeAccept_impl( node->forall, *this );
     2286        maybeAccept_impl( node->types, *this );
     2287        maybeAccept_impl( node->members, *this );
     2288
     2289        VISIT_END( node );
     2290}
     2291
     2292template< typename pass_type >
     2293Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
     2294        MUTATE_START( node );
     2295
     2296        maybeMutate_impl( node->forall, *this );
     2297        maybeMutate_impl( node->types, *this );
     2298        maybeMutate_impl( node->members, *this );
     2299
     2300        MUTATE_END( Type, node );
     2301}
     2302
     2303//--------------------------------------------------------------------------
     2304// TypeofType
    22852305template< typename pass_type >
    22862306void PassVisitor< pass_type >::visit( TypeofType * node ) {
    2287         VISIT_BODY( node );
    2288 }
    2289 
     2307        VISIT_START( node );
     2308
     2309        assert( node->expr );
     2310        maybeAccept_impl( node->expr, *this );
     2311
     2312        VISIT_END( node );
     2313}
     2314
     2315template< typename pass_type >
     2316Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
     2317        MUTATE_START( node );
     2318
     2319        assert( node->expr );
     2320        maybeMutate_impl( node->expr, *this );
     2321
     2322        MUTATE_END( Type, node );
     2323}
     2324
     2325//--------------------------------------------------------------------------
     2326// AttrType
    22902327template< typename pass_type >
    22912328void PassVisitor< pass_type >::visit( AttrType * node ) {
    2292         VISIT_BODY( node );
    2293 }
    2294 
     2329        VISIT_START( node );
     2330
     2331        if ( node->isType ) {
     2332                assert( node->type );
     2333                maybeAccept_impl( node->type, *this );
     2334        } else {
     2335                assert( node->expr );
     2336                maybeAccept_impl( node->expr, *this );
     2337        } // if
     2338
     2339        VISIT_END( node );
     2340}
     2341
     2342template< typename pass_type >
     2343Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
     2344        MUTATE_START( node );
     2345
     2346        if ( node->isType ) {
     2347                assert( node->type );
     2348                maybeMutate_impl( node->type, *this );
     2349        } else {
     2350                assert( node->expr );
     2351                maybeMutate_impl( node->expr, *this );
     2352        } // if
     2353
     2354        MUTATE_END( Type, node );
     2355}
     2356
     2357//--------------------------------------------------------------------------
     2358// VarArgsType
    22952359template< typename pass_type >
    22962360void PassVisitor< pass_type >::visit( VarArgsType * node ) {
    2297         VISIT_BODY( node );
    2298 }
    2299 
     2361        VISIT_START( node );
     2362
     2363        maybeAccept_impl( node->forall, *this );
     2364
     2365        VISIT_END( node );
     2366}
     2367
     2368template< typename pass_type >
     2369Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
     2370        MUTATE_START( node );
     2371
     2372        maybeMutate_impl( node->forall, *this );
     2373
     2374        MUTATE_END( Type, node );
     2375}
     2376
     2377//--------------------------------------------------------------------------
     2378// ZeroType
    23002379template< typename pass_type >
    23012380void PassVisitor< pass_type >::visit( ZeroType * node ) {
    2302         VISIT_BODY( node );
    2303 }
    2304 
     2381        VISIT_START( node );
     2382
     2383        maybeAccept_impl( node->forall, *this );
     2384
     2385        VISIT_END( node );
     2386}
     2387
     2388template< typename pass_type >
     2389Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
     2390        MUTATE_START( node );
     2391
     2392        maybeMutate_impl( node->forall, *this );
     2393
     2394        MUTATE_END( Type, node );
     2395}
     2396
     2397//--------------------------------------------------------------------------
     2398// OneType
    23052399template< typename pass_type >
    23062400void PassVisitor< pass_type >::visit( OneType * node ) {
    2307         VISIT_BODY( node );
    2308 }
    2309 
     2401        VISIT_START( node );
     2402
     2403        maybeAccept_impl( node->forall, *this );
     2404
     2405        VISIT_END( node );
     2406}
     2407
     2408template< typename pass_type >
     2409Type * PassVisitor< pass_type >::mutate( OneType * node ) {
     2410        MUTATE_START( node );
     2411
     2412        maybeMutate_impl( node->forall, *this );
     2413
     2414        MUTATE_END( Type, node );
     2415}
     2416
     2417//--------------------------------------------------------------------------
     2418// Designation
    23102419template< typename pass_type >
    23112420void PassVisitor< pass_type >::visit( Designation * node ) {
    23122421        VISIT_START( node );
    23132422
    2314         maybeAccept_impl( node->get_designators(), *this );
     2423        maybeAccept_impl( node->designators, *this );
    23152424
    23162425        VISIT_END( node );
     
    23212430        MUTATE_START( node );
    23222431
    2323         maybeMutate_impl( node->get_designators(), *this );
     2432        maybeMutate_impl( node->designators, *this );
    23242433
    23252434        MUTATE_END( Designation, node );
     
    23322441        VISIT_START( node );
    23332442
    2334         visitExpression( node->get_value() );
     2443        visitExpression( node->value );
    23352444
    23362445        VISIT_END( node );
     
    23412450        MUTATE_START( node );
    23422451
    2343         node->set_value( mutateExpression( node->get_value() ) );
     2452        node->value = mutateExpression( node->value );
    23442453
    23452454        MUTATE_END( Initializer, node );
    23462455}
    23472456
     2457//--------------------------------------------------------------------------
     2458// ListInit
    23482459template< typename pass_type >
    23492460void PassVisitor< pass_type >::visit( ListInit * node ) {
    2350         VISIT_BODY( node );
    2351 }
    2352 
     2461        VISIT_START( node );
     2462
     2463        maybeAccept_impl( node->designations, *this );
     2464        maybeAccept_impl( node->initializers, *this );
     2465
     2466        VISIT_END( node );
     2467}
     2468
     2469template< typename pass_type >
     2470Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
     2471        MUTATE_START( node );
     2472
     2473        maybeMutate_impl( node->designations, *this );
     2474        maybeMutate_impl( node->initializers, *this );
     2475
     2476        MUTATE_END( Initializer, node );
     2477}
     2478
     2479//--------------------------------------------------------------------------
     2480// ConstructorInit
    23532481template< typename pass_type >
    23542482void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
    2355         VISIT_BODY( node );
    2356 }
    2357 
     2483        VISIT_START( node );
     2484
     2485        maybeAccept_impl( node->ctor, *this );
     2486        maybeAccept_impl( node->dtor, *this );
     2487        maybeAccept_impl( node->init, *this );
     2488
     2489        VISIT_END( node );
     2490}
     2491
     2492template< typename pass_type >
     2493Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
     2494        MUTATE_START( node );
     2495
     2496        maybeMutate_impl( node->ctor, *this );
     2497        maybeMutate_impl( node->dtor, *this );
     2498        maybeMutate_impl( node->init, *this );
     2499
     2500        MUTATE_END( Initializer, node );
     2501}
     2502
     2503//--------------------------------------------------------------------------
     2504// Subrange
    23582505template< typename pass_type >
    23592506void PassVisitor< pass_type >::visit( Subrange * node ) {
    2360         VISIT_BODY( node );
    2361 }
    2362 
     2507        VISIT_START( node );
     2508
     2509        VISIT_END( node );
     2510}
     2511
     2512template< typename pass_type >
     2513Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
     2514        MUTATE_START( node );
     2515
     2516        MUTATE_END( Subrange, node );
     2517}
     2518
     2519//--------------------------------------------------------------------------
     2520// Attribute
    23632521template< typename pass_type >
    23642522void PassVisitor< pass_type >::visit( Constant * node ) {
    2365         VISIT_BODY( node );
    2366 }
    2367 
     2523        VISIT_START( node );
     2524
     2525        VISIT_END( node );
     2526}
     2527
     2528template< typename pass_type >
     2529Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
     2530        MUTATE_START( node );
     2531
     2532        MUTATE_END( Constant, node );
     2533}
     2534
     2535//--------------------------------------------------------------------------
     2536// Attribute
    23682537template< typename pass_type >
    23692538void PassVisitor< pass_type >::visit( Attribute * node ) {
    2370         VISIT_BODY( node );
    2371 }
    2372 
    2373 //---------------------------------------------------------------------------------------------------------------
    2374 
    2375 template< typename pass_type >
    2376 Type * PassVisitor< pass_type >::mutate( TupleType * node ) {
    2377         MUTATE_BODY( Type, node );
    2378 }
    2379 
    2380 template< typename pass_type >
    2381 Type * PassVisitor< pass_type >::mutate( TypeofType * node ) {
    2382         MUTATE_BODY( Type, node );
    2383 }
    2384 
    2385 template< typename pass_type >
    2386 Type * PassVisitor< pass_type >::mutate( AttrType * node ) {
    2387         MUTATE_BODY( Type, node );
    2388 }
    2389 
    2390 template< typename pass_type >
    2391 Type * PassVisitor< pass_type >::mutate( VarArgsType * node ) {
    2392         MUTATE_BODY( Type, node );
    2393 }
    2394 
    2395 template< typename pass_type >
    2396 Type * PassVisitor< pass_type >::mutate( ZeroType * node ) {
    2397         MUTATE_BODY( Type, node );
    2398 }
    2399 
    2400 template< typename pass_type >
    2401 Type * PassVisitor< pass_type >::mutate( OneType * node ) {
    2402         MUTATE_BODY( Type, node );
    2403 }
    2404 
    2405 template< typename pass_type >
    2406 Initializer * PassVisitor< pass_type >::mutate( ListInit * node ) {
    2407         MUTATE_BODY( Initializer, node );
    2408 }
    2409 
    2410 template< typename pass_type >
    2411 Initializer * PassVisitor< pass_type >::mutate( ConstructorInit * node ) {
    2412         MUTATE_BODY( Initializer, node );
    2413 }
    2414 
    2415 template< typename pass_type >
    2416 Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
    2417         MUTATE_BODY( Subrange, node );
    2418 }
    2419 
    2420 template< typename pass_type >
    2421 Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
    2422         MUTATE_BODY( Constant, node );
     2539        VISIT_START( node );
     2540
     2541        maybeAccept_impl( node->parameters, *this );
     2542
     2543        VISIT_END( node );
    24232544}
    24242545
    24252546template< typename pass_type >
    24262547Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
    2427         MUTATE_BODY( Attribute, node );
    2428 }
    2429 
     2548        MUTATE_START( node );
     2549
     2550        maybeMutate_impl( node->parameters, *this );
     2551
     2552        MUTATE_END( Attribute, node );
     2553}
     2554
     2555//--------------------------------------------------------------------------
     2556// TypeSubstitution
    24302557template< typename pass_type >
    24312558TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
  • src/Common/SemanticError.cc

    r2701c91 r3d97b78  
    1414//
    1515
     16#include <cstdarg>
    1617#include <cstdio>                                                                               // for fileno, stderr
    1718#include <unistd.h>                                                                             // for isatty
     
    5051}
    5152
    52 void SemanticWarningImpl( CodeLocation location, std::string msg ) {
     53namespace {
     54        // convert format string and arguments into a single string
     55        std::string fmtToString(const char * fmt, va_list ap) {
     56                int size = 128;
     57                while ( true ) {
     58                        char buf[size];
     59                        va_list args;
     60                        va_copy( args, ap );
     61                        int n = vsnprintf(&buf[0], size, fmt, args);
     62                        va_end( args );
     63                        if ( n < size && n >= 0 ) return buf;
     64                        size *= 2;
     65                }
     66                assert( false );
     67        }
     68}
     69
     70void SemanticWarningImpl( CodeLocation location, Warning, const char * const fmt, ... ) {
     71        va_list args;
     72        va_start(args, fmt);
     73        std::string msg = fmtToString( fmt, args );
     74        va_end(args);
    5375        std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
    5476}
  • src/Common/SemanticError.h

    r2701c91 r3d97b78  
    3737
    3838constexpr const char * const WarningFormats[] = {
    39 
     39        "self assignment of expression: %s",
    4040};
    4141
    4242enum class Warning {
     43        SelfAssignment,
    4344        NUMBER_OF_WARNINGS, //This MUST be the last warning
    4445};
     
    4950);
    5051
    51 #define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[id], __VA_ARGS__)
     52#define SemanticWarning(loc, id, ...) SemanticWarningImpl(loc, id, WarningFormats[(int)id], __VA_ARGS__)
    5253
    5354void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4)));
  • src/Common/utility.h

    r2701c91 r3d97b78  
    162162}
    163163
     164#define toCString( ... ) toString( __VA_ARGS__ ).c_str()
     165
    164166// replace element of list with all elements of another list
    165167template< typename T >
  • src/GenPoly/Specialize.cc

    r2701c91 r3d97b78  
    200200        }
    201201
    202         struct EnvTrimmer {
    203                 TypeSubstitution * env, * newEnv;
    204                 EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){}
    205                 void previsit( TypeDecl * tyDecl ) {
    206                         // transfer known bindings for seen type variables
    207                         if ( Type * t = env->lookup( tyDecl->name ) ) {
    208                                 newEnv->add( tyDecl->name, t );
    209                         }
    210                 }
    211         };
    212 
    213         /// reduce environment to just the parts that are referenced in a given expression
    214         TypeSubstitution * trimEnv( ApplicationExpr * expr, TypeSubstitution * env ) {
    215                 if ( env ) {
    216                         TypeSubstitution * newEnv = new TypeSubstitution();
    217                         PassVisitor<EnvTrimmer> trimmer( env, newEnv );
    218                         expr->accept( trimmer );
    219                         return newEnv;
    220                 }
    221                 return nullptr;
    222         }
    223 
    224202        /// Generates a thunk that calls `actual` with type `funType` and returns its address
    225203        Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) {
     
    265243                }
    266244
    267                 appExpr->set_env( trimEnv( appExpr, env ) );
     245                appExpr->env = TypeSubstitution::newFromExpr( appExpr, env );
    268246                if ( inferParams ) {
    269247                        appExpr->get_inferParams() = *inferParams;
  • src/InitTweak/FixInit.cc

    r2701c91 r3d97b78  
    6868                typedef std::unordered_map< int, int > UnqCount;
    6969
     70                struct SelfAssignChecker {
     71                        void previsit( ApplicationExpr * appExpr );
     72                };
     73
    7074                struct InsertImplicitCalls : public WithTypeSubstitution {
    7175                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    235239
    236240        void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) {
     241                PassVisitor<SelfAssignChecker> checker;
     242                acceptAll( translationUnit, checker );
     243
    237244                // fixes ConstructorInit for global variables. should happen before fixInitializers.
    238245                InitTweak::fixGlobalInit( translationUnit, filename, inLibrary );
     
    309316                        PassVisitor<FixCtorExprs> fixer;
    310317                        mutateAll( translationUnit, fixer );
     318                }
     319
     320                namespace {
     321                        // Relatively simple structural comparison for expressions, needed to determine
     322                        // if two expressions are "the same" (used to determine if self assignment occurs)
     323                        struct StructuralChecker {
     324                                Expression * stripCasts( Expression * expr ) {
     325                                        // this might be too permissive. It's possible that only particular casts are relevant.
     326                                        while ( CastExpr * cast = dynamic_cast< CastExpr * >( expr ) ) {
     327                                                expr = cast->arg;
     328                                        }
     329                                        return expr;
     330                                }
     331
     332                                void previsit( Expression * ) {
     333                                        // anything else does not qualify
     334                                        isSimilar = false;
     335                                }
     336
     337                                template<typename T>
     338                                T * cast( Expression * node ) {
     339                                        // all expressions need to ignore casts, so this bit has been factored out
     340                                        return dynamic_cast< T * >( stripCasts( node ) );
     341                                }
     342
     343                                // ignore casts
     344                                void previsit( CastExpr * ) {}
     345
     346                                void previsit( MemberExpr * memExpr ) {
     347                                        if ( MemberExpr * otherMember = cast< MemberExpr >( other ) ) {
     348                                                if ( otherMember->member == memExpr->member ) {
     349                                                        other = otherMember->aggregate;
     350                                                        return;
     351                                                }
     352                                        }
     353                                        isSimilar = false;
     354                                }
     355
     356                                void previsit( VariableExpr * varExpr ) {
     357                                        if ( VariableExpr * otherVar = cast< VariableExpr >( other ) ) {
     358                                                if ( otherVar->var == varExpr->var ) {
     359                                                        return;
     360                                                }
     361                                        }
     362                                        isSimilar = false;
     363                                }
     364
     365                                void previsit( AddressExpr * ) {
     366                                        if ( AddressExpr * addrExpr = cast< AddressExpr >( other ) ) {
     367                                                other = addrExpr->arg;
     368                                                return;
     369                                        }
     370                                        isSimilar = false;
     371                                }
     372
     373                                Expression * other = nullptr;
     374                                bool isSimilar = true;
     375                        };
     376
     377                        bool structurallySimilar( Expression * e1, Expression * e2 ) {
     378                                PassVisitor<StructuralChecker> checker;
     379                                checker.pass.other = e2;
     380                                e1->accept( checker );
     381                                return checker.pass.isSimilar;
     382                        }
     383                }
     384
     385                void SelfAssignChecker::previsit( ApplicationExpr * appExpr ) {
     386                        DeclarationWithType * function = getFunction( appExpr );
     387                        if ( isAssignment( function ) ) {
     388                                if ( appExpr->args.size() == 2 ) {
     389                                        // check for structural similarity (same variable use, ignore casts, etc. - but does not look too deeply, anything looking like a function is off limits)
     390                                        if ( structurallySimilar( appExpr->args.front(), appExpr->args.back() ) ) {
     391                                                SemanticWarning( appExpr->location, Warning::SelfAssignment, toCString( appExpr->args.front() ) );
     392                                        }
     393                                }
     394                        }
    311395                }
    312396
     
    550634                        // add destructors after current statement
    551635                        for ( Expression * dtor : dtors ) {
     636                                // take relevant bindings from environment
     637                                assert( ! dtor->env );
     638                                dtor->env =  TypeSubstitution::newFromExpr( dtor, impCpCtorExpr->env );
    552639                                stmtsToAddAfter.push_back( new ExprStmt( dtor ) );
    553640                        } // for
  • src/Makefile.in

    r2701c91 r3d97b78  
    247247        SynTree/driver_cfa_cpp-TypeDecl.$(OBJEXT) \
    248248        SynTree/driver_cfa_cpp-Initializer.$(OBJEXT) \
    249         SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) \
    250         SynTree/driver_cfa_cpp-Mutator.$(OBJEXT) \
    251249        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    252250        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
     
    527525        SynTree/FunctionDecl.cc SynTree/AggregateDecl.cc \
    528526        SynTree/NamedTypeDecl.cc SynTree/TypeDecl.cc \
    529         SynTree/Initializer.cc SynTree/Visitor.cc SynTree/Mutator.cc \
    530         SynTree/TypeSubstitution.cc SynTree/Attribute.cc \
    531         SynTree/VarExprReplacer.cc Tuples/TupleAssignment.cc \
    532         Tuples/TupleExpansion.cc Tuples/Explode.cc \
    533         Virtual/ExpandCasts.cc
     527        SynTree/Initializer.cc SynTree/TypeSubstitution.cc \
     528        SynTree/Attribute.cc SynTree/VarExprReplacer.cc \
     529        Tuples/TupleAssignment.cc Tuples/TupleExpansion.cc \
     530        Tuples/Explode.cc Virtual/ExpandCasts.cc
    534531MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    535532        ${cfa_cpplib_PROGRAMS}}
     
    911908SynTree/driver_cfa_cpp-Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \
    912909        SynTree/$(DEPDIR)/$(am__dirstamp)
    913 SynTree/driver_cfa_cpp-Visitor.$(OBJEXT): SynTree/$(am__dirstamp) \
    914         SynTree/$(DEPDIR)/$(am__dirstamp)
    915 SynTree/driver_cfa_cpp-Mutator.$(OBJEXT): SynTree/$(am__dirstamp) \
    916         SynTree/$(DEPDIR)/$(am__dirstamp)
    917910SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT):  \
    918911        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    10531046@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionType.Po@am__quote@
    10541047@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Initializer.Po@am__quote@
    1055 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Po@am__quote@
    10561048@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-NamedTypeDecl.Po@am__quote@
    10571049@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ObjectDecl.Po@am__quote@
     
    10691061@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@
    10701062@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarExprReplacer.Po@am__quote@
    1071 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po@am__quote@
    10721063@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    10731064@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
     
    24782469@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    24792470@am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Initializer.obj `if test -f 'SynTree/Initializer.cc'; then $(CYGPATH_W) 'SynTree/Initializer.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Initializer.cc'; fi`
    2480 
    2481 SynTree/driver_cfa_cpp-Visitor.o: SynTree/Visitor.cc
    2482 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-Visitor.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Tpo -c -o SynTree/driver_cfa_cpp-Visitor.o `test -f 'SynTree/Visitor.cc' || echo '$(srcdir)/'`SynTree/Visitor.cc
    2483 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po
    2484 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/Visitor.cc' object='SynTree/driver_cfa_cpp-Visitor.o' libtool=no @AMDEPBACKSLASH@
    2485 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2486 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Visitor.o `test -f 'SynTree/Visitor.cc' || echo '$(srcdir)/'`SynTree/Visitor.cc
    2487 
    2488 SynTree/driver_cfa_cpp-Visitor.obj: SynTree/Visitor.cc
    2489 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-Visitor.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Tpo -c -o SynTree/driver_cfa_cpp-Visitor.obj `if test -f 'SynTree/Visitor.cc'; then $(CYGPATH_W) 'SynTree/Visitor.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Visitor.cc'; fi`
    2490 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po
    2491 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/Visitor.cc' object='SynTree/driver_cfa_cpp-Visitor.obj' libtool=no @AMDEPBACKSLASH@
    2492 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2493 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Visitor.obj `if test -f 'SynTree/Visitor.cc'; then $(CYGPATH_W) 'SynTree/Visitor.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Visitor.cc'; fi`
    2494 
    2495 SynTree/driver_cfa_cpp-Mutator.o: SynTree/Mutator.cc
    2496 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-Mutator.o -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Tpo -c -o SynTree/driver_cfa_cpp-Mutator.o `test -f 'SynTree/Mutator.cc' || echo '$(srcdir)/'`SynTree/Mutator.cc
    2497 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Po
    2498 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/Mutator.cc' object='SynTree/driver_cfa_cpp-Mutator.o' libtool=no @AMDEPBACKSLASH@
    2499 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2500 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Mutator.o `test -f 'SynTree/Mutator.cc' || echo '$(srcdir)/'`SynTree/Mutator.cc
    2501 
    2502 SynTree/driver_cfa_cpp-Mutator.obj: SynTree/Mutator.cc
    2503 @am__fastdepCXX_TRUE@   $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -MT SynTree/driver_cfa_cpp-Mutator.obj -MD -MP -MF SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Tpo -c -o SynTree/driver_cfa_cpp-Mutator.obj `if test -f 'SynTree/Mutator.cc'; then $(CYGPATH_W) 'SynTree/Mutator.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Mutator.cc'; fi`
    2504 @am__fastdepCXX_TRUE@   $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Po
    2505 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(AM_V_CXX)source='SynTree/Mutator.cc' object='SynTree/driver_cfa_cpp-Mutator.obj' libtool=no @AMDEPBACKSLASH@
    2506 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    2507 @am__fastdepCXX_FALSE@  $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(driver_cfa_cpp_CXXFLAGS) $(CXXFLAGS) -c -o SynTree/driver_cfa_cpp-Mutator.obj `if test -f 'SynTree/Mutator.cc'; then $(CYGPATH_W) 'SynTree/Mutator.cc'; else $(CYGPATH_W) '$(srcdir)/SynTree/Mutator.cc'; fi`
    25082471
    25092472SynTree/driver_cfa_cpp-TypeSubstitution.o: SynTree/TypeSubstitution.cc
  • src/SynTree/Mutator.h

    r2701c91 r3d97b78  
    2222class Mutator {
    2323  protected:
    24         Mutator();
    25         virtual ~Mutator();
     24        Mutator() = default;
     25        virtual ~Mutator() = default;
    2626  public:
    2727        virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) = 0;
  • src/SynTree/TypeSubstitution.cc

    r2701c91 r3d97b78  
    104104bool TypeSubstitution::empty() const {
    105105        return typeEnv.empty() && varEnv.empty();
     106}
     107
     108namespace {
     109        struct EnvTrimmer {
     110                TypeSubstitution * env, * newEnv;
     111                EnvTrimmer( TypeSubstitution * env, TypeSubstitution * newEnv ) : env( env ), newEnv( newEnv ){}
     112                void previsit( TypeDecl * tyDecl ) {
     113                        // transfer known bindings for seen type variables
     114                        if ( Type * t = env->lookup( tyDecl->name ) ) {
     115                                newEnv->add( tyDecl->name, t );
     116                        }
     117                }
     118        };
     119} // namespace
     120
     121/// reduce environment to just the parts that are referenced in a given expression
     122TypeSubstitution * TypeSubstitution::newFromExpr( Expression * expr, TypeSubstitution * env ) {
     123        if ( env ) {
     124                TypeSubstitution * newEnv = new TypeSubstitution();
     125                PassVisitor<EnvTrimmer> trimmer( env, newEnv );
     126                expr->accept( trimmer );
     127                return newEnv;
     128        }
     129        return nullptr;
    106130}
    107131
  • src/SynTree/TypeSubstitution.h

    r2701c91 r3d97b78  
    5454        template< typename TypeInstListIterator >
    5555        void extract( TypeInstListIterator begin, TypeInstListIterator end, TypeSubstitution &result );
     56
     57        /// create a new TypeSubstitution using bindings from env containing all of the type variables in expr
     58        static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env );
    5659
    5760        void normalize();
  • src/SynTree/Visitor.h

    r2701c91 r3d97b78  
    2121class Visitor {
    2222  protected:
    23         Visitor();
    24         virtual ~Visitor();
     23        Visitor() = default;
     24        virtual ~Visitor() = default;
    2525  public:
    2626        // visit: Default implementation of all functions visits the children
  • src/SynTree/module.mk

    r2701c91 r3d97b78  
    4646       SynTree/TypeDecl.cc \
    4747       SynTree/Initializer.cc \
    48        SynTree/Visitor.cc \
    49        SynTree/Mutator.cc \
    5048       SynTree/TypeSubstitution.cc \
    5149       SynTree/Attribute.cc \
  • src/libcfa/concurrency/kernel.c

    r2701c91 r3d97b78  
    171171                __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this);
    172172                terminate(&this);
     173                verify(this.do_terminate);
     174                verify(this_processor != &this);
    173175                P( terminated );
     176                verify(this_processor != &this);
    174177                pthread_join( kernel_thread, NULL );
    175178        }
  • src/tests/.expect/KRfunctions.x86.txt

    r2701c91 r3d97b78  
    8282    signed int __a__i_2;
    8383    signed int __b__i_2;
    84     signed int *(*_tmp_cp_ret0)(signed int __x__i_1, signed int __y__i_1);
    85     ((void)(__x__PFPi_ii__2=(((void)(_tmp_cp_ret0=__f10__FPFPi_ii__iPiPid__1(3, (&__a__i_2), (&__b__i_2), 3.5))) , _tmp_cp_ret0)));
    86     ((void)(_tmp_cp_ret0) /* ^?{} */);
     84    signed int *(*_tmp_cp_ret2)(signed int __x__i_1, signed int __y__i_1);
     85    ((void)(__x__PFPi_ii__2=(((void)(_tmp_cp_ret2=__f10__FPFPi_ii__iPiPid__1(3, (&__a__i_2), (&__b__i_2), 3.5))) , _tmp_cp_ret2)));
     86    ((void)(_tmp_cp_ret2) /* ^?{} */);
    8787    const signed int __f1__FCi_iPiPi__2(signed int __a__i_2, signed int *__b__Pi_2, signed int *__c__Pi_2){
    8888        __attribute__ ((unused)) const signed int ___retval_f1__Ci_2;
  • src/tests/Makefile.am

    r2701c91 r3d97b78  
    123123        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    124124
     125warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@
     126        ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@}
     127        echo > ${@}
  • src/tests/Makefile.in

    r2701c91 r3d97b78  
    800800        ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
    801801
     802warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@
     803        ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@}
     804        echo > ${@}
     805
    802806# Tell versions [3.59,3.63) of GNU make to not export all variables.
    803807# Otherwise a system limit (for SysV at least) may be exceeded.
  • tools/busy.c

    r2701c91 r3d97b78  
    11#include <stdbool.h>
     2#include <stdio.h>
    23#include <stdlib.h>
    34#include <pthread.h>
     
    3132}
    3233
    33 int main() {
    34     while(true) {
    35             pthread_t t[15];
    36             for(int i = 0; i < 15; i++) {
    37                     pthread_create( &t[i], NULL, CallingMalloc, NULL );
    38             }
     34int main(int argc, const char * const argv[]) {
     35        char * endptr;
     36        int nThreads = 15;
     37        switch(argc) {
     38        case 1:
     39                break;
     40        case 2:
     41                nThreads = strtol(argv[1], &endptr, 10);
     42                if( *endptr != 0 || nThreads <= 0 ) {
     43                        fprintf(stderr, "Invalid number of threads %s\n", argv[1]);
     44                        return 1;
     45                }
     46                break;
     47        default:
     48                fprintf(stderr, "Usage: %s [no of threads]\n", argv[0]);
     49                return 1;
     50        }
     51        printf("Running %d threads\n", nThreads);
     52        while(true) {
     53                pthread_t t[nThreads];
     54                for(int i = 0; i < nThreads; i++) {
     55                        pthread_create( &t[i], NULL, CallingMalloc, NULL );
     56                }
    3957
    40             for(int i = 0; i < 15; i++) {
    41                     pthread_join( t[i], NULL );
    42             }
    43     }
     58                for(int i = 0; i < nThreads; i++) {
     59                        pthread_join( t[i], NULL );
     60                }
     61        }
     62        return 0;
    4463}
Note: See TracChangeset for help on using the changeset viewer.