[clang] [HLSL] Fix for build break introduced by #85662 (PR #85839)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 19 11:23:25 PDT 2024


https://github.com/farzonl created https://github.com/llvm/llvm-project/pull/85839

This change fixes a test case failure caused by pr #85662 

>From 7c2833dc32d8d2573454cba99b9a2c65a166d702 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi <farzonlotfi at microsoft.com>
Date: Tue, 19 Mar 2024 14:01:29 -0400
Subject: [PATCH] This change fixes a test case failure caused by pr #85662

---
 clang/include/clang/AST/Type.h  | 5 +++++
 clang/lib/Sema/SemaChecking.cpp | 6 ++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 10916053cdfbf5..be18535e3e4c8c 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2245,6 +2245,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   bool isHalfType() const;         // OpenCL 6.1.1.1, NEON (IEEE 754-2008 half)
   bool isFloat16Type() const;      // C11 extension ISO/IEC TS 18661
   bool isFloat32Type() const;
+  bool isDoubleType() const;
   bool isBFloat16Type() const;
   bool isFloat128Type() const;
   bool isIbm128Type() const;
@@ -7457,6 +7458,10 @@ inline bool Type::isFloat32Type() const {
   return isSpecificBuiltinType(BuiltinType::Float);
 }
 
+inline bool Type::isDoubleType() const {
+  return isSpecificBuiltinType(BuiltinType::Double);
+}
+
 inline bool Type::isBFloat16Type() const {
   return isSpecificBuiltinType(BuiltinType::BFloat16);
 }
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f9112a29027acd..ef3ab16ba29b41 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5486,10 +5486,8 @@ bool CheckFloatOrHalfRepresentations(Sema *S, CallExpr *TheCall) {
 
 bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall) {
   auto checkDoubleVector = [](clang::QualType PassedType) -> bool {
-    if (const auto *VecTy = dyn_cast<VectorType>(PassedType)) {
-      clang::QualType BaseType = VecTy->getElementType();
-      return !BaseType->isHalfType() && !BaseType->isFloat32Type();
-    }
+    if (const auto *VecTy = PassedType->getAs<VectorType>())
+      return VecTy->getElementType()->isDoubleType();
     return false;
   };
   return CheckArgsTypesAreCorrect(S, TheCall, S->Context.FloatTy,



More information about the cfe-commits mailing list