This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Implement add and sub compound assign operators
ClosedPublic

Authored by tbaeder on Oct 22 2022, 6:36 AM.

Diff Detail

Event Timeline

tbaeder created this revision.Oct 22 2022, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 6:36 AM
tbaeder requested review of this revision.Oct 22 2022, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2022, 6:36 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Oct 24 2022, 6:55 AM
clang/test/AST/Interp/literals.cpp
415

I'd also like some test cases where the result of the operation is discarded. e.g.,

constexpr int func() {
  int i = 12;
  i += 10;
  return i;
}
static_assert(func() == 22);

and a test with a float-point type (okay for it to fail for the moment):

constexpr float func() {
  float f = 1.0f;
  f += 10.0f;
  return f;
}
static_assert(func() == 11.0f);
429

We also need tests for failure situations:

constexpr int func() {
  int i = __INT_MAX__;
  i += 1; // oops
  return i;
}

constexpr int another() {
  int i = __INT_MIN__;
  i -= 1; // oops
  return i;
}
tbaeder updated this revision to Diff 470138.Oct 24 2022, 7:12 AM
tbaeder marked 2 inline comments as done.
tbaeder added inline comments.
clang/test/AST/Interp/literals.cpp
429

woops, I was sure I added this but it was for the ++/-- patch it seems.

This revision is now accepted and ready to land.Oct 24 2022, 7:21 AM
This revision was landed with ongoing or failed builds.Oct 30 2022, 12:11 AM
This revision was automatically updated to reflect the committed changes.