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

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 12:40:30 PDT 2024


================
@@ -102,6 +102,7 @@ static ResourceClass getResourceClass(RegisterType RT) {
     return ResourceClass::Sampler;
   case RegisterType::C:
   case RegisterType::I:
+  default:
     llvm_unreachable("unexpected RegisterType value");
   }
----------------
mizvekov wrote:

There is a very useful warning about switching on an enumerator where not all enumerators are covered.

Adding a default case suppresses this warning, but this is undesirable, as we want to see this warning pop up when we add a new enumerator.

```suggestion
  }
  llvm_unreachable("unexpected RegisterType value");
```

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


More information about the cfe-commits mailing list