[PATCH] D132727: [clang][Interp] Implement array initializers and subscript expressions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 29 09:49:46 PDT 2022


aaron.ballman added a comment.

In D132727#3755843 <https://reviews.llvm.org/D132727#3755843>, @tbaeder wrote:

> In D132727#3755571 <https://reviews.llvm.org/D132727#3755571>, @aaron.ballman wrote:
>
>> Precommit CI found a relevant failure:
>
> That needs the lvalue-to-rvalue conversion patch first.

Ah, good to know!

FWIW, one concern I've been pondering is building the new constant expression interpreter in such a way that we're working on higher-level constructs before having the lower-level constructs supported. I worry we're going to miss test coverage because we won't be able to add it until some later changes come in and then we'll forget to go back and add it. There's nothing specific to this review (nor actionable here), but just something to keep in mind as you're working on stuff. Implementing things like the type system (lvalue references, rvalue references, etc) first and then building other layers on top of that (like function calls, variables, etc) when plausible would ease those concerns.



================
Comment at: clang/test/AST/Interp/arrays.cpp:41-44
+template<typename T>
+constexpr T getElementOf(T* array, int i) {
+  return array[i];
+}
----------------
A similar test we might want to add (whenever we get around to references):
```
template <typename T, int N>
constexpr T& getElementOf(T (&array)[N], int I) {
  return array[I];
}
static_assert(getElementOf(foo[2], 3) == &m, "");
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132727/new/

https://reviews.llvm.org/D132727



More information about the cfe-commits mailing list