Skip to content

Commit 09f6679

Browse files
authored
Merge pull request #12746 from tfire/fix/remove-namespace-ast-annotations
Remove use of `using namespace` in header file
2 parents 1827df8 + 3357567 commit 09f6679

39 files changed

+123
-121
lines changed

libsolidity/analysis/ControlFlowAnalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod
129129
// Propagate changes to all exits and queue them for traversal, if needed.
130130
for (auto const& exit: currentNode->exits)
131131
if (
132-
auto exists = valueOrNullptr(nodeInfos, exit);
132+
auto exists = util::valueOrNullptr(nodeInfos, exit);
133133
nodeInfos[exit].propagateFrom(nodeInfo) || !exists
134134
)
135135
nodesToTraverse.insert(exit);

libsolidity/analysis/ControlFlowRevertPruner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void ControlFlowRevertPruner::run()
5757

5858
void ControlFlowRevertPruner::findRevertStates()
5959
{
60-
std::set<CFG::FunctionContractTuple> pendingFunctions = keys(m_functions);
60+
std::set<CFG::FunctionContractTuple> pendingFunctions = util::keys(m_functions);
6161
// We interrupt the search whenever we encounter a call to a function with (yet) unknown
6262
// revert behaviour. The ``wakeUp`` data structure contains information about which
6363
// searches to restart once we know about the behaviour.

libsolidity/analysis/FunctionCallGraph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph(
9797
// assigned to state variables and as such may be reachable after deployment as well.
9898
builder.m_currentNode = CallGraph::SpecialNode::InternalDispatch;
9999
set<CallGraph::Node, CallGraph::CompareByID> defaultNode;
100-
for (CallGraph::Node const& dispatchTarget: valueOrDefault(_creationGraph.edges, CallGraph::SpecialNode::InternalDispatch, defaultNode))
100+
for (CallGraph::Node const& dispatchTarget: util::valueOrDefault(_creationGraph.edges, CallGraph::SpecialNode::InternalDispatch, defaultNode))
101101
{
102102
solAssert(!holds_alternative<CallGraph::SpecialNode>(dispatchTarget), "");
103103
solAssert(get<CallableDeclaration const*>(dispatchTarget) != nullptr, "");

libsolidity/analysis/PostTypeChecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,12 @@ struct ReservedErrorSelector: public PostTypeChecker::Checker
411411
);
412412
else
413413
{
414-
uint32_t selector = selectorFromSignature32(_error.functionType(true)->externalSignature());
414+
uint32_t selector = util::selectorFromSignature32(_error.functionType(true)->externalSignature());
415415
if (selector == 0 || ~selector == 0)
416416
m_errorReporter.syntaxError(
417417
2855_error,
418418
_error.location(),
419-
"The selector 0x" + toHex(toCompactBigEndian(selector, 4)) + " is reserved. Please rename the error to avoid the collision."
419+
"The selector 0x" + util::toHex(toCompactBigEndian(selector, 4)) + " is reserved. Please rename the error to avoid the collision."
420420
);
421421
}
422422
}

libsolidity/analysis/PostTypeContractLevelChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bool PostTypeContractLevelChecker::check(ContractDefinition const& _contract)
5252
for (ErrorDefinition const* error: _contract.interfaceErrors())
5353
{
5454
string signature = error->functionType(true)->externalSignature();
55-
uint32_t hash = selectorFromSignature32(signature);
55+
uint32_t hash = util::selectorFromSignature32(signature);
5656
// Fail if there is a different signature for the same hash.
5757
if (!errorHashes[hash].empty() && !errorHashes[hash].count(signature))
5858
{

libsolidity/analysis/TypeChecker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ void TypeChecker::visitManually(
659659
if (auto const* modifierContract = dynamic_cast<ContractDefinition const*>(modifierDecl->scope()))
660660
if (m_currentContract)
661661
{
662-
if (!contains(m_currentContract->annotation().linearizedBaseContracts, modifierContract))
662+
if (!util::contains(m_currentContract->annotation().linearizedBaseContracts, modifierContract))
663663
m_errorReporter.typeError(
664664
9428_error,
665665
_modifier.location(),
@@ -2143,7 +2143,7 @@ void TypeChecker::typeCheckABIEncodeCallFunction(FunctionCall const& _functionCa
21432143
functionPointerType->declaration().scope() == m_currentContract
21442144
)
21452145
msg += " Did you forget to prefix \"this.\"?";
2146-
else if (contains(
2146+
else if (util::contains(
21472147
m_currentContract->annotation().linearizedBaseContracts,
21482148
functionPointerType->declaration().scope()
21492149
) && functionPointerType->declaration().scope() != m_currentContract)

libsolidity/ast/AST.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ vector<EventDefinition const*> const ContractDefinition::usedInterfaceEvents() c
221221
{
222222
solAssert(annotation().creationCallGraph.set(), "");
223223

224-
return convertContainer<std::vector<EventDefinition const*>>(
224+
return util::convertContainer<std::vector<EventDefinition const*>>(
225225
(*annotation().creationCallGraph)->emittedEvents +
226226
(*annotation().deployedCallGraph)->emittedEvents
227227
);
@@ -239,7 +239,7 @@ vector<ErrorDefinition const*> ContractDefinition::interfaceErrors(bool _require
239239
result +=
240240
(*annotation().creationCallGraph)->usedErrors +
241241
(*annotation().deployedCallGraph)->usedErrors;
242-
return convertContainer<vector<ErrorDefinition const*>>(move(result));
242+
return util::convertContainer<vector<ErrorDefinition const*>>(move(result));
243243
}
244244

245245
vector<pair<util::FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList(bool _includeInheritedFunctions) const

libsolidity/ast/ASTAnnotations.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ namespace solidity::frontend
4747

4848
class Type;
4949
class ArrayType;
50-
using namespace util;
5150

5251
struct CallGraph;
5352

@@ -91,13 +90,13 @@ struct StructurallyDocumentedAnnotation
9190
struct SourceUnitAnnotation: ASTAnnotation
9291
{
9392
/// The "absolute" (in the compiler sense) path of this source unit.
94-
SetOnce<std::string> path;
93+
util::SetOnce<std::string> path;
9594
/// The exported symbols (all global symbols).
96-
SetOnce<std::map<ASTString, std::vector<Declaration const*>>> exportedSymbols;
95+
util::SetOnce<std::map<ASTString, std::vector<Declaration const*>>> exportedSymbols;
9796
/// Experimental features.
9897
std::set<ExperimentalFeature> experimentalFeatures;
9998
/// Using the new ABI coder. Set to `false` if using ABI coder v1.
100-
SetOnce<bool> useABICoderV2;
99+
util::SetOnce<bool> useABICoderV2;
101100
};
102101

103102
struct ScopableAnnotation
@@ -127,15 +126,15 @@ struct DeclarationAnnotation: ASTAnnotation, ScopableAnnotation
127126
struct ImportAnnotation: DeclarationAnnotation
128127
{
129128
/// The absolute path of the source unit to import.
130-
SetOnce<std::string> absolutePath;
129+
util::SetOnce<std::string> absolutePath;
131130
/// The actual source unit.
132131
SourceUnit const* sourceUnit = nullptr;
133132
};
134133

135134
struct TypeDeclarationAnnotation: DeclarationAnnotation
136135
{
137136
/// The name of this type, prefixed by proper namespaces if globally accessible.
138-
SetOnce<std::string> canonicalName;
137+
util::SetOnce<std::string> canonicalName;
139138
};
140139

141140
struct StructDeclarationAnnotation: TypeDeclarationAnnotation
@@ -162,9 +161,9 @@ struct ContractDefinitionAnnotation: TypeDeclarationAnnotation, StructurallyDocu
162161
/// These can either be inheritance specifiers or modifier invocations.
163162
std::map<FunctionDefinition const*, ASTNode const*> baseConstructorArguments;
164163
/// A graph with edges representing calls between functions that may happen during contract construction.
165-
SetOnce<std::shared_ptr<CallGraph const>> creationCallGraph;
164+
util::SetOnce<std::shared_ptr<CallGraph const>> creationCallGraph;
166165
/// A graph with edges representing calls between functions that may happen in a deployed contract.
167-
SetOnce<std::shared_ptr<CallGraph const>> deployedCallGraph;
166+
util::SetOnce<std::shared_ptr<CallGraph const>> deployedCallGraph;
168167

169168
/// List of contracts whose bytecode is referenced by this contract, e.g. through "new".
170169
/// The Value represents the ast node that referenced the contract.
@@ -223,7 +222,7 @@ struct InlineAssemblyAnnotation: StatementAnnotation
223222
/// True, if the assembly block was annotated to be memory-safe.
224223
bool markedMemorySafe = false;
225224
/// True, if the assembly block involves any memory opcode or assigns to variables in memory.
226-
SetOnce<bool> hasMemoryEffects;
225+
util::SetOnce<bool> hasMemoryEffects;
227226
};
228227

229228
struct BlockAnnotation: StatementAnnotation, ScopableAnnotation
@@ -256,19 +255,19 @@ struct IdentifierPathAnnotation: ASTAnnotation
256255
/// Referenced declaration, set during reference resolution stage.
257256
Declaration const* referencedDeclaration = nullptr;
258257
/// What kind of lookup needs to be done (static, virtual, super) find the declaration.
259-
SetOnce<VirtualLookup> requiredLookup;
258+
util::SetOnce<VirtualLookup> requiredLookup;
260259
};
261260

262261
struct ExpressionAnnotation: ASTAnnotation
263262
{
264263
/// Inferred type of the expression.
265264
Type const* type = nullptr;
266265
/// Whether the expression is a constant variable
267-
SetOnce<bool> isConstant;
266+
util::SetOnce<bool> isConstant;
268267
/// Whether the expression is pure, i.e. compile-time constant.
269-
SetOnce<bool> isPure;
268+
util::SetOnce<bool> isPure;
270269
/// Whether it is an LValue (i.e. something that can be assigned to).
271-
SetOnce<bool> isLValue;
270+
util::SetOnce<bool> isLValue;
272271
/// Whether the expression is used in a context where the LValue is actually required.
273272
bool willBeWrittenTo = false;
274273
/// Whether the expression is an lvalue that is only assigned.
@@ -295,7 +294,7 @@ struct IdentifierAnnotation: ExpressionAnnotation
295294
/// Referenced declaration, set at latest during overload resolution stage.
296295
Declaration const* referencedDeclaration = nullptr;
297296
/// What kind of lookup needs to be done (static, virtual, super) find the declaration.
298-
SetOnce<VirtualLookup> requiredLookup;
297+
util::SetOnce<VirtualLookup> requiredLookup;
299298
/// List of possible declarations it could refer to (can contain duplicates).
300299
std::vector<Declaration const*> candidateDeclarations;
301300
/// List of possible declarations it could refer to.
@@ -307,7 +306,7 @@ struct MemberAccessAnnotation: ExpressionAnnotation
307306
/// Referenced declaration, set at latest during overload resolution stage.
308307
Declaration const* referencedDeclaration = nullptr;
309308
/// What kind of lookup needs to be done (static, virtual, super) find the declaration.
310-
SetOnce<VirtualLookup> requiredLookup;
309+
util::SetOnce<VirtualLookup> requiredLookup;
311310
};
312311

313312
struct BinaryOperationAnnotation: ExpressionAnnotation

libsolidity/ast/ASTJsonConverter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ bool ASTJsonConverter::visit(EventDefinition const& _node)
505505
_attributes.emplace_back(
506506
make_pair(
507507
"eventSelector",
508-
toHex(u256(h256::Arith(util::keccak256(_node.functionType(true)->externalSignature()))))
508+
toHex(u256(util::h256::Arith(util::keccak256(_node.functionType(true)->externalSignature()))))
509509
));
510510

511511
setJsonNode(_node, "EventDefinition", std::move(_attributes));

libsolidity/codegen/CompilerContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ void CompilerContext::appendInlineAssembly(
403403
{
404404
if (_insideFunction)
405405
return false;
406-
return contains(_localVariables, _identifier.name.str());
406+
return util::contains(_localVariables, _identifier.name.str());
407407
};
408408
identifierAccess.generateCode = [&](
409409
yul::Identifier const& _identifier,

0 commit comments

Comments
 (0)