Changeset 8d70648 for src/SymTab


Ignore:
Timestamp:
May 30, 2019, 4:15:08 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
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:
a935892, f474e91
Parents:
d76c588 (diff), d88f8b3b (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:
3 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rd76c588 r8d70648  
    4141
    4242namespace SymTab {
    43         Type * SizeType = 0;
    44 
    4543        /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
    4644        struct FuncData {
    47                 typedef FunctionType * (*TypeGen)( Type * );
     45                typedef FunctionType * (*TypeGen)( Type *, bool );
    4846                FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {}
    4947                std::string fname;
     
    231229
    232230        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    233         FunctionType * genDefaultType( Type * paramType ) {
    234                 const auto & typeParams = getGenericParams( paramType );
     231        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
    235232                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    236                 cloneAll( typeParams, ftype->forall );
     233                if ( maybePolymorphic ) {
     234                        // only copy in
     235                        const auto & typeParams = getGenericParams( paramType );
     236                        cloneAll( typeParams, ftype->forall );
     237                }
    237238                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    238239                ftype->parameters.push_back( dstParam );
     
    241242
    242243        /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
    243         FunctionType * genCopyType( Type * paramType ) {
    244                 FunctionType *ftype = genDefaultType( paramType );
     244        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
     245                FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
    245246                ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    246247                ftype->parameters.push_back( srcParam );
     
    249250
    250251        /// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
    251         FunctionType * genAssignType( Type * paramType ) {
    252                 FunctionType *ftype = genCopyType( paramType );
     252        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
     253                FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
    253254                ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    254255                ftype->returnVals.push_back( returnVal );
     
    308309                for ( const FuncData & d : data ) {
    309310                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    310                         FunctionType * ftype = d.genType( type );
     311                        FunctionType * ftype = d.genType( type, true );
    311312
    312313                        // destructor for concurrent type must be mutex
  • src/SymTab/Autogen.h

    rd76c588 r8d70648  
    3737        bool isUnnamedBitfield( ObjectDecl * obj );
    3838
    39         /// size_t type - set when size_t typedef is seen. Useful in a few places,
    40         /// such as in determining array dimension type
    41         extern Type * SizeType;
    42 
    43         /// intrinsic dereference operator for unqualified types - set when *? function is seen in FindSpecialDeclarations.
    44         /// Useful for creating dereference ApplicationExprs without a full resolver pass.
    45         extern FunctionDecl * dereferenceOperator;
    46 
    47         // generate the type of an assignment function for paramType
    48         FunctionType * genAssignType( Type * paramType );
    49 
    50         // generate the type of a default constructor or destructor for paramType
    51         FunctionType * genDefaultType( Type * paramType );
    52 
    53         // generate the type of a copy constructor for paramType
    54         FunctionType * genCopyType( Type * paramType );
     39        /// generate the type of an assignment function for paramType.
     40        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     41        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true );
     42
     43        /// generate the type of a default constructor or destructor for paramType.
     44        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     45        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true );
     46
     47        /// generate the type of a copy constructor for paramType.
     48        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     49        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true );
    5550
    5651        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
  • src/SymTab/Validate.cc

    rd76c588 r8d70648  
    7676#include "SynTree/Visitor.h"           // for Visitor
    7777#include "Validate/HandleAttributes.h" // for handleAttributes
     78#include "Validate/FindSpecialDecls.h" // for FindSpecialDecls
    7879
    7980class CompoundStmt;
     
    288289        };
    289290
    290         FunctionDecl * dereferenceOperator = nullptr;
    291         struct FindSpecialDeclarations final {
    292                 void previsit( FunctionDecl * funcDecl );
    293         };
    294 
    295291        void validate( std::list< Declaration * > &translationUnit, __attribute__((unused)) bool doDebug ) {
    296292                PassVisitor<EnumAndPointerDecay> epc;
     
    299295                PassVisitor<CompoundLiteral> compoundliteral;
    300296                PassVisitor<ValidateGenericParameters> genericParams;
    301                 PassVisitor<FindSpecialDeclarations> finder;
    302297                PassVisitor<LabelAddressFixer> labelAddrFixer;
    303298                PassVisitor<HoistTypeDecls> hoistDecls;
     
    378373                        });
    379374                        Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    380                                 acceptAll( translationUnit, finder ); // xxx - remove this pass soon
     375                                Validate::findSpecialDecls( translationUnit );
    381376                        });
    382377                        Stats::Time::TimeBlock("Fix Label Address", [&]() {
     
    943938                if ( eliminator.pass.typedefNames.count( "size_t" ) ) {
    944939                        // grab and remember declaration of size_t
    945                         SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
     940                        Validate::SizeType = eliminator.pass.typedefNames["size_t"].first->base->clone();
    946941                } else {
    947942                        // xxx - missing global typedef for size_t - default to long unsigned int, even though that may be wrong
    948943                        // eventually should have a warning for this case.
    949                         SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     944                        Validate::SizeType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
    950945                }
    951946        }
     
    13351330                        // need to resolve array dimensions early so that constructor code can correctly determine
    13361331                        // if a type is a VLA (and hence whether its elements need to be constructed)
    1337                         ResolvExpr::findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer );
     1332                        ResolvExpr::findSingleExpression( type->dimension, Validate::SizeType->clone(), indexer );
    13381333
    13391334                        // must re-evaluate whether a type is a VLA, now that more information is available
     
    13721367                return addrExpr;
    13731368        }
    1374 
    1375         void FindSpecialDeclarations::previsit( FunctionDecl * funcDecl ) {
    1376                 if ( ! dereferenceOperator ) {
    1377                         if ( funcDecl->get_name() == "*?" && funcDecl->get_linkage() == LinkageSpec::Intrinsic ) {
    1378                                 FunctionType * ftype = funcDecl->get_functionType();
    1379                                 if ( ftype->get_parameters().size() == 1 && ftype->get_parameters().front()->get_type()->get_qualifiers() == Type::Qualifiers() ) {
    1380                                         dereferenceOperator = funcDecl;
    1381                                 }
    1382                         }
    1383                 }
    1384         }
    13851369} // namespace SymTab
    13861370
Note: See TracChangeset for help on using the changeset viewer.