MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / parseFamilyRules

Method parseFamilyRules

lib/suppressions.cpp:844–896  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

842}
843
844std::vector<std::pair<std::string, std::string>> polyspace::Parser::parseFamilyRules(const std::string& comment, std::string::size_type& pos) {
845 std::vector<std::pair<std::string, std::string>> fr;
846 std::string family;
847 std::string rule;
848 enum class State: uint8_t { family, colon, rule, rule_or_family } state = State::family;
849 const std::string::size_type endpos = startsWith(comment, "/*") ? comment.size() - 2 : comment.size();
850 for (; pos <= endpos; ++pos) {
851 const char c = comment[pos];
852 if (std::strchr("[\"", c))
853 break;
854 switch (state) {
855 case State::family:
856 if (std::isalnum(c) || std::strchr("-_.",c))
857 family += c;
858 else if (!family.empty() && std::strchr(" \t:",c))
859 state = State::colon;
860 break;
861 case State::colon:
862 if (!std::strchr(" \t:", c)) {
863 rule.clear();
864 --pos;
865 state = State::rule;
866 }
867 break;
868 case State::rule:
869 if (std::strchr(", \t",c)) {
870 if (!rule.empty()) {
871 fr.emplace_back(family,rule);
872 rule.clear();
873 if (c != ',')
874 state = State::rule_or_family;
875 }
876 }
877 else
878 rule += c;
879 break;
880 case State::rule_or_family:
881 rule.clear();
882 if (std::isalnum(c)) {
883 --pos;
884 family.clear();
885 state = State::family;
886 } else if (c == ',') {
887 --pos;
888 state = State::rule;
889 }
890 break;
891 }
892 }
893 if (!family.empty() && !rule.empty())
894 fr.emplace_back(family,rule);
895 return fr;
896}
897
898std::set<std::string> polyspace::Parser::parseIds(const std::string& comment, std::string::size_type& pos) const {
899 std::set<std::string> ids;

Callers

nothing calls this directly

Calls 5

isalnumFunction · 0.85
startsWithFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected