summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/AnalysisConsumer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-31 00:34:52 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-31 00:34:52 +0000
commitdf4b3dc3a41b7ec23feda94e15262dd248b22926 (patch)
treea9b69acc6c690dd14102941b9fbbbd4474cee15a /clang/lib/Frontend/AnalysisConsumer.cpp
parentf3f955279b111c447283b40ffd82a1454c7552a0 (diff)
downloadbcm5719-llvm-df4b3dc3a41b7ec23feda94e15262dd248b22926.tar.gz
bcm5719-llvm-df4b3dc3a41b7ec23feda94e15262dd248b22926.zip
Fix use-after-release bug introduced in r77585 where the PathDiagnosticClient
created by AnalysisConsumer would be released by an instance of AnalysisManager and then reused by later instances of AnalysisManager. Ownership of the PathDiagnosticClient now belongs (for now) in AnalysisConsumer. We also need this layering (for now) because the HTMLDiagnostiClient requires that the entire translation unit be processed before emitting diagnostics. This is done in its destructor (which should also be fixed, but that is another issue). This fixes PR 4653. llvm-svn: 77648
Diffstat (limited to 'clang/lib/Frontend/AnalysisConsumer.cpp')
-rw-r--r--clang/lib/Frontend/AnalysisConsumer.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/clang/lib/Frontend/AnalysisConsumer.cpp b/clang/lib/Frontend/AnalysisConsumer.cpp
index 6ed59b4ac2b..ed7ea5e8e7c 100644
--- a/clang/lib/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/Frontend/AnalysisConsumer.cpp
@@ -84,8 +84,7 @@ namespace {
const std::string OutDir;
AnalyzerOptions Opts;
- // PD is owned by AnalysisManager.
- PathDiagnosticClient *PD;
+ llvm::OwningPtr<PathDiagnosticClient> PD;
StoreManagerCreator CreateStoreMgr;
ConstraintManagerCreator CreateConstraintMgr;
@@ -106,7 +105,7 @@ namespace {
switch (Opts.AnalysisDiagOpt) {
default:
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN, AUTOCREATE) \
- case PD_##NAME: PD = CREATEFN(OutDir, PP, PPF); break;
+ case PD_##NAME: PD.reset(CREATEFN(OutDir, PP, PPF)); break;
#include "clang/Frontend/Analyses.def"
}
}
@@ -216,7 +215,7 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
if(!TranslationUnitActions.empty()) {
- AnalysisManager mgr(*Ctx, Diags, LOpts, PD,
+ AnalysisManager mgr(*Ctx, Diags, LOpts, PD.get(),
CreateStoreMgr, CreateConstraintMgr,
Opts.AnalyzerDisplayProgress, Opts.VisualizeEGDot,
Opts.VisualizeEGUbi, Opts.PurgeDead, Opts.EagerlyAssume,
@@ -251,7 +250,7 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
// Create an AnalysisManager that will manage the state for analyzing
// this method/function.
- AnalysisManager mgr(D, *Ctx, Diags, LOpts, PD,
+ AnalysisManager mgr(D, *Ctx, Diags, LOpts, PD.get(),
CreateStoreMgr, CreateConstraintMgr,
Opts.AnalyzerDisplayProgress, Opts.VisualizeEGDot,
Opts.VisualizeEGUbi, Opts.PurgeDead, Opts.EagerlyAssume,
OpenPOWER on IntegriCloud