Skip to content

ClangImporter: synchronize clang and Swift #35290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Jan 7, 2021

This synchronizes the C/C++ standard that Swift uses for the clang
importer with the defaults of the clang compiler.

The default for the C standard remains the same at gnu11. However, if
clang was built with a different default C standard, that will be
preferred.

The default for the C++ standard is moved to C++14. Although this is a
reduced version, it matches what the current clang compiler defaults to.
Additionally, if the user built clang with a different C++ standard,
that standard would be preferred.

Although the C++ support is a bit more conservative, the idea is that we
can be certain that the clang version fully supports this standard as it
it the default version for clang.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

CC: @zoecarver @hlopko @pschuh

@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 7, 2021

Build failed
Swift Test OS X Platform
Git Sha - 95d18fab1f4c2baab88d4ea67155bea64f3adb86

Copy link
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

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

This seems reasonable. Thanks!

@swift-ci
Copy link
Contributor

swift-ci commented Jan 7, 2021

Build failed
Swift Test Linux Platform
Git Sha - 95d18fab1f4c2baab88d4ea67155bea64f3adb86

@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

@swift-ci please test Windows platform

This synchronizes the C/C++ standard that Swift uses for the clang
importer with the defaults of the clang compiler.

The default for the C standard remains the same at `gnu11`.  However, if
clang was built with a different default C standard, that will be
preferred.

The default for the C++ standard is moved to C++14.  Although this is a
reduced version, it matches what the current clang compiler defaults to.
Additionally, if the user built clang with a different C++ standard,
that standard would be preferred.

Although the C++ support is a bit more conservative, the idea is that we
can be certain that the clang version fully supports this standard as it
it the default version for clang.

The test change made here replaces the use of `auto` type parameters to
templates which is a C++17 feature.  Reduce the example to a C++14
equivalent.

The clang version seems to behave differently in preventing the
synthesis of the constexpr value.  This persists into the newer clang
releases as well.  This is reasonable as the value does not need to be
exported necessarily and users will be able to materialize the value.
We use the optimizer to ensure that the value is inlined.

This also repairs the C++ interop tests on Windows with a newer C++
runtime from Microsoft.
@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Jan 7, 2021

SR-14023 tracks the issue identified here with the materialization of the constexpr value.

@swift-ci
Copy link
Contributor

swift-ci commented Jan 8, 2021

Build failed
Swift Test OS X Platform
Git Sha - e600816

@compnerd
Copy link
Member Author

compnerd commented Jan 8, 2021

@swift-ci please test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Jan 8, 2021

Build failed
Swift Test OS X Platform
Git Sha - e600816

@compnerd
Copy link
Member Author

compnerd commented Jan 8, 2021

@swift-ci please test macOS platform

@compnerd compnerd merged commit 62e3896 into swiftlang:main Jan 8, 2021
@compnerd compnerd deleted the synchrony branch January 8, 2021 21:09
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.

3 participants