[PATCH] D146408: [clang][Interp] Start supporting complex types
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 24 01:08:31 PDT 2023
tbaeder added inline comments.
================
Comment at: clang/lib/AST/Interp/Context.cpp:84-85
+ if (T->isAnyComplexType())
+ return std::nullopt;
+
----------------
aaron.ballman wrote:
> Hmmm, this seems surprising to me, I would have assumed that _Complex needed to be a primitive type so that we could perform typical math on it rather than treat it as a pair of values.
I was going to add special opcodes for this case (or add //one// opcode for complex/vector/bitint/... things to do everything?).
If we don't do it this way we'd have to add `isAnyComplexType()` checks everywhere so we can figure out if we need to look at one or two values, don't we?
================
Comment at: clang/test/AST/Interp/complex.cpp:7
+
+constexpr _Complex double z1 = {1.0, 2.0};
+static_assert(__real(z1) == 1.0);
----------------
aaron.ballman wrote:
> Can you add tests for `_Complex int` as well? (That's also covered by `isAnyComplexType()`)
There's a `FIXME` comment above in `EvalEmitter.cpp` so returning those doesn't work yet (but is otherwise not problematic I think.)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D146408/new/
https://reviews.llvm.org/D146408
More information about the cfe-commits
mailing list