diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-07-14 17:40:50 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-07-14 17:40:50 +0000 |
commit | 57202071e477530e9348bc76671ee369b2399b92 (patch) | |
tree | 2dfdcffb6b502a7ddc7f991f48a5433a851965a8 /lib/Analysis/BugReporter.cpp | |
parent | ca33f79346547cf1865c47b53ee99a6cdef07c72 (diff) |
Added method "EmitBasicReport" to BugReporter to simplify the emission of simple bug diagnostics.
Refactored error reporting in CheckObjCDealloc and CheckObjCInstMethSignature to use this new bug reporting interface (major code simplification).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r-- | lib/Analysis/BugReporter.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 081e7925ee..cbd61f8d25 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -731,12 +731,12 @@ void BugReporter::EmitWarning(BugReport& R) { // Determine the range. const SourceRange *Beg, *End; - + if (!D->empty()) { Beg = D->back()->ranges_begin(); End = D->back()->ranges_end(); } - else + else R.getRanges(*this, Beg, End); if (PD) { @@ -745,18 +745,18 @@ void BugReporter::EmitWarning(BugReport& R) { for ( ; Beg != End; ++Beg) piece->addRange(*Beg); - D->push_back(piece); + D->push_back(piece); PD->HandlePathDiagnostic(D.take()); } else { - std::ostringstream os; - + std::ostringstream os; + if (D->empty()) os << R.getDescription(); else os << D->back()->getString(); - - + + Diagnostic& Diag = getDiagnostic(); unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, os.str().c_str()); @@ -764,3 +764,19 @@ void BugReporter::EmitWarning(BugReport& R) { Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg); } } + +void +BugReporter::EmitBasicReport(const char* name, const char* str, + SourceLocation Loc) { + + SimpleBugType BT(name); + DiagCollector C(BT); + Diagnostic& Diag = getDiagnostic(); + Diag.Report(&C, getContext().getFullLoc(Loc), + Diag.getCustomDiagID(Diagnostic::Warning, str), + 0, 0, 0, 0); + + for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I) + EmitWarning(*I); +} + |