The title and the included test file sums everything up -- the only thing I'm mildly afraid of is whether anyone actually depends on the weird behavior of HTMLDiagnostics pretending to be TextDiagnostics if an output directory is not supplied. If it is, I guess we would need to resort to tiptoeing around the compatibility flag.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | ||
---|---|---|
26 | Woops. I rebased this on a patch that moves TextDiagnostics to its own file and forgot about this. |
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h | ||
---|---|---|
209 | This patch most likely changes almost nothing because the default output mode of clang --analyze has always been Plist: lib/Driver/ToolChains/Clang.cpp 2938: // Set the output format. The default is plist, for (lame) historical reasons. 2939- CmdArgs.push_back("-analyzer-output"); 2940- if (Arg *A = Args.getLastArg(options::OPT__analyzer_output)) 2941- CmdArgs.push_back(A->getValue()); 2942- else 2943- CmdArgs.push_back("plist"); I'll double check on historical reasons; i suspect we should be able to transition out of it eventually because this is indeed the worst possible output mode for --analyze. That said, i wonder how/why do our tests currently work without flooding everything with html reports. |
Lets highlight then that this change affects the analyzer in frontend mode, not in the driver configuration. I might make a patch for that too, btw.
@NoQ, were you able to check whether this change could break anything? :)
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h | ||
---|---|---|
209 | Because the HTML report acts like the text if no output file is supplied. |
Hi @Szelethus , it looks like I am a bearer of bad news again :(
This patch seems to crash scan-build on pretty much every project that I tested.
One way to reproduce:
git clone https://github.com/postgres/postgres.git cd postgres/ scan-build -plist-html -o ./out ./configure
Output:
scan-build: Using '/Users/vsavchenko/source/llvm-project/build/Release/bin/clang-11' for static analysis checking build system type... x86_64-apple-darwin19.4.0 checking host system type... x86_64-apple-darwin19.4.0 checking which template to use... darwin checking whether NLS is wanted... no checking for default port number... 5432 checking for block size... 8kB checking for segment size... 1GB checking for WAL block size... 8kB checking whether the C compiler works... no configure: error: in `/Users/vsavchenko/source/postgres': configure: error: C compiler cannot create executables See `config.log' for more details scan-build: Analysis run complete. scan-build: Analysis results (plist files) deposited in '/Users/vsavchenko/source/postgres/out/2020-05-22-194935-27687-1' scan-build: Removing directory '/Users/vsavchenko/source/postgres/out/2020-05-22-194935-27687-1' because it contains no reports. scan-build: No bugs found.
config.log will contain something similar to this:
configure:3987: checking whether the C compiler works configure:4009: /Users/vsavchenko/source/llvm-project/build/Release/bin/../libexec/ccc-analyzer conftest.c >&5 error: analyzer output type 'html' requires an output directory to be specified with -o </path/to/output_directory> 1 error generated. Use of uninitialized value $HtmlDir in concatenation (.) or string at /Users/vsavchenko/source/llvm-project/build/Release/bin/../libexec/ccc-analyzer line 149, <$fh> line 2. mkdir /failures: Read-only file system at /Users/vsavchenko/source/llvm-project/build/Release/bin/../libexec/ccc-analyzer line 150.
This isn't so bad as far as news go, considering you saved a lot of work for me in terms of reproducing this! I'll look into it, thanks! I admit to not use scan-build much. :^)
Reverted in rG429f03089951d62fb370026905c87f1f25cf220f because its late and this is a breaking change to scan-build.
This patch most likely changes almost nothing because the default output mode of clang --analyze has always been Plist:
I'll double check on historical reasons; i suspect we should be able to transition out of it eventually because this is indeed the worst possible output mode for --analyze.
That said, i wonder how/why do our tests currently work without flooding everything with html reports.