diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 27 | ||||
| -rw-r--r-- | clang/lib/Analysis/PathDiagnostic.cpp | 4 | 
2 files changed, 15 insertions, 16 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index 6b68d7f70ec..be1c52d5217 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/lib/Analysis/BugReporter.cpp @@ -382,52 +382,51 @@ void BugReporter::EmitWarning(BugReport& R) {    if (R.getBugType().isCached(R))      return; -  PathDiagnostic D(R.getName());   -  GeneratePathDiagnostic(D, R); +  llvm::OwningPtr<PathDiagnostic> D(new PathDiagnostic(R.getName())); +  GeneratePathDiagnostic(*D.get(), R);    // Emit a full diagnostic for the path if we have a PathDiagnosticClient. -  if (PD && !D.empty()) {  -    PD->HandlePathDiagnostic(D); +  if (PD && !D->empty()) {  +    PD->HandlePathDiagnostic(D.take());      return;        }    // We don't have a PathDiagnosticClient, but we can still emit a single    // line diagnostic.  Determine the location. -  FullSourceLoc L = D.empty() ? R.getLocation(Ctx.getSourceManager()) -                               : D.back()->getLocation(); +  FullSourceLoc L = D->empty() ? R.getLocation(Ctx.getSourceManager()) +                               : D->back()->getLocation();    // Determine the range.    const SourceRange *Beg, *End; -  if (!D.empty()) { -    Beg = D.back()->ranges_begin(); -    End = D.back()->ranges_end(); +  if (!D->empty()) { +    Beg = D->back()->ranges_begin(); +    End = D->back()->ranges_end();    }    else        R.getRanges(Beg, End);    if (PD) { -    PathDiagnostic D(R.getName());      PathDiagnosticPiece* piece = new PathDiagnosticPiece(L, R.getDescription());      for ( ; Beg != End; ++Beg)        piece->addRange(*Beg); -    D.push_back(piece);     -    PD->HandlePathDiagnostic(D); +    D->push_back(piece);     +    PD->HandlePathDiagnostic(D.take());    }    else {      std::ostringstream os;        os << "[CHECKER] "; -    if (D.empty()) +    if (D->empty())        os << R.getDescription();      else -      os << D.back()->getString(); +      os << D->back()->getString();      unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp index e4228c77443..28b76b38f13 100644 --- a/clang/lib/Analysis/PathDiagnostic.cpp +++ b/clang/lib/Analysis/PathDiagnostic.cpp @@ -31,7 +31,7 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,    // Create a PathDiagnostic with a single piece. -  PathDiagnostic D; +  PathDiagnostic* D = new PathDiagnostic();    // Ripped from TextDiagnostics::FormatDiagnostic.  Perhaps we should    // centralize it somewhere? @@ -68,7 +68,7 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,      ++Ranges;    } -  D.push_front(P); +  D->push_front(P);    HandlePathDiagnostic(D);    }  | 

