Skip to content

Commit 2defa13

Browse files
committed
docs: fix stale plugin-authoring guide and dataset layout in spec
The "how to add a check" steps in docs/spec.md referenced a `Y2k38CheckBase.h` with `y2k38::MatcherCallback<T>` / `y2k38::ActionBase<D>` templates that do not exist on this branch — that abstraction was reverted earlier in this PR (72e15ca). A contributor following the spec could not build. Rewrite the steps to match the real pattern: a per-check namespace defining a matcher, a `MatcherCallback`, and a free `addMatcher(MatchFinder*)` registered from `Y2k38AllAction::CreateASTConsumer`. Also correct the dataset tree, which listed a `whitelist/` directory that does not exist and omitted the actual `downcast-bug/` directory. Keep the whitelist convention as documented guidance for new checks. Add `just setup-dev` to the CLAUDE.md build section for parity with README. https://claude.ai/code/session_01DAu2VdTJ6vFYtMw8R1iV7C
1 parent 1cc7041 commit 2defa13

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ unmerged worktree. See `.claude/rules/git-workflow.md` for the full safe cleanup
1515
# First-time setup (downloads ~700 MB LLVM 11)
1616
just setup-llvm
1717

18+
# First-time setup + build in one step (setup-llvm then build)
19+
just setup-dev
20+
1821
# Build everything
1922
just build # Clang plugin (cmake) + Rust reporter (cargo)
2023
just build-plugin # Clang plugin only

docs/spec.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,17 @@ narrow `time_t` to `int`.
105105

106106
Built with CMake against LLVM/Clang 11. Produces `liby2k38-plugin.so`.
107107

108-
Each check is an independent `ASTFrontendAction` subclass registered under a common plugin entry
109-
point (`y2k38-all`). New checks are added by:
110-
111-
1. Creating `lib/<check-name>/` with `*Action.{h,cpp}` (use `y2k38::MatcherCallback<T>` and `y2k38::ActionBase<D>` from `Y2k38CheckBase.h`).
112-
2. Adding the action to `Y2k38AllAction`.
113-
3. Adding a one-line `CMakeLists.txt` that calls `add_y2k38_check(<name> <source>)`.
108+
Each check lives in its own namespace under `lib/<check-name>/` and is registered into a common
109+
plugin entry point (`y2k38-all`). New checks are added by:
110+
111+
1. Creating `lib/<check-name>/<Name>Action.{h,cpp}` with a namespace that defines:
112+
- an AST matcher (e.g. `matcher`),
113+
- a `MatcherCallback : public MatchFinder::MatchCallback` that emits the diagnostic, and
114+
- a free function `void addMatcher(MatchFinder *Finder)` that binds the matcher to the callback.
115+
2. Calling `<namespace>::addMatcher(Finder)` from `Y2k38AllAction::CreateASTConsumer`
116+
(`lib/y2k38-all/Y2k38AllAction.h`).
117+
3. Adding a one-line `CMakeLists.txt` that calls `add_y2k38_check(<name> <source>)`
118+
(see `lib/CMakeLists.txt`).
114119

115120
### Rust Reporter (`reporter/`)
116121

@@ -130,11 +135,13 @@ Environment variables (override defaults at runtime):
130135

131136
```
132137
dataset/
133-
├── blacklist/ # C files that MUST trigger at least one warning
134-
└── whitelist/ # C files that MUST trigger zero warnings
138+
├── blacklist/ # C files that MUST trigger at least one warning
139+
└── downcast-bug/ # time_t downcast examples
135140
```
136141

137-
Used for regression testing.
142+
Used for regression testing. A `whitelist/` (C files that MUST trigger zero warnings) is the
143+
convention for new checks — see `.claude/rules/test-design.md` — and should be added alongside
144+
the corresponding blacklist file.
138145

139146
---
140147

0 commit comments

Comments
 (0)