This is an archive of the discontinued LLVM Phabricator instance.

Fix ABI compatibility of `<stdexcept>` with VCRuntime.
ClosedPublic

Authored by EricWF on Mar 4 2019, 5:48 PM.

Details

Summary

Currently, libc++'s <stdexcept> doesn't play nice with vcruntime. Specifically:

  • logic_error and runtime_error have a different layout.
  • libc++'s logic_error and runtime_error override what() but vcruntime does not.
  • vcruntime uses weak vtables for <stdexcept> types.
  • libc++'s <stdexcept> constructors and assignment operators may have different manglings than vcruntimes.

This patch makes libc++'s declarations in <stdexcept> match those provided by MSVC's STL as closely as possible.
If MSVC doesn't declare a special member, then neither do we. This ensures that the implicit definitions have the same linkage, visibility, triviality, and noexcept-ness.

Diff Detail

Event Timeline

EricWF created this revision.Mar 4 2019, 5:48 PM
EricWF edited the summary of this revision. (Show Details)Mar 4 2019, 5:54 PM
EricWF updated this revision to Diff 189254.Mar 4 2019, 5:59 PM
EricWF added a reviewer: smeenai.
thomasanderson accepted this revision.Mar 4 2019, 6:15 PM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 4 2019, 6:15 PM

Do we have a tester that uses vcruntime?

include/stdexcept
96

Ah, so libc++ is using std::string, and vcruntime is using std::__1::string? But libc++ only defines basic_string in namespace __1, so aren't both actually referring to std::__1::string? I'm a bit confused.

src/support/runtime/stdexcept_default.ipp
37

Indentation.

thomasanderson added inline comments.Mar 6 2019, 12:03 PM
src/support/runtime/stdexcept_default.ipp
49

copy-paste error: s/le/re

EricWF marked 3 inline comments as done.Mar 6 2019, 12:23 PM
EricWF added inline comments.
include/stdexcept
96

The comment calls out the weirdness that std::logic_error isn't versioned, but std::__1::string is. So we don't actually provide the same as vcruntimes logic_error. But that shouldn't be a problem, and means we can put the constructor out-of-line.

EricWF updated this revision to Diff 189558.Mar 6 2019, 12:24 PM
  • Clang format new files.
  • Fix preexisting copy/paste mistake.
This revision was automatically updated to reflect the committed changes.