-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compile --rule-file
pattern only once / extracted regular expressions code to separate file
#6211
base: main
Are you sure you want to change the base?
Conversation
This is mainly so the issues are reported on start-up instead on each file. It does not improve performance much. The refactoring and improved testing will also make it easier to add support for PCRE2 since PCRE is EOL since quite a while (see https://trac.cppcheck.net/ticket/10610). |
cli/cmdlineparser.cpp
Outdated
} | ||
|
||
rule.regex = std::make_shared<Regex>(rule.pattern); | ||
const std::string regex_err = rule.regex->compile(); |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
lib/settings.h
Outdated
@@ -293,6 +299,7 @@ class CPPCHECKLIB WARN_UNUSED Settings { | |||
std::string id = "rule"; // default id | |||
std::string summary; | |||
Severity severity = Severity::style; // default severity | |||
std::shared_ptr<Regex> regex; |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
std::string mPattern; | ||
|
||
class Data; | ||
std::shared_ptr<Data> mData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a shared pointer because the it is used in Settings
are they are being copied (the copies in production code will hopefully go away soon) and we have dynamic memory.
This means that multiple threads will use this but as the used data is const
there should not be any issues. I did not see anything related to thread safety in the PCRE documentation. I will check again though. I hope any potential issues will be caught by the CI.
Thinking about that we a --rule
test which actually has multiple input files. Wil add that.
So it seems the shared pointers do not seem to work with forked processes. But there is something else:
I wonder where the whitespace in the filename is coming from. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
--rule-file
pattern only once / extracted regular expressions code to separate file / improved errorhandling of --rule
and --rule-file=
--rule-file
pattern only once / extracted regular expressions code to separate file
1fb855b
to
b300dc5
Compare
e6c61a6
to
2b3ebf5
Compare
1b2c244
to
2ed6ba0
Compare
…ns code to separate file
The problem is that the memory behind the shared pointer is leaked in the forked process:
|
No description provided.