# kde/clazy architecture

> Architecture diagram of the GitHub repository kde/clazy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kde/clazy
- Repository: https://github.com/kde/clazy

## Overview

clazy is a Clang plugin and standalone analyzer that adds Qt-aware diagnostics and automatic fix-its to C++ compilation. In the plugin workflow, a project is compiled through Clang with clazy loaded; checks are selected, inspect compiler information, and report warnings or fixes. The standalone entry point supports analysis using a JSON compilation database. The tree and excerpts support the major subsystems, but do not show all runtime call wiring, so uncertain connections are omitted.

Main entry points: [`src/checkbase.cpp`](https://github.com/kde/clazy/blob/master/src/checkbase.cpp) (Compiler diagnostics), [`src/checkmanager.cpp`](https://github.com/kde/clazy/blob/master/src/checkmanager.cpp) (Check selection), [`src/checks/level0`](https://github.com/kde/clazy/tree/master/src/checks/level0) (Level 0 checks), [`src/checks/level1`](https://github.com/kde/clazy/tree/master/src/checks/level1) (Level 1 checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Analysis entry points"]
  node_plugin["Clang plugin<br/>[Clazy.cpp]"]
  node_standalone["Standalone analyzer"]
end

subgraph group_engine["Analysis engine"]
  node_manager["Check selection<br/>[checkmanager.cpp]"]
  node_context["Analysis context<br/>[ClazyContext.cpp]"]
  node_visitor["AST traversal"]
  node_access["Qt access metadata"]
  node_suppression["Warning suppression"]
end

subgraph group_checks["Qt checks"]
  node_level0["Level 0 checks"]
  node_level1["Level 1 checks"]
  node_level2["Level 2 checks"]
  node_manual["Manual checks"]
end

subgraph group_results["Diagnostics and fixes"]
  node_diagnostics["Compiler diagnostics<br/>[checkbase.cpp]"]
  node_fixits["Fix-it export<br/>[FixItExporter.cpp]"]
end

node_project(("C++ project"))
node_clang["Clang compiler"]
node_compile_db["JSON compilation database"]

node_project -->|"compile with"| node_clang
node_clang -->|"loads plugin"| node_plugin
node_project -.->|"analyze"| node_standalone
node_compile_db -.->|"provides commands"| node_standalone
node_manager -->|"creates checks"| node_level0
node_manager -->|"creates checks"| node_level1
node_manager -->|"creates checks"| node_level2
node_manager -->|"creates checks"| node_manual
node_level0 -->|"reports findings"| node_diagnostics
node_level1 -->|"reports findings"| node_diagnostics
node_level2 -->|"reports findings"| node_diagnostics
node_manual -->|"reports findings"| node_diagnostics
node_diagnostics -->|"exports fixes"| node_fixits

click node_plugin "https://github.com/kde/clazy/blob/master/src/Clazy.cpp"
click node_standalone "https://github.com/kde/clazy/blob/master/src/ClazyStandaloneMain.cpp"
click node_manager "https://github.com/kde/clazy/blob/master/src/checkmanager.cpp"
click node_context "https://github.com/kde/clazy/blob/master/src/ClazyContext.cpp"
click node_visitor "https://github.com/kde/clazy/blob/master/src/ClazyVisitHelper.cpp"
click node_access "https://github.com/kde/clazy/blob/master/src/AccessSpecifierManager.cpp"
click node_suppression "https://github.com/kde/clazy/blob/master/src/SuppressionManager.cpp"
click node_level0 "https://github.com/kde/clazy/tree/master/src/checks/level0"
click node_level1 "https://github.com/kde/clazy/tree/master/src/checks/level1"
click node_level2 "https://github.com/kde/clazy/tree/master/src/checks/level2"
click node_manual "https://github.com/kde/clazy/tree/master/src/checks/manuallevel"
click node_diagnostics "https://github.com/kde/clazy/blob/master/src/checkbase.cpp"
click node_fixits "https://github.com/kde/clazy/blob/master/src/FixItExporter.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin,node_standalone toneBlue
class node_manager,node_context,node_visitor,node_access,node_suppression,node_compile_db toneAmber
class node_level0,node_level1,node_level2,node_manual toneMint
class node_diagnostics,node_fixits toneRose
class node_project,node_clang toneIndigo
```

## Components

### Analysis entry points

- [Clang plugin](https://github.com/kde/clazy/blob/master/src/Clazy.cpp): `src/Clazy.cpp`
- [Standalone analyzer](https://github.com/kde/clazy/blob/master/src/ClazyStandaloneMain.cpp): `src/ClazyStandaloneMain.cpp`

### Analysis engine

- [Check selection](https://github.com/kde/clazy/blob/master/src/checkmanager.cpp): `src/checkmanager.cpp`
- [Analysis context](https://github.com/kde/clazy/blob/master/src/ClazyContext.cpp): `src/ClazyContext.cpp`
- [AST traversal](https://github.com/kde/clazy/blob/master/src/ClazyVisitHelper.cpp): `src/ClazyVisitHelper.cpp`
- [Qt access metadata](https://github.com/kde/clazy/blob/master/src/AccessSpecifierManager.cpp): `src/AccessSpecifierManager.cpp`
- [Warning suppression](https://github.com/kde/clazy/blob/master/src/SuppressionManager.cpp): `src/SuppressionManager.cpp`

### Qt checks

- [Level 0 checks](https://github.com/kde/clazy/tree/master/src/checks/level0): `src/checks/level0`
- [Level 1 checks](https://github.com/kde/clazy/tree/master/src/checks/level1): `src/checks/level1`
- [Level 2 checks](https://github.com/kde/clazy/tree/master/src/checks/level2): `src/checks/level2`
- [Manual checks](https://github.com/kde/clazy/tree/master/src/checks/manuallevel): `src/checks/manuallevel`

### Diagnostics and fixes

- [Compiler diagnostics](https://github.com/kde/clazy/blob/master/src/checkbase.cpp): `src/checkbase.cpp`
- [Fix-it export](https://github.com/kde/clazy/blob/master/src/FixItExporter.cpp): `src/FixItExporter.cpp`

### Other components

- **C++ project**
- **Clang compiler**
- **JSON compilation database**

## Connections

- C++ project → Clang compiler: compile with
- Clang compiler → Clang plugin: loads plugin
- C++ project → Standalone analyzer: analyze
- JSON compilation database → Standalone analyzer: provides commands
- Check selection → Level 0 checks: creates checks
- Check selection → Level 1 checks: creates checks
- Check selection → Level 2 checks: creates checks
- Check selection → Manual checks: creates checks
- Level 0 checks → Compiler diagnostics: reports findings
- Level 1 checks → Compiler diagnostics: reports findings
- Level 2 checks → Compiler diagnostics: reports findings
- Manual checks → Compiler diagnostics: reports findings
- Compiler diagnostics → Fix-it export: exports fixes
