This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Add precondition check before calling match_results.str() in tests.
Needs RevisionPublic

Authored by amakc11 on Apr 26 2019, 8:21 AM.

Details

Summary

The match_results constructor has the following postcondition: "Ensures: ready() returns false". The str() method of this class has the following precondition: "Requires: ready() == true". However, some tests call match_results.str() right after the constructor without checking the above precondition. This patch fixes this bug in tests.

Diff Detail

Repository
rCXX libc++

Event Timeline

amakc11 created this revision.Apr 26 2019, 8:21 AM
mclow.lists requested changes to this revision.Apr 26 2019, 9:02 AM
mclow.lists added a subscriber: mclow.lists.

Thanks for this patch; but I don't think the suggested changes are what we want.
Instead of:

assert(!m.ready() || m.str() == std::basic_string<CharT>());

I think we should just check:

assert(!m.ready());

because that's the post-condition for the constructor.
If you agree, I can just make the changes myself.

This revision now requires changes to proceed.Apr 26 2019, 9:02 AM

BTW, I agree with you that this is a bug in the tests.

If you agree, I can just make the changes myself.

Yes, please.

Committed revision https://llvm.org/r359324 to fix this.