[clang] Fix build break in SemaHLSL.cpp on MSVC 2022: warning C4715: 'getResourceClass': not all control paths return a value (PR #112767)

Daniel Paoliello via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 12:59:02 PDT 2024


https://github.com/dpaoliello updated https://github.com/llvm/llvm-project/pull/112767

>From 20f602b8c28d966a7cc957a3ca4c6ed43e71258e Mon Sep 17 00:00:00 2001
From: "Daniel Paoliello (HE/HIM)" <danpao at microsoft.com>
Date: Thu, 17 Oct 2024 12:21:25 -0700
Subject: [PATCH 1/2] Fix build break in SemaHLSL.cpp on MSVC 2022: warning
 C4715: 'getResourceClass': not all control paths return a value

---
 clang/lib/Sema/SemaHLSL.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index efb0fbaa432d76..50f0a553bc86e3 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -102,6 +102,7 @@ static ResourceClass getResourceClass(RegisterType RT) {
     return ResourceClass::Sampler;
   case RegisterType::C:
   case RegisterType::I:
+  default:
     llvm_unreachable("unexpected RegisterType value");
   }
 }

>From 7caa2a9af7d1fa71d8874a476c9a4abd74f2b488 Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Thu, 17 Oct 2024 12:58:54 -0700
Subject: [PATCH 2/2] Update clang/lib/Sema/SemaHLSL.cpp

Co-authored-by: Matheus Izvekov <mizvekov at gmail.com>
---
 clang/lib/Sema/SemaHLSL.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 50f0a553bc86e3..0900ff114224a2 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -102,9 +102,9 @@ static ResourceClass getResourceClass(RegisterType RT) {
     return ResourceClass::Sampler;
   case RegisterType::C:
   case RegisterType::I:
-  default:
     llvm_unreachable("unexpected RegisterType value");
   }
+  llvm_unreachable("unhandled RegisterType");
 }
 
 DeclBindingInfo *ResourceBindings::addDeclBindingInfo(const VarDecl *VD,



More information about the cfe-commits mailing list