Changes in src/SymTab/Mangler.cc [3f024c9:1da22500]
- File:
-
- 1 edited
-
src/SymTab/Mangler.cc (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Mangler.cc
r3f024c9 r1da22500 35 35 namespace { 36 36 /// 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> { 38 38 Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams ); 39 39 Mangler( const Mangler & ) = delete; … … 55 55 void postvisit( EnumInstType * aggregateUseType ); 56 56 void postvisit( TypeInstType * aggregateUseType ); 57 void postvisit( TraitInstType * inst );58 57 void postvisit( TupleType * tupleType ); 59 58 void postvisit( VarArgsType * varArgsType ); … … 71 70 bool typeMode; ///< Produce a unique mangled name for a type 72 71 bool mangleGenericParams; ///< Include generic parameters in name mangling if true 73 bool inFunctionType = false; ///< Include type qualifiers if false.74 72 75 73 void mangleDecl( DeclarationWithType *declaration ); … … 179 177 void Mangler::postvisit( PointerType * pointerType ) { 180 178 printQualifiers( pointerType ); 181 // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers 182 if ( ! dynamic_cast<FunctionType *>( pointerType->base ) ) mangleName << "P"; 179 mangleName << "P"; 183 180 maybeAccept( pointerType->base, *visitor ); 184 181 } … … 192 189 193 190 void Mangler::postvisit( ReferenceType * refType ) { 194 // don't print prefix (e.g. 'R') for reference types so that references and non-references do not overload.195 // Further, do not print the qualifiers for a reference type (but do run printQualifers because of TypeDecls, etc.),196 // by pretending every reference type is a function parameter.197 GuardValue( inFunctionType );198 inFunctionType = true;199 191 printQualifiers( refType ); 192 mangleName << "R"; 200 193 maybeAccept( refType->base, *visitor ); 201 194 } … … 213 206 printQualifiers( functionType ); 214 207 mangleName << "F"; 215 // turn on inFunctionType so that printQualifiers does not print most qualifiers for function parameters,216 // since qualifiers on outermost parameter type do not differentiate function types, e.g.,217 // void (*)(const int) and void (*)(int) are the same type, but void (*)(const int *) and void (*)(int *) are different218 GuardValue( inFunctionType );219 inFunctionType = true;220 208 std::list< Type* > returnTypes = getTypes( functionType->get_returnVals() ); 221 209 acceptAll( returnTypes, *visitor ); … … 282 270 } 283 271 284 void Mangler::postvisit( TraitInstType * inst ) {285 printQualifiers( inst );286 mangleName << "_Y" << inst->name << "_";287 }288 289 272 void Mangler::postvisit( TupleType * tupleType ) { 290 273 printQualifiers( tupleType ); … … 321 304 // skip if not including qualifiers 322 305 if ( typeMode ) return; 306 323 307 if ( ! type->get_forall().empty() ) { 324 308 std::list< std::string > assertionNames; … … 353 337 mangleName << "_"; 354 338 } // if 355 if ( ! inFunctionType ) { 356 // these qualifiers do not distinguish the outermost type of a function parameter 357 if ( type->get_const() ) { 358 mangleName << "C"; 359 } // if 360 if ( type->get_volatile() ) { 361 mangleName << "V"; 362 } // if 363 // Removed due to restrict not affecting function compatibility in GCC 364 // if ( type->get_isRestrict() ) { 365 // mangleName << "E"; 366 // } // if 367 if ( type->get_atomic() ) { 368 mangleName << "A"; 369 } // if 370 } 339 if ( type->get_const() ) { 340 mangleName << "C"; 341 } // if 342 if ( type->get_volatile() ) { 343 mangleName << "V"; 344 } // if 371 345 if ( type->get_mutex() ) { 372 346 mangleName << "M"; 373 347 } // if 348 // Removed due to restrict not affecting function compatibility in GCC 349 // if ( type->get_isRestrict() ) { 350 // mangleName << "E"; 351 // } // if 374 352 if ( type->get_lvalue() ) { 375 353 // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues 376 354 mangleName << "L"; 377 355 } 378 379 if ( inFunctionType ) { 380 // turn off inFunctionType so that types can be differentiated for nested qualifiers 381 GuardValue( inFunctionType ); 382 inFunctionType = false; 383 } 356 if ( type->get_atomic() ) { 357 mangleName << "A"; 358 } // if 384 359 } 385 360 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.