AlexanderLanin updated this revision to Diff 241895. AlexanderLanin added a comment.
Review findings applied (no real measurable difference in speed, maybe 100ms) but it's indeed more readable. Without this fix the export took 12.96 seconds, with this patch 11.07 seconds. Difference is even bigger when there are less auto fixable findings (70% with FIX-IT in my example). As there is no test suite available I run this without and with the change and manually compared the output. All warnings without FIX-IT have disappeared from exported, all warnings with FIX-IT are unmodified. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72730/new/ https://reviews.llvm.org/D72730 Files: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py =================================================================== --- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,16 @@ start.append(f) return start +# returns whether passed yaml Diagnostic (see mergekey) element contains FIX-IT +# FIX-IT replacements can be within the warning directly or within the notes. +def isAutoFixable(diag): + if diag["DiagnosticMessage"]["Replacements"]: return True + + for note in diag.get("Notes", []): + if note.get("Replacements", []): + return True + + return False def merge_replacement_files(tmpdir, mergefile): """Merge all replacement files in a directory into a single file""" @@ -116,7 +126,9 @@ content = yaml.safe_load(open(replacefile, 'r')) if not content: continue # Skip empty files. - merged.extend(content.get(mergekey, [])) + for d in content.get(mergekey, []): + if isAutoFixable(d): + merged.append(d) if merged: # MainSourceFile: The key is required by the definition inside
Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py =================================================================== --- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py +++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py @@ -105,6 +105,16 @@ start.append(f) return start +# returns whether passed yaml Diagnostic (see mergekey) element contains FIX-IT +# FIX-IT replacements can be within the warning directly or within the notes. +def isAutoFixable(diag): + if diag["DiagnosticMessage"]["Replacements"]: return True + + for note in diag.get("Notes", []): + if note.get("Replacements", []): + return True + + return False def merge_replacement_files(tmpdir, mergefile): """Merge all replacement files in a directory into a single file""" @@ -116,7 +126,9 @@ content = yaml.safe_load(open(replacefile, 'r')) if not content: continue # Skip empty files. - merged.extend(content.get(mergekey, [])) + for d in content.get(mergekey, []): + if isAutoFixable(d): + merged.append(d) if merged: # MainSourceFile: The key is required by the definition inside
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits