Date: Tue, 17 Jul 2012 18:04:34 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r238554 - stable/9/contrib/llvm/tools/clang/lib/Sema Message-ID: <201207171804.q6HI4YwF078753@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Tue Jul 17 18:04:34 2012 New Revision: 238554 URL: http://svn.freebsd.org/changeset/base/238554 Log: MFC r238429: Pull in r159895 from upstream clang trunk: When marking virtual functions as used for a class' vtable, mark all functions which will appear in the vtable as used, not just those ones which were declared within the class itself. Fixes an issue reported as comment#3 in PR12763 -- we sometimes assert in codegen if we try to emit a reference to a function declaration which we've not marked as referenced. This also matches gcc's observed behavior. This should fix clang assertions when building certain components of the LibreOffice port. Approved by: re (kib) Modified: stable/9/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp Directory Properties: stable/9/contrib/llvm/ (props changed) stable/9/contrib/llvm/tools/clang/ (props changed) Modified: stable/9/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp ============================================================================== --- stable/9/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp Tue Jul 17 17:34:48 2012 (r238553) +++ stable/9/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp Tue Jul 17 18:04:34 2012 (r238554) @@ -10937,14 +10937,23 @@ bool Sema::DefineUsedVTables() { void Sema::MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD) { - for (CXXRecordDecl::method_iterator i = RD->method_begin(), - e = RD->method_end(); i != e; ++i) { - CXXMethodDecl *MD = *i; - - // C++ [basic.def.odr]p2: - // [...] A virtual member function is used if it is not pure. [...] - if (MD->isVirtual() && !MD->isPure()) - MarkFunctionReferenced(Loc, MD); + // Mark all functions which will appear in RD's vtable as used. + CXXFinalOverriderMap FinalOverriders; + RD->getFinalOverriders(FinalOverriders); + for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(), + E = FinalOverriders.end(); + I != E; ++I) { + for (OverridingMethods::const_iterator OI = I->second.begin(), + OE = I->second.end(); + OI != OE; ++OI) { + assert(OI->second.size() > 0 && "no final overrider"); + CXXMethodDecl *Overrider = OI->second.front().Method; + + // C++ [basic.def.odr]p2: + // [...] A virtual member function is used if it is not pure. [...] + if (!Overrider->isPure()) + MarkFunctionReferenced(Loc, Overrider); + } } // Only classes that have virtual bases need a VTT.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207171804.q6HI4YwF078753>