@@ -2947,54 +2947,29 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
29472947 break ;
29482948 }
29492949 case Builtin::BI__builtin_hlsl_resource_uninitializedhandle: {
2950- if (SemaRef.checkArgCount (TheCall, 1 ) ||
2951- CheckResourceHandle (&SemaRef, TheCall, 0 ))
2952- return true ;
2950+ assert (TheCall->getNumArgs () == 1 && " expected 1 arg" );
29532951 // use the type of the handle (arg0) as a return type
29542952 QualType ResourceTy = TheCall->getArg (0 )->getType ();
29552953 TheCall->setType (ResourceTy);
29562954 break ;
29572955 }
29582956 case Builtin::BI__builtin_hlsl_resource_handlefrombinding: {
2959- ASTContext &AST = SemaRef.getASTContext ();
2960- if (SemaRef.checkArgCount (TheCall, 6 ) ||
2961- CheckResourceHandle (&SemaRef, TheCall, 0 ) ||
2962- CheckArgTypeMatches (&SemaRef, TheCall->getArg (1 ), AST.UnsignedIntTy ) ||
2963- CheckArgTypeMatches (&SemaRef, TheCall->getArg (2 ), AST.UnsignedIntTy ) ||
2964- CheckArgTypeMatches (&SemaRef, TheCall->getArg (3 ), AST.IntTy ) ||
2965- CheckArgTypeMatches (&SemaRef, TheCall->getArg (4 ), AST.UnsignedIntTy ) ||
2966- CheckArgTypeMatches (&SemaRef, TheCall->getArg (5 ),
2967- AST.getPointerType (AST.CharTy .withConst ())))
2968- return true ;
2957+ assert (TheCall->getNumArgs () == 6 && " expected 6 args" );
29692958 // use the type of the handle (arg0) as a return type
29702959 QualType ResourceTy = TheCall->getArg (0 )->getType ();
29712960 TheCall->setType (ResourceTy);
29722961 break ;
29732962 }
29742963 case Builtin::BI__builtin_hlsl_resource_handlefromimplicitbinding: {
2975- ASTContext &AST = SemaRef.getASTContext ();
2976- if (SemaRef.checkArgCount (TheCall, 6 ) ||
2977- CheckResourceHandle (&SemaRef, TheCall, 0 ) ||
2978- CheckArgTypeMatches (&SemaRef, TheCall->getArg (1 ), AST.UnsignedIntTy ) ||
2979- CheckArgTypeMatches (&SemaRef, TheCall->getArg (2 ), AST.UnsignedIntTy ) ||
2980- CheckArgTypeMatches (&SemaRef, TheCall->getArg (3 ), AST.IntTy ) ||
2981- CheckArgTypeMatches (&SemaRef, TheCall->getArg (4 ), AST.UnsignedIntTy ) ||
2982- CheckArgTypeMatches (&SemaRef, TheCall->getArg (5 ),
2983- AST.getPointerType (AST.CharTy .withConst ())))
2984- return true ;
2964+ assert (TheCall->getNumArgs () == 6 && " expected 6 args" );
29852965 // use the type of the handle (arg0) as a return type
29862966 QualType ResourceTy = TheCall->getArg (0 )->getType ();
29872967 TheCall->setType (ResourceTy);
29882968 break ;
29892969 }
29902970 case Builtin::BI__builtin_hlsl_resource_counterhandlefromimplicitbinding: {
2971+ assert (TheCall->getNumArgs () == 3 && " expected 3 args" );
29912972 ASTContext &AST = SemaRef.getASTContext ();
2992- if (SemaRef.checkArgCount (TheCall, 3 ) ||
2993- CheckResourceHandle (&SemaRef, TheCall, 0 ) ||
2994- CheckArgTypeMatches (&SemaRef, TheCall->getArg (1 ), AST.UnsignedIntTy ) ||
2995- CheckArgTypeMatches (&SemaRef, TheCall->getArg (2 ), AST.UnsignedIntTy ))
2996- return true ;
2997-
29982973 QualType MainHandleTy = TheCall->getArg (0 )->getType ();
29992974 auto *MainResType = MainHandleTy->getAs <HLSLAttributedResourceType>();
30002975 auto MainAttrs = MainResType->getAttrs ();
@@ -3302,14 +3277,12 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
33023277 break ;
33033278 }
33043279 case Builtin::BI__builtin_hlsl_buffer_update_counter: {
3280+ assert (TheCall->getNumArgs () == 2 && " expected 2 args" );
33053281 auto checkResTy = [](const HLSLAttributedResourceType *ResTy) -> bool {
33063282 return !(ResTy->getAttrs ().ResourceClass == ResourceClass::UAV &&
33073283 ResTy->getAttrs ().RawBuffer && ResTy->hasContainedType ());
33083284 };
3309- if (SemaRef.checkArgCount (TheCall, 2 ) ||
3310- CheckResourceHandle (&SemaRef, TheCall, 0 , checkResTy) ||
3311- CheckArgTypeMatches (&SemaRef, TheCall->getArg (1 ),
3312- SemaRef.getASTContext ().IntTy ))
3285+ if (CheckResourceHandle (&SemaRef, TheCall, 0 , checkResTy))
33133286 return true ;
33143287 Expr *OffsetExpr = TheCall->getArg (1 );
33153288 std::optional<llvm::APSInt> Offset =
0 commit comments