[cfe-commits] r124986 - in /cfe/trunk: lib/CodeGen/CGVTables.cpp test/CodeGenCXX/thunks-available-externally.cpp
Anders Carlsson
andersca at mac.com
Sun Feb 6 12:09:44 PST 2011
Author: andersca
Date: Sun Feb 6 14:09:44 2011
New Revision: 124986
URL: http://llvm.org/viewvc/llvm-project?rev=124986&view=rev
Log:
Fix self-host; if a thunk already exists and has available_externally linkage, we should change its linkage instead of asserting.
Modified:
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/thunks-available-externally.cpp
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=124986&r1=124985&r2=124986&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Sun Feb 6 14:09:44 2011
@@ -2723,8 +2723,13 @@
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.
Modified: cfe/trunk/test/CodeGenCXX/thunks-available-externally.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/thunks-available-externally.cpp?rev=124986&r1=124985&r2=124986&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/thunks-available-externally.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/thunks-available-externally.cpp Sun Feb 6 14:09:44 2011
@@ -68,3 +68,21 @@
}
}
+
+// 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;
+}
+
+}
More information about the cfe-commits
mailing list