aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/codesearch/testdata
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2026-01-21 12:21:38 +0100
committerDmitry Vyukov <dvyukov@google.com>2026-01-22 11:23:54 +0000
commit8e4581b34c9584a49bc595d65c48167b9ecbe34f (patch)
tree107cd943f49b86f1a8e4639c03c73bf80642ba57 /pkg/codesearch/testdata
parent2367ed1e24f80dca97acc30309650f248a2df14b (diff)
tools/clang/codesearch: index struct references
Update #6469
Diffstat (limited to 'pkg/codesearch/testdata')
-rw-r--r--pkg/codesearch/testdata/query-file-index-source1
-rw-r--r--pkg/codesearch/testdata/query-find-references-struct15
-rw-r--r--pkg/codesearch/testdata/source0.c6
-rw-r--r--pkg/codesearch/testdata/source0.c.json37
4 files changed, 59 insertions, 0 deletions
diff --git a/pkg/codesearch/testdata/query-file-index-source b/pkg/codesearch/testdata/query-file-index-source
index 3263deca3..af52513b7 100644
--- a/pkg/codesearch/testdata/query-file-index-source
+++ b/pkg/codesearch/testdata/query-file-index-source
@@ -3,6 +3,7 @@ file-index source0.c
file source0.c defines the following entities:
function close
+function func_accepting_a_struct
function function_with_comment_in_header
function open
struct struct_in_c_file
diff --git a/pkg/codesearch/testdata/query-find-references-struct b/pkg/codesearch/testdata/query-find-references-struct
new file mode 100644
index 000000000..cfb266dc7
--- /dev/null
+++ b/pkg/codesearch/testdata/query-find-references-struct
@@ -0,0 +1,15 @@
+find-references source0.c some_struct "" 1 10
+
+some_struct has 2 references:
+
+function func_accepting_a_struct uses it at source0.c:29
+ 29: int func_accepting_a_struct(struct some_struct* p)
+ 30: {
+
+
+function func_accepting_a_struct uses it at source0.c:31
+ 30: {
+ 31: return ((some_struct_t*)p)->x +
+ 32: ((union some_union*)p)->x;
+
+
diff --git a/pkg/codesearch/testdata/source0.c b/pkg/codesearch/testdata/source0.c
index 2d312ff99..5ac117cab 100644
--- a/pkg/codesearch/testdata/source0.c
+++ b/pkg/codesearch/testdata/source0.c
@@ -25,3 +25,9 @@ void function_with_comment_in_header()
{
same_name_in_several_files();
}
+
+int func_accepting_a_struct(struct some_struct* p)
+{
+ return ((some_struct_t*)p)->x +
+ ((union some_union*)p)->x;
+}
diff --git a/pkg/codesearch/testdata/source0.c.json b/pkg/codesearch/testdata/source0.c.json
index ba6b41751..1732d7c97 100644
--- a/pkg/codesearch/testdata/source0.c.json
+++ b/pkg/codesearch/testdata/source0.c.json
@@ -23,6 +23,43 @@
},
{
"kind": "function",
+ "name": "func_accepting_a_struct",
+ "type": "int (struct some_struct *)",
+ "body": {
+ "file": "source0.c",
+ "start_line": 29,
+ "end_line": 33
+ },
+ "comment": {},
+ "refs": [
+ {
+ "kind": "uses",
+ "entity_kind": "struct",
+ "name": "some_struct",
+ "line": 29
+ },
+ {
+ "kind": "uses",
+ "entity_kind": "typedef",
+ "name": "some_struct_t",
+ "line": 31
+ },
+ {
+ "kind": "uses",
+ "entity_kind": "struct",
+ "name": "some_struct",
+ "line": 31
+ },
+ {
+ "kind": "uses",
+ "entity_kind": "union",
+ "name": "some_union",
+ "line": 32
+ }
+ ]
+ },
+ {
+ "kind": "function",
"name": "func_in_header",
"type": "int ()",
"is_static": true,