[PATCH] D55136: [OpenCL][Sema] Improve BuildResolvedCallExpr handling of builtins
Marco Antognini via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 30 10:21:23 PST 2018
mantognini created this revision.
mantognini added a reviewer: riccibruno.
Herald added subscribers: cfe-commits, kristina, yaxunl.
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.
Repository:
rC Clang
https://reviews.llvm.org/D55136
Files:
lib/Sema/SemaExpr.cpp
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -5549,17 +5549,19 @@
// We special-case function promotion here because we only allow promoting
// builtin functions to function pointers in the callee of a call.
ExprResult Result;
- QualType ReturnTy;
+ QualType ResultTy;
if (BuiltinID &&
Fn->getType()->isSpecificBuiltinType(BuiltinType::BuiltinFn)) {
// Extract the return type from the (builtin) function pointer type.
- auto FnPtrTy = Context.getPointerType(FDecl->getType());
+ // FIXME Several builtins still have setType in Sema::CheckBuiltinFunctionCall.
+ // One should review their definitions in Builtins.def to ensure they
+ // are correct before removing setType calls.
+ QualType FnPtrTy = Context.getPointerType(FDecl->getType());
Result = ImpCastExprToType(Fn, FnPtrTy, CK_BuiltinFnToFnPtr).get();
- auto FnTy = FnPtrTy->getPointeeType()->castAs<FunctionType>();
- ReturnTy = FnTy->getReturnType();
+ ResultTy = FDecl->getCallResultType();
} else {
Result = CallExprUnaryConversions(Fn);
- ReturnTy = Context.BoolTy;
+ ResultTy = Context.BoolTy;
}
if (Result.isInvalid())
return ExprError();
@@ -5571,10 +5573,10 @@
if (Config)
TheCall =
new (Context) CUDAKernelCallExpr(Context, Fn, cast<CallExpr>(Config),
- Args, ReturnTy, VK_RValue, RParenLoc);
+ Args, ResultTy, VK_RValue, RParenLoc);
else
TheCall = new (Context)
- CallExpr(Context, Fn, Args, ReturnTy, VK_RValue, RParenLoc);
+ CallExpr(Context, Fn, Args, ResultTy, VK_RValue, RParenLoc);
if (!getLangOpts().CPlusPlus) {
// C cannot always handle TypoExpr nodes in builtin calls and direct
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55136.176157.patch
Type: text/x-patch
Size: 1887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181130/32e58e4e/attachment.bin>
More information about the cfe-commits
mailing list