[clang] [Clang][counted_by] Refactor __builtin_dynamic_object_size on FAMs (PR #122198)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 14:49:07 PST 2025
================
@@ -1060,238 +1061,331 @@ CodeGenFunction::evaluateOrEmitBuiltinObjectSize(const Expr *E, unsigned Type,
return ConstantInt::get(ResType, ObjectSize, /*isSigned=*/true);
}
-const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberFieldAndOffset(
- ASTContext &Ctx, const RecordDecl *RD, const FieldDecl *FAMDecl,
- uint64_t &Offset) {
+namespace {
+
+/// StructFieldAccess is a simple visitor class to grab the first MemberExpr
+/// from an Expr. It records any ArraySubscriptExpr we meet along the way.
+struct StructFieldAccess
----------------
bwendling wrote:
Both GCC and Clang return the same value for `__bdos(*ptr->array)` with my new change. For `__bdos(&ptr->array)` GCC returns -1 and Clang returns the calculated value (it does that even without this patch). So it's behavior that existed before the advent of `__counted_by` and is probably wrong, but maybe not? People have different expectations for `__bdos` in various situations it seems...
I'm tempted to leave it as is since it isn't a regression, unless you have strong feelings about it.
https://github.com/llvm/llvm-project/pull/122198
More information about the cfe-commits
mailing list