Ignore:
Timestamp:
Jun 2, 2022, 3:11:21 PM (3 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
ced5e2a
Parents:
015925a (diff), fc134a48 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansion.cc

    r015925a re5d9274  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:45:51 2019
    13 // Update Count     : 24
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue May 17 15:02:00 2022
     13// Update Count     : 25
    1414//
    1515
     
    367367                return nullptr;
    368368        }
    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;
    414         }
    415369} // namespace Tuples
    416370
Note: See TracChangeset for help on using the changeset viewer.