Changeset 19858f6 for src/SynTree


Ignore:
Timestamp:
Oct 4, 2019, 9:59:01 AM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
65e10b2
Parents:
970141d (diff), 73fad25 (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

Location:
src/SynTree
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AddressExpr.cc

    r970141d r19858f6  
    5353                        } // if
    5454                }
    55                 // result of & is never an lvalue
    56                 get_result()->set_lvalue( false );
    5755        }
    5856}
  • src/SynTree/ApplicationExpr.cc

    r970141d r19858f6  
    2525#include "Declaration.h"         // for Declaration
    2626#include "Expression.h"          // for ParamEntry, ApplicationExpr, Expression
     27#include "InitTweak/InitTweak.h" // for getFunction
    2728#include "ResolvExpr/typeops.h"  // for extractResultType
    2829#include "Type.h"                // for Type, PointerType, FunctionType
     
    7778
    7879bool ApplicationExpr::get_lvalue() const {
    79         return result->get_lvalue();
     80        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     81        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     82        if ( const DeclarationWithType * func = InitTweak::getFunction( this ) ) {
     83                return func->linkage == LinkageSpec::Intrinsic && lvalueFunctions.count(func->name);
     84        }
     85        return false;
    8086}
    8187
  • src/SynTree/ArrayType.cc

    r970141d r19858f6  
    2626ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes )
    2727        : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) {
    28         base->set_lvalue( false );
    2928}
    3029
  • src/SynTree/CommaExpr.cc

    r970141d r19858f6  
    2323CommaExpr::CommaExpr( Expression *arg1, Expression *arg2 )
    2424                : Expression(), arg1( arg1 ), arg2( arg2 ) {
    25         // xxx - result of a comma expression is never an lvalue, so should set lvalue
    26         // to false on all result types. Actually doing this causes some strange things
    27         // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    2825        set_result( maybeClone( arg2->get_result() ) );
    29         // get_type->set_isLvalue( false );
    3026}
    3127
     
    4036
    4137bool CommaExpr::get_lvalue() const {
    42         // xxx - as above, shouldn't be an lvalue but that information is used anyways.
    43         return result->get_lvalue();
     38        // This is wrong by C, but the current implementation uses it.
     39        // (ex: Specialize, Lvalue and Box)
     40        return arg2->get_lvalue();
    4441}
    4542
  • src/SynTree/Expression.cc

    r970141d r19858f6  
    1919#include <iostream>                  // for ostream, operator<<, basic_ostream
    2020#include <list>                      // for list, _List_iterator, list<>::co...
     21#include <set>                       // for set
    2122
    2223#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     
    6465
    6566bool Expression::get_lvalue() const {
    66         assert( !result->get_lvalue() );
    6767        return false;
    6868}
     
    115115        assert( var->get_type() );
    116116        Type * type = var->get_type()->clone();
    117         type->set_lvalue( true );
    118117
    119118        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    125124        //      long long int value;
    126125        //      if ( decl->valueOf( var, value ) ) {
    127         //              type->set_lvalue( false );
     126        //              type->set_lvalue( false ); // Would have to move to get_lvalue.
    128127        //      }
    129128        // }
     
    140139
    141140bool VariableExpr::get_lvalue() const {
    142         return result->get_lvalue();
     141        // It isn't always an lvalue, but it is never an rvalue.
     142        return true;
    143143}
    144144
     
    277277
    278278bool CastExpr::get_lvalue() const {
    279         return result->get_lvalue();
     279        // This is actually wrong by C, but it works with our current set-up.
     280        return arg->get_lvalue();
    280281}
    281282
     
    360361}
    361362
     363bool UntypedMemberExpr::get_lvalue() const {
     364        return aggregate->get_lvalue();
     365}
     366
    362367void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    363368        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     
    378383        sub.apply( res );
    379384        result = res;
    380         result->set_lvalue( true );
    381385        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    382386}
     
    392396
    393397bool MemberExpr::get_lvalue() const {
    394         assert( result->get_lvalue() );
     398        // This is actually wrong by C, but it works with our current set-up.
    395399        return true;
    396400}
     
    427431                        // if references are still allowed in the AST, dereference returns a reference
    428432                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
    429                 } else {
    430                         // references have been removed, in which case dereference returns an lvalue of the base type.
    431                         ret->result->set_lvalue( true );
    432433                }
    433434        }
     
    447448
    448449bool UntypedExpr::get_lvalue() const {
    449         return result->get_lvalue();
     450        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     451        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     452        std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) );
     453        return lvalueFunctions.count(fname);
    450454}
    451455
     
    510514
    511515bool ConditionalExpr::get_lvalue() const {
    512         return result->get_lvalue();
     516        return false;
    513517}
    514518
     
    570574
    571575bool ConstructorExpr::get_lvalue() const {
    572         return result->get_lvalue();
     576        return false;
    573577}
    574578
     
    582586CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    583587        assert( type && initializer );
    584         type->set_lvalue( true );
    585588        set_result( type );
    586589}
     
    593596
    594597bool CompoundLiteralExpr::get_lvalue() const {
    595         assert( result->get_lvalue() );
    596598        return true;
    597599}
     
    648650}
    649651bool StmtExpr::get_lvalue() const {
    650         return result->get_lvalue();
     652        return false;
    651653}
    652654void StmtExpr::print( std::ostream & os, Indenter indent ) const {
  • src/SynTree/Expression.h

    r970141d r19858f6  
    275275        virtual ~UntypedMemberExpr();
    276276
     277        bool get_lvalue() const final;
     278
    277279        Expression * get_member() const { return member; }
    278280        void set_member( Expression * newValue ) { member = newValue; }
  • src/SynTree/TupleExpr.cc

    r970141d r19858f6  
    5858
    5959bool TupleExpr::get_lvalue() const {
    60         return result->get_lvalue();
     60        return false;
    6161}
    6262
     
    7171        assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() );
    7272        set_result( (*std::next( type->get_types().begin(), index ))->clone() );
    73         // like MemberExpr, TupleIndexExpr is always an lvalue
    74         get_result()->set_lvalue( true );
    7573}
    7674
     
    8381
    8482bool TupleIndexExpr::get_lvalue() const {
    85         assert( result->get_lvalue() );
    86         return true;
     83        return tuple->get_lvalue();
    8784}
    8885
  • src/SynTree/Type.cc

    r970141d r19858f6  
    8585const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
    8686const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
    87 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
     87const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" };
    8888
    8989Type * Type::stripDeclarator() {
  • src/SynTree/Type.h

    r970141d r19858f6  
    102102        }; // StorageClasses
    103103
    104         enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
     104        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Mutex = 1 << 3, Atomic = 1 << 4, NumTypeQualifier = 5 };
    105105        static const char * QualifiersNames[];
    106106        union Qualifiers {
    107                 enum { Mask = ~(Restrict | Lvalue) };
     107                enum { Mask = ~Restrict };
    108108                unsigned int val;
    109109                struct {
     
    111111                        bool is_restrict : 1;
    112112                        bool is_volatile : 1;
    113                         bool is_lvalue : 1;
    114113                        bool is_mutex : 1;
    115114                        bool is_atomic : 1;
     
    153152        bool get_volatile() const { return tq.is_volatile; }
    154153        bool get_restrict() const { return tq.is_restrict; }
    155         bool get_lvalue() const { return tq.is_lvalue; }
    156154        bool get_mutex() const { return tq.is_mutex; }
    157155        bool get_atomic() const { return tq.is_atomic; }
     
    159157        void set_volatile( bool newValue ) { tq.is_volatile = newValue; }
    160158        void set_restrict( bool newValue ) { tq.is_restrict = newValue; }
    161         void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; }
    162159        void set_mutex( bool newValue ) { tq.is_mutex = newValue; }
    163160        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
  • src/SynTree/module.mk

    r970141d r19858f6  
    4949      SynTree/TypeSubstitution.cc \
    5050      SynTree/Attribute.cc \
    51       SynTree/DeclReplacer.cc \
    52       SynTree/TopLvalue.cc
     51      SynTree/DeclReplacer.cc
    5352
    5453SRC += $(SRC_SYNTREE)
Note: See TracChangeset for help on using the changeset viewer.