[PATCH] D37958: [libc++] Correctly propagate user-defined lookup_classname().

Tim Shen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 17 23:17:21 PDT 2017


timshen added inline comments.


================
Comment at: libcxx/test/std/re/re.traits/lookup_classname_user_defined.pass.cpp:46
+    // matches all characters (they are classified as alnum)
+    std::wstring re1 = L"([[:alnum:]]+)";
+    std::regex_search(in, m, std::wregex(re1));
----------------
Quuxplusone wrote:
> Could you add a test here for
> 
>     std::wstring re3 = L"([[:ALNUM:]]+)";
>     std::regex_search(in, m, std::wregex(re3, std::regex_constants::icase));
> 
>     std::wstring re4 = L"(\\W+)";
>     std::regex_search(in, m, std::wregex(re4, std::regex_constants::icase));
> 
> documenting the expected outputs?  It's unclear to me from cppreference
> http://en.cppreference.com/w/cpp/regex/regex_traits/lookup_classname
> whether lookup_classname("W") is supposed to produce a result or not (but you seem to assume it does).
> 
> My understanding is that the "icase" parameter to lookup_classname is talking about the icaseness of the regex matcher; classnames should always be matched with exact case, i.e. `[[:alnum:]]` is always a valid classname and `[[:ALNUM:]]` is always invalid, regardless of regex_constants::icase. But I'm not sure.
[re.req] says that, for lookup_classname(), "The value returned shall be independent of the case of the characters in the sequence."

I take it as regardless of lookup_classname()'s icase argument, [[:ALNUM:]] is always valid.

There are existing tests that confirms it in std/re/re.traits/lookup_classname.pass.cpp. Search for "AlNum".

I fixed my patch, since I was misunderstanding it as well (I thought icase is for the input char sequence). Now they are just forwarded into lookup_classname().


https://reviews.llvm.org/D37958





More information about the cfe-commits mailing list