[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 16:40:03 PDT 2023
nickdesaulniers updated this revision to Diff 524532.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.
- more dyn_cast
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151148/new/
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,9 @@
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 *>())
+ if (const auto *VD = dyn_cast<VarDecl>(V))
+ Result += VD->getFlexibleArrayInitChars(Info.Ctx);
}
return Ret;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151148.524532.patch
Type: text/x-patch
Size: 1180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230522/30f74f14/attachment.bin>
More information about the cfe-commits
mailing list