clang-tools 22.0.0git
clang::clangd::StoreDiags Class Reference

StoreDiags collects the diagnostics that can later be reported by clangd. More...

#include <Diagnostics.h>

Inheritance diagram for clang::clangd::StoreDiags:
[legend]

Public Types

using DiagFixer
 When passed a main diagnostic, returns fixes to add to it.
using LevelAdjuster
using DiagCallback

Public Member Functions

std::vector< Diagtake (const clang::tidy::ClangTidyContext *Tidy=nullptr)
void BeginSourceFile (const LangOptions &Opts, const Preprocessor *PP) override
void EndSourceFile () override
void HandleDiagnostic (DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) override
void contributeFixes (DiagFixer Fixer)
 If set, possibly adds fixes for diagnostics using Fixer.
void setLevelAdjuster (LevelAdjuster Adjuster)
 If set, this allows the client of this class to adjust the level of diagnostics, such as promoting warnings to errors, or ignoring diagnostics.
void setDiagCallback (DiagCallback CB)
 Invokes a callback every time a diagnostics is completely formed.

Detailed Description

StoreDiags collects the diagnostics that can later be reported by clangd.

It groups all notes for a diagnostic into a single Diag and filters out diagnostics that don't mention the main file (i.e. neither the diag itself nor its notes are in the main file).

Definition at line 138 of file Diagnostics.h.

Member Typedef Documentation

◆ DiagCallback

Initial value:
std::function<void(const clang::Diagnostic &, clangd::Diag &)>
A top-level diagnostic that may have Notes and Fixes.
Definition Diagnostics.h:98

Definition at line 155 of file Diagnostics.h.

◆ DiagFixer

Initial value:
std::function<std::vector<Fix>(DiagnosticsEngine::Level,
const clang::Diagnostic &)>

When passed a main diagnostic, returns fixes to add to it.

When passed a note diagnostic, returns fixes to replace it with.

Definition at line 151 of file Diagnostics.h.

◆ LevelAdjuster

Initial value:
std::function<DiagnosticsEngine::Level(
DiagnosticsEngine::Level, const clang::Diagnostic &)>

Definition at line 153 of file Diagnostics.h.

Member Function Documentation

◆ BeginSourceFile()

void clang::clangd::StoreDiags::BeginSourceFile ( const LangOptions & Opts,
const Preprocessor * PP )
override

Definition at line 633 of file Diagnostics.cpp.

◆ contributeFixes()

void clang::clangd::StoreDiags::contributeFixes ( DiagFixer Fixer)
inline

If set, possibly adds fixes for diagnostics using Fixer.

Definition at line 158 of file Diagnostics.h.

Referenced by clang::clangd::ParsedAST::build().

◆ EndSourceFile()

void clang::clangd::StoreDiags::EndSourceFile ( )
override

Definition at line 641 of file Diagnostics.cpp.

Referenced by clang::clangd::ParsedAST::build().

◆ HandleDiagnostic()

◆ setDiagCallback()

void clang::clangd::StoreDiags::setDiagCallback ( DiagCallback CB)
inline

Invokes a callback every time a diagnostics is completely formed.

Handler of the callback can also mutate the diagnostic.

Definition at line 165 of file Diagnostics.h.

Referenced by clang::clangd::ParsedAST::build(), and clang::clangd::buildPreamble().

◆ setLevelAdjuster()

void clang::clangd::StoreDiags::setLevelAdjuster ( LevelAdjuster Adjuster)
inline

If set, this allows the client of this class to adjust the level of diagnostics, such as promoting warnings to errors, or ignoring diagnostics.

Definition at line 162 of file Diagnostics.h.

Referenced by clang::clangd::ParsedAST::build(), and clang::clangd::buildPreamble().

◆ take()


The documentation for this class was generated from the following files: