Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Mangler.cc

    rc0453ca3 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;
     
    7070                                bool typeMode;                  ///< Produce a unique mangled name for a type
    7171                                bool mangleGenericParams;       ///< Include generic parameters in name mangling if true
    72                                 bool inFunctionType = false;    ///< Include type qualifiers if false.
    7372
    7473                                void mangleDecl( DeclarationWithType *declaration );
     
    190189
    191190                        void Mangler::postvisit( ReferenceType * refType ) {
    192                                 // don't print prefix (e.g. 'R') for reference types so that references and non-references do not overload.
    193                                 // Further, do not print the qualifiers for a reference type (but do run printQualifers because of TypeDecls, etc.),
    194                                 // by pretending every reference type is a function parameter.
    195                                 GuardValue( inFunctionType );
    196                                 inFunctionType = true;
    197191                                printQualifiers( refType );
     192                                mangleName << "R";
    198193                                maybeAccept( refType->base, *visitor );
    199194                        }
     
    211206                                printQualifiers( functionType );
    212207                                mangleName << "F";
    213                                 // turn on inFunctionType so that printQualifiers does not print most qualifiers for function parameters,
    214                                 // since qualifiers on outermost parameter type do not differentiate function types, e.g.,
    215                                 // void (*)(const int) and void (*)(int) are the same type, but void (*)(const int *) and void (*)(int *) are different
    216                                 GuardValue( inFunctionType );
    217                                 inFunctionType = true;
    218208                                std::list< Type* > returnTypes = getTypes( functionType->get_returnVals() );
    219209                                acceptAll( returnTypes, *visitor );
     
    314304                                // skip if not including qualifiers
    315305                                if ( typeMode ) return;
     306
    316307                                if ( ! type->get_forall().empty() ) {
    317308                                        std::list< std::string > assertionNames;
     
    346337                                        mangleName << "_";
    347338                                } // if
    348                                 if ( ! inFunctionType ) {
    349                                         // these qualifiers do not distinguish the outermost type of a function parameter
    350                                         if ( type->get_const() ) {
    351                                                 mangleName << "C";
    352                                         } // if
    353                                         if ( type->get_volatile() ) {
    354                                                 mangleName << "V";
    355                                         } // if
    356                                         // Removed due to restrict not affecting function compatibility in GCC
    357                                         // if ( type->get_isRestrict() ) {
    358                                         //      mangleName << "E";
    359                                         // } // if
    360                                         if ( type->get_atomic() ) {
    361                                                 mangleName << "A";
    362                                         } // if
    363                                 }
     339                                if ( type->get_const() ) {
     340                                        mangleName << "C";
     341                                } // if
     342                                if ( type->get_volatile() ) {
     343                                        mangleName << "V";
     344                                } // if
    364345                                if ( type->get_mutex() ) {
    365346                                        mangleName << "M";
    366347                                } // if
     348                                // Removed due to restrict not affecting function compatibility in GCC
     349                //              if ( type->get_isRestrict() ) {
     350                //                      mangleName << "E";
     351                //              } // if
    367352                                if ( type->get_lvalue() ) {
    368353                                        // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues
    369354                                        mangleName << "L";
    370355                                }
    371 
    372                                 if ( inFunctionType ) {
    373                                         // turn off inFunctionType so that types can be differentiated for nested qualifiers
    374                                         GuardValue( inFunctionType );
    375                                         inFunctionType = false;
    376                                 }
     356                                if ( type->get_atomic() ) {
     357                                        mangleName << "A";
     358                                } // if
    377359                        }
    378360                }       // namespace
Note: See TracChangeset for help on using the changeset viewer.