Skip to content

Conversation

@ChrisDodd
Copy link
Contributor

  • fix UnparsedConstant handling
  • clean up corner cases of fromJSON

@ChrisDodd ChrisDodd requested review from asl and fruffy October 21, 2025 03:40
std::enable_if_t<has_fromJSON<T>::value && !std::is_base_of_v<IR::INode, T> &&
std::is_pointer_v<decltype(T::fromJSON(std::declval<JSONLoader &>()))>>
unpack_json(T &v) {
v = *(T::fromJSON(*this));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to force move semantics here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You already get move semantics, as T::fromJSON returns a type T xvalue. That's actually how calling std::move forces move semantics -- std::move is just a function that returns a type T xvalue. There's nothing special about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was under impression that T::fromJSON returns a pointer – T*, no? So v = *(T::fromJSON(*this)) would incur a copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can either return a T or a T *. If it is a T * then it might not be safe to move?

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Oct 21, 2025
@ChrisDodd ChrisDodd force-pushed the cdpdd-json-fixes branch 3 times, most recently from 4d123ef to 46fb2fd Compare October 22, 2025 22:26
@ChrisDodd ChrisDodd requested a review from vlstill October 24, 2025 10:43
Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

Trading a review for a review on #5063

- fix UnparsedConstant handling
- clean up corner cases of fromJSON

Signed-off-by: Chris Dodd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Topics concerning the core segments of the compiler (frontend, midend, parser)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants