| 748 | |
| 749 | |
| 750 | std::list<SuppressionList::Suppression> polyspace::Parser::parse(const std::string &comment, int line, const std::string &filename) const |
| 751 | { |
| 752 | // Syntax for a polyspace suppression: |
| 753 | // https://se.mathworks.com/help/bugfinder/ug/annotate-hide-known-acceptable-polyspace-results-web-browser.html |
| 754 | |
| 755 | std::list<SuppressionList::Suppression> ret; |
| 756 | |
| 757 | if (mFamilyMap.empty()) |
| 758 | return ret; |
| 759 | |
| 760 | for (std::string::size_type pos = comment.find_first_not_of("/* "); pos < comment.size();) { |
| 761 | // polyspace |
| 762 | const auto polyspaceKind = parseKind(comment, pos); |
| 763 | if (polyspaceKind == CommentKind::Invalid) |
| 764 | break; |
| 765 | |
| 766 | // optional range |
| 767 | const int rangeValue = parseRange(comment, pos); |
| 768 | |
| 769 | // ids.. |
| 770 | const std::set<std::string> ids = parseIds(comment, pos); |
| 771 | |
| 772 | // skip justification |
| 773 | if (pos < comment.size() && comment[pos] == '[') { |
| 774 | pos = comment.find(']',pos+1); |
| 775 | if (pos >= comment.size()) |
| 776 | break; |
| 777 | pos = comment.find_first_not_of(" \t", pos+1); |
| 778 | if (pos >= comment.size()) |
| 779 | break; |
| 780 | } |
| 781 | |
| 782 | // extra comment |
| 783 | std::string extraComment; |
| 784 | if (pos < comment.size() && comment[pos] == '\"') { |
| 785 | const std::string::size_type p1 = pos + 1; |
| 786 | pos = comment.find('\"',p1); |
| 787 | if (pos >= comment.size()) |
| 788 | break; |
| 789 | extraComment = comment.substr(p1, pos-p1); |
| 790 | } |
| 791 | |
| 792 | for (const std::string& errorId: ids) { |
| 793 | SuppressionList::Suppression suppr; |
| 794 | suppr.errorId = errorId; |
| 795 | suppr.isInline = true; |
| 796 | suppr.isPolyspace = true; |
| 797 | suppr.fileName = filename; |
| 798 | suppr.lineNumber = line; |
| 799 | suppr.extraComment = extraComment; |
| 800 | |
| 801 | if (rangeValue > 0) { |
| 802 | suppr.type = SuppressionList::Type::block; |
| 803 | suppr.lineBegin = line; |
| 804 | suppr.lineEnd = line + rangeValue; |
| 805 | } |
| 806 | else if (polyspaceKind == polyspace::CommentKind::Regular) |
| 807 | suppr.type = SuppressionList::Type::unique; |
no test coverage detected