@@ -945,24 +945,40 @@ std::string getClassification(const std::string &guideline, ReportType reportTyp
945945 return getClassification (checkers::certCInfo, guideline);
946946 case ReportType::certCpp:
947947 return getClassification (checkers::certCppInfo, guideline);
948- case ReportType::misraC:
948+ case ReportType::misraC2012:
949+ case ReportType::misraC2023:
950+ case ReportType::misraC2025:
949951 {
950- auto components = splitString (guideline, ' .' );
952+ const bool isDirective = guideline.rfind (" Dir " , 0 ) == 0 ;
953+
954+ const std::size_t offset = isDirective ? 4 : 0 ;
955+ auto components = splitString (guideline.substr (offset), ' .' );
951956 if (components.size () != 2 )
952957 return " " ;
953958
954959 const int a = std::stoi (components[0 ]);
955960 const int b = std::stoi (components[1 ]);
956961
957- const std::vector<checkers::MisraInfo> &info = checkers::misraC2012Rules;
958- const auto it = std::find_if (info.cbegin (), info.cend (), [&](const checkers::MisraInfo &i) {
962+ const std::vector<checkers::MisraInfo> *info = nullptr ;
963+ switch (reportType) {
964+ case ReportType::misraC2012:
965+ info = isDirective ? &checkers::misraC2012Directives : &checkers::misraC2012Rules;
966+ break ;
967+ case ReportType::misraC2023:
968+ info = isDirective ? &checkers::misraC2023Directives : &checkers::misraC2023Rules;
969+ break ;
970+ case ReportType::misraC2025:
971+ info = isDirective ? &checkers::misraC2025Directives : &checkers::misraC2025Rules;
972+ break ;
973+ default :
974+ cppcheck::unreachable ();
975+ }
976+
977+ const auto it = std::find_if (info->cbegin (), info->cend (), [&](const checkers::MisraInfo &i) {
959978 return i.a == a && i.b == b;
960979 });
961980
962- if (it == info.cend ())
963- return " " ;
964-
965- return it->str ;
981+ return it == info->cend () ? " " : it->str ;
966982 }
967983 case ReportType::misraCpp2008:
968984 case ReportType::misraCpp2023:
@@ -1022,7 +1038,9 @@ std::string getGuideline(const std::string &errId, ReportType reportType,
10221038 guideline.begin (), static_cast <int (*)(int )>(std::toupper));
10231039 }
10241040 break ;
1025- case ReportType::misraC:
1041+ case ReportType::misraC2012:
1042+ case ReportType::misraC2023:
1043+ case ReportType::misraC2025:
10261044 if (errId.rfind (" misra-c20" , 0 ) == 0 || errId.rfind (" premium-misra-c-20" , 0 ) == 0 )
10271045 guideline = errId.substr (errId.rfind (' -' ) + 1 );
10281046 break ;
@@ -1038,8 +1056,11 @@ std::string getGuideline(const std::string &errId, ReportType reportType,
10381056 break ;
10391057 }
10401058
1041- if (!guideline.empty ())
1059+ if (!guideline.empty ()) {
1060+ if (errId.find (" -dir-" ) != std::string::npos)
1061+ guideline = " Dir " + guideline;
10421062 return guideline;
1063+ }
10431064
10441065 auto it = guidelineMapping.find (errId);
10451066
@@ -1074,7 +1095,9 @@ std::map<std::string, std::string> createGuidelineMapping(ReportType reportType)
10741095 idMapping1 = &checkers::idMappingCertC;
10751096 ext1 = " -C" ;
10761097 break ;
1077- case ReportType::misraC:
1098+ case ReportType::misraC2012:
1099+ case ReportType::misraC2023:
1100+ case ReportType::misraC2025:
10781101 idMapping1 = &checkers::idMappingMisraC;
10791102 break ;
10801103 case ReportType::misraCpp2008:
0 commit comments