This is an archive of the discontinued LLVM Phabricator instance.

[libc++][test] Make some string tests MSVC-friendly
ClosedPublic

Authored by CaseyCarter on Jan 8 2023, 10:01 PM.

Details

Reviewers
philnik
ldionne
Group Reviewers
Restricted Project
Commits
rG6b90f6745ac7: [libc++][test] Make some string tests MSVC-friendly
Summary
  • Using one-or-two letter names for globals is asking for shadowing warnings.
  • MSVCSTL's container proxy allocations strike again
  • MSVCSTL's <string> doesn't define std::out_of_range
  • basic_string::substr takes two arguments of type size_type. Let's use that type instead of size_t and ptrdiff_t to avoid narrowing warnings.

Diff Detail

Event Timeline

CaseyCarter created this revision.Jan 8 2023, 10:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2023, 10:01 PM
CaseyCarter requested review of this revision.Jan 8 2023, 10:01 PM
Herald added a reviewer: Restricted Project. · View Herald TranscriptJan 8 2023, 10:01 PM
philnik accepted this revision.Jan 9 2023, 3:53 AM
philnik added a subscriber: philnik.

LGTM % nit.

libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
48–50

Is this change just academic, or is MSVC actually allocating more than once?

libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
31

Nit: the formatting looks wrong.

This revision is now accepted and ready to land.Jan 9 2023, 3:53 AM
ldionne accepted this revision.Jan 9 2023, 7:27 AM
ldionne added a subscriber: ldionne.

LGTM, the CI issues look unrelated. I just came back from OOO so I guess this might have been fixed already.

LGTM, the CI issues look unrelated. I just came back from OOO so I guess this might have been fixed already.

It's not fixed yet, but it's unrelated. Sorry for breaking the CI.

CaseyCarter added inline comments.Jan 9 2023, 2:59 PM
libcxx/test/std/strings/basic.string/string.cons/dtor.pass.cpp
48–50

This is yet another manifestation of MSVCSTL containers' additional memory allocation when iterator debugging is active.

libcxx/test/std/strings/basic.string/string.ops/string_substr/substr_rvalue.pass.cpp
31

I made these quite long and figured I'd wrap them since nothing in the file was much over 80. I should have simply clang-formatted, which I'll do now.

This revision was landed with ongoing or failed builds.Jan 9 2023, 3:00 PM
This revision was automatically updated to reflect the committed changes.