[clang] [libcxx] [Clang] Add __builtin_invoke and use it in libc++ (PR #116709)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue May 20 10:22:34 PDT 2025
================
@@ -5406,6 +5408,99 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
RParenLoc, CurFPFeatureOverrides());
}
+ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) {
+ SourceLocation Loc = TheCall->getBeginLoc();
+ auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs());
+ assert(llvm::none_of(Args,
+ [](Expr *Arg) { return Arg->isTypeDependent(); }));
+
+ if (Args.size() == 0) {
+ Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args_at_least)
+ << /*callee_type=*/0 << /*min_arg_count=*/1 << /*actual_arg_count=*/0
+ << /*is_non_object=*/0 << TheCall->getSourceRange();
+ return ExprError();
+ }
+
+ auto FuncT = Args[0]->getType();
+
+ if (auto *MPT = FuncT->getAs<MemberPointerType>()) {
----------------
AaronBallman wrote:
```suggestion
if (const auto *MPT = FuncT->getAs<MemberPointerType>()) {
```
You can make this same kind of correction elsewhere; best to try to aim for const correctness where it's not virally annoying.
https://github.com/llvm/llvm-project/pull/116709
More information about the cfe-commits
mailing list