Skip to content

Clang warnings cleanup - #755

Merged
Stephan T. Lavavej (StephanTLavavej) merged 28 commits into
microsoft:masterfrom
cbezault:clang-cl_cleanup
Apr 30, 2020
Merged

Stephan T. Lavavej (StephanTLavavej) merged 28 commits into
microsoft:masterfrom
cbezault:clang-cl_cleanup

Conversation

@cbezault

@cbezault Curtis J Bezault (cbezault) commented Apr 27, 2020 •

Copy link
Copy Markdown
Contributor

I noticed that our code emits a fair number of warnings with clang-cl when building the tests. Previously we were not seeing these warnings because of the way clang treats "system headers".

This change causes clang-cl to emit warnings on our headers and fixes up the existing warnings.

I also resolved Microsoft-internal VSO-609129 " appears to have impossible condition" which was being warned about by clang.

Clang-cl suppresses all warning generated in files which are present in the INCLUDE
environment variable. This is undesirable to us in general, but especially when
builing the test binaries.
One of our tests instantiates a _Static_partition_team with the type of _Count
as a short. We store the result of a short-short division and a short-short
mod operation into a short which results in a narrowing warning from int to short.
This is due to short to int promotion for arithmetic binary operations.
We shouldn't be trying to find a signed value in an array of unsigned
values. I chose to change the search value to an unsinged literal but
casting would have worked too.
Clang complains about unused side-effects when using _STL_VERIFY.
When doing memchr optimizations in find we fallback to the
standard find algorithm when the values are eligible for memchr
optimization but we are constant evaluated. This can result in
emitting sign-mismatch warnings which are pointless since we already
do bounds checking of the search element.

Just cast the search element to the type of the container's values.
We were incorrectly detecting whether or not the second byte in a 2-byte
sjis glyph was valid. Also update the test to cover the full range of
valid sjis 0208 characters.
We do this to avoid overriding /Od with /O2.
Currently std::terminate under _HAS_EXCEPTIONS=0 does not actually
terminate the program and is therefore not noreturn. Just call
_CSTD abort() directly in this case.

Make _Raise [[noreturn]]
@cbezault
Curtis J Bezault (cbezault) requested a review from a team as a code owner April 27, 2020 17:03
@cbezault
Curtis J Bezault (cbezault) marked this pull request as draft April 27, 2020 17:37
Comment thread stl/inc/tuple Outdated
Comment thread stl/inc/xutility
Comment thread stl/inc/exception

inline void __CRTDECL terminate() noexcept { // handle exception termination
[[noreturn]] inline void __CRTDECL terminate() noexcept { // handle exception termination
_CSTD abort();

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.

I suspect we should just unconditionally using ::terminate; instead of defining this, but I'll allow that investigating this machinery is out of scope for the change in this PR. Stephan T. Lavavej (@StephanTLavavej) mentioned this stuff is in his super-secret TODO list - should we have an issue?

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.

I noticed this a while ago and thought I had recorded a TODO, but didn't. (I'm migrating the TODO list to enhancement issues - 5 pages to go!) I agree that we should file an issue for this.

Comment thread stl/inc/random Outdated
Comment thread stl/inc/type_traits Outdated
Comment thread stl/inc/yvals.h Outdated
Comment thread stl/inc/yvals.h
Comment thread tests/std/tests/P0067R5_charconv/env.lst Outdated
Comment thread tests/std/tests/P0067R5_charconv/env.lst
Comment thread tests/utils/stl/test/config.py
Co-Authored-By: Casey Carter 
@StephanTLavavej Stephan T. Lavavej (StephanTLavavej) added the enhancement Something can be improved label Apr 27, 2020
@cbezault
Curtis J Bezault (cbezault) marked this pull request as ready for review April 27, 2020 21:57
Comment thread stl/inc/type_traits Outdated
Comment thread stl/inc/type_traits
Comment thread stl/inc/yvals.h
Comment thread stl/inc/yvals.h Outdated
Comment thread tests/std/tests/P0088R3_variant/env.lst Outdated
Comment thread tests/tr1/include/tfuns.h Outdated
Comment thread stl/inc/cvt/sjis_0208
Comment thread tests/utils/stl/test/config.py Outdated
Comment thread tests/utils/stl/test/config.py
Comment thread stl/inc/type_traits
Comment thread tests/tr1/tests/cvt/sjis_0208/test.cpp
Mysconvert myconv("");

// All ASCII and modified ASCII characters single byte characters
for (unsigned long ch = 0; ch <= 0x7f; ++ch) {

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.

Hm, I guess this introduces a ton of unnecessary nul characters to be tested but still works.

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit 84221fb into microsoft:master Apr 30, 2020
@StephanTLavavej

Copy link
Copy Markdown
Member

Thanks for fixing all of these warnings, and the cvt bugfix, and especially enhancing our test coverage so we remain clean in the future! I had dreamed of this but didn't know how to achieve it in the old infrastructure (as -Wsystem-headers affects UCRT/WinSDK headers too). Amazing work.

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

Labels

enhancement Something can be improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants