Skip to content

Diagnostics

Core

  • Clang diagnostics (errors, warnings, notes)

  • Severity mapping (Error, Warning)

  • Diagnostic ranges with source locations

  • Related information (notes attached to diagnostics)

  • File URI conversion for cross-file diagnostics

  • Pull diagnostics model (textDocument/diagnostic) (clangd#2108)

  • Report all missing #include errors, not just the first — the parser stops on the first fatal error

    cpp
    #include "missing_a.h"  // error reported
    #include "missing_b.h"  // error NOT reported (parser already stopped)
    #include "missing_c.h"  // error NOT reported
  • Show the full include chain for diagnostics originating in header files (clangd#1392)

    // current:  "In included file: expected ';'"
    // expected: "In main.cpp → utils.h → detail/impl.h: expected ';'"
  • Reflect unsaved header file changes in diagnostics (clangd#488)

    // header.h (unsaved buffer): added new_func()
    // main.cpp: calls new_func() → should NOT show "undeclared identifier"
  • Diagnostics for template instantiation errors in preamble headers (clangd#137)

Tags

  • Deprecated tag for -Wdeprecated diagnostics
  • Unnecessary tag for unused variable/parameter warnings

Publishing

  • Push diagnostics on compilation completion
  • Clear diagnostics on file close
  • Per-file diagnostic grouping (interested file + headers)
  • Diagnostic code field with Clang error codes
  • codeDescription with links to Clang documentation
  • Diagnostic source field distinguishing clang vs clang-tidy
  • Configurable debounce delay before computing diagnostics (clangd#1471)
  • Recompute diagnostics in open files when background indexing completes (clangd#2604)

Diagnostic Suppression

  • // NOLINT comment suppression
  • // NOLINTNEXTLINE comment suppression
  • // NOLINTBEGIN / // NOLINTEND block suppression
  • NOLINT for include-cleaner diagnostics (clangd#1982)
  • Configurable severity per diagnostic category in config file (clangd#1937)
  • Filter diagnostics by version control diff — only show warnings near changed lines (clangd#822)

Diagnostic Actions

  • Automatic fix-its attached to diagnostics as code actions

Header Diagnostics

  • Include-cleaner diagnostics for unused and missing #include directives

  • Suppress false -Wunused-function for static inline functions in headers (clangd#1211)

    cpp
    // utils.h
    static inline int helper() { return 42; }
    // should NOT warn "unused function" when checking header standalone
  • Propagate -Wpadded and similar layout warnings from headers (clangd#1429)

  • Suppress false -Wempty-translation-unit from preamble optimization (clangd#2358)

  • Thread safety analysis across header boundaries (clangd#2386)

clang-tidy Integration

  • clang-tidy diagnostics (gated by config)
  • Suppress clang-tidy warnings originating in system-header macros (clangd#1587, clangd#2000)
  • Clang static analyzer support (clangd#905)
  • Version-specific clang-tidy documentation links (clangd#2136)
  • Diagnostics for preprocessor directives that precede code (clangd#2501)

Diagnostic Display

  • Correct diagnostic range for qualified type names — underline the full name, not just the base (clangd#1035)

    cpp
    ns::Inner obj(42);
    //  ^^^^^ only base name underlined
    // should underline "ns::Inner"
  • Show optimization remarks (-Rpass) as diagnostics (clangd#2519)

  • Project-wide warning listing (clangd#1973)

Config File Diagnostics

Diagnostic Correctness

Known issues that should be handled correctly:

  • Macro redefinition warning pointing to the same location (clangd#2479)
  • Wrong -Wmissing-braces fix suggestion for nested array initialization (clangd#2434)
  • Invalid severity 0 when preamble invalidation mixes diagnostic messages (clangd#2124)
  • Undeclared identifier diagnostic hidden by correction-related diagnostics (clangd#547)
  • Misleading downstream diagnostics when --include file is missing (clangd#2229)

Changelog

DateChangePR
Clang diagnostics, severity mapping, tags, push publishing