[cfe-commits] r62873 - in /cfe/trunk: include/clang/Analysis/PathSensitive/BugReporter.h include/clang/Basic/Diagnostic.h lib/Analysis/BugReporter.cpp lib/Basic/Diagnostic.cpp
Ted Kremenek
kremenek at apple.com
Fri Jan 23 12:28:53 PST 2009
Author: kremenek
Date: Fri Jan 23 14:28:53 2009
New Revision: 62873
URL: http://llvm.org/viewvc/llvm-project?rev=62873&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Analysis/BugReporter.cpp
cfe/trunk/lib/Basic/Diagnostic.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h?rev=62873&r1=62872&r2=62873&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/BugReporter.h Fri Jan 23 14:28:53 2009
@@ -305,50 +305,12 @@
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(); }
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=62873&r1=62872&r2=62873&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Jan 23 14:28:53 2009
@@ -484,6 +484,12 @@
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.
Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=62873&r1=62872&r2=62873&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Fri Jan 23 14:28:53 2009
@@ -823,4 +823,46 @@
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;
+ }
+ }
+ }
+}
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=62873&r1=62872&r2=62873&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Fri Jan 23 14:28:53 2009
@@ -255,7 +255,7 @@
// Finally, report it.
Client->HandleDiagnostic(DiagLevel, Info);
- ++NumDiagnostics;
+ if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
}
@@ -551,3 +551,9 @@
}
}
}
+
+/// 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; }
More information about the cfe-commits
mailing list