Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_CONFIGTESTING_H
13 #include "llvm/Support/ScopedPrinter.h"
14 #include "llvm/Support/SourceMgr.h"
15 #include "gmock/gmock.h"
25 std::function<void(
const llvm::SMDiagnostic &)>
callback() {
26 return [
this](
const llvm::SMDiagnostic &
D) {
27 if (
Files.empty() ||
Files.back() !=
D.getFilename())
28 Files.push_back(
D.getFilename().str());
30 if (
D.getKind() > llvm::SourceMgr::DK_Warning)
35 Out.Message =
D.getMessage().str();
36 Out.Kind =
D.getKind();
37 Out.Pos.line =
D.getLineNo() - 1;
38 Out.Pos.character =
D.getColumnNo();
39 if (!
D.getRanges().empty()) {
40 const auto &R =
D.getRanges().front();
42 Out.Rng->start.line =
Out.Rng->end.line =
Out.Pos.line;
43 Out.Rng->start.character = R.first;
44 Out.Rng->end.character = R.second;
50 llvm::SourceMgr::DiagKind
Kind;
52 llvm::Optional<Range>
Rng;
55 *
OS << (
D.Kind == llvm::SourceMgr::DK_Error ?
"error: " :
"warning: ")
56 <<
D.Message <<
"@" << llvm::to_string(
D.Pos);
71 MATCHER_P(diagRange, R,
"") {
return arg.Rng == R; }
74 auto LineCol = SM.getLineAndColumn(L);
76 P.
line = LineCol.first - 1;
llvm::Optional< Range > Rng
std::function< void(const llvm::SMDiagnostic &)> callback()
llvm::SourceMgr * SourceMgr
int line
Line position in a document (zero-based).
const google::protobuf::Message & M
Position toPosition(llvm::SMLoc L, const llvm::SourceMgr &SM)
MATCHER_P(diagMessage, M, "")
int character
Character offset on a line in a document (zero-based).
std::vector< std::string > Files
friend void PrintTo(const Diag &D, std::ostream *OS)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::raw_string_ostream OS
llvm::SourceMgr::DiagKind Kind
std::vector< Diag > Diagnostics
Range toRange(llvm::SMRange R, const llvm::SourceMgr &SM)
CompiledFragmentImpl & Out