Rename PathDiagnosticClient to PathDiagnosticConsumer as per issue 5397

llvm-svn: 140492
This commit is contained in:
David Blaikie 2011-09-26 00:51:36 +00:00
parent 292e76939b
commit 53c125d063
13 changed files with 64 additions and 62 deletions

View File

@ -28,10 +28,10 @@ ANALYSIS_CONSTRAINTS(RangeConstraints, "range", "Use constraint tracking of conc
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE)
#endif #endif
ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", createHTMLDiagnosticClient, false) ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML", createHTMLDiagnosticConsumer, false)
ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", createPlistDiagnosticClient, true) ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists", createPlistDiagnosticConsumer, true)
ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", createPlistHTMLDiagnosticClient, true) ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html", "Output analysis results using HTML wrapped with Plists", createPlistHTMLDiagnosticConsumer, true)
ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results", createTextPathDiagnosticClient, true) ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results", createTextPathDiagnosticConsumer, true)
#undef ANALYSIS_STORE #undef ANALYSIS_STORE
#undef ANALYSIS_CONSTRAINTS #undef ANALYSIS_CONSTRAINTS

View File

@ -218,7 +218,7 @@ class BugReporterData {
public: public:
virtual ~BugReporterData(); virtual ~BugReporterData();
virtual DiagnosticsEngine& getDiagnostic() = 0; virtual DiagnosticsEngine& getDiagnostic() = 0;
virtual PathDiagnosticClient* getPathDiagnosticClient() = 0; virtual PathDiagnosticConsumer* getPathDiagnosticConsumer() = 0;
virtual ASTContext &getASTContext() = 0; virtual ASTContext &getASTContext() = 0;
virtual SourceManager& getSourceManager() = 0; virtual SourceManager& getSourceManager() = 0;
}; };
@ -264,8 +264,8 @@ public:
return D.getDiagnostic(); return D.getDiagnostic();
} }
PathDiagnosticClient* getPathDiagnosticClient() { PathDiagnosticConsumer* getPathDiagnosticConsumer() {
return D.getPathDiagnosticClient(); return D.getPathDiagnosticConsumer();
} }
/// \brief Iterator over the set of BugTypes tracked by the BugReporter. /// \brief Iterator over the set of BugTypes tracked by the BugReporter.

View File

@ -45,11 +45,11 @@ class ExplodedNode;
class PathDiagnostic; class PathDiagnostic;
class PathDiagnosticClient { class PathDiagnosticConsumer {
public: public:
PathDiagnosticClient() {} PathDiagnosticConsumer() {}
virtual ~PathDiagnosticClient() {} virtual ~PathDiagnosticConsumer() {}
virtual void virtual void
FlushDiagnostics(SmallVectorImpl<std::string> *FilesMade = 0) = 0; FlushDiagnostics(SmallVectorImpl<std::string> *FilesMade = 0) = 0;
@ -70,7 +70,7 @@ public:
protected: protected:
/// The actual logic for handling path diagnostics, as implemented /// The actual logic for handling path diagnostics, as implemented
/// by subclasses of PathDiagnosticClient. /// by subclasses of PathDiagnosticConsumer.
virtual void HandlePathDiagnosticImpl(const PathDiagnostic* D) = 0; virtual void HandlePathDiagnosticImpl(const PathDiagnostic* D) = 0;
}; };
@ -288,7 +288,7 @@ public:
const std::string& getString() const { return str; } const std::string& getString() const { return str; }
/// getDisplayHint - Return a hint indicating where the diagnostic should /// getDisplayHint - Return a hint indicating where the diagnostic should
/// be displayed by the PathDiagnosticClient. /// be displayed by the PathDiagnosticConsumer.
DisplayHint getDisplayHint() const { return Hint; } DisplayHint getDisplayHint() const { return Hint; }
virtual PathDiagnosticLocation getLocation() const = 0; virtual PathDiagnosticLocation getLocation() const = 0;

View File

@ -22,17 +22,17 @@ class Preprocessor;
namespace ento { namespace ento {
class PathDiagnosticClient; class PathDiagnosticConsumer;
PathDiagnosticClient* PathDiagnosticConsumer*
createHTMLDiagnosticClient(const std::string& prefix, const Preprocessor &PP); createHTMLDiagnosticConsumer(const std::string& prefix, const Preprocessor &PP);
PathDiagnosticClient* PathDiagnosticConsumer*
createPlistDiagnosticClient(const std::string& prefix, const Preprocessor &PP, createPlistDiagnosticConsumer(const std::string& prefix, const Preprocessor &PP,
PathDiagnosticClient *SubPD = 0); PathDiagnosticConsumer *SubPD = 0);
PathDiagnosticClient* PathDiagnosticConsumer*
createTextPathDiagnosticClient(const std::string& prefix, createTextPathDiagnosticConsumer(const std::string& prefix,
const Preprocessor &PP); const Preprocessor &PP);
} // end GR namespace } // end GR namespace

View File

@ -37,7 +37,7 @@ class AnalysisManager : public BugReporterData {
DiagnosticsEngine &Diags; DiagnosticsEngine &Diags;
const LangOptions &LangInfo; const LangOptions &LangInfo;
llvm::OwningPtr<PathDiagnosticClient> PD; llvm::OwningPtr<PathDiagnosticConsumer> PD;
// Configurable components creators. // Configurable components creators.
StoreManagerCreator CreateStoreMgr; StoreManagerCreator CreateStoreMgr;
@ -76,7 +76,7 @@ class AnalysisManager : public BugReporterData {
public: public:
AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags, AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags,
const LangOptions &lang, PathDiagnosticClient *pd, const LangOptions &lang, PathDiagnosticConsumer *pd,
StoreManagerCreator storemgr, StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr, ConstraintManagerCreator constraintmgr,
CheckerManager *checkerMgr, CheckerManager *checkerMgr,
@ -126,7 +126,7 @@ public:
return LangInfo; return LangInfo;
} }
virtual PathDiagnosticClient *getPathDiagnosticClient() { virtual PathDiagnosticConsumer *getPathDiagnosticConsumer() {
return PD.get(); return PD.get();
} }

View File

@ -15,7 +15,8 @@ using namespace clang;
using namespace ento; using namespace ento;
AnalysisManager::AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags, AnalysisManager::AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags,
const LangOptions &lang, PathDiagnosticClient *pd, const LangOptions &lang,
PathDiagnosticConsumer *pd,
StoreManagerCreator storemgr, StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr, ConstraintManagerCreator constraintmgr,
CheckerManager *checkerMgr, CheckerManager *checkerMgr,

View File

@ -127,13 +127,13 @@ public:
class PathDiagnosticBuilder : public BugReporterContext { class PathDiagnosticBuilder : public BugReporterContext {
BugReport *R; BugReport *R;
PathDiagnosticClient *PDC; PathDiagnosticConsumer *PDC;
llvm::OwningPtr<ParentMap> PM; llvm::OwningPtr<ParentMap> PM;
NodeMapClosure NMC; NodeMapClosure NMC;
public: public:
PathDiagnosticBuilder(GRBugReporter &br, PathDiagnosticBuilder(GRBugReporter &br,
BugReport *r, NodeBackMap *Backmap, BugReport *r, NodeBackMap *Backmap,
PathDiagnosticClient *pdc) PathDiagnosticConsumer *pdc)
: BugReporterContext(br), : BugReporterContext(br),
R(r), PDC(pdc), NMC(Backmap) {} R(r), PDC(pdc), NMC(Backmap) {}
@ -160,8 +160,8 @@ public:
PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S); PathDiagnosticLocation getEnclosingStmtLocation(const Stmt *S);
PathDiagnosticClient::PathGenerationScheme getGenerationScheme() const { PathDiagnosticConsumer::PathGenerationScheme getGenerationScheme() const {
return PDC ? PDC->getGenerationScheme() : PathDiagnosticClient::Extensive; return PDC ? PDC->getGenerationScheme() : PathDiagnosticConsumer::Extensive;
} }
bool supportsLogicalOpControlFlow() const { bool supportsLogicalOpControlFlow() const {
@ -1631,7 +1631,8 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
const ExplodedNode *N = GPair.second.first; const ExplodedNode *N = GPair.second.first;
// Start building the path diagnostic... // Start building the path diagnostic...
PathDiagnosticBuilder PDB(*this, R, BackMap.get(), getPathDiagnosticClient()); PathDiagnosticBuilder PDB(*this, R, BackMap.get(),
getPathDiagnosticConsumer());
// Register additional node visitors. // Register additional node visitors.
R->addVisitor(new NilReceiverBRVisitor()); R->addVisitor(new NilReceiverBRVisitor());
@ -1656,10 +1657,10 @@ void GRBugReporter::GeneratePathDiagnostic(PathDiagnostic& PD,
return; return;
switch (PDB.getGenerationScheme()) { switch (PDB.getGenerationScheme()) {
case PathDiagnosticClient::Extensive: case PathDiagnosticConsumer::Extensive:
GenerateExtensivePathDiagnostic(PD, PDB, N); GenerateExtensivePathDiagnostic(PD, PDB, N);
break; break;
case PathDiagnosticClient::Minimal: case PathDiagnosticConsumer::Minimal:
GenerateMinimalPathDiagnostic(PD, PDB, N); GenerateMinimalPathDiagnostic(PD, PDB, N);
break; break;
} }
@ -1850,7 +1851,7 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
if (!exampleReport) if (!exampleReport)
return; return;
PathDiagnosticClient* PD = getPathDiagnosticClient(); PathDiagnosticConsumer* PD = getPathDiagnosticConsumer();
// FIXME: Make sure we use the 'R' for the path that was actually used. // FIXME: Make sure we use the 'R' for the path that was actually used.
// Probably doesn't make a difference in practice. // Probably doesn't make a difference in practice.
@ -1906,7 +1907,7 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
diagBuilder << *I; diagBuilder << *I;
} }
// Emit a full diagnostic for the path if we have a PathDiagnosticClient. // Emit a full diagnostic for the path if we have a PathDiagnosticConsumer.
if (!PD) if (!PD)
return; return;

View File

@ -786,7 +786,7 @@ void CallEnterNodeBuilder::generateNode(const ProgramState *state) {
// The Diagnostic is actually shared when we create ASTUnits from AST files. // The Diagnostic is actually shared when we create ASTUnits from AST files.
AnalysisManager AMgr(TU->getASTContext(), TU->getDiagnostic(), AnalysisManager AMgr(TU->getASTContext(), TU->getDiagnostic(),
OldMgr.getLangOptions(), OldMgr.getLangOptions(),
OldMgr.getPathDiagnosticClient(), OldMgr.getPathDiagnosticConsumer(),
OldMgr.getStoreManagerCreator(), OldMgr.getStoreManagerCreator(),
OldMgr.getConstraintManagerCreator(), OldMgr.getConstraintManagerCreator(),
OldMgr.getCheckerManager(), OldMgr.getCheckerManager(),

View File

@ -35,7 +35,7 @@ using namespace ento;
namespace { namespace {
class HTMLDiagnostics : public PathDiagnosticClient { class HTMLDiagnostics : public PathDiagnosticConsumer {
llvm::sys::Path Directory, FilePrefix; llvm::sys::Path Directory, FilePrefix;
bool createdDir, noDir; bool createdDir, noDir;
const Preprocessor &PP; const Preprocessor &PP;
@ -78,8 +78,8 @@ HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix,
FilePrefix.appendComponent("report"); FilePrefix.appendComponent("report");
} }
PathDiagnosticClient* PathDiagnosticConsumer*
ento::createHTMLDiagnosticClient(const std::string& prefix, ento::createHTMLDiagnosticConsumer(const std::string& prefix,
const Preprocessor &PP) { const Preprocessor &PP) {
return new HTMLDiagnostics(prefix, PP); return new HTMLDiagnostics(prefix, PP);
} }

View File

@ -82,10 +82,10 @@ PathDiagnostic::PathDiagnostic(StringRef bugtype, StringRef desc,
Desc(StripTrailingDots(desc)), Desc(StripTrailingDots(desc)),
Category(StripTrailingDots(category)) {} Category(StripTrailingDots(category)) {}
void PathDiagnosticClient::HandlePathDiagnostic(const PathDiagnostic *D) { void PathDiagnosticConsumer::HandlePathDiagnostic(const PathDiagnostic *D) {
// For now this simply forwards to HandlePathDiagnosticImpl. In the future // For now this simply forwards to HandlePathDiagnosticImpl. In the future
// we can use this indirection to control for multi-threaded access to // we can use this indirection to control for multi-threaded access to
// the PathDiagnosticClient from multiple bug reporters. // the PathDiagnosticConsumer from multiple bug reporters.
HandlePathDiagnosticImpl(D); HandlePathDiagnosticImpl(D);
} }

View File

@ -60,15 +60,15 @@ struct CompareDiagnostics {
} }
namespace { namespace {
class PlistDiagnostics : public PathDiagnosticClient { class PlistDiagnostics : public PathDiagnosticConsumer {
std::vector<const PathDiagnostic*> BatchedDiags; std::vector<const PathDiagnostic*> BatchedDiags;
const std::string OutputFile; const std::string OutputFile;
const LangOptions &LangOpts; const LangOptions &LangOpts;
llvm::OwningPtr<PathDiagnosticClient> SubPD; llvm::OwningPtr<PathDiagnosticConsumer> SubPD;
bool flushed; bool flushed;
public: public:
PlistDiagnostics(const std::string& prefix, const LangOptions &LangOpts, PlistDiagnostics(const std::string& prefix, const LangOptions &LangOpts,
PathDiagnosticClient *subPD); PathDiagnosticConsumer *subPD);
~PlistDiagnostics() { FlushDiagnostics(NULL); } ~PlistDiagnostics() { FlushDiagnostics(NULL); }
@ -89,18 +89,18 @@ namespace {
PlistDiagnostics::PlistDiagnostics(const std::string& output, PlistDiagnostics::PlistDiagnostics(const std::string& output,
const LangOptions &LO, const LangOptions &LO,
PathDiagnosticClient *subPD) PathDiagnosticConsumer *subPD)
: OutputFile(output), LangOpts(LO), SubPD(subPD), flushed(false) {} : OutputFile(output), LangOpts(LO), SubPD(subPD), flushed(false) {}
PathDiagnosticClient* PathDiagnosticConsumer*
ento::createPlistDiagnosticClient(const std::string& s, const Preprocessor &PP, ento::createPlistDiagnosticConsumer(const std::string& s, const Preprocessor &PP,
PathDiagnosticClient *subPD) { PathDiagnosticConsumer *subPD) {
return new PlistDiagnostics(s, PP.getLangOptions(), subPD); return new PlistDiagnostics(s, PP.getLangOptions(), subPD);
} }
PathDiagnosticClient::PathGenerationScheme PathDiagnosticConsumer::PathGenerationScheme
PlistDiagnostics::getGenerationScheme() const { PlistDiagnostics::getGenerationScheme() const {
if (const PathDiagnosticClient *PD = SubPD.get()) if (const PathDiagnosticConsumer *PD = SubPD.get())
return PD->getGenerationScheme(); return PD->getGenerationScheme();
return Extensive; return Extensive;

View File

@ -23,7 +23,7 @@ namespace {
/// \brief Simple path diagnostic client used for outputting as diagnostic notes /// \brief Simple path diagnostic client used for outputting as diagnostic notes
/// the sequence of events. /// the sequence of events.
class TextPathDiagnostics : public PathDiagnosticClient { class TextPathDiagnostics : public PathDiagnosticConsumer {
const std::string OutputFile; const std::string OutputFile;
DiagnosticsEngine &Diag; DiagnosticsEngine &Diag;
@ -47,8 +47,8 @@ public:
} // end anonymous namespace } // end anonymous namespace
PathDiagnosticClient* PathDiagnosticConsumer*
ento::createTextPathDiagnosticClient(const std::string& out, ento::createTextPathDiagnosticConsumer(const std::string& out,
const Preprocessor &PP) { const Preprocessor &PP) {
return new TextPathDiagnostics(out, PP.getDiagnostics()); return new TextPathDiagnostics(out, PP.getDiagnostics());
} }

View File

@ -45,12 +45,12 @@ static ExplodedNode::Auditor* CreateUbiViz();
// Special PathDiagnosticClients. // Special PathDiagnosticClients.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
static PathDiagnosticClient* static PathDiagnosticConsumer*
createPlistHTMLDiagnosticClient(const std::string& prefix, createPlistHTMLDiagnosticConsumer(const std::string& prefix,
const Preprocessor &PP) { const Preprocessor &PP) {
PathDiagnosticClient *PD = PathDiagnosticConsumer *PD =
createHTMLDiagnosticClient(llvm::sys::path::parent_path(prefix), PP); createHTMLDiagnosticConsumer(llvm::sys::path::parent_path(prefix), PP);
return createPlistDiagnosticClient(prefix, PP, PD); return createPlistDiagnosticConsumer(prefix, PP, PD);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -68,7 +68,7 @@ public:
ArrayRef<std::string> Plugins; ArrayRef<std::string> Plugins;
// PD is owned by AnalysisManager. // PD is owned by AnalysisManager.
PathDiagnosticClient *PD; PathDiagnosticConsumer *PD;
StoreManagerCreator CreateStoreMgr; StoreManagerCreator CreateStoreMgr;
ConstraintManagerCreator CreateConstraintMgr; ConstraintManagerCreator CreateConstraintMgr;
@ -85,7 +85,7 @@ public:
} }
void DigestAnalyzerOptions() { void DigestAnalyzerOptions() {
// Create the PathDiagnosticClient. // Create the PathDiagnosticConsumer.
if (!OutDir.empty()) { if (!OutDir.empty()) {
switch (Opts.AnalysisDiagOpt) { switch (Opts.AnalysisDiagOpt) {
default: default:
@ -96,7 +96,7 @@ public:
} else if (Opts.AnalysisDiagOpt == PD_TEXT) { } else if (Opts.AnalysisDiagOpt == PD_TEXT) {
// Create the text client even without a specified output file since // Create the text client even without a specified output file since
// it just uses diagnostic notes. // it just uses diagnostic notes.
PD = createTextPathDiagnosticClient("", PP); PD = createTextPathDiagnosticConsumer("", PP);
} }
// Create the analyzer component creators. // Create the analyzer component creators.
@ -244,9 +244,9 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
// After all decls handled, run checkers on the entire TranslationUnit. // After all decls handled, run checkers on the entire TranslationUnit.
checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR); checkerMgr->runCheckersOnEndOfTranslationUnit(TU, *Mgr, BR);
// Explicitly destroy the PathDiagnosticClient. This will flush its output. // Explicitly destroy the PathDiagnosticConsumer. This will flush its output.
// FIXME: This should be replaced with something that doesn't rely on // FIXME: This should be replaced with something that doesn't rely on
// side-effects in PathDiagnosticClient's destructor. This is required when // side-effects in PathDiagnosticConsumer's destructor. This is required when
// used with option -disable-free. // used with option -disable-free.
Mgr.reset(NULL); Mgr.reset(NULL);
} }