nickdesaulniers created this revision. Herald added a project: All. nickdesaulniers requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Add test case demonstrating issue. Link: https://github.com/llvm/llvm-project/issues/62789 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150891 Files: 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 @@ -525,6 +525,18 @@ gi = OBJECT_SIZE_BUILTIN(&dsv[9].snd[0], 1); } +// CHECK-LABEL: @test32 +static struct DynStructVar D = { + .fst = {}, + .snd = { 0, 1, 2, }, +}; +unsigned long test32(void) { + // FIXME: GCC returns the sizeof the base type, plus the number of bytes from + // members of the initializer of the flexible array: 19. + // CHECK: ret i64 16 + return __builtin_object_size(&D, 1); +} + // CHECK-LABEL: @PR30346 void PR30346(void) { struct sa_family_t {};
Index: clang/test/CodeGen/object-size.c =================================================================== --- clang/test/CodeGen/object-size.c +++ clang/test/CodeGen/object-size.c @@ -525,6 +525,18 @@ gi = OBJECT_SIZE_BUILTIN(&dsv[9].snd[0], 1); } +// CHECK-LABEL: @test32 +static struct DynStructVar D = { + .fst = {}, + .snd = { 0, 1, 2, }, +}; +unsigned long test32(void) { + // FIXME: GCC returns the sizeof the base type, plus the number of bytes from + // members of the initializer of the flexible array: 19. + // CHECK: ret i64 16 + return __builtin_object_size(&D, 1); +} + // CHECK-LABEL: @PR30346 void PR30346(void) { struct sa_family_t {};
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits