-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #14367: Support polyspace inline suppressions for misra c:20xx rules #8105
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
base: main
Are you sure you want to change the base?
Conversation
| bool polyspace::isPolyspaceComment(const std::string &comment) | ||
| { | ||
| std::string::size_type pos = 0; | ||
| while (pos < comment.size() && std::strchr("/* ", comment[pos])) |
Check warning
Code scanning / Cppcheck Premium
Condition 'comment.size()-pos<polyspace.size()' is always true Warning
| bool convert(SuppressionList::Suppression &suppr) const; | ||
| }; | ||
|
|
||
| class Parser { |
Check warning
Code scanning / Cppcheck Premium
The class 'Parser' does not declare a constructor although it has private member variables which likely require initialization. Warning
|
| return mPeeked; | ||
| } | ||
|
|
||
| if (mComment.size() >= 2 && (mComment.substr(0, 2) == "/*" || mComment.substr(0, 2) == "//")) { |
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.
use mComment.compare instead. Hmm.. I think that the mComment.size() >= 2 && is redundant however it's not bad to be explicitly safe.
| bool polyspace::Suppression::convert(SuppressionList::Suppression &suppr) const | ||
| { | ||
| static const std::map<std::string, std::string> map = { | ||
| { "MISRA-C3", "premium-misra-c-2012-" }, |
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.
if Settings::premiumArgs is nonempty (or contains misra-c-2012) then premium-misra-c-2012- is correct. Otherwise I think we can say misra-c2012- here
| if (comment.size() - pos < polyspace.size()) | ||
| return false; | ||
| return comment.substr(pos, polyspace.size()) == polyspace; |
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.
Something like this will do the same
| if (comment.size() - pos < polyspace.size()) | |
| return false; | |
| return comment.substr(pos, polyspace.size()) == polyspace; | |
| return comment.compare(pos, polyspace.size(), polyspace, 0, polyspace.size()) == 0; |
| bool polyspace::isPolyspaceComment(const std::string &comment) | ||
| { | ||
| std::string::size_type pos = 0; | ||
| while (pos < comment.size() && std::strchr("/* ", comment[pos])) |
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.
| while (pos < comment.size() && std::strchr("/* ", comment[pos])) | |
| pos = comment.find_first_not_of("/* "); |
| #include <simplecpp.h> | ||
|
|
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.
No need for this include as you can just forward declare simplecpp::Token.
|
Should this be behind a flag? Always parsing for something very niche (and premium only?) seems undesired. |



No description provided.