]> granicus.if.org Git - clang/commitdiff
[OpenCL] Minor refactoring to reduce copy/pasted code
authorJoey Gouly <joey.gouly@gmail.com>
Wed, 9 Aug 2017 14:52:47 +0000 (14:52 +0000)
committerJoey Gouly <joey.gouly@gmail.com>
Wed, 9 Aug 2017 14:52:47 +0000 (14:52 +0000)
Set the type of TheCall inside SemaBuiltinReserveRWPipe to reduce
duplicated code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310477 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index bbb4b7592edda20549d4d894b3583c0412f3cca1..0112bffa29b2ade0a1e5c1b92a0563ffe9a46a0d 100644 (file)
@@ -683,6 +683,11 @@ static bool SemaBuiltinReserveRWPipe(Sema &S, CallExpr *Call) {
     return true;
   }
 
+  // Since return type of reserve_read/write_pipe built-in function is
+  // reserve_id_t, which is not defined in the builtin def file , we used int
+  // as return type and need to override the return type of these functions.
+  Call->setType(S.Context.OCLReserveIDTy);
+
   return false;
 }
 
@@ -1086,20 +1091,12 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
   case Builtin::BIwork_group_reserve_write_pipe:
     if (SemaBuiltinReserveRWPipe(*this, TheCall))
       return ExprError();
-    // Since return type of reserve_read/write_pipe built-in function is
-    // reserve_id_t, which is not defined in the builtin def file , we used int
-    // as return type and need to override the return type of these functions.
-    TheCall->setType(Context.OCLReserveIDTy);
     break;
   case Builtin::BIsub_group_reserve_read_pipe:
   case Builtin::BIsub_group_reserve_write_pipe:
     if (checkOpenCLSubgroupExt(*this, TheCall) ||
         SemaBuiltinReserveRWPipe(*this, TheCall))
       return ExprError();
-    // Since return type of reserve_read/write_pipe built-in function is
-    // reserve_id_t, which is not defined in the builtin def file , we used int
-    // as return type and need to override the return type of these functions.
-    TheCall->setType(Context.OCLReserveIDTy);
     break;
   case Builtin::BIcommit_read_pipe:
   case Builtin::BIcommit_write_pipe: