Changeset 4615ac8 for src


Ignore:
Timestamp:
Aug 7, 2019, 4:50:27 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
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:
2d80111, 8c63bb4
Parents:
9e72dbb7
Message:

Added asserts and clears to make sure lvalue is only used where we expect.

Location:
src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/Makefile.in

    r9e72dbb7 r4615ac8  
    231231        SynTree/Initializer.$(OBJEXT) \
    232232        SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \
    233         SynTree/DeclReplacer.$(OBJEXT)
     233        SynTree/DeclReplacer.$(OBJEXT) SynTree/TopLvalue.$(OBJEXT)
    234234am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \
    235235        $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \
     
    694694      SynTree/TypeSubstitution.cc \
    695695      SynTree/Attribute.cc \
    696       SynTree/DeclReplacer.cc
     696      SynTree/DeclReplacer.cc \
     697      SynTree/TopLvalue.cc
    697698
    698699
     
    10231024SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \
    10241025        SynTree/$(DEPDIR)/$(am__dirstamp)
     1026SynTree/TopLvalue.$(OBJEXT): SynTree/$(am__dirstamp) \
     1027        SynTree/$(DEPDIR)/$(am__dirstamp)
    10251028Tuples/$(am__dirstamp):
    10261029        @$(MKDIR_P) Tuples
     
    13331336@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ReferenceType.Po@am__quote@
    13341337@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Statement.Po@am__quote@
     1338@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TopLvalue.Po@am__quote@
    13351339@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleExpr.Po@am__quote@
    13361340@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleType.Po@am__quote@
  • src/SymTab/Validate.cc

    r9e72dbb7 r4615ac8  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 28 13:47:23 2017
    13 // Update Count     : 359
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  7 6:42:00 2019
     13// Update Count     : 360
    1414//
    1515
     
    8181#include "SynTree/Label.h"             // for operator==, Label
    8282#include "SynTree/Mutator.h"           // for Mutator
     83#include "SynTree/TopLvalue.h"         // for assertTopLvalue, clearInnerLvalue
    8384#include "SynTree/Type.h"              // for Type, TypeInstType, EnumInstType
    8485#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     
    308309                PassVisitor<FixQualifiedTypes> fixQual;
    309310
     311                assertTopLvalue( translationUnit );
    310312                {
    311313                        Stats::Heap::newPass("validate-A");
     
    316318                        acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling
    317319                }
     320                assertTopLvalue( translationUnit );
    318321                {
    319322                        Stats::Heap::newPass("validate-B");
    320323                        Stats::Time::BlockGuard guard("validate-B");
     324                        assertTopLvalue( translationUnit );
    321325                        Stats::Time::TimeBlock("Link Reference To Types", [&]() {
    322326                                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
    323327                        });
     328                        clearInnerLvalue( translationUnit );
     329                        assertTopLvalue( translationUnit );
    324330                        Stats::Time::TimeBlock("Fix Qualified Types", [&]() {
    325331                                mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed
    326332                        });
     333                        assertTopLvalue( translationUnit );
    327334                        Stats::Time::TimeBlock("Hoist Structs", [&]() {
    328335                                HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order
    329336                        });
     337                        assertTopLvalue( translationUnit );
    330338                        Stats::Time::TimeBlock("Eliminate Typedefs", [&]() {
    331339                                EliminateTypedef::eliminateTypedef( translationUnit ); //
    332340                        });
    333341                }
     342                assertTopLvalue( translationUnit );
    334343                {
    335344                        Stats::Heap::newPass("validate-C");
     
    340349                        InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
    341350                }
     351                assertTopLvalue( translationUnit );
    342352                {
    343353                        Stats::Heap::newPass("validate-D");
    344354                        Stats::Time::BlockGuard guard("validate-D");
     355                        assertTopLvalue( translationUnit );
    345356                        Stats::Time::TimeBlock("Apply Concurrent Keywords", [&]() {
    346357                                Concurrency::applyKeywords( translationUnit );
    347358                        });
     359                        clearInnerLvalue( translationUnit );
     360                        assertTopLvalue( translationUnit );
    348361                        Stats::Time::TimeBlock("Forall Pointer Decay", [&]() {
    349362                                acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
    350363                        });
     364                        assertTopLvalue( translationUnit );
    351365                        Stats::Time::TimeBlock("Hoist Control Declarations", [&]() {
    352366                                ControlStruct::hoistControlDecls( translationUnit );  // hoist initialization out of for statements; must happen before autogenerateRoutines
    353367                        });
     368                        assertTopLvalue( translationUnit );
    354369                        Stats::Time::TimeBlock("Generate Autogen routines", [&]() {
    355370                                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay_old
    356371                        });
    357                 }
     372                        clearInnerLvalue( translationUnit );
     373                }
     374                assertTopLvalue( translationUnit );
    358375                {
    359376                        Stats::Heap::newPass("validate-E");
    360377                        Stats::Time::BlockGuard guard("validate-E");
     378                        assertTopLvalue( translationUnit );
    361379                        Stats::Time::TimeBlock("Implement Mutex Func", [&]() {
    362380                                Concurrency::implementMutexFuncs( translationUnit );
    363381                        });
     382                        clearInnerLvalue( translationUnit );
     383                        assertTopLvalue( translationUnit );
    364384                        Stats::Time::TimeBlock("Implement Thread Start", [&]() {
    365385                                Concurrency::implementThreadStarter( translationUnit );
    366386                        });
     387                        assertTopLvalue( translationUnit );
    367388                        Stats::Time::TimeBlock("Compound Literal", [&]() {
    368389                                mutateAll( translationUnit, compoundliteral );
    369390                        });
     391                        assertTopLvalue( translationUnit );
    370392                        Stats::Time::TimeBlock("Resolve With Expressions", [&]() {
    371393                                ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables
    372394                        });
    373                 }
     395                        clearInnerLvalue( translationUnit );
     396                }
     397                assertTopLvalue( translationUnit );
    374398                {
    375399                        Stats::Heap::newPass("validate-F");
    376400                        Stats::Time::BlockGuard guard("validate-F");
     401                        assertTopLvalue( translationUnit );
    377402                        Stats::Time::TimeBlock("Fix Object Type", [&]() {
    378403                                FixObjectType::fix( translationUnit );
    379404                        });
     405                        assertTopLvalue( translationUnit );
    380406                        Stats::Time::TimeBlock("Array Length", [&]() {
    381407                                ArrayLength::computeLength( translationUnit );
    382408                        });
     409                        clearInnerLvalue( translationUnit );
     410                        assertTopLvalue( translationUnit );
    383411                        Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    384412                                Validate::findSpecialDecls( translationUnit );
    385413                        });
     414                        assertTopLvalue( translationUnit );
    386415                        Stats::Time::TimeBlock("Fix Label Address", [&]() {
    387416                                mutateAll( translationUnit, labelAddrFixer );
    388417                        });
     418                        assertTopLvalue( translationUnit );
    389419                        Stats::Time::TimeBlock("Handle Attributes", [&]() {
    390420                                Validate::handleAttributes( translationUnit );
    391421                        });
    392422                }
     423                assertTopLvalue( translationUnit );
    393424        }
    394425
  • src/SynTree/module.mk

    r9e72dbb7 r4615ac8  
    4949      SynTree/TypeSubstitution.cc \
    5050      SynTree/Attribute.cc \
    51       SynTree/DeclReplacer.cc
     51      SynTree/DeclReplacer.cc \
     52      SynTree/TopLvalue.cc
    5253
    5354SRC += $(SRC_SYNTREE)
  • src/main.cc

    r9e72dbb7 r4615ac8  
    5959#include "ResolvExpr/Resolver.h"            // for resolve
    6060#include "SymTab/Validate.h"                // for validate
     61#include "SynTree/TopLvalue.h"              // for assertTopLvalue, clearInn...
    6162#include "SynTree/Declaration.h"            // for Declaration
    6263#include "SynTree/Visitor.h"                // for acceptAll
    6364#include "Tuples/Tuples.h"                  // for expandMemberTuples, expan...
    6465#include "Virtual/ExpandCasts.h"            // for expandCasts
     66
    6567
    6668using namespace std;
     
    257259                Stats::Time::StopBlock();
    258260
     261                //std::cerr << "Post-Parse Check" << std::endl;
     262                clearInnerLvalue( translationUnit );
     263                assertTopLvalue( translationUnit );
     264
    259265                // add the assignment statement after the initialization of a type parameter
    260266                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
     
    275281                } // if
    276282
     283                assertTopLvalue( translationUnit );
    277284                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
     285                assertTopLvalue( translationUnit );
    278286                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
     287                assertTopLvalue( translationUnit );
    279288                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
     289                assertTopLvalue( translationUnit );
    280290                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
     291                assertTopLvalue( translationUnit );
    281292                if ( libcfap ) {
    282293                        // generate the bodies of cfa library functions
     
    302313                } // if
    303314
     315                assertTopLvalue( translationUnit );
     316
    304317                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    305318                if ( exprp ) {
     
    308321                } // if
    309322
     323                clearInnerLvalue( translationUnit );
     324                assertTopLvalue( translationUnit );
     325
    310326                // fix ObjectDecl - replaces ConstructorInit nodes
    311327                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
     328                clearInnerLvalue( translationUnit );
     329                assertTopLvalue( translationUnit );
    312330                if ( ctorinitp ) {
    313331                        dump ( translationUnit );
     
    316334
    317335                PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
     336                assertTopLvalue( translationUnit );
    318337
    319338                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
     339                assertTopLvalue( translationUnit );
    320340
    321341                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
     342                clearInnerLvalue( translationUnit );
     343                assertTopLvalue( translationUnit );
    322344
    323345                PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
     346                clearInnerLvalue( translationUnit );
     347                assertTopLvalue( translationUnit );
    324348
    325349                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
     350                assertTopLvalue( translationUnit );
    326351
    327352                if ( tuplep ) {
     
    331356
    332357                PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
     358                assertTopLvalue( translationUnit );
    333359
    334360                PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
     
    337363                        return EXIT_SUCCESS;
    338364                } // if
     365                clearInnerLvalue( translationUnit );
     366                assertTopLvalue( translationUnit );
    339367                PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
    340 
     368                clearInnerLvalue( translationUnit );
     369                assertTopLvalue( translationUnit );
    341370
    342371                if ( bboxp ) {
     
    345374                } // if
    346375                PASS( "Box", GenPoly::box( translationUnit ) );
     376                clearInnerLvalue( translationUnit );
     377                assertTopLvalue( translationUnit );
    347378
    348379                if ( bcodegenp ) {
     
    356387
    357388                CodeTools::fillLocations( translationUnit );
     389                assertTopLvalue( translationUnit );
    358390                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    359391
Note: See TracChangeset for help on using the changeset viewer.