]> granicus.if.org Git - clang/commitdiff
Use castAs instead of cast in thunk generation
authorReid Kleckner <reid@kleckner.net>
Fri, 11 Oct 2013 20:46:27 +0000 (20:46 +0000)
committerReid Kleckner <reid@kleckner.net>
Fri, 11 Oct 2013 20:46:27 +0000 (20:46 +0000)
Calling convention attributes can add sugar to methods that we have to
look through.  This fixes an assertion failure in the provided test
case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192496 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVTables.cpp
test/CodeGenCXX/microsoft-abi-thunks.cpp

index d530016f13b7d66c203d1126aaffcabc69754c73..425c12301fd815e970de5e59ea2acab03f7c900a 100644 (file)
@@ -481,7 +481,7 @@ void CodeGenVTables::maybeEmitThunkForVTable(GlobalDecl GD,
   // We can't emit thunks for member functions with incomplete types.
   const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
   if (!CGM.getTypes().isFuncTypeConvertible(
-                                cast<FunctionType>(MD->getType().getTypePtr())))
+           MD->getType()->castAs<FunctionType>()))
     return;
 
   emitThunk(GD, Thunk, /*ForVTable=*/true);
index 091ef3274b9828de2ca298a74d6437ba86c7ea35..3b4281f76d6b5a786972209f7cea062c370036b4 100644 (file)
@@ -116,3 +116,18 @@ struct H : E {
 H h;
 
 // FIXME: Write vtordisp adjusting thunk tests
+
+namespace CrashOnThunksForAttributedType {
+// We used to crash on this because the type of foo is an AttributedType, not
+// FunctionType, and we had to look through the sugar.
+struct A {
+  virtual void __stdcall foo();
+};
+struct B {
+  virtual void __stdcall foo();
+};
+struct C : A, B {
+  virtual void __stdcall foo();
+};
+C c;
+}