summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/BugReporter.cpp35
-rw-r--r--clang/lib/Analysis/PathDiagnostic.cpp23
2 files changed, 31 insertions, 27 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp
index bf99e6ba637..0074a93b5bc 100644
--- a/clang/lib/Analysis/BugReporter.cpp
+++ b/clang/lib/Analysis/BugReporter.cpp
@@ -773,21 +773,26 @@ void BugReporter::EmitWarning(BugReport& R) {
D->push_back(piece);
PD->HandlePathDiagnostic(D.take());
+ return;
}
else {
- std::ostringstream os;
+ std::string str;
if (D->empty())
- os << R.getDescription();
+ str = R.getDescription();
else
- os << D->back()->getString();
-
+ str = D->back()->getString();
Diagnostic& Diag = getDiagnostic();
- unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning,
- os.str().c_str());
-
- Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg);
+ unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, str.c_str());
+
+ switch (End-Beg) {
+ default: assert(0 && "Don't handle this many ranges yet!");
+ case 0: Diag.Report(L, ErrorDiag); break;
+ case 1: Diag.Report(L, ErrorDiag) << Beg[0]; break;
+ case 2: Diag.Report(L, ErrorDiag) << Beg[0] << Beg[1]; break;
+ case 3: Diag.Report(L, ErrorDiag) << Beg[0] << Beg[1] << Beg[2]; break;
+ }
}
}
@@ -807,9 +812,17 @@ void BugReporter::EmitBasicReport(const char* name, const char* category,
DiagnosticClient *OldClient = Diag.getClient();
Diag.setClient(&C);
- Diag.Report(getContext().getFullLoc(Loc),
- Diag.getCustomDiagID(Diagnostic::Warning, str),
- 0, 0, RBeg, NumRanges);
+ FullSourceLoc L = getContext().getFullLoc(Loc);
+ unsigned DiagID = Diag.getCustomDiagID(Diagnostic::Warning, str);
+
+ switch (NumRanges) {
+ default: assert(0 && "Don't handle this many ranges yet!");
+ case 0: Diag.Report(L, DiagID); break;
+ case 1: Diag.Report(L, DiagID) << RBeg[0]; break;
+ case 2: Diag.Report(L, DiagID) << RBeg[0] << RBeg[1]; break;
+ case 3: Diag.Report(L, DiagID) << RBeg[0] << RBeg[1] << RBeg[2]; break;
+ }
+
Diag.setClient(OldClient);
for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I)
diff --git a/clang/lib/Analysis/PathDiagnostic.cpp b/clang/lib/Analysis/PathDiagnostic.cpp
index 02cfe1e341b..aed83ea84fb 100644
--- a/clang/lib/Analysis/PathDiagnostic.cpp
+++ b/clang/lib/Analysis/PathDiagnostic.cpp
@@ -20,14 +20,8 @@ PathDiagnostic::~PathDiagnostic() {
for (iterator I = begin(), E = end(); I != E; ++I) delete &*I;
}
-void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,
- Diagnostic::Level DiagLevel,
- FullSourceLoc Pos,
- diag::kind ID,
- const std::string **Strs,
- unsigned NumStrs,
- const SourceRange *Ranges,
- unsigned NumRanges) {
+void PathDiagnosticClient::HandleDiagnostic(Diagnostic::Level DiagLevel,
+ const DiagnosticInfo &Info) {
// Create a PathDiagnostic with a single piece.
@@ -42,16 +36,13 @@ void PathDiagnosticClient::HandleDiagnostic(Diagnostic &Diags,
case Diagnostic::Fatal: LevelStr = "fatal error: "; break;
}
- std::string Msg = FormatDiagnostic(Diags, DiagLevel, ID, Strs, NumStrs);
+ std::string Msg = FormatDiagnostic(Info);
- PathDiagnosticPiece* P = new PathDiagnosticPiece(Pos, LevelStr+Msg);
-
- while (NumRanges) {
- P->addRange(*Ranges);
- --NumRanges;
- ++Ranges;
- }
+ PathDiagnosticPiece *P =
+ new PathDiagnosticPiece(Info.getLocation(), LevelStr+Msg);
+ for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
+ P->addRange(Info.getRange(i));
D->push_front(P);
HandlePathDiagnostic(D);
OpenPOWER on IntegriCloud