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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits