This is useful for performing custom build system integration that works by appending '--analyze --analyzer-output html' to all clang build commands. In this case there is now still a way to have a fancy index.html with the output.
Details
Diff Detail
Event Timeline
clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test | ||
---|---|---|
11–12 | The script is indeed capable of finding html reports in sub-directories and it's a fairly useful feature because in a custom build system integration it's likely that clang's -o flag will be very messed up. |
Thanks! I would mention in the Summary the necessary flags to perform index-only output. (May write some release notes?)
That option sounds very strange, but I like it. For example to run only necessary custom tests one could write:
-analyzer-checker=core,unix,custom.checkers \ -analyzer-config silence-checkers="core;unix"
clang/tools/scan-build/bin/scan-build | ||
---|---|---|
953 | May inject Diag "Analysis run complete.\n"; here? | |
976 | If we stick to printing information to the user: Diag "No bugs found.\n"?. | |
1303 | What about --index-only? | |
1618 | I may smash this duplicated error-handling above in one if-stmt, given that the options are correlate with each other. |
clang/tools/scan-build/bin/scan-build | ||
---|---|---|
953 | Indeed! | |
976 | We already kind of have it when it says "deleting output directory because it contains no reports". | |
1303 | Renamed to --generate-index-only :) | |
1618 | Dunno, i'd rather keep the structure. The function is huge, i'd rather keep it well-structured, and "each option is handled in exactly once if-statement" is good for it. |
Reverted due to a lot of buildbot failures, eg. http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/62758/steps/test-check-all/logs/stdio
$ "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/tools/scan-build/bin/scan-build" "--use-analyzer=/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/bin/clang" "--generate-index-only" "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir" # command output: scan-build: Analysis run complete. scan-build: 3 bugs found. scan-build: Run 'scan-view /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir' to examine bug reports. $ ":" "RUN: at line 16" $ "ls" "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir" $ "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/bin/FileCheck" "-check-prefix" "CHECK-FILES" "/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test" # command stderr: /home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test:19:19: error: CHECK-FILES-NEXT: expected string not found in input CHECK-FILES-NEXT: report-1.html ^ <stdin>:2:1: note: scanning from here report-2.html ^ error: command failed with exit status: 1
Weird, all three bugs found but report-1 is not present, is it just that ls doesn't sort the output or is it about our deduplication removing a different duplicate?..
That is very unfortunate, but may if you could introduce a bullet-proof ls we could see if the scan-build sub-directory removal is non-alphabetical. I think the latter smells more badly.
clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test | ||
---|---|---|
17 | If you think that the ls is the problem may we need ls -R to print out every folder. (https://explainshell.com/explain?cmd=ls+-R) There are more exotic ways to sort the order, like LANG=C ls: https://stackoverflow.com/questions/878249/unixs-ls-sort-by-name/878269 |
Could you mention how to use this feature in the Summary please?
cd reports scan-build --generate-index-only .
And something is not right, I have tried it:
Use of uninitialized value $Clang in concatenation (.) or string at /llvm-project/clang/tools/scan-build/bin/scan-build line 1895. sh: 1: : Permission denied
But it made the index.html and works like a charm.
Yup, this was supposed to work.
And something is not right, I have tried it:
Use of uninitialized value $Clang in concatenation (.) or string at /llvm-project/clang/tools/scan-build/bin/scan-build line 1895.
Uh-oh. Does this still show up if you specify --use-analyzer explicitly? Because %scan_build in tests includes this flag because otherwise it has no knowledge of the clang build directory.
sh: 1: : Permission denied
This looks like a separate problem, dunno.
Well, then please mention the proper usage is:
cd reports scan-build --use-analyzer clang --generate-index-only .
With that none of the concatenation and sh permission issue shows up. However it would be a nice QoL if that extra flag is not needed to generate HTML.
Re-landed as rG0c27fd82e1e6.
I sorted the list of HTML files before deduplicating and the buildbots seem silent for now.
Also fxd the uninitialized variable $Clang use when --use-analyzer= is not specified; here's what it was used for:
The script is indeed capable of finding html reports in sub-directories and it's a fairly useful feature because in a custom build system integration it's likely that clang's -o flag will be very messed up.