Skip to content

Commit

Permalink
feat(schema): add /thunk edges and clean up ref/writes (#5848)
Browse files Browse the repository at this point in the history
* feat(schema): add /thunk edges and clean up ref/writes

* feat(schema): add java thunk example
  • Loading branch information
zrlk committed Sep 18, 2023
1 parent 9c7b2dd commit 07c418f
Showing 1 changed file with 89 additions and 2 deletions.
91 changes: 89 additions & 2 deletions kythe/docs/schema/schema.txt
Expand Up @@ -1216,6 +1216,57 @@ struct S { static int foo(); };
C<S> cs;
--------------------------------------------------------------------------------

[[refcallthunk]]
ref/call/thunk
~~~~~~~~~~~~~~

Brief description::
A *ref/call/thunk* F if A is an anchor that may allow F to be called in the
future.
Points from::
anchors
Points toward::
<<function,functions>>
Ordinals are used::
never
See also::
<<refcall,[ref/call]>>
Notes::
This is an experimental definition and is expected to undergo refinement.

This edge is meant to represent delayed calls to functions, such as when a
thread procedure is passed to a threading library.

[kythe,C++,"In some contexts, uses of functions as values are thunks."]
--------------------------------------------------------------------------------
//- @f defines/binding FnF
void f();
//- @g defines/binding FnG
void g(void (*h)());
void i() {
//- @f ref FnF
//- @"g(f)" ref/call FnG
//- // @f ref/call/thunk FnF -- currently unsupported
//- !{ @f ref/call FnF }
g(f);
//- @f ref FnF
//- // @f ref/call/thunk FnF -- currently unsupported
auto j = f;
}
--------------------------------------------------------------------------------

[kythe,Java,"Java method references make thunks."]
--------------------------------------------------------------------------------
import java.util.function.Consumer;
public class E {
//- @f defines/binding FnF
void f(Object v) { }
//- @f ref FnF
//- // @"this::f" ref/call/thunk FnF -- currently unsupported
Consumer<Object> myF = this::f;
}
--------------------------------------------------------------------------------

[[refdoc]]
ref/doc
~~~~~~~
Expand Down Expand Up @@ -1496,8 +1547,6 @@ Points toward::
semantic nodes
Ordinals are used::
never
Notes::
This is an experimental definition and is expected to undergo refinement.

[kythe,C++,"Various assignment expressions are writes"]
--------------------------------------------------------------------------------
Expand All @@ -1516,6 +1565,44 @@ void f() {
}
--------------------------------------------------------------------------------

[[refwritesthunk]]
ref/writes/thunk
~~~~~~~~~~~~~~~~

Brief description::
A *ref/writes/thunk* B if A refers to B in an expression that is likely to
cause a later update the value of B.
Commonly arises from::
value uses of setter functions, alias passing
Points from::
anchors
Points toward::
semantic nodes
Ordinals are used::
never
See also::
<<refwrites,[ref/writes]>>
Notes::
This is an experimental definition and is expected to undergo refinement.

[kythe,C++,"Various assignment expressions are thunkful writes"]
--------------------------------------------------------------------------------
void f(int* x_out, int& y_out, const int& z);
void g() {
//- @x defines/binding VarX
//- @y defines/binding VarY
//- @z defines/binding VarZ
int x, y, z;
//- @x ref VarX
//- @y ref VarY
//- @z ref VarZ
//- // @x ref/writes/thunk VarX -- currently unsupported
//- // @y ref/writes/thunk VarY -- currently unsupported
//- !{ @z ref/writes/thunk VarZ }
f(&x, y, z);
}
--------------------------------------------------------------------------------

[[satisfies]]
satisfies
~~~~~~~~~
Expand Down

0 comments on commit 07c418f

Please sign in to comment.