This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Resolve warnings for Wshift-sign-overflow
ClosedPublic

Authored by ddcc on Aug 16 2022, 4:31 PM.

Details

Reviewers
philnik
ldionne
Group Reviewers
Restricted Project
Commits
rG774c39313e83: [libcxx] Resolve warnings for Wshift-sign-overflow
Summary

These warning were identified while debugging modules with Wsystem-headers.

Diff Detail

Event Timeline

ddcc created this revision.Aug 16 2022, 4:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2022, 4:31 PM
Herald added a subscriber: arichardson. · View Herald Transcript
ddcc requested review of this revision.Aug 16 2022, 4:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2022, 4:31 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision.Aug 16 2022, 5:07 PM

Thanks! LGTM with green CI.

libcxx/include/__chrono/duration.h
215

That's a very complex way to write numeric_limits<intmax_t>::max().

This revision is now accepted and ready to land.Aug 16 2022, 5:07 PM
Mordante added inline comments.
libcxx/include/__chrono/duration.h
215

This is a private field is there a reason not to use an __ugly name?
@philnik shouldn't clang-tidy have spotted this?

philnik added inline comments.Aug 17 2022, 8:54 AM
libcxx/include/__chrono/duration.h
215

I think clang-tidy currently only checks parameters and private non-static members. I'm sure there is a configuration for readability-identifier-naming for this case. I'll check that when the simpler cases are checked. (BTW readability- is a complete misnomer for our purposes).

Mordante added inline comments.Aug 17 2022, 10:01 AM
libcxx/include/__chrono/duration.h
215

Ah that explains it. I thought it did all privates.

(BTW readability- is a complete misnomer for our purposes).

:-D good luck filing a bug report ;-)

215

I think clang-tidy currently only checks parameters and private non-static members. I'm sure there is a configuration for readability-identifier-naming for this case. I'll check that when the simpler cases are checked. (BTW readability- is a complete misnomer for our purposes).

This revision was landed with ongoing or failed builds.Aug 17 2022, 10:31 AM
This revision was automatically updated to reflect the committed changes.
ddcc added a comment.EditedAug 17 2022, 10:40 AM

Hmm apparently there's some CUDA builder failures, so I've reverted for now.

https://lab.llvm.org/buildbot#builders/1/builds/33677
https://lab.llvm.org/buildbot#builders/55/builds/33820
https://lab.llvm.org/buildbot#builders/46/builds/33687

/ssd/cuda-k80-0/work/clang-cuda-k80/clang/bin/../include/c++/v1/ratio:143:33: error: in-class initializer for static data member is not a constant expression
   static const intmax_t min = numeric_limits<intmax_t>::min() + 1;

Do these computations need to be marked constexpr? I think the underlying one in numeric_limit is already _LIBCPP_CONSTEXPR.

@ddcc Please ensure that the pre-commit CI is green before landing. This failure will probably get catched there.