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

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 12:26:12 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Daniel Paoliello (dpaoliello)

<details>
<summary>Changes</summary>

Adds a default case to the switch to the existing `llvm_unreachable` statement.

Build break was introduced by #<!-- -->111203

It was not caught by the builders as they use Visual Studio 2019, whereas this warning only appears in 2022.

---
Full diff: https://github.com/llvm/llvm-project/pull/112767.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaHLSL.cpp (+1) 


``````````diff
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");
   }
 }

``````````

</details>


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


More information about the cfe-commits mailing list