1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

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.

MFC after:	3 days
This commit is contained in:
Dimitry Andric 2012-07-13 21:48:01 +00:00
parent cc59cb7622
commit f8079271e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=238429

View File

@ -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;
// 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 (MD->isVirtual() && !MD->isPure())
MarkFunctionReferenced(Loc, MD);
// 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.