]> granicus.if.org Git - clang/commitdiff
Fix self-host; if a thunk already exists and has available_externally linkage, we...
authorAnders Carlsson <andersca@mac.com>
Sun, 6 Feb 2011 20:09:44 +0000 (20:09 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 6 Feb 2011 20:09:44 +0000 (20:09 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124986 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVTables.cpp
test/CodeGenCXX/thunks-available-externally.cpp

index 3dd7a15fe359314d31a80377f1b966d4fb788ac2..d74226ec89bbbe5e13a22777dea03d866b935a4f 100644 (file)
@@ -2723,8 +2723,13 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk,
       return;
     }
 
-    // We should never be able to get a function with a definition here.
-    assert(false && "Shouldn't have an already existing definition");
+    // If a function has a body, it should have available_externally linkage.
+    assert(ThunkFn->hasAvailableExternallyLinkage() &&
+           "Function should have available_externally linkage!");
+
+    // Change the linkage.
+    CGM.setFunctionLinkage(cast<CXXMethodDecl>(GD.getDecl()), ThunkFn);
+    return;
   }
 
   // Actually generate the thunk body.
index 697a00018787dca3210d31ae1f871d8f2d551baf..dfdb786b18ee7b03d1f8432e4b2958675d63a9b9 100644 (file)
@@ -68,3 +68,21 @@ void f() {
 }
 
 }
+
+// Test that we don't assert.
+namespace Test3 {
+
+struct A {
+  virtual ~A();
+
+  int a;
+};
+
+struct B : A { };
+struct C : virtual B { };
+
+void f() {
+  C c;
+}
+
+}