This revision was automatically updated to reflect the committed changes.
Closed by commit rL348120: [OpenCL][Sema] Improve BuildResolvedCallExpr 
handling of builtins (authored by mantognini, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55136?vs=176157&id=176353#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55136/new/

https://reviews.llvm.org/D55136

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -5562,17 +5562,20 @@
   // 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 @@
   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


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -5562,17 +5562,20 @@
   // 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 @@
   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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to