[PATCH] D133934: [clang][Interp] Handle sizeof() expressions
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 15 07:53:17 PDT 2022
tbaeder added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:289
+ QualType ArgType = E->getTypeOfArgument();
+ return this->emitConst(E, Ctx.getASTContext().getTypeSize(ArgType));
+ }
----------------
erichkeane wrote:
> You probably want `getTypeSizeInChars`. `getTypeSize` returns it in bits, so this would give the wrong answer. You should probably add some tests to make sure the values you are getting back are sane (like `char` is 1, etc).
Yeah, right. I explicitly didn't compare with fixed values when writing the tests so I don't run into the usual problems, but they wouldn't caught this problem...
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133934/new/
https://reviews.llvm.org/D133934
More information about the cfe-commits
mailing list