[PATCH] D76509: [analyzer][NFC] Move the text output type to its own file, move code to PathDiagnosticConsumer creator functions

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 20 09:44:40 PDT 2020


Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, baloghadamsoftware, martong, balazske, rnkovacs, dcoughlin, steakhal.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, usaxena95, Charusso, gamesh411, dkrupp, donat.nagy, kadircet, mikhail.ramalho, a.sidorin, szepet, ilya-biryukov, whisperity, mgorny.
Szelethus added a child revision: D76510: [analyzer] Change the default output type to PD_TEXT_MINIMAL, error if an output loc is missing for PathDiagConsumers that need it.

TableGen and `.def` files (which are meant to be used with the preprocessor) come with obvious downsides. One of those issues is that generated `switch`-`case` branches have to be identical. This pushes corner cases either to an outer code block, or into the generated code.

Inspect the removed code in `AnalysisConsumer::DigestAnalyzerOptions`. You can see how corner cases like a not existing output file, the analysis output type being set to `PD_NONE`, or whether to complement the output with additional diagnostics on stderr  lay //around// the preprocessor generated code. This is a bit problematic, as to how to deal with such errors is not in the hands of the users of this interface (those implementing output types, like `PlistDiagnostics` etc).

This patch changes this by moving these corner cases into the generated code, more specifically, into the called functions. In addition, I introduced a new output type for convenience purposes, `PD_TEXT_MINIMAL`, which always existed conceptually, but never in the actual `Analyses.def` file. This refactoring allowed me to move `TextDiagnostics` (renamed from `ClangDiagPathDiagConsumer`) to its own file, which it really deserved.

Also, those that had the misfortune to gaze upon `Analyses.def` will probably enjoy the sight that a clang-format did on it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76509

Files:
  clang/include/clang/StaticAnalyzer/Core/Analyses.def
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76509.251663.patch
Type: text/x-patch
Size: 25159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200320/f9d1ccfe/attachment-0001.bin>


More information about the cfe-commits mailing list