12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef TOOLS_CLANG_PLUGINS_HESIENDIAGNOSTICBUILDER_H_
- #define TOOLS_CLANG_PLUGINS_HESIENDIAGNOSTICBUILDER_H_
- #include "clang/Basic/Diagnostic.h"
- #include "clang/Basic/SourceLocation.h"
- namespace chrome_checker {
- class SuppressibleDiagnosticBuilder : public clang::DiagnosticBuilder {
- public:
- SuppressibleDiagnosticBuilder(clang::DiagnosticsEngine* diagnostics,
- clang::SourceLocation loc,
- unsigned diagnostic_id,
- bool suppressed)
- : DiagnosticBuilder(diagnostics->Report(loc, diagnostic_id)),
- diagnostics_(diagnostics),
- suppressed_(suppressed) {}
- ~SuppressibleDiagnosticBuilder() {
- if (suppressed_) {
-
-
- FlushCounts();
- Clear();
-
-
- diagnostics_->Clear();
- }
- }
- template <typename T>
- friend const SuppressibleDiagnosticBuilder& operator<<(
- const SuppressibleDiagnosticBuilder& builder,
- const T& value) {
- const DiagnosticBuilder& base_builder = builder;
- base_builder << value;
- return builder;
- }
- private:
- clang::DiagnosticsEngine* const diagnostics_;
- const bool suppressed_;
- };
- }
- #endif
|