This is an archive of the discontinued LLVM Phabricator instance.

[libc++][Modules] Fix a few module related warnings
ClosedPublic

Authored by iana on Jul 27 2023, 11:38 PM.

Details

Summary

I'm getting a few -Wundefined-inline warnings, and a -Wnon-modular-include-in-module too. Fix all of those.

Diff Detail

Event Timeline

iana created this revision.Jul 27 2023, 11:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 11:38 PM
Herald added a subscriber: ributzka. · View Herald Transcript
iana requested review of this revision.Jul 27 2023, 11:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 11:38 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
iana added a comment.Jul 27 2023, 11:42 PM

An example warning I'm hitting locally:

In module 'std_private_algorithm_copy_n' imported from /.../usr/include/c++/v1/__string/char_traits.h:12:
/.../usr/include/c++/v1/__algorithm/copy_n.h:57:1: warning: inline function 'std::copy_n<const char *, unsigned long, char *>' is not defined [-Wundefined-inline]
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
^
/.../usr/include/c++/v1/__string/char_traits.h:242:14: note: used here
        std::copy_n(__s2, __n, __s1);
             ^

The only way I could find to fix that warning was to make the std_private_string_char_traits module export *.

iana updated this revision to Diff 545215.Jul 28 2023, 10:03 AM

Add a missing include to pstl_sort

iana added a comment.Jul 28 2023, 8:11 PM

I can't reproduce the warning in check-cxx or run-buildbot generic-modules and I don't know why. It looks like the tests have -Werror=all, and just in case I tried adding -Werror=undefined-inline, but they still come up green. So I'm stumped why this seems to only reproduce when I install libc++ into my macOS SDK, but it seems like a serious problem with an easy fix that we'd better put into llvm 17.

Mordante accepted this revision.Jul 29 2023, 5:20 AM

I can't reproduce the warning in check-cxx or run-buildbot generic-modules and I don't know why. It looks like the tests have -Werror=all, and just in case I tried adding -Werror=undefined-inline, but they still come up green. So I'm stumped why this seems to only reproduce when I install libc++ into my macOS SDK, but it seems like a serious problem with an easy fix that we'd better put into llvm 17.

I think the changes are not too intrusive for LLVM-17 so I'm fine with backporting it.
LGTM!

This revision is now accepted and ready to land.Jul 29 2023, 5:20 AM
This revision was automatically updated to reflect the committed changes.