Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.cc

    rf465f0e r1da22500  
    3535                namespace {
    3636                        /// Mangles names to a unique C identifier
    37                         struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler>, public WithGuards {
     37                        struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler> {
    3838                                Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams );
    3939                                Mangler( const Mangler & ) = delete;
     
    5555                                void postvisit( EnumInstType * aggregateUseType );
    5656                                void postvisit( TypeInstType * aggregateUseType );
    57                                 void postvisit( TraitInstType * inst );
    5857                                void postvisit( TupleType * tupleType );
    5958                                void postvisit( VarArgsType * varArgsType );
     
    7170                                bool typeMode;                  ///< Produce a unique mangled name for a type
    7271                                bool mangleGenericParams;       ///< Include generic parameters in name mangling if true
    73                                 bool inFunctionType = false;    ///< Include type qualifiers if false.
    7472
    7573                                void mangleDecl( DeclarationWithType *declaration );
     
    191189
    192190                        void Mangler::postvisit( ReferenceType * refType ) {
    193                                 // don't print prefix (e.g. 'R') for reference types so that references and non-references do not overload.
    194                                 // Further, do not print the qualifiers for a reference type (but do run printQualifers because of TypeDecls, etc.),
    195                                 // by pretending every reference type is a function parameter.
    196                                 GuardValue( inFunctionType );
    197                                 inFunctionType = true;
    198191                                printQualifiers( refType );
     192                                mangleName << "R";
    199193                                maybeAccept( refType->base, *visitor );
    200194                        }
     
    212206                                printQualifiers( functionType );
    213207                                mangleName << "F";
    214                                 // turn on inFunctionType so that printQualifiers does not print most qualifiers for function parameters,
    215                                 // since qualifiers on outermost parameter type do not differentiate function types, e.g.,
    216                                 // void (*)(const int) and void (*)(int) are the same type, but void (*)(const int *) and void (*)(int *) are different
    217                                 GuardValue( inFunctionType );
    218                                 inFunctionType = true;
    219208                                std::list< Type* > returnTypes = getTypes( functionType->get_returnVals() );
    220209                                acceptAll( returnTypes, *visitor );
     
    281270                        }
    282271
    283                         void Mangler::postvisit( TraitInstType * inst ) {
    284                                 printQualifiers( inst );
    285                                 mangleName << "_Y" << inst->name << "_";
    286                         }
    287 
    288272                        void Mangler::postvisit( TupleType * tupleType ) {
    289273                                printQualifiers( tupleType );
     
    320304                                // skip if not including qualifiers
    321305                                if ( typeMode ) return;
     306
    322307                                if ( ! type->get_forall().empty() ) {
    323308                                        std::list< std::string > assertionNames;
     
    352337                                        mangleName << "_";
    353338                                } // if
    354                                 if ( ! inFunctionType ) {
    355                                         // these qualifiers do not distinguish the outermost type of a function parameter
    356                                         if ( type->get_const() ) {
    357                                                 mangleName << "C";
    358                                         } // if
    359                                         if ( type->get_volatile() ) {
    360                                                 mangleName << "V";
    361                                         } // if
    362                                         // Removed due to restrict not affecting function compatibility in GCC
    363                                         // if ( type->get_isRestrict() ) {
    364                                         //      mangleName << "E";
    365                                         // } // if
    366                                         if ( type->get_atomic() ) {
    367                                                 mangleName << "A";
    368                                         } // if
    369                                 }
     339                                if ( type->get_const() ) {
     340                                        mangleName << "C";
     341                                } // if
     342                                if ( type->get_volatile() ) {
     343                                        mangleName << "V";
     344                                } // if
    370345                                if ( type->get_mutex() ) {
    371346                                        mangleName << "M";
    372347                                } // if
     348                                // Removed due to restrict not affecting function compatibility in GCC
     349                //              if ( type->get_isRestrict() ) {
     350                //                      mangleName << "E";
     351                //              } // if
    373352                                if ( type->get_lvalue() ) {
    374353                                        // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues
    375354                                        mangleName << "L";
    376355                                }
    377 
    378                                 if ( inFunctionType ) {
    379                                         // turn off inFunctionType so that types can be differentiated for nested qualifiers
    380                                         GuardValue( inFunctionType );
    381                                         inFunctionType = false;
    382                                 }
     356                                if ( type->get_atomic() ) {
     357                                        mangleName << "A";
     358                                } // if
    383359                        }
    384360                }       // namespace
Note: See TracChangeset for help on using the changeset viewer.