<p dir="ltr">Jordan, could you take a look at this patch?</p>
<div class="gmail_quote">On 15 Jan 2014 18:09, "Alexander Kornienko" <<a href="mailto:alexfh@google.com">alexfh@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi jordan_rose, krememek,<br>
<br>
Make objects returned by CreateAnalysisConsumer expose an interface,<br>
that allows providing a custom PathDiagnosticConsumer, so that users can have<br>
raw data in a form easily usable from the code (unlike plist/HTML in a file).<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2556" target="_blank">http://llvm-reviews.chandlerc.com/D2556</a><br>
<br>
Files:<br>
include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
<br>
Index: include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
===================================================================<br>
--- include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
+++ include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h<br>
@@ -15,26 +15,32 @@<br>
#ifndef LLVM_CLANG_GR_ANALYSISCONSUMER_H<br>
#define LLVM_CLANG_GR_ANALYSISCONSUMER_H<br>
<br>
+#include "clang/AST/ASTConsumer.h"<br>
#include "clang/Basic/LLVM.h"<br>
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"<br>
+#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"<br>
#include <string><br>
<br>
namespace clang {<br>
<br>
-class ASTConsumer;<br>
class Preprocessor;<br>
class DiagnosticsEngine;<br>
<br>
namespace ento {<br>
class CheckerManager;<br>
<br>
+class AnalysisASTConsumer : public ASTConsumer {<br>
+public:<br>
+ virtual void ReplaceDiagnosticConsumer(PathDiagnosticConsumer *Consumer) = 0;<br>
+};<br>
+<br>
/// CreateAnalysisConsumer - Creates an ASTConsumer to run various code<br>
/// analysis passes. (The set of analyses run is controlled by command-line<br>
/// options.)<br>
-ASTConsumer* CreateAnalysisConsumer(const Preprocessor &pp,<br>
- const std::string &output,<br>
- AnalyzerOptionsRef opts,<br>
- ArrayRef<std::string> plugins);<br>
+AnalysisASTConsumer *CreateAnalysisConsumer(const Preprocessor &pp,<br>
+ const std::string &output,<br>
+ AnalyzerOptionsRef opts,<br>
+ ArrayRef<std::string> plugins);<br>
<br>
} // end GR namespace<br>
<br>
Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
===================================================================<br>
--- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
+++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp<br>
@@ -145,7 +145,7 @@<br>
<br>
namespace {<br>
<br>
-class AnalysisConsumer : public ASTConsumer,<br>
+class AnalysisConsumer : public AnalysisASTConsumer,<br>
public DataRecursiveASTVisitor<AnalysisConsumer> {<br>
enum {<br>
AM_None = 0,<br>
@@ -377,6 +377,16 @@<br>
return true;<br>
}<br>
<br>
+ virtual void<br>
+ ReplaceDiagnosticConsumer(PathDiagnosticConsumer *Consumer) LLVM_OVERRIDE {<br>
+ for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),<br>
+ E = PathConsumers.end();<br>
+ I != E; ++I)<br>
+ delete *I;<br>
+ PathConsumers.clear();<br>
+ PathConsumers.push_back(Consumer);<br>
+ }<br>
+<br>
private:<br>
void storeTopLevelDecls(DeclGroupRef DG);<br>
<br>
@@ -687,10 +697,10 @@<br>
// AnalysisConsumer creation.<br>
//===----------------------------------------------------------------------===//<br>
<br>
-ASTConsumer* ento::CreateAnalysisConsumer(const Preprocessor& pp,<br>
- const std::string& outDir,<br>
- AnalyzerOptionsRef opts,<br>
- ArrayRef<std::string> plugins) {<br>
+AnalysisASTConsumer *<br>
+ento::CreateAnalysisConsumer(const Preprocessor &pp, const std::string &outDir,<br>
+ AnalyzerOptionsRef opts,<br>
+ ArrayRef<std::string> plugins) {<br>
// Disable the effects of '-Werror' when using the AnalysisConsumer.<br>
pp.getDiagnostics().setWarningsAsErrors(false);<br>
</blockquote></div>