diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-23 20:28:53 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-23 20:28:53 +0000 |
commit | ea06ec1cade1d256a0f2b15e0aebd8ab0fbcbe33 (patch) | |
tree | 3cc990c942e90e0173f2b4775c7ee95c717074a6 /clang/lib/Analysis/BugReporter.cpp | |
parent | 3d5d14ea15eee48eb846c079d7efee296f53048c (diff) | |
download | bcm5719-llvm-ea06ec1cade1d256a0f2b15e0aebd8ab0fbcbe33.tar.gz bcm5719-llvm-ea06ec1cade1d256a0f2b15e0aebd8ab0fbcbe33.zip |
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.
llvm-svn: 62873
Diffstat (limited to 'clang/lib/Analysis/BugReporter.cpp')
-rw-r--r-- | clang/lib/Analysis/BugReporter.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/clang/lib/Analysis/BugReporter.cpp b/clang/lib/Analysis/BugReporter.cpp index adb3325f53d..e3735670cf6 100644 --- a/clang/lib/Analysis/BugReporter.cpp +++ b/clang/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; + } + } + } +} |