From 280ea308c321115445df610f1a75b05bbadca5f3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 17 Nov 2025 11:17:23 +0100 Subject: pkg/codesearch: add skeleton for code searching tool Add a clang tool that is used for code indexing (tools/clang/codesearch/). It follows conventions and build procedure of the declextract tool. Add pkg/codesearch package that aggregates the info exposed by the clang tools, and allows doing simple queries: - show source code of an entity (function, struct, etc) - show entity comment - show all entities defined in a source file Add tools/syz-codesearch wrapper tool that allows to create index for a kernel build, and then run code queries on it. --- pkg/clangtool/clangtool.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/clangtool') diff --git a/pkg/clangtool/clangtool.go b/pkg/clangtool/clangtool.go index 4e3914cf8..8711b5411 100644 --- a/pkg/clangtool/clangtool.go +++ b/pkg/clangtool/clangtool.go @@ -155,7 +155,10 @@ func runTool[Output any, OutputPtr OutputDataPtr[Output]](cfg *Config, dbFile, f cfg.KernelSrc), cfg.KernelObj), "/") // Suppress warning since we may build the tool on a different clang // version that produces more warnings. - data, err := exec.Command(cfg.ToolBin, "-p", dbFile, "--extra-arg=-w", file).Output() + // Comments are needed for codesearch tool, but may be useful for declextract + // in the future if we try to parse them with LLMs. + data, err := exec.Command(cfg.ToolBin, "-p", dbFile, + "--extra-arg=-w", "--extra-arg=-fparse-all-comments", file).Output() if err != nil { var exitErr *exec.ExitError if errors.As(err, &exitErr) { -- cgit mrf-deployment