Changeset 57acae0


Ignore:
Timestamp:
Apr 23, 2018, 3:04:15 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
9d5fb67
Parents:
da7fe39
git-author:
Rob Schluntz <rschlunt@…> (04/23/18 15:02:59)
git-committer:
Rob Schluntz <rschlunt@…> (04/23/18 15:04:15)
Message:

Update condition for adding cast to address-of-reference, update debug prints

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Lvalue.cc

    rda7fe39 r57acae0  
    1717#include <string>                        // for string
    1818
    19 #include "Common/Debug.h"
    2019#include "Common/PassVisitor.h"
    2120#include "GenPoly.h"                     // for isPolyType
     
    129128                PassVisitor<AddrRef> addrRef;
    130129                PassVisitor<FixIntrinsicResult> intrinsicResults;
    131                 Debug::codeGen( translationUnit, "begin" );
    132130                mutateAll( translationUnit, intrinsicResults );
    133                 Debug::codeGen( translationUnit, "intrinsicResults" );
    134131                mutateAll( translationUnit, addrRef );
    135                 Debug::codeGen( translationUnit, "addrRef" );
    136132                mutateAll( translationUnit, refCvt );
    137                 Debug::codeGen( translationUnit, "refCvt" );
    138133                mutateAll( translationUnit, fixer );
    139                 Debug::codeGen( translationUnit, "fixer" );
    140134                mutateAll( translationUnit, collapser );
    141                 Debug::codeGen( translationUnit, "collapser" );
    142135                mutateAll( translationUnit, genLval );
    143                 Debug::codeGen( translationUnit, "genLval" );
    144136                mutateAll( translationUnit, elim );  // last because other passes need reference types to work
    145                 Debug::codeGen( translationUnit, "elim" );
    146137
    147138                // from this point forward, no other pass should create reference types.
     
    310301                                }
    311302
    312                                 if ( addCast ) {
    313                                         PRINT( std::cerr << "adding cast..." << std::endl; )
     303                                // if addrExpr depth is 0, then the result is a pointer because the arg was depth 1 and not lvalue.
     304                                // This means the dereference result is not a reference, is lvalue, and one less pointer depth than
     305                                // the addrExpr. Thus the cast is meaningless.
     306                                // TODO: One thing to double check is whether it is possible for the types to differ outside of the single
     307                                // pointer level (i.e. can the base type of addrExpr differ from the type of addrExpr-arg?).
     308                                // If so then the cast might need to be added, conditional on a more sophisticated check.
     309                                if ( addCast && addrExpr->result->referenceDepth() != 0 ) {
     310                                        PRINT( std::cerr << "adding cast to " << addrExpr->result << std::endl; )
    314311                                        return new CastExpr( ret, addrExpr->result->clone() );
    315312                                }
  • src/InitTweak/InitTweak.cc

    rda7fe39 r57acae0  
    520520
    521521        ApplicationExpr * createBitwiseAssignment( Expression * dst, Expression * src ) {
    522                 std::cerr << "=== createBitwiseAssignment ===" << std::endl;
    523                 std::cerr << "== dst: " << dst << std::endl;
    524                 std::cerr << "== src: " << src << std::endl;
    525 
    526522                static FunctionDecl * assign = nullptr;
    527523                if ( ! assign ) {
     
    544540                        // src = new CastExpr( src, new ReferenceType( noQualifiers, src->result->stripReferences()->clone() ) );
    545541                }
    546                 std::cerr << "============= endl : " << std::endl;
    547                 std::cerr << "-- dst: " << dst << std::endl;
    548                 std::cerr << "-- src: " << src << std::endl;
    549542                return new ApplicationExpr( VariableExpr::functionPointer( assign ), { dst, src } );
    550543        }
Note: See TracChangeset for help on using the changeset viewer.