This is an archive of the discontinued LLVM Phabricator instance.

Fix a mangling failure on clang-cl C++17
ClosedPublic

Authored by tzik on May 15 2018, 11:41 PM.

Details

Summary

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.

Diff Detail

Repository
rC Clang

Event Timeline

tzik created this revision.May 15 2018, 11:41 PM
rnk added a comment.May 16 2018, 11:31 AM

I searched around, and I noticed that VTableContext::getMethodVTableIndex has the same implied contract that the caller must always provide a canonical declaration or things will break. It looks like it has three callers, and they all do this. We should probably sink the canonicalization into this helper as well and clean up the now-superfluous canonicalizations at the call site.

tzik updated this revision to Diff 147244.May 16 2018, 10:56 PM
tzik added a comment.May 16 2018, 11:00 PM
In D46929#1101780, @rnk wrote:

I searched around, and I noticed that VTableContext::getMethodVTableIndex has the same implied contract that the caller must always provide a canonical declaration or things will break. It looks like it has three callers, and they all do this. We should probably sink the canonicalization into this helper as well and clean up the now-superfluous canonicalizations at the call site.

Updated.
As I'm not sure if it's safe to use non-canonicalized CXXMethodDecl for EmitVirtualMemPtrThunk and CGCall, I left using the canonical decl.
For other part, non-canonical decl looks working fine to me.

rnk accepted this revision.May 17 2018, 10:28 AM

lgtm

Shall I go ahead and commit this for you?

lib/AST/VTableBuilder.cpp
2507

Thanks for that!

This revision is now accepted and ready to land.May 17 2018, 10:28 AM
thakis added a subscriber: thakis.May 17 2018, 10:52 AM

Please do, tzik doesn't have commit access yet.

This revision was automatically updated to reflect the committed changes.