svn commit: r238429 - head/contrib/llvm/tools/clang/lib/Sema

Dimitry Andric dim at FreeBSD.org
Fri Jul 13 21:48:02 UTC 2012


Author: dim
Date: Fri Jul 13 21:48:01 2012
New Revision: 238429
URL: http://svn.freebsd.org/changeset/base/238429

Log:
  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

Modified:
  head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp

Modified: head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	Fri Jul 13 21:27:18 2012	(r238428)
+++ head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	Fri Jul 13 21:48:01 2012	(r238429)
@@ -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.


More information about the svn-src-all mailing list