[all-commits] [llvm/llvm-project] 7bf871: [analyzer][NFC] Move the text output type to its o...

Kristóf Umann via All-commits all-commits at lists.llvm.org
Mon Mar 23 13:50:47 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 7bf871c39f739a7382ba89c97f50fd047f36f894
      https://github.com/llvm/llvm-project/commit/7bf871c39f739a7382ba89c97f50fd047f36f894
  Author: Kirstóf Umann <dkszelethus at gmail.com>
  Date:   2020-03-23 (Mon, 23 Mar 2020)

  Changed paths:
    M clang/include/clang/StaticAnalyzer/Core/Analyses.def
    M clang/lib/StaticAnalyzer/Core/CMakeLists.txt
    M clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
    A clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
    M clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
    M clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt

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

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.

Differential Revision: https://reviews.llvm.org/D76509




More information about the All-commits mailing list