From d2f4c2dcfb6a914319dcb6a6e687eae95a0c893e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 11:25:15 +0000 Subject: [PATCH 1/5] ruff_cpp_spo: harvest_pgring example (PG-Ring SPO harvest, clean-room input for D-ASM-11) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh --- crates/ruff_cpp_spo/Cargo.toml | 4 + .../ruff_cpp_spo/examples/harvest_pgring.rs | 243 ++++++++++++++++++ 2 files changed, 247 insertions(+) create mode 100644 crates/ruff_cpp_spo/examples/harvest_pgring.rs diff --git a/crates/ruff_cpp_spo/Cargo.toml b/crates/ruff_cpp_spo/Cargo.toml index eb1ebbeeb6e4f..ce556109bae9b 100644 --- a/crates/ruff_cpp_spo/Cargo.toml +++ b/crates/ruff_cpp_spo/Cargo.toml @@ -57,6 +57,10 @@ required-features = ["libclang"] name = "harvest_ladybug" required-features = ["libclang"] +[[example]] +name = "harvest_pgring" +required-features = ["libclang"] + [dev-dependencies] # End-to-end pipeline test only (harvest -> reassemble -> ruff_cpp_codegen emit). # The harvester does NOT depend on the codegen at runtime — this is the test diff --git a/crates/ruff_cpp_spo/examples/harvest_pgring.rs b/crates/ruff_cpp_spo/examples/harvest_pgring.rs new file mode 100644 index 0000000000000..73f9ff29b38c0 --- /dev/null +++ b/crates/ruff_cpp_spo/examples/harvest_pgring.rs @@ -0,0 +1,243 @@ +//! Harvest the PG-Ring graph query engine (Gómez-Brandón, Hogan, Navarro, +//! ISWC 2026, arXiv 2608.03840) into a structural manifest: classes, their +//! fields and method signatures, and the call graph of every function body. +//! +//! PG-Ring is GPL-3.0. This example reads the source only to extract the +//! STRUCTURE (which iterators exist, which methods they offer, who calls whom) +//! that a clean-room reimplementation is designed against. No code is copied, +//! and the corpus is never vendored here. +//! +//! Run: +//! ```sh +//! PGRING_SRC=/home/user/adaworldapi/pg-ring \ +//! SDSL_INCLUDE=/home/user/adaworldapi/sdsl-lite/include \ +//! LIBCLANG_PATH=/usr/lib/llvm-18/lib \ +//! cargo run -p ruff_cpp_spo --features libclang --example harvest_pgring +//! ``` +//! +//! Outputs (directory `OUT_DIR`, default `/tmp/pgring_harvest`): +//! - `manifest.ndjson`: the SPO triples of every class (shared IR). +//! - `.txt`: one readable summary per source file: classes with bases, +//! fields and method signatures, then every function with its callees. + +#![expect( + clippy::print_stderr, + reason = "manifest-emission CLI example (mirrors harvest_textord)" +)] + +use std::collections::BTreeSet; +use std::fmt::Write as _; +use std::path::{Path, PathBuf}; + +use ruff_cpp_spo::{ + CppClass, Declaration, NAMESPACE, model_from_class, walk_free_functions_with_diagnostics, + walk_tu_with_diagnostics, +}; +use ruff_spo_triplet::{ModelGraph, expand, to_ndjson}; + +/// Every `.hpp`, `.h`, `.cpp` and `.c` under `dir`, recursively, sorted. +fn sources(dir: &Path, out: &mut Vec) { + let Ok(entries) = std::fs::read_dir(dir) else { + return; + }; + let mut paths: Vec = entries.filter_map(Result::ok).map(|e| e.path()).collect(); + paths.sort(); + for p in paths { + if p.is_dir() { + sources(&p, out); + } else if p + .extension() + .is_some_and(|e| e == "hpp" || e == "h" || e == "cpp" || e == "c") + { + out.push(p); + } + } +} + +fn summarize_class(c: &CppClass, s: &mut String) { + let _ = writeln!(s, "class {}", c.qualified_name()); + for d in &c.declarations { + match d { + Declaration::Base(b) => { + let _ = writeln!(s, " base {}", b.name); + } + Declaration::Field(f) => { + let _ = writeln!(s, " field {}: {}", f.name, f.type_name); + } + Declaration::Method(m) => { + let ret = m.return_type.as_deref().unwrap_or("void"); + let flags = if m.is_static { " static" } else { "" }; + let _ = writeln!( + s, + " method {}({}) -> {ret}{flags}", + m.name, + m.param_types.join(", ") + ); + } + Declaration::Template(t) => { + let _ = writeln!(s, " template {:?} {}", t.kind, t.name); + } + _ => {} + } + } +} + +/// Library namespaces pulled in through `#include` that are not PG-Ring's own +/// code. Their declarations reach every translation unit; keeping them would +/// bury the engine under SDSL and the standard library. +const FOREIGN: [&str; 3] = ["sdsl", "std", "__gnu_cxx"]; + +fn is_foreign(qualified: &str) -> bool { + qualified.starts_with("__") + || FOREIGN + .iter() + .any(|ns| qualified == *ns || qualified.starts_with(&format!("{ns}::"))) +} + +/// The source file that DEFINES `name` (a `class name` / `struct name` not +/// followed by `;`), found by text scan. libclang reports a class in every +/// translation unit that includes it, so the walk alone cannot attribute it. +fn defining_file<'a>(name: &str, texts: &'a [(String, String)]) -> Option<&'a str> { + texts.iter().find_map(|(rel, text)| { + ["class ", "struct "].iter().find_map(|kw| { + let needle = format!("{kw}{name}"); + text.match_indices(&needle).find_map(|(i, _)| { + let rest = &text[i + needle.len()..]; + let next = rest.chars().next()?; + if next.is_alphanumeric() || next == '_' { + return None; + } + let decl_end = rest.find(['{', ';'])?; + (rest.as_bytes()[decl_end] == b'{').then_some(rel.as_str()) + }) + }) + }) +} + +fn main() -> Result<(), Box> { + let root = PathBuf::from( + std::env::var("PGRING_SRC").unwrap_or_else(|_| "/home/user/adaworldapi/pg-ring".into()), + ); + let sdsl = std::env::var("SDSL_INCLUDE") + .unwrap_or_else(|_| "/home/user/adaworldapi/sdsl-lite/include".into()); + let out_dir = PathBuf::from( + std::env::var("OUT_DIR").unwrap_or_else(|_| "/tmp/pgring_harvest".into()), + ); + std::fs::create_dir_all(&out_dir)?; + + let mut files = Vec::new(); + sources(&root.join("include"), &mut files); + sources(&root.join("src"), &mut files); + if files.is_empty() { + return Err(format!("no sources under {}; set PGRING_SRC", root.display()).into()); + } + + let args = [ + "-std=c++17".to_string(), + "-x".to_string(), + "c++".to_string(), + format!("-I{}", root.join("include").display()), + format!("-I{}", root.join("libCSD").display()), + format!("-I{sdsl}"), + ]; + + let texts: Vec<(String, String)> = files + .iter() + .filter_map(|f| { + let rel = f.strip_prefix(&root).unwrap_or(f).display().to_string(); + std::fs::read_to_string(f).ok().map(|t| (rel, t)) + }) + .collect(); + + let mut all: Vec = Vec::new(); + let mut seen: BTreeSet = BTreeSet::new(); + let mut functions: Vec<(String, String)> = Vec::new(); + let mut seen_fn: BTreeSet = BTreeSet::new(); + let mut diag_report = String::new(); + for f in &files { + let rel = f.strip_prefix(&root).unwrap_or(f).display().to_string(); + match walk_tu_with_diagnostics(f, &args) { + Ok((classes, diags)) => { + if !diags.is_empty() { + let _ = writeln!(diag_report, "{rel}: {} error(s)", diags.len()); + for d in diags.iter().take(3) { + let _ = writeln!(diag_report, " {d}"); + } + } + for c in classes { + if !is_foreign(&c.qualified_name()) && seen.insert(c.qualified_name()) { + all.push(c); + } + } + } + Err(e) => { + let _ = writeln!(diag_report, "{rel}: class walk failed: {e}"); + } + } + match walk_free_functions_with_diagnostics(f, &args) { + Ok((fns, _)) => { + for func in fns { + let q = func.qualified_name(); + let sig = format!("{q}({})", func.param_types.join(", ")); + if is_foreign(&q) || !seen_fn.insert(sig.clone()) { + continue; + } + let ret = func.return_type.as_deref().unwrap_or("void"); + let line = format!("fn {sig} -> {ret}\n calls: {}\n", func.calls.join(", ")); + // The file whose text holds `name(` attributes the + // definition; the walk sees it in every including TU. + let tail = func.name.clone(); + let home = texts + .iter() + .find(|(_, t)| t.contains(&format!("{tail}("))) + .map_or_else(|| rel.clone(), |(r, _)| r.clone()); + functions.push((home, line)); + } + } + Err(e) => { + let _ = writeln!(diag_report, "{rel}: function walk failed: {e}"); + } + } + } + + for (rel, _) in &texts { + let mut s = format!("# {rel}\n"); + for c in &all { + if defining_file(&c.name, &texts) == Some(rel.as_str()) { + summarize_class(c, &mut s); + } + } + for (home, line) in &functions { + if home == rel { + s.push_str(line); + } + } + std::fs::write(out_dir.join(format!("{}.txt", rel.replace('/', "__"))), &s)?; + } + let unattributed: Vec<&str> = all + .iter() + .filter(|c| defining_file(&c.name, &texts).is_none()) + .map(|c| c.name.as_str()) + .collect(); + let _ = writeln!(diag_report, "\nclasses with no defining file found: {unattributed:?}"); + std::fs::write(out_dir.join("_diagnostics.txt"), &diag_report)?; + let n_functions = functions.len(); + let warned = diag_report.lines().filter(|l| l.contains(" error(s)")).count(); + + let mut graph = ModelGraph::new(NAMESPACE); + for c in &all { + graph.models.push(model_from_class(c)); + } + let triples = expand(&graph); + std::fs::write(out_dir.join("manifest.ndjson"), to_ndjson(&triples))?; + eprintln!( + "[harvest] {} files, {} unique classes, {} function definitions, {} files with parse errors, {} triples -> {}", + files.len(), + all.len(), + n_functions, + warned, + triples.len(), + out_dir.display() + ); + Ok(()) +} From abe5d61c0b027cdebf6d42fafaccf7355fc9a3e3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 11:56:12 +0000 Subject: [PATCH 2/5] Format harvest_pgring example with rustfmt Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh --- crates/ruff_cpp_spo/examples/harvest_pgring.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/ruff_cpp_spo/examples/harvest_pgring.rs b/crates/ruff_cpp_spo/examples/harvest_pgring.rs index 73f9ff29b38c0..8e6a243480f49 100644 --- a/crates/ruff_cpp_spo/examples/harvest_pgring.rs +++ b/crates/ruff_cpp_spo/examples/harvest_pgring.rs @@ -120,9 +120,8 @@ fn main() -> Result<(), Box> { ); let sdsl = std::env::var("SDSL_INCLUDE") .unwrap_or_else(|_| "/home/user/adaworldapi/sdsl-lite/include".into()); - let out_dir = PathBuf::from( - std::env::var("OUT_DIR").unwrap_or_else(|_| "/tmp/pgring_harvest".into()), - ); + let out_dir = + PathBuf::from(std::env::var("OUT_DIR").unwrap_or_else(|_| "/tmp/pgring_harvest".into())); std::fs::create_dir_all(&out_dir)?; let mut files = Vec::new(); @@ -219,10 +218,16 @@ fn main() -> Result<(), Box> { .filter(|c| defining_file(&c.name, &texts).is_none()) .map(|c| c.name.as_str()) .collect(); - let _ = writeln!(diag_report, "\nclasses with no defining file found: {unattributed:?}"); + let _ = writeln!( + diag_report, + "\nclasses with no defining file found: {unattributed:?}" + ); std::fs::write(out_dir.join("_diagnostics.txt"), &diag_report)?; let n_functions = functions.len(); - let warned = diag_report.lines().filter(|l| l.contains(" error(s)")).count(); + let warned = diag_report + .lines() + .filter(|l| l.contains(" error(s)")) + .count(); let mut graph = ModelGraph::new(NAMESPACE); for c in &all { From 54e3b19809abf1d25807e9efbbccd35feae18b54 Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Sun, 18 Oct 2026 17:37:01 +0200 Subject: [PATCH 3/5] ci(typos): keep anc recursive predicate intact in MeTTa fixture --- _typos.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_typos.toml b/_typos.toml index e65835d3cdea6..68f0105c9489a 100644 --- a/_typos.toml +++ b/_typos.toml @@ -34,6 +34,9 @@ CPY = "CPY" # it's a Ruff rule category # P-code / R2IL opcode names, not prose. INT_SCARRY is signed-carry; the # hook's "scary" correction silently corrupts an emitted wire tag. scarry = "scarry" +# `anc` is an intentional MeTTa predicate for ancestor in a recursive +# Datalog-style test. Replacing it with `and` changes the program's meaning. +anc = "anc" # Tesseract really does ship `src/ccstruct/statistc.h` under that spelling. # "Correcting" it points the harvest docs at a file that does not exist. statistc = "statistc" From a768597e4eeb19c0663fac67488a5a224d086620 Mon Sep 17 00:00:00 2001 From: AdaWorldAPI Date: Sun, 18 Oct 2026 18:28:01 +0200 Subject: [PATCH 4/5] fix(ci): pin Ruff release-train 0.17.0 for cargo publish verification --- Cargo.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index af579c00ca502..7d272e991b8e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,10 @@ license = "MIT" [workspace.dependencies] char_str = { version = "0.0.4", default-features = false, features = ["std"] } -ruff = { version = "0.17.0", path = "crates/ruff" } +# Internal release train: keep published tarball dependency versions +# identical to these local paths; ^0.17.0 allows 0.17.1 and mixes 0.0.18 +# ruff_* crates with this workspace's 0.0.17 ABI during cargo publish --dry-run. +ruff = { version = "=0.17.0", path = "crates/ruff" } ruff_annotate_snippets = { version = "0.0.17", path = "crates/ruff_annotate_snippets" } ruff_cache = { version = "0.0.17", path = "crates/ruff_cache" } ruff_command_line = { version = "0.0.17", path = "crates/ruff_command_line" } @@ -32,7 +35,7 @@ ruff_diagnostics = { version = "0.0.17", path = "crates/ruff_diagnostics" } ruff_formatter = { version = "0.0.17", path = "crates/ruff_formatter" } ruff_graph = { version = "0.0.17", path = "crates/ruff_graph" } ruff_index = { version = "0.0.17", path = "crates/ruff_index" } -ruff_linter = { version = "0.17.0", path = "crates/ruff_linter" } +ruff_linter = { version = "=0.17.0", path = "crates/ruff_linter" } ruff_macros = { version = "0.0.17", path = "crates/ruff_macros" } ruff_markdown = { version = "0.0.17", path = "crates/ruff_markdown" } ruff_memory_usage = { version = "0.0.17", path = "crates/ruff_memory_usage" } From 1d380817a94408477521d8f487ff120a6b76a7d2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 17 Oct 2026 12:03:49 +0000 Subject: [PATCH 5/5] ruff_cpp_spo: record each function definition's file; fix the PG-Ring harvester's attribution CppFunction gains file, the definition's own location. The walker reports an inline header function in every translation unit that includes it, and a text search for its name finds declarations and calls first, so the harvester attributed functions to the wrong files. harvest_pgring now: - attributes functions by that location; - names an out-of-line method once (Class::method, not Class::Class::method) and prints the callee spelling so definitions join their call edges; - takes a class from a translation unit with parse errors only when no clean unit declares it, and lists the classes taken that way; - states that methods defined inside a class body are signatures only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011BMJnDBAfzcuQh5HeT39Rh --- .../ruff_cpp_spo/examples/harvest_pgring.rs | 84 +++++++++++++++---- crates/ruff_cpp_spo/src/clang_walker.rs | 13 +++ crates/ruff_cpp_spo/src/lib.rs | 8 ++ 3 files changed, 91 insertions(+), 14 deletions(-) diff --git a/crates/ruff_cpp_spo/examples/harvest_pgring.rs b/crates/ruff_cpp_spo/examples/harvest_pgring.rs index 8e6a243480f49..06c0c1dd31f4b 100644 --- a/crates/ruff_cpp_spo/examples/harvest_pgring.rs +++ b/crates/ruff_cpp_spo/examples/harvest_pgring.rs @@ -1,6 +1,11 @@ //! Harvest the PG-Ring graph query engine (Gómez-Brandón, Hogan, Navarro, //! ISWC 2026, arXiv 2608.03840) into a structural manifest: classes, their -//! fields and method signatures, and the call graph of every function body. +//! fields and method signatures, and the call graph of every free function +//! and out-of-line method definition. +//! +//! Methods defined inside a class body (inline, the common case in a +//! header-only library) appear only as signatures: the function walker does +//! not descend into class bodies, so their callees are not in the call graph. //! //! PG-Ring is GPL-3.0. This example reads the source only to extract the //! STRUCTURE (which iterators exist, which methods they offer, who calls whom) @@ -18,7 +23,11 @@ //! Outputs (directory `OUT_DIR`, default `/tmp/pgring_harvest`): //! - `manifest.ndjson`: the SPO triples of every class (shared IR). //! - `.txt`: one readable summary per source file: classes with bases, -//! fields and method signatures, then every function with its callees. +//! fields and method signatures, then every function defined in that file +//! with its callees. +//! - `_diagnostics.txt`: translation units with parse errors. A class is taken +//! from such a unit only when no unit without errors declares it, and the +//! classes taken that way are listed. #![expect( clippy::print_stderr, @@ -30,8 +39,8 @@ use std::fmt::Write as _; use std::path::{Path, PathBuf}; use ruff_cpp_spo::{ - CppClass, Declaration, NAMESPACE, model_from_class, walk_free_functions_with_diagnostics, - walk_tu_with_diagnostics, + CppClass, CppFunction, Declaration, NAMESPACE, model_from_class, + walk_free_functions_with_diagnostics, walk_tu_with_diagnostics, }; use ruff_spo_triplet::{ModelGraph, expand, to_ndjson}; @@ -114,6 +123,22 @@ fn defining_file<'a>(name: &str, texts: &'a [(String, String)]) -> Option<&'a st }) } +/// The identity of a harvested function. An out-of-line method is named +/// `Class::method` by the walker and also carries `Class` as its last scope +/// component; joining the two would repeat the class (`Class::Class::method`). +fn function_identity(func: &CppFunction) -> String { + match func.namespace.split_last() { + Some((owner, outer)) if func.name.starts_with(&format!("{owner}::")) => { + if outer.is_empty() { + func.name.clone() + } else { + format!("{}::{}", outer.join("::"), func.name) + } + } + _ => func.qualified_name(), + } +} + fn main() -> Result<(), Box> { let root = PathBuf::from( std::env::var("PGRING_SRC").unwrap_or_else(|_| "/home/user/adaworldapi/pg-ring".into()), @@ -150,6 +175,9 @@ fn main() -> Result<(), Box> { let mut all: Vec = Vec::new(); let mut seen: BTreeSet = BTreeSet::new(); + // Classes seen only in translation units with parse errors: a partial AST, + // used only for a class that no clean unit declares. + let mut from_errored: Vec = Vec::new(); let mut functions: Vec<(String, String)> = Vec::new(); let mut seen_fn: BTreeSet = BTreeSet::new(); let mut diag_report = String::new(); @@ -164,7 +192,12 @@ fn main() -> Result<(), Box> { } } for c in classes { - if !is_foreign(&c.qualified_name()) && seen.insert(c.qualified_name()) { + if is_foreign(&c.qualified_name()) { + continue; + } + if !diags.is_empty() { + from_errored.push(c); + } else if seen.insert(c.qualified_name()) { all.push(c); } } @@ -176,20 +209,31 @@ fn main() -> Result<(), Box> { match walk_free_functions_with_diagnostics(f, &args) { Ok((fns, _)) => { for func in fns { - let q = func.qualified_name(); + let q = function_identity(&func); let sig = format!("{q}({})", func.param_types.join(", ")); if is_foreign(&q) || !seen_fn.insert(sig.clone()) { continue; } let ret = func.return_type.as_deref().unwrap_or("void"); - let line = format!("fn {sig} -> {ret}\n calls: {}\n", func.calls.join(", ")); - // The file whose text holds `name(` attributes the - // definition; the walk sees it in every including TU. - let tail = func.name.clone(); - let home = texts - .iter() - .find(|(_, t)| t.contains(&format!("{tail}("))) - .map_or_else(|| rel.clone(), |(r, _)| r.clone()); + // Callees of a method are spelled `Class::method` (no + // namespace); print that spelling too so a definition + // joins its call edges. + let key = if func.name == q { + String::new() + } else { + format!(" callee name: {}\n", func.name) + }; + let line = format!( + "fn {sig} -> {ret}\n{key} calls: {}\n", + func.calls.join(", ") + ); + // The definition's own location attributes it; the walk + // sees an inline header function in every including TU. + let home = func + .file + .as_deref() + .map(|p| p.strip_prefix(&root).unwrap_or(p).display().to_string()) + .unwrap_or_else(|| rel.clone()); functions.push((home, line)); } } @@ -199,6 +243,18 @@ fn main() -> Result<(), Box> { } } + let mut recovered: Vec = Vec::new(); + for c in from_errored { + if seen.insert(c.qualified_name()) { + recovered.push(c.qualified_name()); + all.push(c); + } + } + let _ = writeln!( + diag_report, + "\nclasses taken from units with parse errors (partial AST): {recovered:?}" + ); + for (rel, _) in &texts { let mut s = format!("# {rel}\n"); for c in &all { diff --git a/crates/ruff_cpp_spo/src/clang_walker.rs b/crates/ruff_cpp_spo/src/clang_walker.rs index 91190cf4e4ace..040d58634686e 100644 --- a/crates/ruff_cpp_spo/src/clang_walker.rs +++ b/crates/ruff_cpp_spo/src/clang_walker.rs @@ -320,6 +320,10 @@ fn collect_functions(entity: &Entity, out: &mut Vec) { // member question and is false for a free function, so the // storage class is the right source here. let is_static = child.get_storage_class() == Some(StorageClass::Static); + let file = child + .get_location() + .and_then(|l| l.get_file_location().file) + .map(|f| f.get_path()); out.push(CppFunction { namespace: enclosing_scopes(&child), name, @@ -327,6 +331,7 @@ fn collect_functions(entity: &Entity, out: &mut Vec) { return_type, param_types, is_static, + file, }); } } @@ -2378,6 +2383,14 @@ void Widget::dispatch() { .unwrap_or_else(|| panic!("Widget::dispatch missing; got {funcs:?}")); assert_eq!(dispatch.namespace, vec!["Widget".to_string()]); + // The definition's own file is recorded, so a caller can attribute it + // without searching text for the name. + assert_eq!( + dispatch.file.as_deref().and_then(|f| f.file_name()), + path.file_name(), + "the definition must carry the file it is defined in" + ); + // Fix 1 + codex P2 (#57): in-TU dispatch between two out-of-line // methods resolves CLASS-QUALIFIED, so same-named methods of // different classes can never collapse in the call graph. diff --git a/crates/ruff_cpp_spo/src/lib.rs b/crates/ruff_cpp_spo/src/lib.rs index 09d1efec40f0e..38a4b4823f0ad 100644 --- a/crates/ruff_cpp_spo/src/lib.rs +++ b/crates/ruff_cpp_spo/src/lib.rs @@ -184,6 +184,14 @@ pub struct CppFunction { /// obtain by overloading. See `examples/harvest_openggs.rs` for the mapping /// that omits it, and why omission is a truer encoding than either value. pub is_static: bool, + /// The file that holds this DEFINITION, from the cursor's own location. + /// + /// The walker reports a function in every translation unit that includes + /// its definition (an inline header function reaches every `.cpp`), so the + /// TU being walked is not where the function lives, and a text search for + /// its name finds declarations and call sites first. `None` only when + /// libclang reports no file for the cursor. + pub file: Option, } #[cfg(feature = "libclang")]