summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorMarco Antognini <marco.antognini@arm.com>2018-12-03 10:58:56 +0000
committerMarco Antognini <marco.antognini@arm.com>2018-12-03 10:58:56 +0000
commitb3301b33e1e69bcd32f7369925ed2961754921d5 (patch)
tree01d2e3210200af5719a5419a3a2dfa99624430fd /clang/lib/Sema
parentc2bea66cf2596663c1fbef2ad9d7a2fab12aefbd (diff)
downloadbcm5719-llvm-b3301b33e1e69bcd32f7369925ed2961754921d5.tar.gz
bcm5719-llvm-b3301b33e1e69bcd32f7369925ed2961754921d5.zip
[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
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f4edd7b89bf..03115514e37 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5562,17 +5562,20 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
// 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();
@@ -5584,10 +5587,10 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
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
OpenPOWER on IntegriCloud