[PATCH] D22034: [MSVC][DLL] use local vftable mangling only exported classes with virtual destructor

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 13 09:16:34 PDT 2016

majnemer added a comment.

Running your patch against the following:

  struct __declspec(dllimport) S {
    virtual void f() {}
  S x;
  constexpr S y;

results in:

> Global is marked as dllimport, but not external

>  [2 x i8*]* @"\01??_7S@@6B@"

>  fatal error: error in backend: Broken module found, compilation aborted!

>  clang-3.9: error: clang frontend command failed with exit code 70 (use -v to see invocation)

I don't think your approach will correctly handle instances where we need to emit a local vftable and reference an imported vftable simultaneously.

A flag on CXXRecordDecl which is sensitive to the most recent expression evaluation might not be the best way to go.
Perhaps we should be able to use the VFTableBuilder to build imported and local vftables for the same vftable? Not entirely sure though...

Comment at: lib/AST/ExprConstant.cpp:5765
@@ +5764,3 @@
+  if (Info.EvalMode == EvalInfo::EM_ConstantExpression) {
+    if (CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(
+            E->getType()->castAs<RecordType>()->getDecl()))
I'd use `auto *` here.


More information about the cfe-commits mailing list