Skip to content

Mark several functions as noexcept. - #1937

Merged
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
ThomasFWise:more_noexcepts
Aug 18, 2022
Merged

Mark several functions as noexcept.#1937
Stephan T. Lavavej (StephanTLavavej) merged 16 commits into
microsoft:mainfrom
ThomasFWise:more_noexcepts

Conversation

@ThomasFWise

@ThomasFWise Thomas Wise (ThomasFWise) commented May 27, 2021

Copy link
Copy Markdown
Contributor

This can be important for performance on x86 when calling these functions from code that is marked noexcept.

Drive by: fix optional::operator CMP to correctly only expect an implicit conversion to bool; example fail: https://gcc.godbolt.org/z/xojTqn3vx

@ThomasFWise
Thomas Wise (ThomasFWise) requested a review from a team as a code owner May 27, 2021 17:48
@SuperWig

Copy link
Copy Markdown
Contributor

If I'm not mistaken, if it's not specified as noexcept in the standard then they need to be commented as // strengthened to signify that.

Comment thread stl/inc/list Outdated
@StephanTLavavej

Copy link
Copy Markdown
Member

I've pushed a merge with main to resolve conflicts in <vector> after the toolset update removed _CONSTEXPR20_CONTAINER (it's now _CONSTEXPR20 or plain constexpr), followed by running clang-format.

@CaseyCarter

Copy link
Copy Markdown
Contributor

I merged main yet again and resolved a trivial conflict in <optional> where one of the recently removed banner comments appeared in the context around a change.

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.

Publishing an ancient partial review.

Comment thread stl/inc/xstddef Outdated
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
… on x86 when calling these functions from code that is marked noexcept.
- AdamBucior: remove noexcept from compare operators on sequence types
- Casey:
   - _Implicitly_convert_to (_Fake_copy_init)
   - /* strengthened */
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/type_traits Outdated
Comment thread stl/inc/xstddef
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/xutility Outdated
Comment thread stl/inc/xutility
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Additionally, this fixes a few existing XFAILs in libc++'s test suite
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional
Comment thread stl/inc/xutility Outdated
Comment thread tests/libcxx/expected_results.txt
Comment thread stl/inc/optional
@StephanTLavavej

Copy link
Copy Markdown
Member

Merge conflicts need to be resolved now that #1347 has landed. 🛬

@strega-nil-ms

Copy link
Copy Markdown
Contributor

Merged (and fixed an issue I noticed while merging)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I'll validate and push changes for the small issues I found (only one was significant, regarding a missing noexcept annotation on the tagged base class constructor).

Comment thread stl/inc/type_traits
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional Outdated
Comment thread stl/inc/optional
Comment thread stl/inc/optional
Comment thread stl/inc/optional

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.

Marking request changes as I do not wish to merge without finishing the {_Implicitly_convert_to, _Fake_decay_copy, _Fake_copy_init} discussion.

@strega-nil-ms nicole mazzuca (strega-nil-ms) added the decision needed We need to choose something before working on this label Aug 17, 2022
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) removed the decision needed We need to choose something before working on this label Aug 18, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member

We've decided to go with nicole mazzuca (@strega-nil-ms)'s proposed unification to _Fake_copy_init in a followup PR (to avoid mixing a large mechanical change with a behavioral change).

@StephanTLavavej

Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit ae0c274 into microsoft:main Aug 18, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member

Thomas Wise (@ThomasFWise) Thanks for strengthening these exception specifications, and congratulations on your first microsoft/STL commit!

Also thanks to nicole mazzuca (@strega-nil-ms) for landing this PR!

🎉 😻 🦾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Must go faster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants