|
31 | 31 | from . import gcc_toolchain |
32 | 32 |
|
33 | 33 | from .analyzers import analyzer_types |
34 | | -from .analyzers.config_handler import CheckerState |
35 | 34 | from .analyzers.clangsa.analyzer import ClangSA |
| 35 | +from .analyzers.config_handler import CheckerState |
36 | 36 |
|
37 | 37 | LOG = get_logger('analyzer') |
38 | 38 |
|
@@ -305,31 +305,6 @@ def handle_reproducer(source_analyzer, rh, zip_file, actions_map): |
305 | 305 | LOG.debug("ZIP file written at '%s'", zip_file) |
306 | 306 |
|
307 | 307 |
|
308 | | -def handle_failure( |
309 | | - source_analyzer, rh, zip_file, result_base, actions_map, skip_handlers, |
310 | | - rs_handler: ReviewStatusHandler |
311 | | -): |
312 | | - """ |
313 | | - If the analysis fails a debug zip is packed together which contains |
314 | | - build, analysis information and source files to be able to |
315 | | - reproduce the failed analysis. |
316 | | - """ |
317 | | - handle_reproducer(source_analyzer, rh, zip_file, actions_map) |
318 | | - |
319 | | - # In case of compiler errors the error message still needs to be collected |
320 | | - # from the standard output by this postprocess phase so we can present them |
321 | | - # as CodeChecker reports. |
322 | | - checks = source_analyzer.config_handler.checks() |
323 | | - state = checks.get('clang-diagnostic-error', (CheckerState.ENABLED, ''))[0] |
324 | | - if state == CheckerState.ENABLED: |
325 | | - rh.postprocess_result(skip_handlers, rs_handler) |
326 | | - |
327 | | - # Remove files that successfully analyzed earlier on. |
328 | | - plist_file = result_base + ".plist" |
329 | | - if os.path.exists(plist_file): |
330 | | - os.remove(plist_file) |
331 | | - |
332 | | - |
333 | 308 | def setup_process_timeout(proc, timeout, |
334 | 309 | failure_callback=None): |
335 | 310 | """ |
@@ -554,20 +529,34 @@ def handle_analysis_result(success, zip_file=zip_file): |
554 | 529 | necessary files are collected for debugging. These .zip files can |
555 | 530 | also be generated by --generate-reproducer flag. |
556 | 531 | """ |
557 | | - if generate_reproducer: |
558 | | - handle_reproducer(source_analyzer, rh, |
559 | | - os.path.join(reproducer_dir, zip_file), |
560 | | - actions_map) |
561 | | - |
562 | 532 | if success: |
563 | 533 | handle_success(rh, result_file, result_base, |
564 | 534 | filter_handlers, rs_handler, |
565 | 535 | capture_analysis_output, success_dir) |
566 | | - elif not generate_reproducer: |
567 | | - handle_failure(source_analyzer, rh, |
568 | | - os.path.join(failed_dir, zip_file), |
569 | | - result_base, actions_map, skip_handlers, |
570 | | - rs_handler) |
| 536 | + else: |
| 537 | + # Postprocess failed analyses to capture compiler errors |
| 538 | + # in reports/statistics, unless clang-diagnostic-error |
| 539 | + # checker is explicitly disabled. |
| 540 | + checks = source_analyzer.config_handler.checks() |
| 541 | + state = checks.get('clang-diagnostic-error', |
| 542 | + (CheckerState.ENABLED, ''))[0] |
| 543 | + if state != CheckerState.DISABLED: |
| 544 | + rh.postprocess_result(skip_handlers, rs_handler) |
| 545 | + |
| 546 | + # Remove stale plist files from previous successful runs |
| 547 | + plist_file = result_base + ".plist" |
| 548 | + if os.path.exists(plist_file): |
| 549 | + os.remove(plist_file) |
| 550 | + |
| 551 | + # Generate reproducer or failure zip |
| 552 | + if generate_reproducer: |
| 553 | + handle_reproducer(source_analyzer, rh, |
| 554 | + os.path.join(reproducer_dir, zip_file), |
| 555 | + actions_map) |
| 556 | + elif not success: |
| 557 | + handle_reproducer(source_analyzer, rh, |
| 558 | + os.path.join(failed_dir, zip_file), |
| 559 | + actions_map) |
571 | 560 |
|
572 | 561 | if rh.analyzer_returncode == 0: |
573 | 562 | handle_analysis_result(success=True) |
|
0 commit comments