Changes in src/SymTab/Mangler.cc [1da22500:f465f0e]
- File:
-
- 1 edited
-
src/SymTab/Mangler.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Mangler.cc
r1da22500 rf465f0e 35 35 namespace { 36 36 /// Mangles names to a unique C identifier 37 struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler> {37 struct Mangler : public WithShortCircuiting, public WithVisitorRef<Mangler>, public WithGuards { 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 ); 57 58 void postvisit( TupleType * tupleType ); 58 59 void postvisit( VarArgsType * varArgsType ); … … 70 71 bool typeMode; ///< Produce a unique mangled name for a type 71 72 bool mangleGenericParams; ///< Include generic parameters in name mangling if true 73 bool inFunctionType = false; ///< Include type qualifiers if false. 72 74 73 75 void mangleDecl( DeclarationWithType *declaration ); … … 189 191 190 192 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; 191 198 printQualifiers( refType ); 192 mangleName << "R";193 199 maybeAccept( refType->base, *visitor ); 194 200 } … … 206 212 printQualifiers( functionType ); 207 213 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; 208 219 std::list< Type* > returnTypes = getTypes( functionType->get_returnVals() ); 209 220 acceptAll( returnTypes, *visitor ); … … 270 281 } 271 282 283 void Mangler::postvisit( TraitInstType * inst ) { 284 printQualifiers( inst ); 285 mangleName << "_Y" << inst->name << "_"; 286 } 287 272 288 void Mangler::postvisit( TupleType * tupleType ) { 273 289 printQualifiers( tupleType ); … … 304 320 // skip if not including qualifiers 305 321 if ( typeMode ) return; 306 307 322 if ( ! type->get_forall().empty() ) { 308 323 std::list< std::string > assertionNames; … … 337 352 mangleName << "_"; 338 353 } // if 339 if ( type->get_const() ) { 340 mangleName << "C"; 341 } // if 342 if ( type->get_volatile() ) { 343 mangleName << "V"; 344 } // 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 } 345 370 if ( type->get_mutex() ) { 346 371 mangleName << "M"; 347 372 } // if 348 // Removed due to restrict not affecting function compatibility in GCC349 // if ( type->get_isRestrict() ) {350 // mangleName << "E";351 // } // if352 373 if ( type->get_lvalue() ) { 353 374 // mangle based on whether the type is lvalue, so that the resolver can differentiate lvalues and rvalues 354 375 mangleName << "L"; 355 376 } 356 if ( type->get_atomic() ) { 357 mangleName << "A"; 358 } // if 377 378 if ( inFunctionType ) { 379 // turn off inFunctionType so that types can be differentiated for nested qualifiers 380 GuardValue( inFunctionType ); 381 inFunctionType = false; 382 } 359 383 } 360 384 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.