Skip to content

Commit 2741606

Browse files
committed
More const
1 parent 6154f7b commit 2741606

44 files changed

Lines changed: 83 additions & 83 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libevmasm/ConstantOptimiser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ unsigned ConstantOptimisationMethod::optimiseConstants(
4545
if (item.type() == Push)
4646
pushes[item]++;
4747
std::map<u256, AssemblyItems> pendingReplacements;
48-
for (auto it: pushes)
48+
for (const auto& it: pushes)
4949
{
5050
AssemblyItem const& item = it.first;
5151
if (item.data() < 0x100)

libevmasm/ControlFlowGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void ControlFlowGraph::gatherKnowledge()
292292
}
293293
}
294294
else
295-
for (auto tag: tags)
295+
for (const auto& tag: tags)
296296
addWorkQueueItem(item, BlockId(tag), state);
297297
}
298298
else if (block.begin <= pc && pc < block.end)
@@ -327,7 +327,7 @@ BasicBlocks ControlFlowGraph::rebuildCode()
327327
pushes[ref]++;
328328

329329
std::set<BlockId> blocksToAdd;
330-
for (auto it: m_blocks)
330+
for (const auto& it: m_blocks)
331331
blocksToAdd.insert(it.first);
332332
std::set<BlockId> blocksAdded;
333333
BasicBlocks blocks;

libevmasm/ExpressionClasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ bool ExpressionClasses::knownToBeDifferentBy32(ExpressionClasses::Id _a, Express
159159
return v && *v + 31 > u256(62);
160160
}
161161

162-
bool ExpressionClasses::knownZero(Id _c)
162+
bool ExpressionClasses::knownZero(Id _c) const
163163
{
164164
return Pattern(u256(0)).matches(representative(_c), *this);
165165
}
@@ -169,7 +169,7 @@ bool ExpressionClasses::knownNonZero(Id _c)
169169
return Pattern(u256(0)).matches(representative(find(Instruction::ISZERO, {_c})), *this);
170170
}
171171

172-
u256 const* ExpressionClasses::knownConstant(Id _c)
172+
u256 const* ExpressionClasses::knownConstant(Id _c) const
173173
{
174174
std::map<unsigned, Expression const*> matchGroups;
175175
Pattern constant(Push);

libevmasm/ExpressionClasses.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ class ExpressionClasses
101101
bool knownToBeDifferentBy32(Id _a, Id _b);
102102
/// @returns true if the value of the given class is known to be zero.
103103
/// @note that this is not the negation of knownNonZero
104-
bool knownZero(Id _c);
104+
bool knownZero(Id _c) const;
105105
/// @returns true if the value of the given class is known to be nonzero.
106106
/// @note that this is not the negation of knownZero
107107
bool knownNonZero(Id _c);
108108
/// @returns a pointer to the value if the given class is known to be a constant,
109109
/// and a nullptr otherwise.
110-
u256 const* knownConstant(Id _c);
110+
u256 const* knownConstant(Id _c) const;
111111

112112
/// Stores a copy of the given AssemblyItem and returns a pointer to the copy that is valid for
113113
/// the lifetime of the ExpressionClasses object.

liblangutil/CharStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class CharStream
116116

117117
/// Tests whether or not given octet sequence is present at the current position in stream.
118118
/// @returns true if the sequence could be found, false otherwise.
119-
bool prefixMatch(std::string_view _sequence)
119+
bool prefixMatch(std::string_view _sequence) const
120120
{
121121
if (isPastEndOfInput(_sequence.size()))
122122
return false;

libsolidity/analysis/ControlFlowBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ bool ControlFlowBuilder::visit(Return const& _return)
427427
{
428428
appendControlFlow(*_return.expression());
429429
// Returns with return expression are considered to be assignments to the return parameters.
430-
for (auto returnParameter: _return.annotation().functionReturnParameters->parameters())
430+
for (const auto& returnParameter: _return.annotation().functionReturnParameters->parameters())
431431
m_currentNode->variableOccurrences.emplace_back(
432432
*returnParameter,
433433
VariableOccurrence::Kind::Assignment,

libsolidity/analysis/DeclarationContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void DeclarationContainer::populateHomonyms(std::back_insert_iterator<Homonyms>
204204
for (DeclarationContainer const* innerContainer: m_innerContainers)
205205
innerContainer->populateHomonyms(_it);
206206

207-
for (auto [name, location]: m_homonymCandidates)
207+
for (const auto& [name, location]: m_homonymCandidates)
208208
{
209209
ResolvingSettings settings;
210210
settings.recursive = true;

libsolidity/analysis/NameAndTypeResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void NameAndTypeResolver::warnHomonymDeclarations() const
250250
DeclarationContainer::Homonyms homonyms;
251251
m_scopes.at(nullptr)->populateHomonyms(back_inserter(homonyms));
252252

253-
for (auto [innerLocation, outerDeclarations]: homonyms)
253+
for (const auto& [innerLocation, outerDeclarations]: homonyms)
254254
{
255255
solAssert(innerLocation && !outerDeclarations.empty(), "");
256256

libsolidity/analysis/SyntaxChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool SyntaxChecker::visit(UnaryOperation const& _operation)
358358
bool SyntaxChecker::visit(InlineAssembly const& _inlineAssembly)
359359
{
360360
if (_inlineAssembly.flags())
361-
for (auto flag: *_inlineAssembly.flags())
361+
for (const auto& flag: *_inlineAssembly.flags())
362362
{
363363
if (*flag == "memory-safe")
364364
{

libsolidity/ast/ASTJsonExporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ bool ASTJsonExporter::visit(IdentifierPath const& _node)
334334
{
335335
Json nameLocations = Json::array();
336336

337-
for (SourceLocation const location: _node.pathLocations())
337+
for (SourceLocation const& location: _node.pathLocations())
338338
nameLocations.emplace_back(sourceLocationToString(location));
339339

340340
setJsonNode(_node, "IdentifierPath", {

0 commit comments

Comments
 (0)