[cfe-commits] r167906 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/Sema/DeclSpec.h lib/AST/ASTContext.cpp lib/AST/Decl.cpp lib/AST/ItaniumMangle.cpp lib/Sema/SemaDecl.cpp test/CodeGenCXX/mangle.cpp test/CodeGenCXX/template-anonymous-types.cpp test/SemaCXX/warn-unused-filescoped.cpp

David Blaikie dblaikie at gmail.com
Tue Nov 13 20:42:23 PST 2012


On Tue, Nov 13, 2012 at 6:36 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Tue, Nov 13, 2012 at 5:52 PM, David Blaikie <dblaikie at gmail.com> wrote:
>> Author: dblaikie
>> Date: Tue Nov 13 19:52:05 2012
>> New Revision: 167906
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=167906&view=rev
>> Log:
>> Provide the correct mangling and linkage for certain unnamed nested classes.
>>
>> This corrects the mangling and linkage of classes (& their member functions) in
>> cases like this:
>>
>>   struct foo {
>>     struct {
>>       void func() { ... }
>>     } x;
>>   };
>>
>> we were accidentally giving this nested unnamed struct 'no' linkage where it
>> should've had the linkage of the outer class. The mangling was incorrecty too,
>> mangling as TU-wide unnamed type mangling of $_X rather than class-scoped
>> mangling of UtX_.
>>
>> This also fixes -Wunused-member-function which would incorrectly diagnose
>> 'func' as unused due to it having no linkage & thus appearing to be TU-local
>> when in fact it might be correctly used in another TU.
>>
>> Similar mangling should be applied to function local classes in similar cases
>> but I've deferred that for a subsequent patch.
> [...]
>> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=167906&r1=167905&r2=167906&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
>> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Nov 13 19:52:05 2012
>> @@ -1117,6 +1117,18 @@
>>          break;
>>        }
>>      }
>> +
>> +    int UnnamedMangle = Context.getASTContext().getUnnamedTagManglingNumber(TD);
>> +    if (UnnamedMangle != -1) {
>> +      Out << "Ut";
>> +      if (UnnamedMangle != 0)
>> +        Out << llvm::utostr(UnnamedMangle - 1);
>> +      Out << '_';
>> +      break;
>> +    }
>> +
>> +    //assert(cast<RecordDecl>(RD)->isAnonymousStructOrUnion() && "Don't mangle unnamed things as "
>> +    //  "anonymous things");
>
> Was this accidentally left behind?

Indeed. Thanks for the catch. Removed in r167911.

- David



More information about the cfe-commits mailing list