| 345 | // make local |
| 346 | template <typename TT> |
| 347 | void preVisitMakeLocal ( ExprMakeLocal * expr, TT && collectAliasSources ) { |
| 348 | auto it = cmresDest.find(expr); |
| 349 | if ( it!=cmresDest.end() ) { |
| 350 | // left |
| 351 | auto resOut = it->second; |
| 352 | ExpressionSources resSrc; |
| 353 | if ( collectSources(program, resOut, resSrc, false, true) ) { |
| 354 | if ( checkAliasing ) { |
| 355 | program->error("[[" + string(expr->__rtti) + " ]] always aliases", |
| 356 | "some form of ... *ptr ... = [[" + string(expr->__rtti) + " ...]] where we don't know where pointer came from", "", |
| 357 | expr->at, CompilationError::invalid_expression); |
| 358 | } else { |
| 359 | expr->alwaysAlias = true; |
| 360 | } |
| 361 | return; |
| 362 | } |
| 363 | // check if there are any globals |
| 364 | bool anyGlobals = false; |
| 365 | for ( auto v : resSrc ) { |
| 366 | if ( v->global ) { |
| 367 | anyGlobals = true; |
| 368 | break; |
| 369 | } |
| 370 | } |
| 371 | // right |
| 372 | ExpressionSources argSrc; |
| 373 | if ( collectAliasSources(argSrc,anyGlobals) ) { |
| 374 | if ( checkAliasing ) { |
| 375 | program->error("[[" + string(expr->__rtti) + " ]] always aliases", |
| 376 | "some form of ... = [[" + string(expr->__rtti) + " ... *ptr ... ]] where we don't know where pointer came from", "", |
| 377 | expr->at, CompilationError::invalid_expression); |
| 378 | } else { |
| 379 | expr->alwaysAlias = true; |
| 380 | } |
| 381 | } else if ( auto aliasVar = intersectSources ( resSrc, argSrc ) ) { |
| 382 | if ( checkAliasing ) { |
| 383 | program->error("[[" + string(expr->__rtti) + " ]] aliases", |
| 384 | "some form of ... " + aliasVar->name + " ... = [[" + string(expr->__rtti) + " ... " + aliasVar->name + " ... ]]", "", |
| 385 | expr->at, CompilationError::invalid_expression); |
| 386 | } else { |
| 387 | expr->alwaysAlias = true; |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | virtual void preVisit ( ExprMakeArray * expr ) override { |
| 393 | Visitor::preVisit(expr); |
| 394 | preVisitMakeLocal(expr,[&](ExpressionSources & argSrc, bool anyGlobals) -> bool { |
nothing calls this directly
no test coverage detected