Changeset 486341f for src


Ignore:
Timestamp:
Aug 24, 2016, 1:55:39 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
3906301, 4e2b9710, 60aa49a7, a2a8d2a6
Parents:
0555f4b
Message:

add option to CodeGen? to output unmangled name, add ctorWarnings test

Location:
src
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r0555f4b r486341f  
    8383        }
    8484
    85         CodeGenerator::CodeGenerator( std::ostream & os ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ) {}
     85        CodeGenerator::CodeGenerator( std::ostream & os, bool mangle ) : indent( *this), cur_indent( 0 ), insideFunction( false ), output( os ), printLabels( *this ), mangle( mangle ) {}
    8686
    8787        CodeGenerator::CodeGenerator( std::ostream & os, std::string init, int indentation, bool infunp )
     
    9595        }
    9696
    97         string mangleName( DeclarationWithType * decl ) {
     97        string CodeGenerator::mangleName( DeclarationWithType * decl ) {
     98                if ( ! mangle ) return decl->get_name();
    9899                if ( decl->get_mangleName() != "" ) {
    99100                        // need to incorporate scope level in order to differentiate names for destructors
  • src/CodeGen/CodeGenerator.h

    r0555f4b r486341f  
    3030                static int tabsize;
    3131
    32                 CodeGenerator( std::ostream &os );
     32                CodeGenerator( std::ostream &os, bool mangle = true );
    3333                CodeGenerator( std::ostream &os, std::string, int indent = 0, bool infun = false );
    3434                CodeGenerator( std::ostream &os, char *, int indent = 0, bool infun = false );
     
    114114                std::ostream &output;
    115115                LabelPrinter printLabels;
     116                bool mangle = true;
    116117
    117118                void printDesignators( std::list< Expression * > & );
     
    119120                void handleAggregate( AggregateDecl *aggDecl );
    120121                void handleTypedef( NamedTypeDecl *namedType );
     122                std::string mangleName( DeclarationWithType * decl );
    121123        }; // CodeGenerator
    122124
  • src/CodeGen/GenType.cc

    r0555f4b r486341f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenType.cc -- 
     7// GenType.cc --
    88//
    99// Author           : Richard C. Bilson
     
    2828        class GenType : public Visitor {
    2929          public:
    30                 GenType( const std::string &typeString );
     30                GenType( const std::string &typeString, bool mangle = true );
    3131                std::string get_typeString() const { return typeString; }
    3232                void set_typeString( const std::string &newValue ) { typeString = newValue; }
    33  
     33
    3434                virtual void visit( FunctionType *funcType );
    3535                virtual void visit( VoidType *voidType );
     
    4242                virtual void visit( TypeInstType *typeInst );
    4343                virtual void visit( VarArgsType *varArgsType );
    44  
     44
    4545          private:
    4646                void handleQualifiers( Type *type );
    4747                void genArray( const Type::Qualifiers &qualifiers, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
    48  
     48
    4949                std::string typeString;
     50                bool mangle = true;
    5051        };
    5152
    52         std::string genType( Type *type, const std::string &baseString ) {
    53                 GenType gt( baseString );
     53        std::string genType( Type *type, const std::string &baseString, bool mangle ) {
     54                GenType gt( baseString, mangle );
    5455                type->accept( gt );
    5556                return gt.get_typeString();
    5657        }
    5758
    58         GenType::GenType( const std::string &typeString ) : typeString( typeString ) {}
     59        GenType::GenType( const std::string &typeString, bool mangle ) : typeString( typeString ), mangle( mangle ) {}
    5960
    6061        void GenType::visit( VoidType *voidType ) {
     
    100101                } // if
    101102                if ( dimension != 0 ) {
    102                         CodeGenerator cg( os );
     103                        CodeGenerator cg( os, mangle );
    103104                        dimension->accept( cg );
    104105                } else if ( isVarLen ) {
     
    109110
    110111                typeString = os.str();
    111  
     112
    112113                base->accept( *this );
    113114        }
     
    142143                        } // if
    143144                } // if
    144  
     145
    145146                /************* parameters ***************/
    146147
     
    154155                        } // if
    155156                } else {
    156                         CodeGenerator cg( os );
     157                        CodeGenerator cg( os, mangle );
    157158                        os << "(" ;
    158159
     
    164165                        os << ")";
    165166                } // if
    166  
     167
    167168                typeString = os.str();
    168169
  • src/CodeGen/GenType.h

    r0555f4b r486341f  
    2121
    2222namespace CodeGen {
    23         std::string genType( Type *type, const std::string &baseString );
     23        std::string genType( Type *type, const std::string &baseString, bool mangle = true );
    2424} // namespace CodeGen
    2525
  • src/InitTweak/FixInit.cc

    r0555f4b r486341f  
    735735                        for ( DeclarationWithType * member : unhandled ) {
    736736                                // emit a warning for each unhandled member
    737                                 warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name() ), ", member ", member->get_name(), " may not have been ", isConstructor( funcDecl->get_name() ) ? "constructed" : "destructed" );
     737                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", member->get_name(), " may not have been ", isConstructor( funcDecl->get_name() ) ? "constructed" : "destructed" );
    738738                        }
    739739
     
    789789                void WarnStructMembers::visit( MemberExpr * memberExpr ) {
    790790                        if ( ! checkWarnings( function ) ) return;
    791                         if ( ! isConstructor( function->get_name() ) );
     791                        if ( ! isConstructor( function->get_name() ) ) return;
    792792
    793793                        if ( ApplicationExpr * deref = dynamic_cast< ApplicationExpr * >( memberExpr->get_aggregate() ) ) {
     
    797797                                                        if ( unhandled.count( memberExpr->get_member() ) ) {
    798798                                                                // emit a warning because a member was used before it was constructed
    799                                                                 warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name() ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
     799                                                                warn( "in ", CodeGen::genType( function->get_functionType(), function->get_name(), false ), ", member ", memberExpr->get_member()->get_name(), " used before being constructed" );
    800800                                                        }
    801801                                                }
  • src/tests/Makefile.am

    r0555f4b r486341f  
    6262        ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    6363
     64ctorWarnings: ctorWarnings.c
     65        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
     66
  • src/tests/Makefile.in

    r0555f4b r486341f  
    670670        ${CC} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
    671671
     672ctorWarnings: ctorWarnings.c
     673        ${CC} ${CFALGS} -CFA -XCFA -p ${<} -o /dev/null 2> ${@}
     674
    672675# Tell versions [3.59,3.63) of GNU make to not export all variables.
    673676# Otherwise a system limit (for SysV at least) may be exceeded.
Note: See TracChangeset for help on using the changeset viewer.