aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-23 20:28:53 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-23 20:28:53 +0000
commitcabe66811fe43835b8c5a0854552768fc53261e3 (patch)
tree0ce092634dcc21912dac2b2f972ab3146415fb58 /lib/Analysis/BugReporter.cpp
parentd9fb9726613aba37553fcdb85d1ed0726f94b0e8 (diff)
Added virtual method DiagnosticClient::IncludeInDiagnosticCounts(). This is used by Diagnostics to determine if a diagnostic sent to a given DiagnosticClient should be included in the count of diagnostics. The default implementation of this method returns 'true'.
Implemented DiagCollector::IncludeInDiagnosticCounts() to return 'false' so that the batching of diagnostics for use with BugReporter doesn't mess up the count of real diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r--lib/Analysis/BugReporter.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index adb3325f53..e3735670cf 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -823,4 +823,46 @@ void BugReporter::EmitBasicReport(const char* name, const char* category,
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;
+ }
+ }
+ }
+}