[PATCH] D46929: Fix a mangling failure on clang-cl C++17

Taiju Tsuiki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 15 23:41:43 PDT 2018


tzik created this revision.
tzik added reviewers: majnemer, rnk.
Herald added a subscriber: cfe-commits.

MethodVFTableLocations in MigrosoftVTableContext contains canonicalized
decl. But, it's sometimes asked to lookup for non-canonicalized decl,
and that causes assertion failure, and compilation failure.
Fixes PR37481.


Repository:
  rC Clang

https://reviews.llvm.org/D46929

Files:
  lib/AST/VTableBuilder.cpp
  test/CodeGenCXX/PR37481.cpp


Index: test/CodeGenCXX/PR37481.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/PR37481.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -o /dev/null -emit-llvm -std=c++17 -triple x86_64-pc-windows-msvc %s
+
+struct Foo {
+  virtual void f();
+  virtual void g();
+};
+
+void Foo::f() {}
+void Foo::g() {}
+
+template <void (Foo::*)()>
+void h() {}
+
+void x() {
+  h<&Foo::f>();
+  h<&Foo::g>();
+}
Index: lib/AST/VTableBuilder.cpp
===================================================================
--- lib/AST/VTableBuilder.cpp
+++ lib/AST/VTableBuilder.cpp
@@ -3737,6 +3737,8 @@
   if (isa<CXXDestructorDecl>(GD.getDecl()))
     assert(GD.getDtorType() == Dtor_Deleting);
 
+  GD = GD.getCanonicalDecl();
+
   MethodVFTableLocationsTy::iterator I = MethodVFTableLocations.find(GD);
   if (I != MethodVFTableLocations.end())
     return I->second;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46929.146996.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180516/24b3b81b/attachment.bin>


More information about the cfe-commits mailing list