aboutsummaryrefslogtreecommitdiffstats
path: root/tools/clang/codesearch/codesearch.cpp
Commit message (Collapse)AuthorAgeFilesLines
* tools/clang: build clang tools on linux onlyDmitry Vyukov2026-02-231-0/+2
| | | | | | | This will hopefully prevent: imports github.com/google/syzkaller/tools/clang/codesearch: C++ source files not allowed when not using cgo or SWIG: codesearch.cpp
* tools/clang/codesearch: improve codesearch to handle global variablesArtem Metla2026-02-171-0/+24
| | | | | | | | | | | Contributes to #6469. To handle global variables: * Add EntityKindGlobalVariable * Modify TraverseVarDecl() function logic * Add a check to ensure StartLine and EndLine are in the same file * Fix missing #include <cstdint> in json.h
* tools/clang: compile clang tools into the binaryDmitry Vyukov2026-02-061-3/+18
| | | | | | | | | | | | | | | | | | Compiled clang tools into Go binaries using cgo. This significantly simplifies building and deployment. This also enables unit testing of clang tools. Now raw go test for clang tools will build them, run, and verify output. Each clang tool is still started as a subprocess. I've experimented with running them in-process, but this makes stdout/stderr interception extremly complicated, and it seems that clang tools still use unsynchronized global state, which breaks when invoked multiple times. Subprocesses also make it safer in the face of potential memory leaks, or memory corruptions in clang tools. Fixes #6645
* pkg/codesearch: remove check for invalid C which is not expected at this pointTamas Koczka2026-01-281-1/+1
| | | | Also fixes a lint error.
* pkg/codesearch: expose struct layout in codesearchTamas Koczka2026-01-281-0/+19
| | | | | | | | | | - Extract struct field offsets and sizes in the C++ codesearch indexer. - Add 'fields' to the JSON definition output. - Update pkg/codesearch to parse and expose the new field information. - Add 'struct-layout' command to syz-codesearch for debugging. - Add 'codesearch-struct-layout' tool to pkg/aflow/tool/codesearcher/ to allow LLM agents to query struct memory layout and map byte offsets to fields. - Support pointer marshaling for optional JSON values (e.g. *uint)
* tools/clang/codesearch: migrate dyn_cast to dyn_cast_if_presentYulong Zhang2026-01-271-5/+5
| | | | | In LLVM 16+ dyn_cast is no longer null-safe and hence leads to crashes. This commit switches it to dyn_cast_if_null.
* pkg/codesearch: support finding field reads/writesDmitry Vyukov2026-01-261-4/+43
|
* tools/clang/codesearch: index struct referencesDmitry Vyukov2026-01-221-12/+77
| | | | Update #6469
* pkg/codesearch: do indexing of struct/union/enumDmitry Vyukov2026-01-211-21/+62
| | | | Update #6469
* pkg/codesearch: support searching for referencesDmitry Vyukov2026-01-211-5/+43
| | | | | | | | | Extend codesearch clang tool to export info about function references (calls, takes-address-of). Add pkg/codesearch command find-references. Export find-references in pkg/aflow/tools/codesearcher to LLMs. Update #6469
* tools/clang/codesearch: fix a typoFlorent Revest2026-01-201-1/+1
|
* tools/clang/codesearch: support building with -Wchanges-meaningFlorent Revest2026-01-201-11/+11
| | | | | | | | | | | | | | | | When compiling with the changes-meaning flag, syz-codesearch gets a bunch of errors such as this one: codesearch.cpp:30:15: error: declaration of ‘clang::SourceRange MacroDef::SourceRange’ changes meaning of ‘SourceRange’ [-Wchanges-meaning] 30 | SourceRange SourceRange; // soruce range of the value | ^~~~~~~~~~~ codesearch.cpp:30:3: note: used here to mean ‘class clang::SourceRange’ 30 | SourceRange SourceRange; // soruce range of the value | ^~~~~~~~~~~ Let's iron them out early before the code base grows too reliant on this pattern.
* pkg/codesearch: add skeleton for code searching toolDmitry Vyukov2025-11-201-0/+153
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.