@@ -2401,40 +2401,17 @@ static bool CheckArgTypeMatches(Sema *S, Expr *Arg, QualType ExpectedType) {
24012401 return false ;
24022402}
24032403
2404- bool CheckAllArgTypesAreCorrect (
2404+ static bool CheckAllArgTypesAreCorrect (
24052405 Sema *S, CallExpr *TheCall,
2406- llvm::ArrayRef<
2407- llvm::function_ref<bool (Sema *, SourceLocation, int , QualType)>>
2408- Checks) {
2409- unsigned NumArgs = TheCall->getNumArgs ();
2410- if (Checks.size () == 1 ) {
2411- // Apply the single check to all arguments
2412- for (unsigned I = 0 ; I < NumArgs; ++I) {
2413- Expr *Arg = TheCall->getArg (I);
2414- if (Checks[0 ](S, Arg->getBeginLoc (), I + 1 , Arg->getType ()))
2415- return true ;
2416- }
2417- return false ;
2418- } else if (Checks.size () == NumArgs) {
2419- // Apply each check to the corresponding argument
2420- for (unsigned I = 0 ; I < NumArgs; ++I) {
2421- Expr *Arg = TheCall->getArg (I);
2422- if (Checks[I](S, Arg->getBeginLoc (), I + 1 , Arg->getType ()))
2423- return true ;
2424- }
2425- return false ;
2426- } else {
2427- // Mismatch: error or fallback
2428- S->Diag (TheCall->getBeginLoc (), diag::err_builtin_invalid_arg_type)
2429- << NumArgs << Checks.size ();
2430- return true ;
2406+ llvm::function_ref<bool (Sema *S, SourceLocation Loc, int ArgOrdinal,
2407+ clang::QualType PassedType)>
2408+ Check) {
2409+ for (unsigned I = 0 ; I < TheCall->getNumArgs (); ++I) {
2410+ Expr *Arg = TheCall->getArg (I);
2411+ if (Check (S, Arg->getBeginLoc (), I + 1 , Arg->getType ()))
2412+ return true ;
24312413 }
2432- }
2433-
2434- bool CheckAllArgTypesAreCorrect (
2435- Sema *S, CallExpr *TheCall,
2436- llvm::function_ref<bool (Sema *, SourceLocation, int , QualType)> Check) {
2437- return CheckAllArgTypesAreCorrect (S, TheCall, llvm::ArrayRef{Check});
2414+ return false ;
24382415}
24392416
24402417static bool CheckFloatOrHalfRepresentation (Sema *S, SourceLocation Loc,
@@ -2451,38 +2428,6 @@ static bool CheckFloatOrHalfRepresentation(Sema *S, SourceLocation Loc,
24512428 return false ;
24522429}
24532430
2454- static bool CheckFloatOrHalfVectorsRepresentation (Sema *S, SourceLocation Loc,
2455- int ArgOrdinal,
2456- clang::QualType PassedType) {
2457- const auto *VecTy = PassedType->getAs <VectorType>();
2458-
2459- clang::QualType BaseType =
2460- PassedType->isVectorType ()
2461- ? PassedType->castAs <clang::VectorType>()->getElementType ()
2462- : PassedType;
2463- if (!VecTy || !BaseType->isHalfType () && !BaseType->isFloat32Type ())
2464- return S->Diag (Loc, diag::err_builtin_invalid_arg_type)
2465- << ArgOrdinal << /* vector of */ 5 << /* no int */ 0
2466- << /* half or float */ 2 << PassedType;
2467- return false ;
2468- }
2469-
2470- static bool CheckFloatOrHalfScalarRepresentation (Sema *S, SourceLocation Loc,
2471- int ArgOrdinal,
2472- clang::QualType PassedType) {
2473- const auto *VecTy = PassedType->getAs <VectorType>();
2474-
2475- clang::QualType BaseType =
2476- PassedType->isVectorType ()
2477- ? PassedType->castAs <clang::VectorType>()->getElementType ()
2478- : PassedType;
2479- if (VecTy || !BaseType->isHalfType () && !BaseType->isFloat32Type ())
2480- return S->Diag (Loc, diag::err_builtin_invalid_arg_type)
2481- << ArgOrdinal << /* scalar or vector of */ 5 << /* no int */ 0
2482- << /* half or float */ 2 << PassedType;
2483- return false ;
2484- }
2485-
24862431static bool CheckModifiableLValue (Sema *S, CallExpr *TheCall,
24872432 unsigned ArgIndex) {
24882433 auto *Arg = TheCall->getArg (ArgIndex);
@@ -4050,4 +3995,4 @@ bool SemaHLSL::handleInitialization(VarDecl *VDecl, Expr *&Init) {
40503995 }
40513996 Init = C;
40523997 return true ;
4053- }
3998+ }
0 commit comments