File tree Expand file tree Collapse file tree 5 files changed +15
-8
lines changed Expand file tree Collapse file tree 5 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ enum class RootElementFlag : uint32_t {
159159};
160160
161161#define ROOT_PARAMETER (Val, Enum ) Enum = Val,
162- enum RootParameterType : uint32_t {
162+ enum class RootParameterType : uint32_t {
163163#include " DXContainerConstants.def"
164164};
165165
@@ -176,7 +176,7 @@ inline bool isValidParameterType(uint32_t V) {
176176}
177177
178178#define SHADER_VISIBILITY (Val, Enum ) Enum = Val,
179- enum ShaderVisibility : uint32_t {
179+ enum class ShaderVisibility : uint32_t {
180180#include " DXContainerConstants.def"
181181};
182182
Original file line number Diff line number Diff line change @@ -139,7 +139,8 @@ struct RootParameterView {
139139
140140struct RootConstantView : RootParameterView {
141141 static bool classof (const RootParameterView *V) {
142- return V->Header .ParameterType == dxbc::RootParameterType::Constants32Bit;
142+ return V->Header .ParameterType ==
143+ (uint32_t )dxbc::RootParameterType::Constants32Bit;
143144 }
144145
145146 llvm::Expected<dxbc::RootConstants> read () {
@@ -183,7 +184,10 @@ class RootSignature {
183184 getParameter (const dxbc::RootParameterHeader &Header) const {
184185 size_t DataSize;
185186
186- switch (Header.ParameterType ) {
187+ if (!dxbc::isValidParameterType (Header.ParameterType ))
188+ return parseFailed (" invalid parameter type" );
189+
190+ switch (static_cast <dxbc::RootParameterType>(Header.ParameterType )) {
187191 case dxbc::RootParameterType::Constants32Bit:
188192 DataSize = sizeof (dxbc::RootConstants);
189193 break ;
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ size_t RootSignatureDesc::getSize() const {
3434
3535 for (const auto &P : Parameters) {
3636 switch (P.Header .ParameterType ) {
37- case dxbc::RootParameterType::Constants32Bit:
37+ case static_cast < uint32_t >( dxbc::RootParameterType::Constants32Bit) :
3838 Size += sizeof (dxbc::RootConstants);
3939 break ;
4040 }
@@ -75,7 +75,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
7575 const auto &P = Parameters[I];
7676
7777 switch (P.Header .ParameterType ) {
78- case dxbc::RootParameterType::Constants32Bit:
78+ case static_cast < uint32_t >( dxbc::RootParameterType::Constants32Bit) :
7979 support::endian::write (BOS, P.Constants .ShaderRegister ,
8080 llvm::endianness::little);
8181 support::endian::write (BOS, P.Constants .RegisterSpace ,
Original file line number Diff line number Diff line change 1919#include " llvm/Support/Errc.h"
2020#include " llvm/Support/Error.h"
2121#include " llvm/Support/raw_ostream.h"
22+ #include < cstdint>
2223
2324using namespace llvm ;
2425
@@ -276,7 +277,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
276277
277278 switch (Param.Type ) {
278279
279- case dxbc::RootParameterType::Constants32Bit:
280+ case static_cast < uint32_t >( dxbc::RootParameterType::Constants32Bit) :
280281 NewParam.Constants .Num32BitValues = Param.Constants .Num32BitValues ;
281282 NewParam.Constants .RegisterSpace = Param.Constants .RegisterSpace ;
282283 NewParam.Constants .ShaderRegister = Param.Constants .ShaderRegister ;
Original file line number Diff line number Diff line change 1616#include " llvm/BinaryFormat/DXContainer.h"
1717#include " llvm/Support/Error.h"
1818#include " llvm/Support/ScopedPrinter.h"
19+ #include < cstdint>
1920#include < system_error>
2021
2122namespace llvm {
@@ -279,8 +280,9 @@ void MappingTraits<llvm::DXContainerYAML::RootParameterYamlDesc>::mapping(
279280 IO &IO, llvm::DXContainerYAML::RootParameterYamlDesc &P) {
280281 IO.mapRequired (" ParameterType" , P.Type );
281282 IO.mapRequired (" ShaderVisibility" , P.Visibility );
283+
282284 switch (P.Type ) {
283- case dxbc::RootParameterType::Constants32Bit:
285+ case static_cast < uint32_t >( dxbc::RootParameterType::Constants32Bit) :
284286 IO.mapRequired (" Constants" , P.Constants );
285287 break ;
286288 }
You can’t perform that action at this time.
0 commit comments