[PATCH] D144457: [clang][Interp] Handle global composite temporaries
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 17 11:57:51 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:852
+ return false;
+ return this->emitInitGlobalTempComp(TempDecl, E);
}
----------------
Should this still happen even if `TempDecl` is null? It looks like `getLifetimeExtendedTemporaryDecl()` can return a null pointer, but perhaps there's a reason we can't get that result here?
================
Comment at: clang/lib/AST/Interp/Pointer.cpp:235-237
+ for (unsigned I = 0; I != R->getNumFields(); ++I) {
+ const Pointer FieldPtr = this->atField(R->getField(I)->Offset);
+ Result.getStructField(I) = FieldPtr.toRValue(Ctx);
----------------
Pointer to a field? That means, I would like tests that involve bit-fields. :-)
================
Comment at: clang/lib/AST/Interp/Pointer.cpp:236
+ for (unsigned I = 0; I != R->getNumFields(); ++I) {
+ const Pointer FieldPtr = this->atField(R->getField(I)->Offset);
+ Result.getStructField(I) = FieldPtr.toRValue(Ctx);
----------------
================
Comment at: clang/lib/AST/Interp/Pointer.cpp:241
+ for (unsigned I = 0; I != R->getNumBases(); ++I) {
+ const Pointer BasePtr = this->atField(R->getBase(I)->Offset);
+ Result.getStructBase(I) = BasePtr.toRValue(Ctx);
----------------
================
Comment at: clang/lib/AST/Interp/Record.h:90
unsigned getNumBases() const { return Bases.size(); }
+ const Base *getBase(unsigned I) const { return &Bases[I]; }
Base *getBase(unsigned I) { return &Bases[I]; }
----------------
It might make sense to add an assert to both `getBase()` functions to verify that `I` is within a valid range.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144457/new/
https://reviews.llvm.org/D144457
More information about the cfe-commits
mailing list