clang: include/clang/Basic/DiagnosticError.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_BASIC_DIAGNOSTICERROR_H

10#define LLVM_CLANG_BASIC_DIAGNOSTICERROR_H

11

13#include "llvm/Support/Error.h"

14#include

15

17

18

19

20

22public:

24

25 void log(raw_ostream &OS) const override { OS << "clang diagnostic"; }

26

29

30

31

33 return llvm::make_error(

35 }

36

37

38

39

40 static std::optional take(llvm::Error &Err) {

41 std::optional Result;

42 Err = llvm::handleErrors(std::move(Err), [&](DiagnosticError &E) {

43 Result = std::move(E.getDiagnostic());

44 });

46 }

47

48 static char ID;

49

50private:

51

52 std::error_code convertToErrorCode() const override {

53 return llvm::inconvertibleErrorCode();

54 }

55

57};

58

59}

60

61#endif

Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.

Carries a Clang diagnostic in an llvm::Error.

DiagnosticError(PartialDiagnosticAt Diag)

static std::optional< PartialDiagnosticAt > take(llvm::Error &Err)

Extracts and returns the diagnostic payload from the given Error if the error is a DiagnosticError.

static llvm::Error create(SourceLocation Loc, PartialDiagnostic Diag)

Creates a new DiagnosticError that contains the given diagnostic at the given location.

PartialDiagnosticAt & getDiagnostic()

const PartialDiagnosticAt & getDiagnostic() const

void log(raw_ostream &OS) const override

Encodes a location in the source.

The JSON file list parser is used to communicate input to InstallAPI.

@ Result

The result type of a method or function.

std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt

A partial diagnostic along with the source location where this diagnostic occurs.