[PATCH] D137240: [clang][Interp] Support alignof()
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 3 10:49:56 PDT 2022
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM
================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:444
+ // alignment of the referenced type.
+ if (const ReferenceType *Ref = ArgType->getAs<ReferenceType>())
+ ArgType = Ref->getPointeeType();
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > You're missing the rest of the standards quote from http://eel.is/c++draft/expr.alignof#3. There is some logic missing here for array types. Getting the alignment of an array gives you the alignment of its element type. (And there don't seem to be any tests for calling alignof on an array, so we should add some.)
> This seems to be handled by `ASTContext`? It "just works" at least and this added code block is almost copy/paste from the current constant interpreter. I'll add some tests though.
Ahhh, so it is! Interesting that the AST handles half of the requirements and expects callers to handle the other half.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137240/new/
https://reviews.llvm.org/D137240
More information about the cfe-commits
mailing list