Skip to content

Commit cdac6a2

Browse files
committed
[libyul] Fix false-negative maybe-uninitialized warning on gcc.
1 parent 26263c6 commit cdac6a2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

libyul/optimiser/ForLoopConditionIntoBody.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ void ForLoopConditionIntoBody::run(OptimiserStepContext& _context, Block& _ast)
3232

3333
void ForLoopConditionIntoBody::operator()(ForLoop& _forLoop)
3434
{
35+
std::optional<BuiltinHandle> booleanNegationFunctionHandle = m_dialect.booleanNegationFunctionHandle();
3536
if (
36-
m_dialect.booleanNegationFunctionHandle() &&
37+
booleanNegationFunctionHandle &&
3738
!std::holds_alternative<Literal>(*_forLoop.condition) &&
3839
!std::holds_alternative<Identifier>(*_forLoop.condition)
3940
)
@@ -47,7 +48,7 @@ void ForLoopConditionIntoBody::operator()(ForLoop& _forLoop)
4748
std::make_unique<Expression>(
4849
FunctionCall {
4950
debugData,
50-
BuiltinName{debugData, *m_dialect.booleanNegationFunctionHandle()},
51+
BuiltinName{debugData, *booleanNegationFunctionHandle},
5152
util::make_vector<Expression>(std::move(*_forLoop.condition))
5253
}
5354
),

libyul/optimiser/UnusedPruner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ void UnusedPruner::operator()(Block& _block)
8181
[&](NameWithDebugData const& _typedName) { return used(_typedName.name); }
8282
))
8383
{
84+
std::optional<BuiltinHandle> discardFunctionHandle = m_dialect.discardFunctionHandle();
8485
if (!varDecl.value)
8586
statement = Block{std::move(varDecl.debugData), {}};
8687
else if (
@@ -91,10 +92,10 @@ void UnusedPruner::operator()(Block& _block)
9192
subtractReferences(ReferencesCounter::countReferences(*varDecl.value));
9293
statement = Block{std::move(varDecl.debugData), {}};
9394
}
94-
else if (varDecl.variables.size() == 1 && m_dialect.discardFunctionHandle())
95+
else if (varDecl.variables.size() == 1 && discardFunctionHandle)
9596
statement = ExpressionStatement{varDecl.debugData, FunctionCall{
9697
varDecl.debugData,
97-
BuiltinName{varDecl.debugData, *m_dialect.discardFunctionHandle()},
98+
BuiltinName{varDecl.debugData, *discardFunctionHandle},
9899
{*std::move(varDecl.value)}
99100
}};
100101
}

0 commit comments

Comments
 (0)