Skip to content

Commit 6c7ea40

Browse files
authored
Fix #13265 (generate lib/checkers.cpp, update id mappings) (#6953)
1 parent eab6b48 commit 6c7ea40

12 files changed

+1774
-657
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ LIBOBJ = $(libcppdir)/valueflow.o \
206206
$(libcppdir)/checkclass.o \
207207
$(libcppdir)/checkcondition.o \
208208
$(libcppdir)/checkers.o \
209+
$(libcppdir)/checkersidmapping.o \
209210
$(libcppdir)/checkersreport.o \
210211
$(libcppdir)/checkexceptionsafety.o \
211212
$(libcppdir)/checkfunctions.o \
@@ -529,6 +530,9 @@ $(libcppdir)/checkcondition.o: lib/checkcondition.cpp lib/addoninfo.h lib/astuti
529530
$(libcppdir)/checkers.o: lib/checkers.cpp lib/checkers.h lib/config.h
530531
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkers.cpp
531532

533+
$(libcppdir)/checkersidmapping.o: lib/checkersidmapping.cpp lib/checkers.h lib/config.h
534+
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkersidmapping.cpp
535+
532536
$(libcppdir)/checkersreport.o: lib/checkersreport.cpp lib/addoninfo.h lib/checkers.h lib/checkersreport.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
533537
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkersreport.cpp
534538

gui/resultstree.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,19 @@ void ResultsTree::keyPressEvent(QKeyEvent *event)
262262
void ResultsTree::setReportType(ReportType reportType) {
263263
mReportType = reportType;
264264

265-
auto readInfo = [this](const std::vector<checkers::Info>& info) {
266-
for (const auto& i: info)
267-
for (const QString& cppcheckId: QString(i.cppcheckIds).split(","))
268-
mGuideline[cppcheckId] = QString(i.guideline).toUpper();
269-
};
270-
271-
auto readIdMapping = [this](const std::vector<checkers::IdMapping>& idMapping) {
265+
auto readIdMapping = [this](const std::vector<checkers::IdMapping>& idMapping, const char* ext = "") {
272266
for (const auto& i: idMapping)
273267
for (const QString& cppcheckId: QString(i.cppcheckId).split(","))
274-
mGuideline[cppcheckId] = i.guideline;
268+
mGuideline[cppcheckId] = QString(i.guideline) + ext;
275269
};
276270

277271
if (reportType == ReportType::autosar)
278-
readInfo(checkers::autosarInfo);
272+
readIdMapping(checkers::idMappingAutosar);
279273
else if (reportType == ReportType::certC)
280-
readInfo(checkers::certCInfo);
274+
readIdMapping(checkers::idMappingCertC, "-C");
281275
else if (reportType == ReportType::certCpp) {
282-
readInfo(checkers::certCInfo);
283-
readInfo(checkers::certCppInfo);
276+
readIdMapping(checkers::idMappingCertC, "-C");
277+
readIdMapping(checkers::idMappingCertCpp, "-CPP");
284278
}
285279
else if (reportType == ReportType::misraC)
286280
readIdMapping(checkers::idMappingMisraC);

gui/test/resultstree/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_executable(test-resultstree
1010
${CMAKE_SOURCE_DIR}/gui/report.cpp
1111
${CMAKE_SOURCE_DIR}/gui/xmlreportv2.cpp
1212
${CMAKE_SOURCE_DIR}/lib/checkers.cpp
13+
${CMAKE_SOURCE_DIR}/lib/checkersidmapping.cpp
1314
)
1415
target_include_directories(test-resultstree PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib)
1516
target_compile_definitions(test-resultstree PRIVATE SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")

gui/test/resultstree/resultstree.pro

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ SOURCES += testresultstree.cpp \
1919
../../showtypes.cpp \
2020
../../report.cpp \
2121
../../xmlreportv2.cpp \
22-
../../../lib/checkers.cpp
22+
../../../lib/checkers.cpp \
23+
../../../lib/checkersidmapping.cpp
2324

2425
HEADERS += testresultstree.h \
2526
../../resultstree.h \

0 commit comments

Comments
 (0)