TextDiagnosticBuffer.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This is a concrete diagnostic client, which buffers the diagnostic messages.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "clang/Frontend/TextDiagnosticBuffer.h"
  14. #include "llvm/ADT/SmallString.h"
  15. using namespace clang;
  16. /// HandleDiagnostic - Store the errors, warnings, and notes that are
  17. /// reported.
  18. ///
  19. void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
  20. const DiagnosticInfo &Info) {
  21. llvm::SmallString<100> Buf;
  22. Info.FormatDiagnostic(Buf);
  23. switch (Level) {
  24. default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
  25. case Diagnostic::Note:
  26. Notes.push_back(std::make_pair(Info.getLocation(), Buf.str()));
  27. break;
  28. case Diagnostic::Warning:
  29. Warnings.push_back(std::make_pair(Info.getLocation(), Buf.str()));
  30. break;
  31. case Diagnostic::Error:
  32. case Diagnostic::Fatal:
  33. Errors.push_back(std::make_pair(Info.getLocation(), Buf.str()));
  34. break;
  35. }
  36. }