Changes in src/Tuples/TupleExpansion.cc [9939dc3:07de76b]
- File:
-
- 1 edited
-
src/Tuples/TupleExpansion.cc (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansion.cc
r9939dc3 r07de76b 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue May 17 15:02:00 202213 // Update Count : 2 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 13 23:45:51 2019 13 // Update Count : 24 14 14 // 15 15 … … 323 323 std::vector<ast::ptr<ast::Type>> types; 324 324 ast::CV::Qualifiers quals{ 325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | 325 ast::CV::Const | ast::CV::Volatile | ast::CV::Restrict | ast::CV::Lvalue | 326 326 ast::CV::Atomic | ast::CV::Mutex }; 327 327 … … 366 366 } 367 367 return nullptr; 368 } 369 370 namespace { 371 /// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure 372 struct ImpurityDetector : public WithShortCircuiting { 373 ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {} 374 375 void previsit( const ApplicationExpr * appExpr ) { 376 visit_children = false; 377 if ( const DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) { 378 if ( function->linkage == LinkageSpec::Intrinsic ) { 379 if ( function->name == "*?" || function->name == "?[?]" ) { 380 // intrinsic dereference, subscript are pure, but need to recursively look for impurity 381 visit_children = true; 382 return; 383 } 384 } 385 } 386 maybeImpure = true; 387 } 388 void previsit( const UntypedExpr * ) { maybeImpure = true; visit_children = false; } 389 void previsit( const UniqueExpr * ) { 390 if ( ignoreUnique ) { 391 // bottom out at unique expression. 392 // The existence of a unique expression doesn't change the purity of an expression. 393 // That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression. 394 visit_children = false; 395 return; 396 } 397 } 398 399 bool maybeImpure = false; 400 bool ignoreUnique; 401 }; 402 } // namespace 403 404 bool maybeImpure( const Expression * expr ) { 405 PassVisitor<ImpurityDetector> detector( false ); 406 expr->accept( detector ); 407 return detector.pass.maybeImpure; 408 } 409 410 bool maybeImpureIgnoreUnique( const Expression * expr ) { 411 PassVisitor<ImpurityDetector> detector( true ); 412 expr->accept( detector ); 413 return detector.pass.maybeImpure; 368 414 } 369 415 } // namespace Tuples
Note:
See TracChangeset
for help on using the changeset viewer.