Skip to content

Commit 4de3158

Browse files
committed
Replace simple llvm_unreachable with asserts
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent 6550bf5 commit 4de3158

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

llvm/include/llvm/Support/SYCLPropertySetIO.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,13 @@ class SYCLPropertyValue {
9090

9191
// Get property value as unsigned 32-bit integer
9292
uint32_t asUint32() const {
93-
if (Ty != UINT32)
94-
llvm_unreachable("must be UINT32 value");
93+
assert((Ty == UINT32) && "must be UINT32 value");
9594
return std::get<uint32_t>(Val);
9695
}
9796

9897
// Get raw data size in bits.
9998
SizeTy getByteArraySizeInBits() const {
100-
if (Ty != BYTE_ARRAY)
101-
llvm_unreachable("must be BYTE_ARRAY value");
99+
assert((Ty == BYTE_ARRAY) && "must be BYTE_ARRAY value");
102100
SizeTy Res = 0;
103101

104102
for (size_t I = 0; I < sizeof(SizeTy); ++I) {
@@ -123,16 +121,14 @@ class SYCLPropertyValue {
123121

124122
// Get byte array data including the leading bytes encoding the size.
125123
const std::byte *asRawByteArray() const {
126-
if (Ty != BYTE_ARRAY)
127-
llvm_unreachable("must be BYTE_ARRAY value");
124+
assert((Ty == BYTE_ARRAY) && "must be BYTE_ARRAY value");
128125
auto *ByteArrayVal = std::get<std::byte *>(Val);
129126
return ByteArrayVal;
130127
}
131128

132129
// Get byte array data excluding the leading bytes encoding the size.
133130
const std::byte *asByteArray() const {
134-
if (Ty != BYTE_ARRAY)
135-
llvm_unreachable("must be BYTE_ARRAY value");
131+
assert((Ty == BYTE_ARRAY) && "must be BYTE_ARRAY value");
136132

137133
auto ByteArrayVal = std::get<std::byte *>(Val);
138134
return ByteArrayVal + sizeof(SizeTy);
@@ -142,15 +138,13 @@ class SYCLPropertyValue {
142138

143139
// Set property value when data type is UINT32_T
144140
void set(uint32_t V) {
145-
if (Ty != UINT32)
146-
llvm_unreachable("invalid type tag for this operation");
141+
assert((Ty == UINT32) && "must be UINT32 value");
147142
Val = V;
148143
}
149144

150145
// Set property value when data type is BYTE_ARRAY
151146
void set(std::byte *V, int DataSize) {
152-
if (Ty != BYTE_ARRAY)
153-
llvm_unreachable("invalid type tag for this operation");
147+
assert((Ty == BYTE_ARRAY) && "must be BYTE_ARRAY value");
154148
size_t DataBitSize = DataSize * CHAR_BIT;
155149
constexpr size_t SizeFieldSize = sizeof(SizeTy);
156150
// Allocate space for size and data.

0 commit comments

Comments
 (0)