[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

Andrew Rogers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 31 08:20:22 PDT 2018


adr26 updated this revision to Diff 149300.
adr26 added a comment.

Hi Reid,

I've added testcases matching the issues I hit in `microsoft-abi-member-pointers.cpp` (no change to the rest of the fix). If you are happy with this, please feel free to push.

I checked with MSVC, and as per the added testcases, it appears to always lock in the inheritance model as virutal when there's a member funtion pointer in a dependant base, irrespective of whether the most-derived class ends up using single/multiple/virtual inheritance. In fact if, for example, you annotate DerivedFunctor (in the test I've added) using an MS inheritance keyword - i.e. as "class __single_inheritance DerviceFunctor" - then MSVC complains that it's already fixed the representation to be virtual:

  C:\Temp\clang\clang>cl C:\workspaces\llvm\tools\clang\test\CodeGenCXX\microsoft-abi-member-pointers.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26428.1 for x86
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  microsoft-abi-member-pointers.cpp
  C:\workspaces\llvm\tools\clang\test\CodeGenCXX\microsoft-abi-member-pointers.cpp(81): error C2286: pointers to members of 'pr37399::DerivedFunctor<void>' representation is already set to virtual_inheritance - declaration ignored
  C:\workspaces\llvm\tools\clang\test\CodeGenCXX\microsoft-abi-member-pointers.cpp(27): note: see declaration of 'pr37399::DerivedFunctor<void>'

as such, these tests cover the cases I was hitting and appear to have behavioural parity with MSVC (as is the intention!).

Thanks, Andrew R


https://reviews.llvm.org/D46664

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/microsoft-abi-member-pointers.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46664.149300.patch
Type: text/x-patch
Size: 9360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180531/330fec67/attachment.bin>


More information about the cfe-commits mailing list