[PATCH] D137240: [clang][Interp] Support alignof()

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 3 00:12:56 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:444
+    //     alignment of the referenced type.
+    if (const ReferenceType *Ref = ArgType->getAs<ReferenceType>())
+      ArgType = Ref->getPointeeType();
----------------
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.


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

https://reviews.llvm.org/D137240



More information about the cfe-commits mailing list