nickdesaulniers added a comment. Cool!
How about some codegen tests? This looks a lot like the EuroLLVM keynote: https://llvm.swoogo.com/2023eurollvm/agenda (Thursday `-fbounds-safety`). What's your plan for reconciling this with the authors of that? Have you reached out to them with this proposal? ================ Comment at: clang/include/clang/Basic/Attr.td:4167 + let Documentation = [ElementCountDocs]; + let LangOpts = [COnly]; +} ---------------- Does C++ not support VLAs? ================ Comment at: clang/include/clang/Basic/AttrDocs.td:6957 + let Content = [{ +Clang supports the ``__element_count__`` attribute for flexible array members. + }]; ---------------- Maybe worth noting that this the number of elements and not the number of bytes? ================ Comment at: clang/lib/CodeGen/CGExpr.cpp:951-952 + if (auto *ME = dyn_cast<MemberExpr>(CE->getSubExpr())) { + if (ME->isFlexibleArrayMemberLike(CGF.getContext(), + StrictFlexArraysLevel, true)) { + if (auto *MD = dyn_cast<FieldDecl>(ME->getMemberDecl())) { ---------------- eventually, we may want to support non-FAMs: ``` struct foo { size_t count; char arr [PATH_MAX] __attribute((element_count("count"))); }; char *foo (size_t offset) { struct foo my_foo = { .count = sizeof("hello"), .arr = "hello", }; return &my_foo.arr[offset]; } ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148381/new/ https://reviews.llvm.org/D148381 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits