Changes in / [3d97b78:2701c91]


Ignore:
Files:
2 added
2 deleted
17 edited

Legend:

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

    r3d97b78 r2701c91  
    22772277}
    22782278
    2279 //--------------------------------------------------------------------------
    2280 // TupleType
     2279
    22812280template< typename pass_type >
    22822281void PassVisitor< pass_type >::visit( TupleType * node ) {
    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 }
     2282        VISIT_BODY( node );
     2283}
     2284
     2285template< typename pass_type >
     2286void PassVisitor< pass_type >::visit( TypeofType * node ) {
     2287        VISIT_BODY( node );
     2288}
     2289
     2290template< typename pass_type >
     2291void PassVisitor< pass_type >::visit( AttrType * node ) {
     2292        VISIT_BODY( node );
     2293}
     2294
     2295template< typename pass_type >
     2296void PassVisitor< pass_type >::visit( VarArgsType * node ) {
     2297        VISIT_BODY( node );
     2298}
     2299
     2300template< typename pass_type >
     2301void PassVisitor< pass_type >::visit( ZeroType * node ) {
     2302        VISIT_BODY( node );
     2303}
     2304
     2305template< typename pass_type >
     2306void PassVisitor< pass_type >::visit( OneType * node ) {
     2307        VISIT_BODY( node );
     2308}
     2309
     2310template< typename pass_type >
     2311void PassVisitor< pass_type >::visit( Designation * node ) {
     2312        VISIT_START( node );
     2313
     2314        maybeAccept_impl( node->get_designators(), *this );
     2315
     2316        VISIT_END( node );
     2317}
     2318
     2319template< typename pass_type >
     2320Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
     2321        MUTATE_START( node );
     2322
     2323        maybeMutate_impl( node->get_designators(), *this );
     2324
     2325        MUTATE_END( Designation, node );
     2326}
     2327
     2328//--------------------------------------------------------------------------
     2329// SingleInit
     2330template< typename pass_type >
     2331void PassVisitor< pass_type >::visit( SingleInit * node ) {
     2332        VISIT_START( node );
     2333
     2334        visitExpression( node->get_value() );
     2335
     2336        VISIT_END( node );
     2337}
     2338
     2339template< typename pass_type >
     2340Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
     2341        MUTATE_START( node );
     2342
     2343        node->set_value( mutateExpression( node->get_value() ) );
     2344
     2345        MUTATE_END( Initializer, node );
     2346}
     2347
     2348template< typename pass_type >
     2349void PassVisitor< pass_type >::visit( ListInit * node ) {
     2350        VISIT_BODY( node );
     2351}
     2352
     2353template< typename pass_type >
     2354void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
     2355        VISIT_BODY( node );
     2356}
     2357
     2358template< typename pass_type >
     2359void PassVisitor< pass_type >::visit( Subrange * node ) {
     2360        VISIT_BODY( node );
     2361}
     2362
     2363template< typename pass_type >
     2364void PassVisitor< pass_type >::visit( Constant * node ) {
     2365        VISIT_BODY( node );
     2366}
     2367
     2368template< typename pass_type >
     2369void PassVisitor< pass_type >::visit( Attribute * node ) {
     2370        VISIT_BODY( node );
     2371}
     2372
     2373//---------------------------------------------------------------------------------------------------------------
    22912374
    22922375template< typename pass_type >
    22932376Type * 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
    2305 template< typename pass_type >
    2306 void PassVisitor< pass_type >::visit( TypeofType * node ) {
    2307         VISIT_START( node );
    2308 
    2309         assert( node->expr );
    2310         maybeAccept_impl( node->expr, *this );
    2311 
    2312         VISIT_END( node );
     2377        MUTATE_BODY( Type, node );
    23132378}
    23142379
    23152380template< typename pass_type >
    23162381Type * 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
    2327 template< typename pass_type >
    2328 void PassVisitor< pass_type >::visit( AttrType * node ) {
    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 );
     2382        MUTATE_BODY( Type, node );
    23402383}
    23412384
    23422385template< typename pass_type >
    23432386Type * 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
    2359 template< typename pass_type >
    2360 void PassVisitor< pass_type >::visit( VarArgsType * node ) {
    2361         VISIT_START( node );
    2362 
    2363         maybeAccept_impl( node->forall, *this );
    2364 
    2365         VISIT_END( node );
     2387        MUTATE_BODY( Type, node );
    23662388}
    23672389
    23682390template< typename pass_type >
    23692391Type * 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
    2379 template< typename pass_type >
    2380 void PassVisitor< pass_type >::visit( ZeroType * node ) {
    2381         VISIT_START( node );
    2382 
    2383         maybeAccept_impl( node->forall, *this );
    2384 
    2385         VISIT_END( node );
     2392        MUTATE_BODY( Type, node );
    23862393}
    23872394
    23882395template< typename pass_type >
    23892396Type * 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
    2399 template< typename pass_type >
    2400 void PassVisitor< pass_type >::visit( OneType * node ) {
    2401         VISIT_START( node );
    2402 
    2403         maybeAccept_impl( node->forall, *this );
    2404 
    2405         VISIT_END( node );
     2397        MUTATE_BODY( Type, node );
    24062398}
    24072399
    24082400template< typename pass_type >
    24092401Type * 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
    2419 template< typename pass_type >
    2420 void PassVisitor< pass_type >::visit( Designation * node ) {
    2421         VISIT_START( node );
    2422 
    2423         maybeAccept_impl( node->designators, *this );
    2424 
    2425         VISIT_END( node );
    2426 }
    2427 
    2428 template< typename pass_type >
    2429 Designation * PassVisitor< pass_type >::mutate( Designation * node ) {
    2430         MUTATE_START( node );
    2431 
    2432         maybeMutate_impl( node->designators, *this );
    2433 
    2434         MUTATE_END( Designation, node );
    2435 }
    2436 
    2437 //--------------------------------------------------------------------------
    2438 // SingleInit
    2439 template< typename pass_type >
    2440 void PassVisitor< pass_type >::visit( SingleInit * node ) {
    2441         VISIT_START( node );
    2442 
    2443         visitExpression( node->value );
    2444 
    2445         VISIT_END( node );
    2446 }
    2447 
    2448 template< typename pass_type >
    2449 Initializer * PassVisitor< pass_type >::mutate( SingleInit * node ) {
    2450         MUTATE_START( node );
    2451 
    2452         node->value = mutateExpression( node->value );
    2453 
    2454         MUTATE_END( Initializer, node );
    2455 }
    2456 
    2457 //--------------------------------------------------------------------------
    2458 // ListInit
    2459 template< typename pass_type >
    2460 void PassVisitor< pass_type >::visit( ListInit * node ) {
    2461         VISIT_START( node );
    2462 
    2463         maybeAccept_impl( node->designations, *this );
    2464         maybeAccept_impl( node->initializers, *this );
    2465 
    2466         VISIT_END( node );
     2402        MUTATE_BODY( Type, node );
    24672403}
    24682404
    24692405template< typename pass_type >
    24702406Initializer * 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
    2481 template< typename pass_type >
    2482 void PassVisitor< pass_type >::visit( ConstructorInit * node ) {
    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 );
     2407        MUTATE_BODY( Initializer, node );
    24902408}
    24912409
    24922410template< typename pass_type >
    24932411Initializer * 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
    2505 template< typename pass_type >
    2506 void PassVisitor< pass_type >::visit( Subrange * node ) {
    2507         VISIT_START( node );
    2508 
    2509         VISIT_END( node );
     2412        MUTATE_BODY( Initializer, node );
    25102413}
    25112414
    25122415template< typename pass_type >
    25132416Subrange * PassVisitor< pass_type >::mutate( Subrange * node  )  {
    2514         MUTATE_START( node );
    2515 
    2516         MUTATE_END( Subrange, node );
    2517 }
    2518 
    2519 //--------------------------------------------------------------------------
    2520 // Attribute
    2521 template< typename pass_type >
    2522 void PassVisitor< pass_type >::visit( Constant * node ) {
    2523         VISIT_START( node );
    2524 
    2525         VISIT_END( node );
     2417        MUTATE_BODY( Subrange, node );
    25262418}
    25272419
    25282420template< typename pass_type >
    25292421Constant * PassVisitor< pass_type >::mutate( Constant * node  )  {
    2530         MUTATE_START( node );
    2531 
    2532         MUTATE_END( Constant, node );
    2533 }
    2534 
    2535 //--------------------------------------------------------------------------
    2536 // Attribute
    2537 template< typename pass_type >
    2538 void PassVisitor< pass_type >::visit( Attribute * node ) {
    2539         VISIT_START( node );
    2540 
    2541         maybeAccept_impl( node->parameters, *this );
    2542 
    2543         VISIT_END( node );
     2422        MUTATE_BODY( Constant, node );
    25442423}
    25452424
    25462425template< typename pass_type >
    25472426Attribute * PassVisitor< pass_type >::mutate( Attribute * node  )  {
    2548         MUTATE_START( node );
    2549 
    2550         maybeMutate_impl( node->parameters, *this );
    2551 
    2552         MUTATE_END( Attribute, node );
    2553 }
    2554 
    2555 //--------------------------------------------------------------------------
    2556 // TypeSubstitution
     2427        MUTATE_BODY( Attribute, node );
     2428}
     2429
    25572430template< typename pass_type >
    25582431TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) {
  • src/Common/SemanticError.cc

    r3d97b78 r2701c91  
    1414//
    1515
    16 #include <cstdarg>
    1716#include <cstdio>                                                                               // for fileno, stderr
    1817#include <unistd.h>                                                                             // for isatty
     
    5150}
    5251
    53 namespace {
    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 
    70 void 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);
     52void SemanticWarningImpl( CodeLocation location, std::string msg ) {
    7553        std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl;
    7654}
  • src/Common/SemanticError.h

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

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

    r3d97b78 r2701c91  
    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
    202224        /// Generates a thunk that calls `actual` with type `funType` and returns its address
    203225        Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) {
     
    243265                }
    244266
    245                 appExpr->env = TypeSubstitution::newFromExpr( appExpr, env );
     267                appExpr->set_env( trimEnv( appExpr, env ) );
    246268                if ( inferParams ) {
    247269                        appExpr->get_inferParams() = *inferParams;
  • src/InitTweak/FixInit.cc

    r3d97b78 r2701c91  
    6868                typedef std::unordered_map< int, int > UnqCount;
    6969
    70                 struct SelfAssignChecker {
    71                         void previsit( ApplicationExpr * appExpr );
    72                 };
    73 
    7470                struct InsertImplicitCalls : public WithTypeSubstitution {
    7571                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    239235
    240236        void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) {
    241                 PassVisitor<SelfAssignChecker> checker;
    242                 acceptAll( translationUnit, checker );
    243 
    244237                // fixes ConstructorInit for global variables. should happen before fixInitializers.
    245238                InitTweak::fixGlobalInit( translationUnit, filename, inLibrary );
     
    316309                        PassVisitor<FixCtorExprs> fixer;
    317310                        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                         }
    395311                }
    396312
     
    634550                        // add destructors after current statement
    635551                        for ( Expression * dtor : dtors ) {
    636                                 // take relevant bindings from environment
    637                                 assert( ! dtor->env );
    638                                 dtor->env =  TypeSubstitution::newFromExpr( dtor, impCpCtorExpr->env );
    639552                                stmtsToAddAfter.push_back( new ExprStmt( dtor ) );
    640553                        } // for
  • src/Makefile.in

    r3d97b78 r2701c91  
    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) \
    249251        SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \
    250252        SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \
     
    525527        SynTree/FunctionDecl.cc SynTree/AggregateDecl.cc \
    526528        SynTree/NamedTypeDecl.cc SynTree/TypeDecl.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
     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
    531534MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \
    532535        ${cfa_cpplib_PROGRAMS}}
     
    908911SynTree/driver_cfa_cpp-Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \
    909912        SynTree/$(DEPDIR)/$(am__dirstamp)
     913SynTree/driver_cfa_cpp-Visitor.$(OBJEXT): SynTree/$(am__dirstamp) \
     914        SynTree/$(DEPDIR)/$(am__dirstamp)
     915SynTree/driver_cfa_cpp-Mutator.$(OBJEXT): SynTree/$(am__dirstamp) \
     916        SynTree/$(DEPDIR)/$(am__dirstamp)
    910917SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT):  \
    911918        SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp)
     
    10461053@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionType.Po@am__quote@
    10471054@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@
    10481056@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-NamedTypeDecl.Po@am__quote@
    10491057@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ObjectDecl.Po@am__quote@
     
    10611069@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@
    10621070@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@
    10631072@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@
    10641073@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@
     
    24692478@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    24702479@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
     2481SynTree/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
     2488SynTree/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
     2495SynTree/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
     2502SynTree/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`
    24712508
    24722509SynTree/driver_cfa_cpp-TypeSubstitution.o: SynTree/TypeSubstitution.cc
  • src/SynTree/Mutator.h

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

    r3d97b78 r2701c91  
    104104bool TypeSubstitution::empty() const {
    105105        return typeEnv.empty() && varEnv.empty();
    106 }
    107 
    108 namespace {
    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
    122 TypeSubstitution * 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;
    130106}
    131107
  • src/SynTree/TypeSubstitution.h

    r3d97b78 r2701c91  
    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 );
    5956
    6057        void normalize();
  • src/SynTree/Visitor.h

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

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

    r3d97b78 r2701c91  
    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);
    175173                P( terminated );
    176                 verify(this_processor != &this);
    177174                pthread_join( kernel_thread, NULL );
    178175        }
  • src/tests/.expect/KRfunctions.x86.txt

    r3d97b78 r2701c91  
    8282    signed int __a__i_2;
    8383    signed int __b__i_2;
    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) /* ^?{} */);
     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) /* ^?{} */);
    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

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

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

    r3d97b78 r2701c91  
    11#include <stdbool.h>
    2 #include <stdio.h>
    32#include <stdlib.h>
    43#include <pthread.h>
     
    3231}
    3332
    34 int 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                 }
     33int 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            }
    5739
    58                 for(int i = 0; i < nThreads; i++) {
    59                         pthread_join( t[i], NULL );
    60                 }
    61         }
    62         return 0;
     40            for(int i = 0; i < 15; i++) {
     41                    pthread_join( t[i], NULL );
     42            }
     43    }
    6344}
Note: See TracChangeset for help on using the changeset viewer.