Crafter.Build/tests
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jorijn van der Graaf 5888af29ed feat(lint): libclang-backed token layer
Adds LintContext::Tokens() and friends, backed by clang_tokenize, as the
substrate the rules will move onto. Nothing consumes it yet.

libclang is dlopen'd rather than linked: -lclang would break the mingw and
MSVC cross-builds at link time and would put a libclang.so.NN runtime
dependency into the otherwise self-contained release tarballs. The clang-c
header is used for its declarations only, and the function-pointer table is
typed with decltype so the signatures cannot drift from the real API.

Three properties this buys that the hand-rolled scanners could not have:

  - a raw string literal or block comment is ONE token, so the documented
    "raw string literals are not recognized" limitation goes away;
  - `//` inside a literal is not a comment, so LineHasComment() replaces the
    Line(n).contains("//") probes that false-positive on it;
  - tokens cover preprocessor branches that are inactive for the host, since
    clang_tokenize lexes rather than evaluates #if. Token rules therefore
    keep seeing every platform's code, which an AST could not offer.

The parse backing the tokenizer is expected to fail on module units — no
PCMs, no build flags — and that is fine, because lexing has no semantic
prerequisites. Verified in the new tests.

LintSummary::Clean() now counts `errors`. It previously ignored them, so an
infrastructure failure that produced no findings reported clean and exited
0; a missing libclang would have been exactly that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 02:54:38 +02:00
..
ConcurrentCacheRace linting 2026-07-23 01:24:42 +02:00
ConcurrentDependencyReset linting 2026-07-23 01:24:42 +02:00
DependencyLink linting 2026-07-23 01:24:42 +02:00
HelloWorld linting 2026-07-23 01:24:42 +02:00
HouseRules linting 2026-07-23 01:24:42 +02:00
Lint feat(lint): libclang-backed token layer 2026-07-27 02:54:38 +02:00
ModuleInterface linting 2026-07-23 01:24:42 +02:00
RunSingleTestExit linting 2026-07-23 01:24:42 +02:00
ShaderCompile linting 2026-07-23 01:24:42 +02:00
StandardArgs linting 2026-07-23 01:24:42 +02:00
StaticLib linting 2026-07-23 01:24:42 +02:00
TestRunnerSpec linting 2026-07-23 01:24:42 +02:00
VariantId linting 2026-07-23 01:24:42 +02:00
WasiBrowserRuntime linting 2026-07-23 01:24:42 +02:00
WasmVariants linting 2026-07-23 01:24:42 +02:00