finds.dev← search

// the find

chrisforbes/sparse

★ 10 · C · NOASSERTION · updated Aug 2011

Sparse, a semantic parser & static analysis tool for C [upstream: kernel.org]

Sparse is a C semantic parser originally developed by Linus Torvalds for the Linux kernel, used to catch type annotation violations (like __user, __kernel address space mismatches) that regular compilers miss. This GitHub mirror by chrisforbes is a snapshot from 2011; the real upstream lives at kernel.org and is still actively maintained there. It's for people building static analysis tools on top of C code, not for general-purpose use.

The API is genuinely minimal — parse a file with one call, get a complete symbol tree, no callbacks, no global state to manage. The hand-written tokenizer and parser avoid the lex/yacc abstraction tax and give you full control over error recovery. Lazy type evaluation is a real design win: you don't pay for full type resolution on symbols you never inspect. The validation/ directory is an honest test suite with targeted negative cases, not just happy-path examples.

This mirror is frozen at 2011 and has 10 stars — if you use this you're on your own for bug fixes; go to kernel.org/pub/software/devel/sparse instead. C11 and C17 language features are missing or incomplete; if your codebase uses anything past C99 you'll hit parse failures. Documentation is sparse in the bad sense: data-structures.txt covers the internals but there's essentially no guide for writing your own analysis pass on top of the tree. No package manager integration — you're building from source with a bare Makefile and hoping your system headers cooperate.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →