Skip to content

Commit 49dda57

Browse files
replace array with initializer_list.
1 parent 074ff7c commit 49dda57

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

source/api/AST/AnyBlock.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ class RecordBlock
839839
case RECORD_IS_TYPE_DEF:
840840
return decodeRecord(R, I->IsTypeDef, Blob);
841841
case RECORD_BITS:
842-
return decodeRecord<1u>(R, {&I->specs.raw}, Blob);
842+
return decodeRecord(R, {&I->specs.raw}, Blob);
843843
case RECORD_FRIENDS:
844844
return decodeRecord(R, I->Friends, Blob);
845845
default:
@@ -899,7 +899,7 @@ class FunctionBlock
899899
case FUNCTION_IS_METHOD:
900900
return decodeRecord(R, I->IsMethod, Blob);
901901
case FUNCTION_BITS:
902-
return decodeRecord<2u>(R, {&I->specs0.raw, &I->specs1.raw}, Blob);
902+
return decodeRecord(R, {&I->specs0.raw, &I->specs1.raw}, Blob);
903903
default:
904904
return TopLevelBlock::parseRecord(R, ID, Blob);
905905
}
@@ -1128,7 +1128,7 @@ class VarBlock
11281128
switch(ID)
11291129
{
11301130
case VARIABLE_BITS:
1131-
return decodeRecord<1u>(R, {&I->specs.raw}, Blob);
1131+
return decodeRecord(R, {&I->specs.raw}, Blob);
11321132
default:
11331133
break;
11341134
}

source/api/AST/DecodeRecord.hpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -242,23 +242,25 @@ decodeRecord(
242242
return llvm::Error::success();
243243
}
244244

245-
template<std::size_t N>
246245
inline
247246
llvm::Error
248247
decodeRecord(
249248
Record const& R,
250-
std::array<BitFieldFullValue*, N> values,
249+
std::initializer_list<BitFieldFullValue*> values,
251250
llvm::StringRef Blob)
252251
{
253252
auto n = R[0];
254-
if(n != N)
255-
return makeError("wrong size(", n, ") for Bitfields[", N, "]");
256-
for(std::size_t i = 0; i < N; ++i)
253+
if(n != values.size())
254+
return makeError("wrong size(", n, ") for Bitfields[", values.size(), "]");
255+
256+
auto itr = values.begin();
257+
for(std::size_t i = 0; i < values.size(); ++i)
257258
{
259+
258260
auto const v = R[i + 1];
259261
if(v > (std::numeric_limits<std::uint32_t>::max)())
260262
return makeError(v, " is out of range for Bits");
261-
*values[i] = v;
263+
**itr++ = v;
262264
}
263265
return llvm::Error::success();
264266
}

0 commit comments

Comments
 (0)