Commit 5e7866ca authored by Reid Kleckner's avatar Reid Kleckner
Browse files

Merge r244488 to the 3.7 release branch

It avoids doing key function optimizations when the key function is
dllimported.

Fixed PR24409.

llvm-svn: 245388
parent 0fb856a3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2014,6 +2014,12 @@ static const CXXMethodDecl *computeKeyFunction(ASTContext &Context,
        continue;
    }

    // If the key function is dllimport but the class isn't, then the class has
    // no key function. The DLL that exports the key function won't export the
    // vtable in this case.
    if (MD->hasAttr<DLLImportAttr>() && !RD->hasAttr<DLLImportAttr>())
      return nullptr;

    // We found it.
    return MD;
  }
+8 −0
Original line number Diff line number Diff line
@@ -20,3 +20,11 @@ struct __declspec(dllimport) V {
  virtual void f();
} v;
// GNU-DAG: @_ZTV1V = external dllimport

struct W {
  __declspec(dllimport) virtual void f();
  virtual void g();
} w;
// GNU-DAG: @_ZTV1W = linkonce_odr
// GNU-DAG: @_ZTS1W = linkonce_odr
// GNU-DAG: @_ZTI1W = linkonce_odr