virtual ~DiagCollector() {}
- virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
- const DiagnosticInfo &Info) {
-
- // FIXME: Use a map from diag::kind to BugType, instead of having just
- // one BugType.
- const char *Desc = Info.getDiags()->getDescription(Info.getID());
- Reports.push_back(DiagBugReport(Desc, D, Info.getLocation()));
- DiagBugReport& R = Reports.back();
-
- for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
- R.addRange(Info.getRange(i));
-
- // FIXME: This is losing/ignoring formatting.
- for (unsigned i = 0, e = Info.getNumArgs(); i != e; ++i) {
- switch (Info.getArgKind(i)) {
- case Diagnostic::ak_std_string:
- R.addString(Info.getArgStdStr(i));
- break;
- case Diagnostic::ak_c_string:
- R.addString(Info.getArgCStr(i));
- break;
- case Diagnostic::ak_sint:
- R.addString(llvm::itostr(Info.getArgSInt(i)));
- break;
- case Diagnostic::ak_uint:
- R.addString(llvm::utostr_32(Info.getArgUInt(i)));
- break;
- case Diagnostic::ak_identifierinfo:
- R.addString(Info.getArgIdentifier(i)->getName());
- break;
- case Diagnostic::ak_qualtype:
- case Diagnostic::ak_declarationname: {
- llvm::SmallString<64> Str;
- Info.getDiags()->ConvertArgToString(Info.getArgKind(i),
- Info.getRawArg(i), 0, 0, 0, 0, Str);
- R.addString(std::string(Str.begin(), Str.end()));
- break;
- }
- }
- }
- }
+ bool IncludeInDiagnosticCounts() const { return false; }
- // Iterators.
+ void HandleDiagnostic(Diagnostic::Level DiagLevel,
+ const DiagnosticInfo &Info);
+ // Iterators.
typedef std::list<DiagBugReport>::iterator iterator;
iterator begin() { return Reports.begin(); }
iterator end() { return Reports.end(); }
class DiagnosticClient {
public:
virtual ~DiagnosticClient();
+
+ /// IncludeInDiagnosticCounts - This method (whose default implementation
+ /// returns true) indicates whether the diagnostics handled by this
+ /// DiagnosticClient should be included in the number of diagnostics
+ /// reported by Diagnostic.
+ virtual bool IncludeInDiagnosticCounts() const;
/// HandleDiagnostic - Handle this diagnostic, reporting it to the user or
/// capturing it to a log as needed.
for (DiagCollector::iterator I = C.begin(), E = C.end(); I != E; ++I)
EmitWarning(*I);
}
+
+void DiagCollector::HandleDiagnostic(Diagnostic::Level DiagLevel,
+ const DiagnosticInfo &Info) {
+
+ // FIXME: Use a map from diag::kind to BugType, instead of having just
+ // one BugType.
+ const char *Desc = Info.getDiags()->getDescription(Info.getID());
+ Reports.push_back(DiagBugReport(Desc, D, Info.getLocation()));
+ DiagBugReport& R = Reports.back();
+
+ for (unsigned i = 0, e = Info.getNumRanges(); i != e; ++i)
+ R.addRange(Info.getRange(i));
+
+ // FIXME: This is losing/ignoring formatting.
+ for (unsigned i = 0, e = Info.getNumArgs(); i != e; ++i) {
+ switch (Info.getArgKind(i)) {
+ case Diagnostic::ak_std_string:
+ R.addString(Info.getArgStdStr(i));
+ break;
+ case Diagnostic::ak_c_string:
+ R.addString(Info.getArgCStr(i));
+ break;
+ case Diagnostic::ak_sint:
+ R.addString(llvm::itostr(Info.getArgSInt(i)));
+ break;
+ case Diagnostic::ak_uint:
+ R.addString(llvm::utostr_32(Info.getArgUInt(i)));
+ break;
+ case Diagnostic::ak_identifierinfo:
+ R.addString(Info.getArgIdentifier(i)->getName());
+ break;
+ case Diagnostic::ak_qualtype:
+ case Diagnostic::ak_declarationname: {
+ llvm::SmallString<64> Str;
+ Info.getDiags()->ConvertArgToString(Info.getArgKind(i),
+ Info.getRawArg(i), 0, 0, 0, 0, Str);
+ R.addString(std::string(Str.begin(), Str.end()));
+ break;
+ }
+ }
+ }
+}
// Finally, report it.
Client->HandleDiagnostic(DiagLevel, Info);
- ++NumDiagnostics;
+ if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
}
}
}
}
+
+/// IncludeInDiagnosticCounts - This method (whose default implementation
+/// returns true) indicates whether the diagnostics handled by this
+/// DiagnosticClient should be included in the number of diagnostics
+/// reported by Diagnostic.
+bool DiagnosticClient::IncludeInDiagnosticCounts() const { return true; }