fixed #14261 - Regex: added `std::regex` implementation / added `engine` to rule XML to specify regex engine
Might make sense to be able to specify the type via a rule file as well. That would also allow to mix and match the engines depending on required performance/features. Or maybe even only allow it via a file so to not add another CLI option and not having to deal with the left-to-right issues.
This will only add the additional engine. I will also do some performance tests.
The follow-up steps are:
- implement PCRE2 as an additional engine and make it optional via a new build flag
- make
std::regexthe default and deprecateHAVE_RULESand PCRE1 so the feature works without any build dependencies - remove
HAVE_RULESand PCRE1 shortly after (most distros have already dropped the dependency since the library has long been EOL)
thanks for working on this. :+1:
Might make sense to be able to specify the type via a rule file as well. That would also allow to mix and match the engines depending on required performance/features. Or maybe even only allow it via a file so to not add another CLI option and not having to deal with the left-to-right issues.
@danmar any comment on this?
No comment so I will go with the way to specify the engine via XML only and not providing a CLI option for it.
The follow-up steps are:
I filed some tickets for those: https://trac.cppcheck.net/ticket/14262 https://trac.cppcheck.net/ticket/14263
The documentation on how to use rules is unfortunately some PDFs hosted at Sourceforge so there is nowhere to add the new field. I filed https://trac.cppcheck.net/ticket/14264 about migrating the documentation.
Great - std::regex appears to behave differently in Visual Studio:
D:\a\cppcheck\cppcheck\test\testregex.cpp:181(TestRegExStd::exactmatch): Assertion failed.
Expected:
0
Actual:
2
Why am I not surprised?!
And on macos testrunner is not showing the failed test:
TestVarID::structuredBindings
Testing Complete
Number of tests: 5164
Number of todos: 371
make: *** [test] Error 1
Error: Process completed with exit code 2.
Great -
std::regexappears to behave differently in Visual Studio:
Apparently std::regex is partially broken in the current Visual Studio version (not sure if it is what affects the test): https://developercommunity.visualstudio.com/t/std::regex-gives-a-different-result-in-m/10417784
So that partially derails the plan going forward and makes things more awkward. And I have not even profiled it yet...
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Coincidentally Visual Studio 2026 was released just a few hours ago and I can confirm that the test passes in it.