Changeset 3d97b78
- Timestamp:
- Mar 1, 2018, 6:12:05 PM (7 years ago)
- 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. - Files:
-
- 2 added
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/PassVisitor.impl.h
r2701c91 r3d97b78 2277 2277 } 2278 2278 2279 2279 //-------------------------------------------------------------------------- 2280 // TupleType 2280 2281 template< typename pass_type > 2281 2282 void 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 2292 template< typename pass_type > 2293 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 2285 2305 template< typename pass_type > 2286 2306 void 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 2315 template< typename pass_type > 2316 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 2290 2327 template< typename pass_type > 2291 2328 void 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 2342 template< typename pass_type > 2343 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 2295 2359 template< typename pass_type > 2296 2360 void 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 2368 template< typename pass_type > 2369 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 2300 2379 template< typename pass_type > 2301 2380 void 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 2388 template< typename pass_type > 2389 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 2305 2399 template< typename pass_type > 2306 2400 void 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 2408 template< typename pass_type > 2409 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 2310 2419 template< typename pass_type > 2311 2420 void PassVisitor< pass_type >::visit( Designation * node ) { 2312 2421 VISIT_START( node ); 2313 2422 2314 maybeAccept_impl( node-> get_designators(), *this );2423 maybeAccept_impl( node->designators, *this ); 2315 2424 2316 2425 VISIT_END( node ); … … 2321 2430 MUTATE_START( node ); 2322 2431 2323 maybeMutate_impl( node-> get_designators(), *this );2432 maybeMutate_impl( node->designators, *this ); 2324 2433 2325 2434 MUTATE_END( Designation, node ); … … 2332 2441 VISIT_START( node ); 2333 2442 2334 visitExpression( node-> get_value());2443 visitExpression( node->value ); 2335 2444 2336 2445 VISIT_END( node ); … … 2341 2450 MUTATE_START( node ); 2342 2451 2343 node-> set_value( mutateExpression( node->get_value() ));2452 node->value = mutateExpression( node->value ); 2344 2453 2345 2454 MUTATE_END( Initializer, node ); 2346 2455 } 2347 2456 2457 //-------------------------------------------------------------------------- 2458 // ListInit 2348 2459 template< typename pass_type > 2349 2460 void 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 2469 template< typename pass_type > 2470 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 2353 2481 template< typename pass_type > 2354 2482 void 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 2492 template< typename pass_type > 2493 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 2358 2505 template< typename pass_type > 2359 2506 void PassVisitor< pass_type >::visit( Subrange * node ) { 2360 VISIT_BODY( node ); 2361 } 2362 2507 VISIT_START( node ); 2508 2509 VISIT_END( node ); 2510 } 2511 2512 template< typename pass_type > 2513 Subrange * PassVisitor< pass_type >::mutate( Subrange * node ) { 2514 MUTATE_START( node ); 2515 2516 MUTATE_END( Subrange, node ); 2517 } 2518 2519 //-------------------------------------------------------------------------- 2520 // Attribute 2363 2521 template< typename pass_type > 2364 2522 void PassVisitor< pass_type >::visit( Constant * node ) { 2365 VISIT_BODY( node ); 2366 } 2367 2523 VISIT_START( node ); 2524 2525 VISIT_END( node ); 2526 } 2527 2528 template< typename pass_type > 2529 Constant * PassVisitor< pass_type >::mutate( Constant * node ) { 2530 MUTATE_START( node ); 2531 2532 MUTATE_END( Constant, node ); 2533 } 2534 2535 //-------------------------------------------------------------------------- 2536 // Attribute 2368 2537 template< typename pass_type > 2369 2538 void 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 ); 2423 2544 } 2424 2545 2425 2546 template< typename pass_type > 2426 2547 Attribute * 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 2430 2557 template< typename pass_type > 2431 2558 TypeSubstitution * PassVisitor< pass_type >::mutate( TypeSubstitution * node ) { -
src/Common/SemanticError.cc
r2701c91 r3d97b78 14 14 // 15 15 16 #include <cstdarg> 16 17 #include <cstdio> // for fileno, stderr 17 18 #include <unistd.h> // for isatty … … 50 51 } 51 52 52 void SemanticWarningImpl( CodeLocation location, std::string msg ) { 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); 53 75 std::cerr << ErrorHelpers::bold() << location << ErrorHelpers::warning_str() << ErrorHelpers::reset_font() << msg << std::endl; 54 76 } -
src/Common/SemanticError.h
r2701c91 r3d97b78 37 37 38 38 constexpr const char * const WarningFormats[] = { 39 39 "self assignment of expression: %s", 40 40 }; 41 41 42 42 enum class Warning { 43 SelfAssignment, 43 44 NUMBER_OF_WARNINGS, //This MUST be the last warning 44 45 }; … … 49 50 ); 50 51 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__) 52 53 53 54 void SemanticWarningImpl (CodeLocation loc, Warning warn, const char * const fmt, ...) __attribute__((format(printf, 3, 4))); -
src/Common/utility.h
r2701c91 r3d97b78 162 162 } 163 163 164 #define toCString( ... ) toString( __VA_ARGS__ ).c_str() 165 164 166 // replace element of list with all elements of another list 165 167 template< typename T > -
src/GenPoly/Specialize.cc
r2701c91 r3d97b78 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 variables207 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 expression214 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 224 202 /// Generates a thunk that calls `actual` with type `funType` and returns its address 225 203 Expression * Specialize::createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams ) { … … 265 243 } 266 244 267 appExpr-> set_env( trimEnv( appExpr, env ));245 appExpr->env = TypeSubstitution::newFromExpr( appExpr, env ); 268 246 if ( inferParams ) { 269 247 appExpr->get_inferParams() = *inferParams; -
src/InitTweak/FixInit.cc
r2701c91 r3d97b78 68 68 typedef std::unordered_map< int, int > UnqCount; 69 69 70 struct SelfAssignChecker { 71 void previsit( ApplicationExpr * appExpr ); 72 }; 73 70 74 struct InsertImplicitCalls : public WithTypeSubstitution { 71 75 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which … … 235 239 236 240 void fix( std::list< Declaration * > & translationUnit, const std::string & filename, bool inLibrary ) { 241 PassVisitor<SelfAssignChecker> checker; 242 acceptAll( translationUnit, checker ); 243 237 244 // fixes ConstructorInit for global variables. should happen before fixInitializers. 238 245 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); … … 309 316 PassVisitor<FixCtorExprs> fixer; 310 317 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 } 311 395 } 312 396 … … 550 634 // add destructors after current statement 551 635 for ( Expression * dtor : dtors ) { 636 // take relevant bindings from environment 637 assert( ! dtor->env ); 638 dtor->env = TypeSubstitution::newFromExpr( dtor, impCpCtorExpr->env ); 552 639 stmtsToAddAfter.push_back( new ExprStmt( dtor ) ); 553 640 } // for -
src/Makefile.in
r2701c91 r3d97b78 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) \251 249 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT) \ 252 250 SynTree/driver_cfa_cpp-Attribute.$(OBJEXT) \ … … 527 525 SynTree/FunctionDecl.cc SynTree/AggregateDecl.cc \ 528 526 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 534 531 MAINTAINERCLEANFILES = Parser/parser.output ${libdir}/${notdir \ 535 532 ${cfa_cpplib_PROGRAMS}} … … 911 908 SynTree/driver_cfa_cpp-Initializer.$(OBJEXT): SynTree/$(am__dirstamp) \ 912 909 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)917 910 SynTree/driver_cfa_cpp-TypeSubstitution.$(OBJEXT): \ 918 911 SynTree/$(am__dirstamp) SynTree/$(DEPDIR)/$(am__dirstamp) … … 1053 1046 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-FunctionType.Po@am__quote@ 1054 1047 @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@1056 1048 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-NamedTypeDecl.Po@am__quote@ 1057 1049 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ObjectDecl.Po@am__quote@ … … 1069 1061 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VarArgsType.Po@am__quote@ 1070 1062 @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@1072 1063 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-VoidType.Po@am__quote@ 1073 1064 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/driver_cfa_cpp-ZeroOneType.Po@am__quote@ … … 2478 2469 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2479 2470 @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.cc2482 @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.cc2483 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Visitor.Po2484 @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.cc2487 2488 SynTree/driver_cfa_cpp-Visitor.obj: SynTree/Visitor.cc2489 @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.Po2491 @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.cc2496 @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.cc2497 @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Tpo SynTree/$(DEPDIR)/driver_cfa_cpp-Mutator.Po2498 @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.cc2501 2502 SynTree/driver_cfa_cpp-Mutator.obj: SynTree/Mutator.cc2503 @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.Po2505 @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`2508 2471 2509 2472 SynTree/driver_cfa_cpp-TypeSubstitution.o: SynTree/TypeSubstitution.cc -
src/SynTree/Mutator.h
r2701c91 r3d97b78 22 22 class Mutator { 23 23 protected: 24 Mutator() ;25 virtual ~Mutator() ;24 Mutator() = default; 25 virtual ~Mutator() = default; 26 26 public: 27 27 virtual DeclarationWithType * mutate( ObjectDecl * objectDecl ) = 0; -
src/SynTree/TypeSubstitution.cc
r2701c91 r3d97b78 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 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; 106 130 } 107 131 -
src/SynTree/TypeSubstitution.h
r2701c91 r3d97b78 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 expr 58 static TypeSubstitution * newFromExpr( Expression * expr, TypeSubstitution * env ); 56 59 57 60 void normalize(); -
src/SynTree/Visitor.h
r2701c91 r3d97b78 21 21 class Visitor { 22 22 protected: 23 Visitor() ;24 virtual ~Visitor() ;23 Visitor() = default; 24 virtual ~Visitor() = default; 25 25 public: 26 26 // visit: Default implementation of all functions visits the children -
src/SynTree/module.mk
r2701c91 r3d97b78 46 46 SynTree/TypeDecl.cc \ 47 47 SynTree/Initializer.cc \ 48 SynTree/Visitor.cc \49 SynTree/Mutator.cc \50 48 SynTree/TypeSubstitution.cc \ 51 49 SynTree/Attribute.cc \ -
src/libcfa/concurrency/kernel.c
r2701c91 r3d97b78 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); 173 175 P( terminated ); 176 verify(this_processor != &this); 174 177 pthread_join( kernel_thread, NULL ); 175 178 } -
src/tests/.expect/KRfunctions.x86.txt
r2701c91 r3d97b78 82 82 signed int __a__i_2; 83 83 signed int __b__i_2; 84 signed int *(*_tmp_cp_ret 0)(signed int __x__i_1, signed int __y__i_1);85 ((void)(__x__PFPi_ii__2=(((void)(_tmp_cp_ret 0=__f10__FPFPi_ii__iPiPid__1(3, (&__a__i_2), (&__b__i_2), 3.5))) , _tmp_cp_ret0)));86 ((void)(_tmp_cp_ret 0) /* ^?{} */);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) /* ^?{} */); 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
r2701c91 r3d97b78 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
r2701c91 r3d97b78 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 802 806 # Tell versions [3.59,3.63) of GNU make to not export all variables. 803 807 # Otherwise a system limit (for SysV at least) may be exceeded. -
tools/busy.c
r2701c91 r3d97b78 1 1 #include <stdbool.h> 2 #include <stdio.h> 2 3 #include <stdlib.h> 3 4 #include <pthread.h> … … 31 32 } 32 33 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 } 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 } 39 57 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; 44 63 }
Note: See TracChangeset
for help on using the changeset viewer.