[PATCH] D151148: [clang][ExprConstant] fix __builtin_object_size for compound literal
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 22 13:31:35 PDT 2023
nickdesaulniers created this revision.
nickdesaulniers added reviewers: efriedma, erichkeane.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Fixup to D150892 <https://reviews.llvm.org/D150892>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151148
Files:
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGen/object-size.c
Index: clang/test/CodeGen/object-size.c
===================================================================
--- clang/test/CodeGen/object-size.c
+++ clang/test/CodeGen/object-size.c
@@ -551,6 +551,10 @@
// CHECK: ret i64 16
return OBJECT_SIZE_BUILTIN(&D34, 1);
}
+unsigned long test35(void) {
+ // CHECK: ret i64 16
+ return OBJECT_SIZE_BUILTIN(&(struct DynStructVar){}, 1);
+}
// CHECK-LABEL: @PR30346
void PR30346(void) {
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11736,9 +11736,8 @@
bool Ret = HandleSizeof(Info, ExprLoc, Ty, Result);
if (Ty->isStructureType() &&
Ty->getAsStructureType()->getDecl()->hasFlexibleArrayMember()) {
- const auto *VD =
- cast<VarDecl>(LVal.getLValueBase().get<const ValueDecl *>());
- Result += VD->getFlexibleArrayInitChars(Info.Ctx);
+ if (const auto *V = LVal.getLValueBase().dyn_cast<const ValueDecl *>())
+ Result += cast<VarDecl>(V)->getFlexibleArrayInitChars(Info.Ctx);
}
return Ret;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151148.524459.patch
Type: text/x-patch
Size: 1140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230522/c702de1b/attachment-0001.bin>
More information about the cfe-commits
mailing list