Skip to content

Commit 94a1a5d

Browse files
[analyzer][tests] Fix issue comparison script
When newer build has duplicate issues the script tried to remove it from the list more than once. The new approach changes the way we filter out matching issues. Differential Revision: https://reviews.llvm.org/D96611
1 parent f042fd4 commit 94a1a5d

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

clang/utils/analyzer/CmpRuns.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from copy import copy
3737
from enum import Enum
3838
from typing import (Any, DefaultDict, Dict, List, NamedTuple, Optional,
39-
Sequence, TextIO, TypeVar, Tuple, Union)
39+
Sequence, Set, TextIO, TypeVar, Tuple, Union)
4040

4141

4242
Number = Union[int, float]
@@ -374,8 +374,9 @@ def compare_results(results_old: AnalysisRun, results_new: AnalysisRun,
374374

375375
# Quadratic algorithms in this part are fine because 'old' and 'new'
376376
# are most commonly of size 1.
377-
for a in copy(old):
378-
for b in copy(new):
377+
common: Set[AnalysisDiagnostic] = set()
378+
for a in old:
379+
for b in new:
379380
if a.get_issue_identifier() == b.get_issue_identifier():
380381
a_path_len = a.get_path_length()
381382
b_path_len = b.get_path_length()
@@ -394,16 +395,22 @@ def compare_results(results_old: AnalysisRun, results_new: AnalysisRun,
394395
path_difference_data.append(
395396
a_path_len - b_path_len)
396397

397-
res.add_common(a)
398-
old.remove(a)
399-
new.remove(b)
398+
res.add_common(b)
399+
common.add(a)
400+
401+
old = filter_issues(old, common)
402+
new = filter_issues(new, common)
403+
common = set()
400404

401-
for a in copy(old):
402-
for b in copy(new):
405+
for a in old:
406+
for b in new:
403407
if a.is_similar_to(b):
404408
res.add_changed(a, b)
405-
old.remove(a)
406-
new.remove(b)
409+
common.add(a)
410+
common.add(b)
411+
412+
old = filter_issues(old, common)
413+
new = filter_issues(new, common)
407414

408415
# Whatever is left in 'old' doesn't have a corresponding diagnostic
409416
# in 'new', so we need to mark it as 'removed'.
@@ -443,6 +450,12 @@ def compare_results(results_old: AnalysisRun, results_new: AnalysisRun,
443450
return res
444451

445452

453+
def filter_issues(origin: List[AnalysisDiagnostic],
454+
to_remove: Set[AnalysisDiagnostic]) \
455+
-> List[AnalysisDiagnostic]:
456+
return [diag for diag in origin if diag not in to_remove]
457+
458+
446459
def compute_percentile(values: Sequence[T], percentile: float) -> T:
447460
"""
448461
Return computed percentile.

0 commit comments

Comments
 (0)