Skip to content

Major Clang update for C++/WinRT#492

Merged
kennykerr merged 27 commits into
masterfrom
kennykerr-clang
Jul 3, 2019
Merged

Major Clang update for C++/WinRT#492
kennykerr merged 27 commits into
masterfrom
kennykerr-clang

Conversation

@kennykerr

Copy link
Copy Markdown
Contributor

This turned from a minor update to a pretty major update as I decided to finally get all of the C++/WinRT unit tests to build with Clang. And we have a lot of tests...

Clang support has always been mostly a best effort by smoke testing with simple apps. This was mainly done in support of conformance. Being able to compile all our unit tests means that we can do much much better. Notably with this update, you can finally use C++ coroutines with Clang. This has some interesting possibilities as Clang has a much more advanced optimizer when it comes to coroutines.

Beyond coroutine support, I've fixed a number of conformance issues highlighted by Clang and done a lot of work to clean up the build support to make it simpler and easier to build with either VC or Clang. It's not quite warning-free for Clang just yet, but its a lot closer. I've dealt with all the errors and most of the warnings. More to come as I can now far more easily test with Clang.

Comment thread src/tool/cppwinrt/strings/base_identity.h
Comment thread src/tool/cppwinrt/strings/base_meta.h
Class::StaticTestReturn();

auto discarded = Class::StaticProperty(); discarded;
[[maybe_unused]] auto discarded = Class::StaticProperty();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang isn't fooled...

@@ -0,0 +1,125 @@

#ifndef __clang__

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang uses a completely different ABI for coroutine support. This means that the VC <experimental/coroutine> header does not support the Clang frontend.


#else

namespace std::experimental

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's a compiler difference that you're smoothing over, it seems likely that projects could accidentally take a dependency on your adapter layer. Would it make sense to put the adapter in a cppwinrt::details namespace, then in the VC version, just do namespace cppwinrt::details { using std::experimental; }, then consume from there so that clang projects using cppwinrt can't easily take an accidental dependency on something that you might want to change later once things standardize a bit more?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trick is that everything here is part of the public library support for coroutines. This is intentionally designed for libraries to take a dependency on and is unavoidable. As such, care is taken that this accurately represents the same library surface as the VC header and the C++20 standard - specifically nothing more is provided. The only implementation detail is the implementation of the functions that call the Clang intrinsics.

@BenJKuhn BenJKuhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically looks good. A couple minor comments on clang compat & coroutines to consider, though.

@kennykerr

Copy link
Copy Markdown
Contributor Author

Thanks Ben!

@kennykerr kennykerr merged commit f648db9 into master Jul 3, 2019
@kennykerr kennykerr deleted the kennykerr-clang branch July 3, 2019 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants