================
@@ -1856,6 +1905,44 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl
&gd, unsigned builtinID,
return RValue::get(emitBuiltinObjectSize(e->getArg(0), type, resType,
/*EmittedE=*/nullptr, isDynamic));
}
+ case Builtin::BI__builtin_counted_by_ref: {
+ // Sema has already checked that the argument is a (side-effect free)
+ // member access of a flexible array member or a pointer, and set the
+ // result type to a pointer to the count field if the member has a
+ // counted_by attribute, and to 'void *' otherwise.
+ mlir::Location loc = getLoc(e->getSourceRange());
+
+ // Default to returning '(void *) 0'.
+ mlir::Value result = builder.getNullPtr(convertType(e->getType()), loc);
+
+ const Expr *arg = e->getArg(0)->IgnoreParenImpCasts();
+ if (const auto *me = dyn_cast<MemberExpr>(arg)) {
----------------
slant14 wrote:
Sema already rejects &p->array and &p->array[i] in this revision, so those
never reach codegen. the tests (clang/test/Sema/builtin-counted-by-ref.c:34)
covers both
https://github.com/llvm/llvm-project/pull/235781
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits