CXLoadedDiagnostic.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*===-- CXLoadedDiagnostic.h - Handling of persisent diags ------*- C++ -*-===*\
  2. |* *|
  3. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  4. |* Exceptions. *|
  5. |* See https://llvm.org/LICENSE.txt for license information. *|
  6. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  7. |* *|
  8. |*===----------------------------------------------------------------------===*|
  9. |* *|
  10. |* Implements handling of persisent diagnostics. *|
  11. |* *|
  12. \*===----------------------------------------------------------------------===*/
  13. #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
  14. #define LLVM_CLANG_TOOLS_LIBCLANG_CXLOADEDDIAGNOSTIC_H
  15. #include "CIndexDiagnostic.h"
  16. #include "llvm/ADT/StringRef.h"
  17. #include "clang/Basic/LLVM.h"
  18. #include <vector>
  19. namespace clang {
  20. class CXLoadedDiagnostic : public CXDiagnosticImpl {
  21. public:
  22. CXLoadedDiagnostic() : CXDiagnosticImpl(LoadedDiagnosticKind),
  23. severity(0), category(0) {}
  24. ~CXLoadedDiagnostic() override;
  25. /// Return the severity of the diagnostic.
  26. CXDiagnosticSeverity getSeverity() const override;
  27. /// Return the location of the diagnostic.
  28. CXSourceLocation getLocation() const override;
  29. /// Return the spelling of the diagnostic.
  30. CXString getSpelling() const override;
  31. /// Return the text for the diagnostic option.
  32. CXString getDiagnosticOption(CXString *Disable) const override;
  33. /// Return the category of the diagnostic.
  34. unsigned getCategory() const override;
  35. /// Return the category string of the diagnostic.
  36. CXString getCategoryText() const override;
  37. /// Return the number of source ranges for the diagnostic.
  38. unsigned getNumRanges() const override;
  39. /// Return the source ranges for the diagnostic.
  40. CXSourceRange getRange(unsigned Range) const override;
  41. /// Return the number of FixIts.
  42. unsigned getNumFixIts() const override;
  43. /// Return the FixIt information (source range and inserted text).
  44. CXString getFixIt(unsigned FixIt,
  45. CXSourceRange *ReplacementRange) const override;
  46. static bool classof(const CXDiagnosticImpl *D) {
  47. return D->getKind() == LoadedDiagnosticKind;
  48. }
  49. /// Decode the CXSourceLocation into file, line, column, and offset.
  50. static void decodeLocation(CXSourceLocation location,
  51. CXFile *file,
  52. unsigned *line,
  53. unsigned *column,
  54. unsigned *offset);
  55. struct Location {
  56. CXFile file;
  57. unsigned line;
  58. unsigned column;
  59. unsigned offset;
  60. Location() : line(0), column(0), offset(0) {}
  61. };
  62. Location DiagLoc;
  63. std::vector<CXSourceRange> Ranges;
  64. std::vector<std::pair<CXSourceRange, const char *> > FixIts;
  65. const char *Spelling;
  66. llvm::StringRef DiagOption;
  67. llvm::StringRef CategoryText;
  68. unsigned severity;
  69. unsigned category;
  70. };
  71. }
  72. #endif