Skip to content

Conversation

zrlk
Copy link
Contributor

@zrlk zrlk commented Mar 22, 2024

This might need a little more refinement before it's viable to use
(e.g., we might need to track which types we've already emitted flat
code for to avoid too much redundant output).

@zrlk zrlk requested a review from a team March 22, 2024 20:41
@@ -761,6 +764,12 @@ class GraphObserver {
virtual void recordTypeEdge(const NodeId& TermNodeId,
const NodeId& TypeNodeId) {}

/// \brief Records the type of a node's initializer as an edge in the graph.
Copy link
Contributor

@shahms shahms Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one? A node may have several initializers, e.g.

class A {
  A(): mem_(AnotherOne()) {}
  A(double yano): mem_(yano) {} 

  int mem_ = Default();
};

Each of those initializations of mem_ may be from a differently typed result, but using the semantic node has no way of distinguishing them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point; while we can tell you all the types (mumble, mumble) that were used for initialization, we can't tell you anything about those use sites.

For the moment only variable declarations are in scope (no fielddecls/initializers and no assignments).

if (!ty.isNull()) {
if (auto init_ty = BuildNodeIdForType(ty)) {
Observer.recordInitTypeEdge(DeclNode, *init_ty);
Observer.recordFlatSource(*init_ty, ty.getAsString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the "flat source" separately rather than just pointing to the type node and using its marked source?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to try both (rendering the markedsource in various places (on-demand?/denormalization) versus just using this fact).

@zrlk zrlk merged commit ef3a32c into kythe:master Mar 22, 2024
@zrlk zrlk deleted the cxx-init-types branch March 22, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants