Skip to content

Commit 330369a

Browse files
author
joaosaffran
committed
changing back enums to enum class
1 parent 8511fa9 commit 330369a

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

llvm/include/llvm/Object/DXContainer.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ struct RootParameterView {
139139

140140
struct 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;

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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,

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/Support/Errc.h"
2020
#include "llvm/Support/Error.h"
2121
#include "llvm/Support/raw_ostream.h"
22+
#include <cstdint>
2223

2324
using 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;

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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

2122
namespace 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
}

0 commit comments

Comments
 (0)