Changes in / [3d97b78:2701c91]
- Files:
-
- 2 added
- 2 deleted
- 17 edited
-
src/Common/PassVisitor.impl.h (modified) (1 diff)
-
src/Common/SemanticError.cc (modified) (2 diffs)
-
src/Common/SemanticError.h (modified) (2 diffs)
-
src/Common/utility.h (modified) (1 diff)
-
src/GenPoly/Specialize.cc (modified) (2 diffs)
-
src/InitTweak/FixInit.cc (modified) (4 diffs)
-
src/Makefile.in (modified) (6 diffs)
-
src/SynTree/Mutator.cc (added)
-
src/SynTree/Mutator.h (modified) (1 diff)
-
src/SynTree/TypeSubstitution.cc (modified) (1 diff)
-
src/SynTree/TypeSubstitution.h (modified) (1 diff)
-
src/SynTree/Visitor.cc (added)
-
src/SynTree/Visitor.h (modified) (1 diff)
-
src/SynTree/module.mk (modified) (1 diff)
-
src/libcfa/concurrency/kernel.c (modified) (1 diff)
-
src/tests/.expect/KRfunctions.x86.txt (modified) (1 diff)
-
src/tests/Makefile.am (modified) (1 diff)
-
src/tests/Makefile.in (modified) (1 diff)
-
src/tests/warnings/.expect/self-assignment.txt (deleted)
-
src/tests/warnings/self-assignment.c (deleted)
-
tools/busy.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r3d97b78 r2701c91 2277 2277 } 2278 2278 2279 //-------------------------------------------------------------------------- 2280 // TupleType 2279 2281 2280 template< typename pass_type > 2282 2281 void 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 2285 template< typename pass_type > 2286 void PassVisitor< pass_type >::visit( TypeofType * node ) { 2287 VISIT_BODY( node ); 2288 } 2289 2290 template< typename pass_type > 2291 void PassVisitor< pass_type >::visit( AttrType * node ) { 2292 VISIT_BODY( node ); 2293 } 2294 2295 template< typename pass_type > 2296 void PassVisitor< pass_type >::visit( VarArgsType * node ) { 2297 VISIT_BODY( node ); 2298 } 2299 2300 template< typename pass_type > 2301 void PassVisitor< pass_type >::visit( ZeroType * node ) { 2302 VISIT_BODY( node ); 2303 } 2304 2305 template< typename pass_type > 2306 void PassVisitor< pass_type >::visit( OneType * node ) { 2307 VISIT_BODY( node ); 2308 } 2309 2310 template< typename pass_type > 2311 void 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 2319 template< typename pass_type > 2320 Designation * 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 2330 template< typename pass_type > 2331 void PassVisitor< pass_type >::visit( SingleInit * node ) { 2332 VISIT_START( node ); 2333 2334 visitExpression( node->get_value() ); 2335 2336 VISIT_END( node ); 2337 } 2338 2339 template< typename pass_type > 2340 Initializer * 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 2348 template< typename pass_type > 2349 void PassVisitor< pass_type >::visit( ListInit * node ) { 2350 VISIT_BODY( node ); 2351 } 2352 2353 template< typename pass_type > 2354 void PassVisitor< pass_type >::visit( ConstructorInit * node ) { 2355 VISIT_BODY( node ); 2356 } 2357 2358 template< typename pass_type > 2359 void PassVisitor< pass_type >::visit( Subrange * node ) { 2360 VISIT_BODY( node ); 2361 } 2362 2363 template< typename pass_type > 2364 void PassVisitor< pass_type >::visit( Constant * node ) { 2365 VISIT_BODY( node ); 2366 } 2367 2368 template< typename pass_type > 2369 void PassVisitor< pass_type >::visit( Attribute * node ) { 2370 VISIT_BODY( node ); 2371 } 2372 2373 //--------------------------------------------------------------------------------------------------------------- 2291 2374 2292 2375 template< typename pass_type > 2293 2376 Type * 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 ); 2313 2378 } 2314 2379 2315 2380 template< typename pass_type > 2316 2381 Type * 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 ); 2340 2383 } 2341 2384 2342 2385 template< typename pass_type > 2343 2386 Type * 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 ); 2366 2388 } 2367 2389 2368 2390 template< typename pass_type > 2369 2391 Type * 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 ); 2386 2393 } 2387 2394 2388 2395 template< typename pass_type > 2389 2396 Type * 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 ); 2406 2398 } 2407 2399 2408 2400 template< typename pass_type > 2409 2401 Type * 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 ); 2467 2403 } 2468 2404 2469 2405 template< typename pass_type > 2470 2406 Initializer * 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 ); 2490 2408 } 2491 2409 2492 2410 template< typename pass_type > 2493 2411 Initializer * 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 ); 2510 2413 } 2511 2414 2512 2415 template< typename pass_type > 2513 2416 Subrange * 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 ); 2526 2418 } 2527 2419 2528 2420 template< typename pass_type > 2529 2421 Constant * 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 ); 2544 2423 } 2545 2424 2546 2425 template< typename pass_type > 2547 2426 Attribute * 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 2557 2430 template< typename pass_type > 2558 2431 TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { -
src/Common/SemanticError.cc
r3d97b78 r2701c91 14 14 // 15 15 16 #include <cstdarg>17 16 #include <cstdio> // for fileno, stderr 18 17 #include <unistd.h> // for isatty … … 51 50 } 52 51 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); 52 void SemanticWarningImpl( CodeLocation location, std::string msg ) { 75 53 std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl; 76 54 } -
src/Common/SemanticError.h
r3d97b78 r2701c91 37 37 38 38 constexpr const char * const WarningFormats[] = { 39 "self assignment of expression: %s", 39 40 40 }; 41 41 42 42 enum class Warning { 43 SelfAssignment,44 43 NUMBER_OF_WARNINGS, //This MUST be the last warning 45 44 }; … … 50 49 ); 51 50 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__) 53 52 54 53 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4))); -
src/Common/utility.h
r3d97b78 r2701c91 162 162 } 163 163 164 #define toCString( ... ) toString( __VA_ARGS__ ).c_str()165 166 164 // replace element of list with all elements of another list 167 165 template< typename T > -
src/GenPoly/Specialize.cc
r3d97b78 r2701c91 200 200 } 201 201 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 202 224 /// Generates a thunk that calls `actual` with type `funType` and returns its address 203 225 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 243 265 } 244 266 245 appExpr-> env = TypeSubstitution::newFromExpr( appExpr, env);267 appExpr->set_env( trimEnv( appExpr, env ) ); 246 268 if ( inferParams ) { 247 269 appExpr->get_inferParams() = *inferParams; -
src/InitTweak/FixInit.cc
r3d97b78 r2701c91 68 68 typedef std::unordered_map< int, int > UnqCount; 69 69 70 struct SelfAssignChecker {71 void previsit( ApplicationExpr * appExpr );72 };73 74 70 struct InsertImplicitCalls : public WithTypeSubstitution { 75 71 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 239 235 240 236 void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) { 241 PassVisitor<SelfAssignChecker> checker;242 acceptAll( translationUnit, checker );243 244 237 // fixes ConstructorInit for global variables. should happen before fixInitializers. 245 238 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); … … 316 309 PassVisitor<FixCtorExprs> fixer; 317 310 mutateAll( translationUnit, fixer ); 318 }319 320 namespace {321 // Relatively simple structural comparison for expressions, needed to determine322 // 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 qualify334 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 out340 return dynamic_cast< T * >( stripCasts( node ) );341 }342 343 // ignore casts344 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 }395 311 } 396 312 … … 634 550 // add destructors after current statement 635 551 for ( Expression * dtor : dtors ) { 636 // take relevant bindings from environment637 assert( ! dtor->env );638 dtor->env = TypeSubstitution::newFromExpr( dtor, impCpCtorExpr->env );639 552 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 640 553 } // for -
src/Makefile.in
r3d97b78 r2701c91 247 247 SynTree/driver_cfa_cpp-TypeDecl.$(OBJEXT) \ 248 248 SynTree/driver_cfa_cpp-Initializer.$(OBJEXT) \ 249 SynTree/driver_cfa_cpp-Visitor.$(OBJEXT) \ 250 SynTree/driver_cfa_cpp-Mutator.$(OBJEXT) \ 249 251 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 250 252 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ … … 525 527 SynTree/FunctionDecl.cc SynTree/AggregateDecl.cc \ 526 528 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 531 534 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 532 535 ${cfa_cpplib_PROGRAMS}} … … 908 911 SynTree/driver_cfa_cpp-Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \ 909 912 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) 910 917 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT): \ 911 918 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) … … 1046 1053 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionType.Po@am__quote@ 1047 1054 @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@ 1048 1056 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-NamedTypeDecl.Po@am__quote@ 1049 1057 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ObjectDecl.Po@am__quote@ … … 1061 1069 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 1062 1070 @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@ 1063 1072 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 1064 1073 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ … … 2469 2478 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2470 2479 @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` 2471 2508 2472 2509 SynTree/driver_cfa_cpp-TypeSubstitution.o: SynTree/TypeSubstitution.cc -
src/SynTree/Mutator.h
r3d97b78 r2701c91 22 22 class Mutator { 23 23 protected: 24 Mutator() = default;25 virtual ~Mutator() = default;24 Mutator(); 25 virtual ~Mutator(); 26 26 public: 27 27 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) = 0; -
src/SynTree/TypeSubstitution.cc
r3d97b78 r2701c91 104 104 bool TypeSubstitution::empty() const { 105 105 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 variables114 if ( Type * t = env->lookup( tyDecl->name ) ) {115 newEnv->add( tyDecl->name, t );116 }117 }118 };119 } // namespace120 121 /// reduce environment to just the parts that are referenced in a given expression122 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;130 106 } 131 107 -
src/SynTree/TypeSubstitution.h
r3d97b78 r2701c91 54 54 template< typename TypeInstListIterator > 55 55 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 expr58 static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env );59 56 60 57 void normalize(); -
src/SynTree/Visitor.h
r3d97b78 r2701c91 21 21 class Visitor { 22 22 protected: 23 Visitor() = default;24 virtual ~Visitor() = default;23 Visitor(); 24 virtual ~Visitor(); 25 25 public: 26 26 // visit: Default implementation of all functions visits the children -
src/SynTree/module.mk
r3d97b78 r2701c91 46 46 SynTree/TypeDecl.cc \ 47 47 SynTree/Initializer.cc \ 48 SynTree/Visitor.cc \ 49 SynTree/Mutator.cc \ 48 50 SynTree/TypeSubstitution.cc \ 49 51 SynTree/Attribute.cc \ -
src/libcfa/concurrency/kernel.c
r3d97b78 r2701c91 171 171 __cfaabi_dbg_print_safe("Kernel : core %p signaling termination\n", &this); 172 172 terminate(&this); 173 verify(this.do_terminate);174 verify(this_processor != &this);175 173 P( terminated ); 176 verify(this_processor != &this);177 174 pthread_join( kernel_thread, NULL ); 178 175 } -
src/tests/.expect/KRfunctions.x86.txt
r3d97b78 r2701c91 82 82 signed int __a__i_2; 83 83 signed int __b__i_2; 84 signed int *(*_tmp_cp_ret 2)(signed int __x__i_1, signed int __y__i_1);85 ((void)(__x__PFPi_ii__2=(((void)(_tmp_cp_ret 2=__f10__FPFPi_ii__iPiPid__1(3, (&__a__i_2), (&__b__i_2), 3.5))) , _tmp_cp_ret2)));86 ((void)(_tmp_cp_ret 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) /* ^?{} */); 87 87 const signed int __f1__FCi_iPiPi__2(signed int __a__i_2, signed int *__b__Pi_2, signed int *__c__Pi_2){ 88 88 __attribute__ ((unused)) const signed int ___retval_f1__Ci_2; -
src/tests/Makefile.am
r3d97b78 r2701c91 123 123 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 124 124 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 800 800 ${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@} 801 801 802 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@803 ${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@}804 echo > ${@}805 806 802 # Tell versions [3.59,3.63) of GNU make to not export all variables. 807 803 # Otherwise a system limit (for SysV at least) may be exceeded. -
tools/busy.c
r3d97b78 r2701c91 1 1 #include <stdbool.h> 2 #include <stdio.h>3 2 #include <stdlib.h> 4 3 #include <pthread.h> … … 32 31 } 33 32 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 } 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 } 57 39 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 } 63 44 }
Note:
See TracChangeset
for help on using the changeset viewer.