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

2020-03-23 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Szelethus marked 6 inline comments as done.
Closed by commit rG7bf871c39f73: [analyzer][NFC] Move the text output type to 
its own file, move code to… (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D76509?vs=251973=252138#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

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
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt

Index: clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
===
--- clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
+++ clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
@@ -21,6 +21,4 @@
   clangLex
   clangStaticAnalyzerCheckers
   clangStaticAnalyzerCore
-  clangRewrite
-  clangToolingCore
   )
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -65,126 +65,6 @@
 STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
 
 //===--===//
-// Special PathDiagnosticConsumers.
-//===--===//
-
-void ento::createPlistHTMLDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  createHTMLDiagnosticConsumer(
-  AnalyzerOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP,
-  CTU);
-  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
-}
-
-void ento::createTextPathDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  llvm_unreachable("'text' consumer should be enabled on ClangDiags");
-}
-
-namespace {
-class ClangDiagPathDiagConsumer : public PathDiagnosticConsumer {
-  DiagnosticsEngine 
-  LangOptions LO;
-
-  bool IncludePath = false;
-  bool ShouldEmitAsError = false;
-  bool ApplyFixIts = false;
-
-public:
-  ClangDiagPathDiagConsumer(DiagnosticsEngine , LangOptions LO)
-  : Diag(Diag), LO(LO) {}
-  ~ClangDiagPathDiagConsumer() override {}
-  StringRef getName() const override { return "ClangDiags"; }
-
-  bool supportsLogicalOpControlFlow() const override { return true; }
-  bool supportsCrossFileDiagnostics() const override { return true; }
-
-  PathGenerationScheme getGenerationScheme() const override {
-return IncludePath ? Minimal : None;
-  }
-
-  void enablePaths() { IncludePath = true; }
-  void enableWerror() { ShouldEmitAsError = true; }
-  void enableApplyFixIts() { ApplyFixIts = true; }
-
-  void FlushDiagnosticsImpl(std::vector ,
-FilesMade *filesMade) override {
-unsigned WarnID =
-ShouldEmitAsError
-? Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")
-: Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
-unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0");
-SourceManager  = Diag.getSourceManager();
-
-Replacements Repls;
-auto reportPiece = [&](unsigned ID, FullSourceLoc Loc, StringRef String,
-   ArrayRef Ranges,
-   ArrayRef Fixits) {
-  if (!ApplyFixIts) {
-Diag.Report(Loc, ID) << String << Ranges << Fixits;
-return;
-  }
-
-  Diag.Report(Loc, ID) << String << Ranges;
-  for (const FixItHint  : Fixits) {
-Replacement Repl(SM, Hint.RemoveRange, Hint.CodeToInsert);
-
-if (llvm::Error Err = Repls.add(Repl)) {
-  llvm::errs() << "Error applying replacement " << Repl.toString()
-   << ": " << Err << "\n";
-}
-  }
-};
-
-for (std::vector::iterator I = Diags.begin(),
- E = Diags.end();
- I != E; ++I) {
-  const PathDiagnostic *PD = *I;
-  reportPiece(WarnID, PD->getLocation().asLocation(),
-  PD->getShortDescription(), PD->path.back()->getRanges(),
-  PD->path.back()->getFixits());
-
-  // First, add extra notes, even if paths should not be included.
-  for (const auto  : PD->path) {
-if (!isa(Piece.get()))
-  continue;
-
-reportPiece(NoteID, Piece->getLocation().asLocation(),
-   

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

2020-03-23 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware accepted this revision.
baloghadamsoftware added a comment.

Much more logical than the existing setup. LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

https://reviews.llvm.org/D76509



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-03-23 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

OK, LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

https://reviews.llvm.org/D76509



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-03-23 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 15 inline comments as done.
Szelethus added a comment.

Thanks, @martong!




Comment at: clang/include/clang/StaticAnalyzer/Core/Analyses.def:61
+
+ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal",
+ "Emits minimal diagnostics to stderr, stating only the "

martong wrote:
> Just out of curiosity: is there a way to know which one is the default?
Not from this file, unfortunately. You need to go to `AnalyzerOptions.h`. It 
would be great if we were able to list the possible options as well as the 
default value (similarly to `-analyzer-config`s), but I don't have plant to do 
it myself anytime soon.



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:140
+
+  // FIXME: HTML is currently our default output type, but if the output
+  // directory isn't specified, it acts like if it was in the minimal text

martong wrote:
> Actually, now I wonder where should we document the default output type ... I 
> am pretty sure it should be done somewhere where it is obvious, maybe in 
> `Analyses.def`?
`AnalyzerOptions.h`.



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:142
+  // directory isn't specified, it acts like if it was in the minimal text
+  // output mode. This doesn't make much sense, we should have the minimal text
+  // as our default. In the case of backward compatibility concerns, this could

martong wrote:
> Man, I understand you pain now, this is really muddled, do you plan to sort 
> this out in an upcoming patch?
Allow me to indulge you with the relieving fix found in D76510 :)



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:148
+  // TODO: Emit an error here.
+  if (OutputDir.empty())
+return;

martong wrote:
> martong wrote:
> > Would be an `assert` better here?
> ```
>  // if the output
>   // directory isn't specified, it acts like if it was in the minimal text
>   // output mode.
> ```
> So, why don't we do this check **before** calling 
> createTextMinimalPathDiagnosticConsumer ?
> 
  if (OutputDir.empty())
return;

  createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, CTU);
  C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, true));

Otherwise this would be a functional //and// breaking change. Mind that in this 
patch, HTML is still our default output type. If I were to move the text 
diagnostics below this line, we would no longer emit any diagnostics to stderr. 
I actually had the same idea, got ~670 breaking test :^)

  if (OutputDir.empty()) {
createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, 
CTU);
return;
  }

  C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, true));

With this code, we would no longer emit to stderr, only to HTML, should an 
output directory be specified.



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:148
+  // TODO: Emit an error here.
+  if (OutputDir.empty())
+return;

Szelethus wrote:
> martong wrote:
> > martong wrote:
> > > Would be an `assert` better here?
> > ```
> >  // if the output
> >   // directory isn't specified, it acts like if it was in the minimal text
> >   // output mode.
> > ```
> > So, why don't we do this check **before** calling 
> > createTextMinimalPathDiagnosticConsumer ?
> > 
>   if (OutputDir.empty())
> return;
> 
>   createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, 
> CTU);
>   C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, true));
> 
> Otherwise this would be a functional //and// breaking change. Mind that in 
> this patch, HTML is still our default output type. If I were to move the text 
> diagnostics below this line, we would no longer emit any diagnostics to 
> stderr. I actually had the same idea, got ~670 breaking test :^)
> 
>   if (OutputDir.empty()) {
> createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, 
> CTU);
> return;
>   }
> 
>   C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, true));
> 
> With this code, we would no longer emit to stderr, only to HTML, should an 
> output directory be specified.
> Would be an assert better here?

No, the point of the patch is to handle user errors (such as setting the output 
type to html but forgetting to supply the output location) in these factory 
functions. An assert would've been appropriate if I left 
`AnalysisConsumer::DigestAnalyzerOptions` untouched, as previously, that is 
where we checked such inconsistencies.



Comment at: clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp:1
+//===--- TextDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ 
-*-===//
+//

martong wrote:
> Is this just a blind copy (and rename) from `AnalysisConsumer`, or should I 
> take a deeper look into anything here?
Well, almost:

* Moved the 

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

2020-03-23 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/Analyses.def:17
 
-ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store", 
CreateRegionStoreManager)
+ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store",
+   CreateRegionStoreManager)

Yay! I am a big fun of the 80 col limit! :)



Comment at: clang/include/clang/StaticAnalyzer/Core/Analyses.def:61
+
+ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal",
+ "Emits minimal diagnostics to stderr, stating only the "

Just out of curiosity: is there a way to know which one is the default?



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:140
+
+  // FIXME: HTML is currently our default output type, but if the output
+  // directory isn't specified, it acts like if it was in the minimal text

Actually, now I wonder where should we document the default output type ... I 
am pretty sure it should be done somewhere where it is obvious, maybe in 
`Analyses.def`?



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:142
+  // directory isn't specified, it acts like if it was in the minimal text
+  // output mode. This doesn't make much sense, we should have the minimal text
+  // as our default. In the case of backward compatibility concerns, this could

Man, I understand you pain now, this is really muddled, do you plan to sort 
this out in an upcoming patch?



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:148
+  // TODO: Emit an error here.
+  if (OutputDir.empty())
+return;

Would be an `assert` better here?



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:148
+  // TODO: Emit an error here.
+  if (OutputDir.empty())
+return;

martong wrote:
> Would be an `assert` better here?
```
 // if the output
  // directory isn't specified, it acts like if it was in the minimal text
  // output mode.
```
So, why don't we do this check **before** calling 
createTextMinimalPathDiagnosticConsumer ?




Comment at: clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp:1
+//===--- TextDiagnostics.cpp - Text Diagnostics for Paths ---*- C++ 
-*-===//
+//

Is this just a blind copy (and rename) from `AnalysisConsumer`, or should I 
take a deeper look into anything here?



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:156
 #include "clang/StaticAnalyzer/Core/Analyses.def"
-}
-  }
+default:
+  llvm_unreachable("Unkown analyzer output type!");

Some build bots will not compile if you handle all cases in the swtich and you 
still have a `default`, beware.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:348
   void reportAnalyzerProgress(StringRef S);
-};
+}; // namespace
 } // end anonymous namespace

Either the `;` is redundant or this is not the end of a namespace.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

https://reviews.llvm.org/D76509



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-03-23 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 251973.
Szelethus added a comment.

Unbreak clang-tidy.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

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

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -60,115 +60,6 @@
 STATISTIC(PercentReachableBlocks, "The % of reachable basic blocks.");
 STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
 
-//===--===//
-// Special PathDiagnosticConsumers.
-//===--===//
-
-void ento::createPlistHTMLDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  createHTMLDiagnosticConsumer(
-  AnalyzerOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP,
-  CTU);
-  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
-}
-
-void ento::createTextPathDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  llvm_unreachable("'text' consumer should be enabled on ClangDiags");
-}
-
-namespace {
-class ClangDiagPathDiagConsumer : public PathDiagnosticConsumer {
-  DiagnosticsEngine 
-  bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false;
-
-public:
-  ClangDiagPathDiagConsumer(DiagnosticsEngine )
-  : Diag(Diag) {}
-  ~ClangDiagPathDiagConsumer() override {}
-  StringRef getName() const override { return "ClangDiags"; }
-
-  bool supportsLogicalOpControlFlow() const override { return true; }
-  bool supportsCrossFileDiagnostics() const override { return true; }
-
-  PathGenerationScheme getGenerationScheme() const override {
-return IncludePath ? Minimal : None;
-  }
-
-  void enablePaths() { IncludePath = true; }
-  void enableWerror() { ShouldEmitAsError = true; }
-  void enableFixitsAsRemarks() { FixitsAsRemarks = true; }
-
-  void FlushDiagnosticsImpl(std::vector ,
-FilesMade *filesMade) override {
-unsigned WarnID =
-ShouldEmitAsError
-? Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")
-: Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
-unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0");
-unsigned RemarkID = Diag.getCustomDiagID(DiagnosticsEngine::Remark, "%0");
-
-auto reportPiece =
-[&](unsigned ID, SourceLocation Loc, StringRef String,
-ArrayRef Ranges, ArrayRef Fixits) {
-  if (!FixitsAsRemarks) {
-Diag.Report(Loc, ID) << String << Ranges << Fixits;
-  } else {
-Diag.Report(Loc, ID) << String << Ranges;
-for (const FixItHint  : Fixits) {
-  SourceManager  = Diag.getSourceManager();
-  llvm::SmallString<128> Str;
-  llvm::raw_svector_ostream OS(Str);
-  // FIXME: Add support for InsertFromRange and
-  // BeforePreviousInsertion.
-  assert(!Hint.InsertFromRange.isValid() && "Not implemented yet!");
-  assert(!Hint.BeforePreviousInsertions && "Not implemented yet!");
-  OS << SM.getSpellingColumnNumber(Hint.RemoveRange.getBegin())
- << "-" << SM.getSpellingColumnNumber(Hint.RemoveRange.getEnd())
- << ": '" << Hint.CodeToInsert << "'";
-  Diag.Report(Loc, RemarkID) << OS.str();
-}
-  }
-};
-
-for (std::vector::iterator I = Diags.begin(),
- E = Diags.end();
- I != E; ++I) {
-  const PathDiagnostic *PD = *I;
-  reportPiece(WarnID, PD->getLocation().asLocation(),
-  PD->getShortDescription(), PD->path.back()->getRanges(),
-  PD->path.back()->getFixits());
-
-  // First, add extra notes, even if paths should not be included.
-  for (const auto  : PD->path) {
-if (!isa(Piece.get()))
-  continue;
-
-reportPiece(NoteID, Piece->getLocation().asLocation(),
-Piece->getString(), Piece->getRanges(), Piece->getFixits());
-  }
-
-  if (!IncludePath)
-continue;
-
-  // Then, add the path notes if necessary.
-  PathPieces FlatPath = 

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

2020-03-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:148
   void DigestAnalyzerOptions() {
-if (Opts->AnalysisDiagOpt != PD_NONE) {
-  // Create the PathDiagnosticConsumer.
-  ClangDiagPathDiagConsumer *clangDiags =
-  new ClangDiagPathDiagConsumer(PP.getDiagnostics());
-  PathConsumers.push_back(clangDiags);
-
-  if (Opts->AnalyzerWerror)
-clangDiags->enableWerror();
-
-  if (Opts->ShouldEmitFixItHintsAsRemarks)
-clangDiags->enableFixitsAsRemarks();
-
-  if (Opts->AnalysisDiagOpt == PD_TEXT) {
-clangDiags->enablePaths();
-
-  } else if (!OutDir.empty()) {
-switch (Opts->AnalysisDiagOpt) {
-default:
+switch (Opts->AnalysisDiagOpt) {
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
\

Will need to handle `PD_NONE`, or clang-tidy will crash all over the place.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76509/new/

https://reviews.llvm.org/D76509



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-03-20 Thread Kristóf Umann via Phabricator via cfe-commits
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

Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -60,115 +60,6 @@
 STATISTIC(PercentReachableBlocks, "The % of reachable basic blocks.");
 STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
 
-//===--===//
-// Special PathDiagnosticConsumers.
-//===--===//
-
-void ento::createPlistHTMLDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  createHTMLDiagnosticConsumer(
-  AnalyzerOpts, C, std::string(llvm::sys::path::parent_path(prefix)), PP,
-  CTU);
-  createPlistMultiFileDiagnosticConsumer(AnalyzerOpts, C, prefix, PP, CTU);
-}
-
-void ento::createTextPathDiagnosticConsumer(
-AnalyzerOptions , PathDiagnosticConsumers ,
-const std::string , const clang::Preprocessor ,
-const cross_tu::CrossTranslationUnitContext ) {
-  llvm_unreachable("'text' consumer should be enabled on ClangDiags");
-}
-
-namespace {
-class ClangDiagPathDiagConsumer : public PathDiagnosticConsumer {
-  DiagnosticsEngine 
-  bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false;
-
-public:
-  ClangDiagPathDiagConsumer(DiagnosticsEngine )
-  : Diag(Diag) {}
-  ~ClangDiagPathDiagConsumer() override {}
-  StringRef getName() const override { return "ClangDiags"; }
-
-  bool supportsLogicalOpControlFlow() const override { return true; }
-  bool supportsCrossFileDiagnostics() const override { return true; }
-
-  PathGenerationScheme getGenerationScheme() const override {
-return IncludePath ? Minimal : None;
-  }
-
-  void enablePaths() { IncludePath = true; }
-  void enableWerror() { ShouldEmitAsError = true; }
-  void enableFixitsAsRemarks() { FixitsAsRemarks = true; }
-
-  void FlushDiagnosticsImpl(std::vector ,
-FilesMade *filesMade) override {
-unsigned WarnID =
-ShouldEmitAsError
-? Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0")
-: Diag.getCustomDiagID(DiagnosticsEngine::Warning, "%0");
-unsigned NoteID = Diag.getCustomDiagID(DiagnosticsEngine::Note, "%0");
-unsigned RemarkID = Diag.getCustomDiagID(DiagnosticsEngine::Remark, "%0");
-
-auto reportPiece =
-[&](unsigned ID, SourceLocation Loc, StringRef String,
-ArrayRef Ranges,