Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy: include what you use #2226

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Checks: >
-misc-no-recursion,
-misc-non-private-member-variables-in-classes,
-misc-use-anonymous-namespace,
-misc-include-cleaner,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-nodiscard,
Expand Down
9 changes: 8 additions & 1 deletion cmd/dev/embed_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@
limitations under the License.
*/

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
#include <regex>
#include <string>
#include <utility>
#include <vector>

#include <CLI/CLI.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim.hpp>

namespace fs = std::filesystem;

Expand Down Expand Up @@ -62,6 +68,7 @@ void to_byte_array(fs::path& in, fs::path& out, const std::string& ns) {
std::ofstream out_stream{out.string()};
out_stream << "/* Generated from " << in.filename().string() << " using silkworm embed_json tool */\n";
out_stream << "#include \"" + var_name + ".hpp\"\n";
out_stream << "#include <string_view>\n";
out_stream << "constexpr char " << var_name << "_data_internal[] = {\n";

auto max{bytes.size()};
Expand Down
3 changes: 2 additions & 1 deletion cmd/dev/embed_toml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/

#include <cctype>
#include <cstddef>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <string_view>
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def requirements(self):
self.requires('asio-grpc/2.9.2')
self.requires('benchmark/1.6.1')
self.requires('boost/1.83.0')
self.requires('cli11/2.2.0')
self.requires('cli11/2.4.2')
self.requires('gmp/6.2.1')
self.requires('grpc/1.54.3')
self.requires('gtest/1.12.1')
Expand Down
6 changes: 6 additions & 0 deletions silkworm/core/chain/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
#include <functional>
#include <set>
#include <string>
#include <string_view>

#include <evmc/evmc.h>

#include <silkworm/core/common/overloaded.hpp>
#include <silkworm/core/types/address.hpp>
#include <silkworm/core/types/evmc_bytes32.hpp>

namespace silkworm {

using namespace std::string_view_literals;
using namespace evmc::literals;

constexpr const char* kTerminalTotalDifficulty{"terminalTotalDifficulty"};

static inline void member_to_json(nlohmann::json& json, const std::string& key, const std::optional<uint64_t>& source) {
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ struct ChainConfig {

std::ostream& operator<<(std::ostream& out, const ChainConfig& obj);

using namespace std::string_view_literals;
using namespace evmc::literals;

inline constexpr evmc::bytes32 kMainnetGenesisHash{0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3_bytes32};
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "genesis.hpp"

#include <bit>
#include <optional>

#include <silkworm/core/chain/config.hpp>
#include <silkworm/core/chain/genesis_bor_mainnet.hpp>
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis_bor_mainnet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Generated from genesis_bor_mainnet.json using silkworm embed_json tool */
#include "genesis_bor_mainnet.hpp"
#include <string_view>
constexpr char genesis_bor_mainnet_data_internal[] = {
0x7b, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis_holesky.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Generated from genesis_holesky.json using silkworm embed_json tool */
#include "genesis_holesky.hpp"
#include <string_view>
constexpr char genesis_holesky_data_internal[] = {
0x7b, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x78, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis_mainnet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Generated from genesis_mainnet.json using silkworm embed_json tool */
#include "genesis_mainnet.hpp"
#include <string_view>
constexpr char genesis_mainnet_data_internal[] = {
0x7b, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x33, 0x32, 0x38, 0x32, 0x37,
0x39, 0x31, 0x64, 0x36, 0x66, 0x64, 0x37, 0x31, 0x33, 0x66, 0x31, 0x65, 0x39, 0x34, 0x66, 0x34,
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis_mumbai.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Generated from genesis_mumbai.json using silkworm embed_json tool */
#include "genesis_mumbai.hpp"
#include <string_view>
constexpr char genesis_mumbai_data_internal[] = {
0x7b, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x30, 0x30, 0x30, 0x30,
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/chain/genesis_sepolia.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Generated from genesis_sepolia.json using silkworm embed_json tool */
#include "genesis_sepolia.hpp"
#include <string_view>
constexpr char genesis_sepolia_data_internal[] = {
0x7b, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x22, 0x3a, 0x7b, 0x22, 0x30, 0x78, 0x61, 0x32, 0x41,
0x36, 0x64, 0x39, 0x33, 0x34, 0x33, 0x39, 0x31, 0x34, 0x34, 0x46, 0x46, 0x45, 0x34, 0x44, 0x32,
Expand Down
2 changes: 0 additions & 2 deletions silkworm/core/common/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

namespace silkworm {

using namespace std::string_view_literals;

template <class T>
concept UnsignedIntegral = std::unsigned_integral<T> || std::same_as<T, intx::uint128> ||
std::same_as<T, intx::uint256> || std::same_as<T, intx::uint512>;
Expand Down
3 changes: 3 additions & 0 deletions silkworm/core/common/test_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

#include "test_util.hpp"

#include <intx/intx.hpp>

#include <silkworm/core/types/evmc_bytes32.hpp>
#include <silkworm/core/types/log.hpp>
#include <silkworm/core/types/receipt.hpp>

namespace silkworm::test {

Expand Down
6 changes: 6 additions & 0 deletions silkworm/core/common/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
#include "util.hpp"

#include <algorithm>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <regex>

#include <intx/intx.hpp>

#include <silkworm/core/common/assert.hpp>
#include <silkworm/core/common/base.hpp>
#include <silkworm/core/common/bytes.hpp>

namespace silkworm {

Expand Down
4 changes: 3 additions & 1 deletion silkworm/core/crypto/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

#include "ecdsa.h"

#include <secp256k1.h>
#include <stdint.h>
#include <string.h>

#include <ethash/hash_types.h>
#include <ethash/keccak.h>
#include <secp256k1_ecdh.h>
#include <secp256k1_recovery.h>

//! \brief Tries recover public key used for message signing.
Expand Down
1 change: 0 additions & 1 deletion silkworm/core/crypto/ecdsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <secp256k1.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
Expand Down
2 changes: 2 additions & 0 deletions silkworm/core/crypto/kzg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#include <blst.h>

#include <cstdint>

#include <silkworm/core/crypto/sha256.h>
#include <silkworm/core/protocol/param.hpp>

Expand Down
1 change: 1 addition & 0 deletions silkworm/core/crypto/rmd160.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/* header files */
#include "rmd160.h"

#include <stdint.h>
#include <string.h>

/********************************************************************/
Expand Down
1 change: 0 additions & 1 deletion silkworm/core/crypto/rmd160.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#pragma once

#include <stddef.h>
#include <stdint.h>

#if defined(__cplusplus)
Expand Down
2 changes: 2 additions & 0 deletions silkworm/core/crypto/secp256k1n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "secp256k1n.hpp"

#include <intx/intx.hpp>

namespace silkworm {

bool is_valid_signature(const intx::uint256& r, const intx::uint256& s, bool homestead) noexcept {
Expand Down
1 change: 1 addition & 0 deletions silkworm/core/crypto/sha256.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "sha256.h"

#include <stdint.h>
#include <string.h>

#if defined(__x86_64__)
Expand Down
8 changes: 8 additions & 0 deletions silkworm/core/execution/call_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@

#include "call_tracer.hpp"

#include <cstddef>
#include <cstdint>

#include <evmc/evmc.h>
#include <evmc/evmc.hpp>
#include <evmc/hex.hpp>
#include <evmc/instructions.h>
#include <evmone/baseline_instruction_table.hpp>
#include <evmone/execution_state.hpp>
#include <evmone/instructions.hpp>
#include <intx/intx.hpp>

#include <silkworm/core/common/assert.hpp>
#include <silkworm/core/protocol/intrinsic_gas.hpp>
#include <silkworm/core/types/address.hpp>
#include <silkworm/core/types/block.hpp>

using namespace evmone;
using namespace evmone::baseline;
Expand Down
7 changes: 7 additions & 0 deletions silkworm/core/execution/evm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,26 @@

#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstring>
#include <functional>
#include <iterator>
#include <memory>
#include <utility>
#include <vector>

#include <ethash/keccak.hpp>
#include <evmc/evmc.h>
#include <evmone/evmone.h>
#include <evmone/tracing.hpp>
#include <intx/intx.hpp>

#include <silkworm/core/common/base.hpp>
#include <silkworm/core/common/empty_hashes.hpp>
#include <silkworm/core/execution/precompile.hpp>
#include <silkworm/core/protocol/param.hpp>
#include <silkworm/core/types/address.hpp>
#include <silkworm/core/types/log.hpp>

namespace silkworm {

Expand Down
1 change: 1 addition & 0 deletions silkworm/core/execution/precompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <libff/common/profiling.hpp>
#pragma GCC diagnostic pop

#include <silkworm/core/common/base.hpp>
#include <silkworm/core/common/endian.hpp>
#include <silkworm/core/crypto/blake2b.h>
#include <silkworm/core/crypto/ecdsa.h>
Expand Down
5 changes: 5 additions & 0 deletions silkworm/core/execution/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@

#include "processor.hpp"

#include <algorithm>
#include <cassert>
#include <cstdint>

#include <evmc/evmc.h>

#include <silkworm/core/protocol/intrinsic_gas.hpp>
#include <silkworm/core/protocol/param.hpp>
#include <silkworm/core/trie/vector_root.hpp>
#include <silkworm/core/types/receipt.hpp>

namespace silkworm {

Expand Down
2 changes: 2 additions & 0 deletions silkworm/core/execution/processor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "processor.hpp"

#include <optional>

#include <catch2/catch_test_macros.hpp>
#include <evmc/evmc.hpp>

Expand Down
7 changes: 7 additions & 0 deletions silkworm/core/protocol/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@

#include "blockchain.hpp"

#include <optional>
#include <utility>
#include <vector>

#include <intx/intx.hpp>

#include <silkworm/core/common/assert.hpp>
#include <silkworm/core/execution/processor.hpp>
#include <silkworm/core/types/block.hpp>

namespace silkworm::protocol {

Expand Down
9 changes: 9 additions & 0 deletions silkworm/core/protocol/bor/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@

#include "config.hpp"

#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include <evmc/evmc.hpp>
#include <nlohmann/json.hpp>

#include <silkworm/core/common/assert.hpp>
#include <silkworm/core/common/base.hpp>
#include <silkworm/core/common/bytes.hpp>
#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/common/small_map.hpp>
#include <silkworm/core/common/util.hpp>
#include <silkworm/core/types/address.hpp>

Expand Down
2 changes: 2 additions & 0 deletions silkworm/core/protocol/bor_rule_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#include <silkworm/core/common/assert.hpp>
#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/crypto/ecdsa.h>
#include <silkworm/core/types/block.hpp>
#include <silkworm/core/types/evmc_bytes32.hpp>
#include <silkworm/core/types/log.hpp>

#include "param.hpp"

Expand Down
4 changes: 4 additions & 0 deletions silkworm/core/protocol/ethash_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include "ethash_config.hpp"

#include <optional>

#include <nlohmann/json.hpp>

namespace silkworm::protocol {

nlohmann::json EthashConfig::to_json() const noexcept {
Expand Down
Loading
Loading