diff --git a/tools/report-converter/codechecker_report_converter/analyzers/sanitizers/ub/parser.py b/tools/report-converter/codechecker_report_converter/analyzers/sanitizers/ub/parser.py index 4c3498fa14..65bec1b221 100644 --- a/tools/report-converter/codechecker_report_converter/analyzers/sanitizers/ub/parser.py +++ b/tools/report-converter/codechecker_report_converter/analyzers/sanitizers/ub/parser.py @@ -188,6 +188,7 @@ def parse_sanitizer_message( stack_traces, events, line = self.parse_stack_trace(it, line) message = match.group('message').strip() + checker_name = None for check, patterns in self.checks.items(): if any(pattern.search(message) for pattern in patterns): checker_name = f"{self.checker_name}.{check}" diff --git a/tools/report-converter/tests/unit/analyzers/test_ubsan_parser.py b/tools/report-converter/tests/unit/analyzers/test_ubsan_parser.py index 0bcb62ada7..b8e031e795 100644 --- a/tools/report-converter/tests/unit/analyzers/test_ubsan_parser.py +++ b/tools/report-converter/tests/unit/analyzers/test_ubsan_parser.py @@ -90,6 +90,16 @@ def test_ubsan1(self): self.__check_analyzer_result('ubsan1.out', 'ubsan1.cpp_ubsan.plist', ['files/ubsan1.cpp'], 'ubsan1.plist') + def test_ubsan1_nonmatching_msg(self): + """ + Test for the test_ubsan1_nonmatching_msg.plist file, where the reported + error message doesn't match any of the checkers we recognize. + """ + self.maxDiff = None + self.__check_analyzer_result( + 'ubsan1_nonmatching_msg.out', 'ubsan1.cpp_ubsan.plist', + ['files/ubsan1.cpp'], 'ubsan1_nonmatching_msg.plist') + def test_ubsan2(self): """ Test for the ubsan2.plist file. """ self.__check_analyzer_result('ubsan2.out', 'ubsan2.cpp_ubsan.plist', diff --git a/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.out b/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.out new file mode 100644 index 0000000000..f404c69e0c --- /dev/null +++ b/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.out @@ -0,0 +1 @@ +files/ubsan1.cpp:4:5: runtime error: This is not an actual error message, just tests whether we crash on a msg we don't associate with a checker. diff --git a/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.plist b/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.plist new file mode 100644 index 0000000000..7de0a96b6c --- /dev/null +++ b/tools/report-converter/tests/unit/analyzers/ubsan_output_test_files/ubsan1_nonmatching_msg.plist @@ -0,0 +1,69 @@ + + + + + diagnostics + + + category + unknown + check_name + UndefinedBehaviorSanitizer + description + This is not an actual error message, just tests whether we crash on a msg we don't associate with a checker. + issue_hash_content_of_line_in_context + 253cc81796d3eccc4c6fa0c4ade5bb53 + location + + col + 5 + file + 0 + line + 4 + + path + + + depth + 0 + kind + event + location + + col + 5 + file + 0 + line + 4 + + message + This is not an actual error message, just tests whether we crash on a msg we don't associate with a checker. + + + type + ubsan + + + files + + files/ubsan1.cpp + + metadata + + analyzer + + name + ubsan + + generated_by + + name + report-converter + version + x.y.z + + + +