File indexing completed on 2026-05-10 08:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_BASIC_DIAGNOSTICERROR_H
0010 #define LLVM_CLANG_BASIC_DIAGNOSTICERROR_H
0011
0012 #include "clang/Basic/PartialDiagnostic.h"
0013 #include "llvm/Support/Error.h"
0014 #include <optional>
0015
0016 namespace clang {
0017
0018
0019
0020
0021 class DiagnosticError : public llvm::ErrorInfo<DiagnosticError> {
0022 public:
0023 DiagnosticError(PartialDiagnosticAt Diag) : Diag(std::move(Diag)) {}
0024
0025 void log(raw_ostream &OS) const override { OS << "clang diagnostic"; }
0026
0027 PartialDiagnosticAt &getDiagnostic() { return Diag; }
0028 const PartialDiagnosticAt &getDiagnostic() const { return Diag; }
0029
0030
0031
0032 static llvm::Error create(SourceLocation Loc, PartialDiagnostic Diag) {
0033 return llvm::make_error<DiagnosticError>(
0034 PartialDiagnosticAt(Loc, std::move(Diag)));
0035 }
0036
0037
0038
0039
0040 static std::optional<PartialDiagnosticAt> take(llvm::Error &Err) {
0041 std::optional<PartialDiagnosticAt> Result;
0042 Err = llvm::handleErrors(std::move(Err), [&](DiagnosticError &E) {
0043 Result = std::move(E.getDiagnostic());
0044 });
0045 return Result;
0046 }
0047
0048 static char ID;
0049
0050 private:
0051
0052 std::error_code convertToErrorCode() const override {
0053 return llvm::inconvertibleErrorCode();
0054 }
0055
0056 PartialDiagnosticAt Diag;
0057 };
0058
0059 }
0060
0061 #endif