This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Correctly handle invalid regex character class names
ClosedPublic

Authored by miyuki on Jan 19 2018, 3:53 AM.

Details

Summary

Currently when a regular expression contains an invalid character
class name std::regex constructors throw an std::regex_error with
std::regex_constants::error_brack code.

This patch changes the code to std::regex_constants::error_ctype and
adds a test.

Diff Detail

Repository
rL LLVM

Event Timeline

miyuki created this revision.Jan 19 2018, 3:53 AM
mclow.lists accepted this revision.Jan 19 2018, 12:34 PM

This looks fine to me. Thanks!

test/std/re/re.regex/re.regex.construct/bad_ctype.pass.cpp
28 ↗(On Diff #130584)

I'm a big fan of the "return NOW" style of programming.
But this matches the other tests, so I'm ok with it.
(If I care enough, I'll change them all later)

try { std::regex re(pat); }
catch catch (const std::regex_error &ex) { return ex.code() == std::regex_constants::error_ctype; }
return false;
This revision is now accepted and ready to land.Jan 19 2018, 12:34 PM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.