[PATCH] [-cxx-abi microsoft] Emit thunks for pointers to virtual member functions
Reid Kleckner
rnk at google.com
Thu Nov 14 16:45:54 PST 2013
LGTM with one last fix
================
Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:993
@@ +992,3 @@
+ LinkageInfo LV = MD->getLinkageAndVisibility();
+ ThunkFn->setLinkage(LV.getLinkage() != ExternalLinkage
+ ? llvm::GlobalValue::InternalLinkage
----------------
I think you really want MD->isExternallyVisible() to handle the VisibleNoLinkage case, which would be triggered by something evil like:
inline __forceinline bool foo(bool set_mp) {
struct B {
virtual void f() {}
static bool compare_mps(void (B::*mp1)(), void (B::*mp2)()) {
return mp1 == mp2;
}
};
if (set_mp)
mp = reinterpret_cast<void (A::*)()>(&B::f);
return B::compare_mps(&B::f, reinterpret_cast<void (B::*)()>(mp));
}
If you use internal linkage here, you'll get two distinct thunks, and the comparison will be false when it shouldn't be.
http://llvm-reviews.chandlerc.com/D2104
More information about the cfe-commits
mailing list