diff --git a/clang/test/Analysis/scan-build/html_output.test b/clang/test/Analysis/scan-build/html_output.test index eed2051d4df62..add35d83b9588 100644 --- a/clang/test/Analysis/scan-build/html_output.test +++ b/clang/test/Analysis/scan-build/html_output.test @@ -19,13 +19,17 @@ CHECK-FILENAMES: report-{{.*}}.html CHECK-FILENAMES: scanview.css CHECK-FILENAMES: sorttable.js - -// The index should have a link to the report for the single issue. +// Tests for the front page. RUN: cat %t.output_dir/*/index.html \ RUN: | FileCheck %s -check-prefix CHECK-INDEX-HTML +// Let's confirm that the new filtering facility is present. +CHECK-INDEX-HTML: Filter Results by File + +// The index should have a link to the report for the single issue. CHECK-INDEX-HTML: + // The report should describe the issue. RUN: cat %t.output_dir/*/report-*.html \ RUN: | FileCheck %s -check-prefix CHECK-REPORT-HTML diff --git a/clang/tools/scan-build/bin/scan-build b/clang/tools/scan-build/bin/scan-build index 04734d9cfa9af..37241c6d85c5b 100755 --- a/clang/tools/scan-build/bin/scan-build +++ b/clang/tools/scan-build/bin/scan-build @@ -722,9 +722,18 @@ ENDTEXT print OUT < + +

Filter Results by File

+ +

Reports

- +
diff --git a/clang/tools/scan-build/share/scan-build/sorttable.js b/clang/tools/scan-build/share/scan-build/sorttable.js index 32faa078d8993..e608daa9e39bc 100644 --- a/clang/tools/scan-build/share/scan-build/sorttable.js +++ b/clang/tools/scan-build/share/scan-build/sorttable.js @@ -490,3 +490,23 @@ var forEach = function(object, block, context) { resolve.forEach(object, block, context); } }; + +// filter results by filename +const searchFiles = () => { + const columns = [ + { name: 'Filename', index: 2, isFilter: true }, + ] + const filterColumns = columns.filter(c => c.isFilter).map(c => c.index) + const trs = document.querySelectorAll(`#reports_table tr:not(.header)`) + const filter = document.querySelector('#file_input').value + const regex = new RegExp(escape(filter), 'i') + const isFoundInTds = td => regex.test(td.innerHTML) + const isFound = childrenArr => childrenArr.some(isFoundInTds) + const setTrStyleDisplay = ({ style, children }) => { + style.display = isFound([ + ...filterColumns.map(c => children[c]) + ]) ? '' : 'none' + } + + trs.forEach(setTrStyleDisplay) +}
Bug Group Bug Type ▾