Skip to content

Commit b3301b3

Browse files
committed
[OpenCL][Sema] Improve BuildResolvedCallExpr handling of builtins
Summary: This is a follow-up on https://reviews.llvm.org/D52879, addressing a few issues. This: - adds a FIXME for later improvement for specific builtins: I previously have only checked OpenCL ones and ensured tests cover those. - fixed the CallExpr type. Reviewers: riccibruno Reviewed By: riccibruno Subscribers: yaxunl, Anastasia, kristina, svenvh, cfe-commits Differential Revision: https://reviews.llvm.org/D55136 llvm-svn: 348120
1 parent c2bea66 commit b3301b3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5562,17 +5562,20 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
55625562
// We special-case function promotion here because we only allow promoting
55635563
// builtin functions to function pointers in the callee of a call.
55645564
ExprResult Result;
5565-
QualType ReturnTy;
5565+
QualType ResultTy;
55665566
if (BuiltinID &&
55675567
Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
55685568
// Extract the return type from the (builtin) function pointer type.
5569-
auto FnPtrTy = Context.getPointerType(FDecl->getType());
5569+
// FIXME Several builtins still have setType in
5570+
// Sema::CheckBuiltinFunctionCall. One should review their
5571+
// definitions in Builtins.def to ensure they are correct before
5572+
// removing setType calls.
5573+
QualType FnPtrTy = Context.getPointerType(FDecl->getType());
55705574
Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
5571-
auto FnTy = FnPtrTy->getPointeeType()->castAs<FunctionType>();
5572-
ReturnTy = FnTy->getReturnType();
5575+
ResultTy = FDecl->getCallResultType();
55735576
} else {
55745577
Result = CallExprUnaryConversions(Fn);
5575-
ReturnTy = Context.BoolTy;
5578+
ResultTy = Context.BoolTy;
55765579
}
55775580
if (Result.isInvalid())
55785581
return ExprError();
@@ -5584,10 +5587,10 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
55845587
if (Config)
55855588
TheCall =
55865589
new (Context) CUDAKernelCallExpr(Context, Fn, cast<CallExpr>(Config),
5587-
Args, ReturnTy, VK_RValue, RParenLoc);
5590+
Args, ResultTy, VK_RValue, RParenLoc);
55885591
else
55895592
TheCall = new (Context)
5590-
CallExpr(Context, Fn, Args, ReturnTy, VK_RValue, RParenLoc);
5593+
CallExpr(Context, Fn, Args, ResultTy, VK_RValue, RParenLoc);
55915594

55925595
if (!getLangOpts().CPlusPlus) {
55935596
// C cannot always handle TypoExpr nodes in builtin calls and direct

0 commit comments

Comments
 (0)