From 033559206c624e245530573ea70a8d70e522c7b5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 27 May 2021 17:38:15 +0200 Subject: [PATCH 1/2] Check for style of namespace. --- scripts/check_style.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/check_style.sh b/scripts/check_style.sh index f3e00d8ed..78b0aa23c 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -47,6 +47,7 @@ FORMATERROR=$( preparedGrep "\<(if|for|while|switch)\(" # no space after "if", "for", "while" or "switch" preparedGrep "\\s*\([^=]*\>\s:\s.*\)" # no space before range based for-loop preparedGrep "\\s*\(.*\)\s*\{\s*$" # "{\n" on same line as "if" + preparedGrep "namespace .*\{" preparedGrep "[,\(<]\s*const " # const on left side of type preparedGrep "^\s*(static)?\s*const " # const on left side of type (beginning of line) preparedGrep "^ [^*]|[^*] | [^*]" # uses spaces for indentation or mixes spaces and tabs From d305c219d85c543a64efc69b6478abb292456998 Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 27 May 2021 17:41:04 +0200 Subject: [PATCH 2/2] Fix namespace styles. --- liblangutil/Scanner.cpp | 3 ++- libsolidity/analysis/ControlFlowBuilder.h | 3 ++- libsolidity/codegen/Compiler.h | 3 ++- libsolidity/codegen/CompilerContext.h | 3 ++- libsolidity/codegen/CompilerUtils.h | 3 ++- libsolidity/codegen/ExpressionCompiler.h | 3 ++- libsolutil/JSON.h | 3 ++- libyul/AsmParser.cpp | 3 ++- libyul/optimiser/StructuralSimplifier.cpp | 3 ++- 9 files changed, 18 insertions(+), 9 deletions(-) diff --git a/liblangutil/Scanner.cpp b/liblangutil/Scanner.cpp index 5a9f9fcce..5dbc2529c 100644 --- a/liblangutil/Scanner.cpp +++ b/liblangutil/Scanner.cpp @@ -62,7 +62,8 @@ using namespace std; -namespace solidity::langutil { +namespace solidity::langutil +{ string to_string(ScannerError _errorCode) { diff --git a/libsolidity/analysis/ControlFlowBuilder.h b/libsolidity/analysis/ControlFlowBuilder.h index 879d9b241..0fd64fd0d 100644 --- a/libsolidity/analysis/ControlFlowBuilder.h +++ b/libsolidity/analysis/ControlFlowBuilder.h @@ -26,7 +26,8 @@ #include #include -namespace solidity::frontend { +namespace solidity::frontend +{ /** Helper class that builds the control flow of a function or modifier. * Modifiers are not yet applied to the functions. This is done in a second diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h index 6e6fd968e..0d021b723 100644 --- a/libsolidity/codegen/Compiler.h +++ b/libsolidity/codegen/Compiler.h @@ -31,7 +31,8 @@ #include #include -namespace solidity::frontend { +namespace solidity::frontend +{ class Compiler { diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index e4358ccb5..a40afb498 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -47,7 +47,8 @@ #include #include -namespace solidity::frontend { +namespace solidity::frontend +{ class Compiler; diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index 0930ff1c8..721f65614 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -29,7 +29,8 @@ #include #include -namespace solidity::frontend { +namespace solidity::frontend +{ class Type; // forward diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index 57ba34549..b583b8327 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -39,7 +39,8 @@ namespace solidity::evmasm class AssemblyItem; // forward } -namespace solidity::frontend { +namespace solidity::frontend +{ // forward declarations class CompilerContext; diff --git a/libsolutil/JSON.h b/libsolutil/JSON.h index 485aa600e..c1d045e73 100644 --- a/libsolutil/JSON.h +++ b/libsolutil/JSON.h @@ -27,7 +27,8 @@ #include -namespace solidity::util { +namespace solidity::util +{ /// Removes members with null value recursively from (@a _json). Json::Value removeNullMembers(Json::Value _json); diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index 20a0e9f03..20d39c4f6 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -40,7 +40,8 @@ using namespace solidity::util; using namespace solidity::langutil; using namespace solidity::yul; -namespace { +namespace +{ [[nodiscard]] shared_ptr updateLocationEndFrom( diff --git a/libyul/optimiser/StructuralSimplifier.cpp b/libyul/optimiser/StructuralSimplifier.cpp index cb212bdee..8dd4ab7f9 100644 --- a/libyul/optimiser/StructuralSimplifier.cpp +++ b/libyul/optimiser/StructuralSimplifier.cpp @@ -28,7 +28,8 @@ using namespace solidity::yul; using OptionalStatements = std::optional>; -namespace { +namespace +{ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _constExprVal) {