Changeset be8bd88 for src/SymTab


Ignore:
Timestamp:
Mar 8, 2017, 3:22:50 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
031a2c95, 0e7ea335
Parents:
87c3bef (diff), 6363ad1 (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/SymTab
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r87c3bef rbe8bd88  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 15:02:50 2017
    13 // Update Count     : 13
     12// Last Modified On : Tue Mar  7 07:42:44 2017
     13// Update Count     : 51
    1414//
    1515
     
    125125        FunctionType * genDefaultType( Type * paramType ) {
    126126                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    127                 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );
     127                ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr );
    128128                ftype->get_parameters().push_back( dstParam );
    129129
     
    134134        FunctionType * genCopyType( Type * paramType ) {
    135135                FunctionType *ftype = genDefaultType( paramType );
    136                 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
     136                ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    137137                ftype->get_parameters().push_back( srcParam );
    138138                return ftype;
     
    142142        FunctionType * genAssignType( Type * paramType ) {
    143143                FunctionType *ftype = genCopyType( paramType );
    144                 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
     144                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    145145                ftype->get_returnVals().push_back( returnVal );
    146146                return ftype;
     
    161161                // Routines at global scope marked "static" to prevent multiple definitions in separate translation units
    162162                // because each unit generates copies of the default routines for each aggregate.
    163                 DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static;
     163//              DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static;
     164                DeclarationNode::StorageClasses scs = functionNesting > 0 ? DeclarationNode::StorageClasses() : DeclarationNode::StorageClasses( DeclarationNode::StaticClass );
    164165                LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen;
    165                 FunctionDecl * decl = new FunctionDecl( fname, sc, spec, ftype, new CompoundStmt( noLabels ), true, false );
     166                FunctionDecl * decl = new FunctionDecl( fname, scs, spec, ftype, new CompoundStmt( noLabels ),
     167                                                                                                std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) );
    166168                decl->fixUniqueId();
    167169                return decl;
     
    458460                                        continue;
    459461                                }
    460                                 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );
     462                                memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );
    461463                                FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    462464                                makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout );
     
    538540                for ( Declaration * member : aggregateDecl->get_members() ) {
    539541                        if ( DeclarationWithType * field = dynamic_cast< DeclarationWithType * >( member ) ) {
    540                                 ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );
     542                                ObjectDecl * srcParam = new ObjectDecl( "src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, field->get_type()->clone(), 0 );
    541543
    542544                                FunctionType * memCtorType = ctorType->clone();
     
    603605                TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
    604606                typeInst->set_baseType( typeDecl );
    605                 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr );
    606                 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr );
     607                ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr );
     608                ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr );
    607609
    608610                std::list< Statement * > stmts;
     
    616618                } // if
    617619                FunctionType *type = new FunctionType( Type::Qualifiers(), false );
    618                 type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst, 0 ) );
     620                type->get_returnVals().push_back( new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, typeInst, 0 ) );
    619621                type->get_parameters().push_back( dst );
    620622                type->get_parameters().push_back( src );
     
    715717                        if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) {
    716718                                if ( ! done.count( ty->get_baseType() ) ) {
    717                                         TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any );
     719                                        TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::StorageClasses(), nullptr, TypeDecl::Any );
    718720                                        TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl );
    719                                         newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genAssignType( inst ), nullptr, true, false ) );
    720                                         newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) );
    721                                         newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genCopyType( inst ), nullptr, true, false ) );
    722                                         newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) );
     721                                        newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genAssignType( inst ), nullptr,
     722                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     723                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
     724                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     725                                        newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genCopyType( inst ), nullptr,
     726                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
     727                                        newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, genDefaultType( inst ), nullptr,
     728                                                                                                                                                   std::list< Attribute * >(), DeclarationNode::FuncSpecifiers( DeclarationNode::InlineSpec ) ) );
    723729                                        typeParams.push_back( newDecl );
    724730                                        done.insert( ty->get_baseType() );
  • src/SymTab/Autogen.h

    r87c3bef rbe8bd88  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Feb  1 16:31:00 2017
    13 // Update Count     : 2
     12// Last Modified On : Mon Mar  6 23:33:01 2017
     13// Update Count     : 4
    1414//
    1515
     
    102102                }
    103103
    104                 ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
     104                ObjectDecl *index = new ObjectDecl( indexName.newName(), DeclarationNode::StorageClasses(), LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::SignedInt ), new SingleInit( begin, std::list<Expression*>() ) );
    105105
    106106                UntypedExpr *cond = new UntypedExpr( cmp );
  • src/SymTab/FixFunction.cc

    r87c3bef rbe8bd88  
    1010// Created On       : Sun May 17 16:19:49 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:31:10 2016
    13 // Update Count     : 3
     12// Last Modified On : Mon Mar  6 23:36:59 2017
     13// Update Count     : 6
    1414//
    1515
     
    2121
    2222namespace SymTab {
    23         FixFunction::FixFunction() : isVoid( false ) {
    24         }
     23        FixFunction::FixFunction() : isVoid( false ) {}
    2524
    2625        DeclarationWithType * FixFunction::mutate(FunctionDecl *functionDecl) {
    27                 ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );
     26                ObjectDecl *pointer = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClasses(), functionDecl->get_linkage(), 0, new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0, functionDecl->get_attributes() );
    2827                functionDecl->get_attributes().clear();
    2928                delete functionDecl;
  • src/SymTab/Indexer.cc

    r87c3bef rbe8bd88  
    1010// Created On       : Sun May 17 21:37:33 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 16 14:59:19 2017
    13 // Update Count     : 13
     12// Last Modified On : Tue Mar  7 07:45:32 2017
     13// Update Count     : 16
    1414//
    1515
     
    738738                                ObjectDecl *newobj = dynamic_cast< ObjectDecl* >( added );
    739739                                ObjectDecl *oldobj = dynamic_cast< ObjectDecl* >( existing );
    740                                 if ( newobj->get_storageClass() != DeclarationNode::Extern && oldobj->get_storageClass() != DeclarationNode::Extern ) {
     740                                if ( ! newobj->get_storageClasses()[ DeclarationNode::Extern ] && ! oldobj->get_storageClasses()[ DeclarationNode::Extern ] ) {
    741741                                        throw SemanticError( "duplicate object definition for ", added );
    742742                                } // if
  • src/SymTab/Validate.cc

    r87c3bef rbe8bd88  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 23 21:33:55 2017
    13 // Update Count     : 318
     12// Last Modified On : Tue Mar  7 07:51:36 2017
     13// Update Count     : 349
    1414//
    1515
     
    9797        class ReturnTypeFixer final : public Visitor {
    9898          public:
    99 
    10099                typedef Visitor Parent;
    101100                using Parent::visit;
     
    104103
    105104                virtual void visit( FunctionDecl * functionDecl );
    106 
    107105                virtual void visit( FunctionType * ftype );
    108106        };
     
    161159          private:
    162160                virtual void visit( FunctionDecl * functionDecl );
    163 
    164161                virtual void visit( ReturnStmt * returnStmt );
    165162
     
    211208
    212209        class CompoundLiteral final : public GenPoly::DeclMutator {
    213                 DeclarationNode::StorageClass storageclass = DeclarationNode::NoStorageClass;
     210                DeclarationNode::StorageClasses storageClasses;
    214211
    215212                using GenPoly::DeclMutator::mutate;
     
    660657                // Note, qualifiers on the typedef are superfluous for the forward declaration.
    661658                if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) {
    662                         return aggDecl->get_baseStruct() ? Mutator::mutate( aggDecl->get_baseStruct() ) : new StructDecl( aggDecl->get_name() );
     659                        return new StructDecl( aggDecl->get_name() );
    663660                } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) {
    664                         return aggDecl->get_baseUnion() ? Mutator::mutate( aggDecl->get_baseUnion() ) : new UnionDecl( aggDecl->get_name() );
     661                        return new UnionDecl( aggDecl->get_name() );
    665662                } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) {
    666663                        return new EnumDecl( enumDecl->get_name() );
     
    691688                DeclarationWithType *ret = Mutator::mutate( objDecl );
    692689                typedefNames.endScope();
    693                 // is the type a function?
    694                 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) {
     690
     691                if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { // function type?
    695692                        // replace the current object declaration with a function declaration
    696                         FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn(), objDecl->get_attributes() );
     693                        FunctionDecl * newDecl = new FunctionDecl( ret->get_name(), ret->get_storageClasses(), ret->get_linkage(), funtype, 0, objDecl->get_attributes(), ret->get_funcSpec() );
    697694                        objDecl->get_attributes().clear();
    698695                        objDecl->set_type( nullptr );
    699696                        delete objDecl;
    700697                        return newDecl;
    701                 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) {
    702                         throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl );
    703698                } // if
    704699                return ret;
     
    759754                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    760755                        } // if
    761                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::NoStorageClass, type ) );
     756                        TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), DeclarationNode::StorageClasses(), type ) );
    762757                        typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
    763758                } // if
     
    813808
    814809        DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) {
    815                 storageclass = objectDecl->get_storageClass();
     810                storageClasses = objectDecl->get_storageClasses();
    816811                DeclarationWithType * temp = Mutator::mutate( objectDecl );
    817                 storageclass = DeclarationNode::NoStorageClass;
    818812                return temp;
    819813        }
     
    824818                static UniqueName indexName( "_compLit" );
    825819
    826                 ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageclass, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );
     820                ObjectDecl *tempvar = new ObjectDecl( indexName.newName(), storageClasses, LinkageSpec::C, 0, compLitExpr->get_type(), compLitExpr->get_initializer() );
    827821                compLitExpr->set_type( 0 );
    828822                compLitExpr->set_initializer( 0 );
     
    863857                        TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) );
    864858                        // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false.
    865                         ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
     859                        ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::StorageClasses(), LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );
    866860                        deleteAll( retVals );
    867861                        retVals.clear();
Note: See TracChangeset for help on using the changeset viewer.