8 jun 2010 kl. 07.53 skrev Douglas Gregor: > > On Jun 8, 2010, at 7:49 AM, Anders Carlsson wrote: > >> Author: andersca >> Date: Tue Jun 8 09:49:03 2010 >> New Revision: 105606 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=105606&view=rev >> Log: >> Correctly mangle static variables of anonymous struct/union type. >> >> Modified: >> cfe/trunk/lib/CodeGen/Mangle.cpp >> cfe/trunk/test/CodeGenCXX/mangle-unnamed.cpp >> >> Modified: cfe/trunk/lib/CodeGen/Mangle.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Mangle.cpp?rev=105606&r1=105605&r2=105606&view=diff >> ============================================================================== >> --- cfe/trunk/lib/CodeGen/Mangle.cpp (original) >> +++ cfe/trunk/lib/CodeGen/Mangle.cpp Tue Jun 8 09:49:03 2010 >> @@ -598,6 +598,28 @@ >> mangleUnqualifiedName(0, Name, KnownArity); >> } >> >> +static const FieldDecl *FindFirstNamedDataMember(const RecordDecl *RD) { >> + assert(RD->isAnonymousStructOrUnion() && >> + "Expected anonymous struct or union!"); >> + >> + for (RecordDecl::field_iterator I = RD->field_begin(), E = >> RD->field_end(); >> + I != E; ++I) { >> + const FieldDecl *FD = *I; >> + >> + if (FD->getIdentifier()) >> + return FD; >> + >> + if (const RecordType *RT = FD->getType()->getAs<RecordType>()) { >> + if (const FieldDecl *NamedDataMember = >> + FindFirstNamedDataMember(RT->getDecl())) >> + return NamedDataMember; >> + } >> + } >> + >> + // We didn't find a named data member. >> + return 0; >> +} >> + >> void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND, >> DeclarationName Name, >> unsigned KnownArity) { >> @@ -630,6 +652,28 @@ >> } >> } >> >> + if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) { >> + // We must have an anonymous union or struct declaration. >> + const RecordDecl *RD = >> + cast<RecordDecl>(VD->getType()->getAs<RecordType>()->getDecl()); > > Should you > > assert(RD->isAnonymousStructOrUnion()); >
I already do that in FindFirstNamedDataMember. Would you like me to add another assert? - Anders _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
