diff options
author | MacroFake <falke.marco@gmail.com> | 2022-07-12 18:03:00 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-07-12 18:05:59 +0200 |
commit | 1d89fc695a3aeb3e3dcadf371b7667572b38c836 (patch) | |
tree | 366d0c9f3bf0bb5d89b41f6b8b5485dfbd99b597 /src/util | |
parent | 46fcb52cb19462c74dceb085b8ca727c47a6ad32 (diff) | |
parent | 07f2c25d04c39a0074e1d9ee1b24b3e359c8153f (diff) |
Merge bitcoin/bitcoin#25324: refactor: add most of src/util to iwyu
07f2c25d04c39a0074e1d9ee1b24b3e359c8153f refactor: add most of src/util to iwyu (fanquake)
Pull request description:
These files change infrequently, and not much header shuffling is required.
We don't add everything in src/util/ yet, because IWYU makes some
dubious suggestions, which I'm going to follow up with upstream.
Soon we'll swap `src/util/xyz.cpp` for just `src/util/`.
ACKs for top commit:
hebasto:
ACK 07f2c25d04c39a0074e1d9ee1b24b3e359c8153f, I have reviewed the code and it looks OK, I agree it can be merged.
Tree-SHA512: 07d76435c2bff1a62c4967eb0efaafe619cc3bbaf4166741d8520927b24336c01aee59822f8082ee2a01e15046a0f5d506b4b23a6e40ceb750f3226ed8167847
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/asmap.cpp | 5 | ||||
-rw-r--r-- | src/util/bip32.cpp | 7 | ||||
-rw-r--r-- | src/util/bip32.h | 1 | ||||
-rw-r--r-- | src/util/bytevectorhash.cpp | 2 | ||||
-rw-r--r-- | src/util/bytevectorhash.h | 3 | ||||
-rw-r--r-- | src/util/error.cpp | 4 | ||||
-rw-r--r-- | src/util/hasher.cpp | 4 | ||||
-rw-r--r-- | src/util/hasher.h | 6 | ||||
-rw-r--r-- | src/util/message.cpp | 18 | ||||
-rw-r--r-- | src/util/message.h | 3 | ||||
-rw-r--r-- | src/util/moneystr.cpp | 1 | ||||
-rw-r--r-- | src/util/readwritefile.cpp | 3 | ||||
-rw-r--r-- | src/util/serfloat.h | 2 | ||||
-rw-r--r-- | src/util/spanparsing.cpp | 3 | ||||
-rw-r--r-- | src/util/strencodings.cpp | 9 | ||||
-rw-r--r-- | src/util/strencodings.h | 5 | ||||
-rw-r--r-- | src/util/string.cpp | 2 | ||||
-rw-r--r-- | src/util/syserror.cpp | 1 | ||||
-rw-r--r-- | src/util/thread.cpp | 1 | ||||
-rw-r--r-- | src/util/time.cpp | 11 | ||||
-rw-r--r-- | src/util/time.h | 2 | ||||
-rw-r--r-- | src/util/translation.h | 2 | ||||
-rw-r--r-- | src/util/url.cpp | 3 | ||||
-rw-r--r-- | src/util/vector.h | 1 |
24 files changed, 70 insertions, 29 deletions
diff --git a/src/util/asmap.cpp b/src/util/asmap.cpp index ceb8379c1c..b1db3b5f0d 100644 --- a/src/util/asmap.cpp +++ b/src/util/asmap.cpp @@ -8,10 +8,13 @@ #include <crypto/common.h> #include <fs.h> #include <logging.h> +#include <serialize.h> #include <streams.h> +#include <algorithm> #include <cassert> -#include <map> +#include <cstdio> +#include <utility> #include <vector> namespace { diff --git a/src/util/bip32.cpp b/src/util/bip32.cpp index 4c7e948368..39e43eeb31 100644 --- a/src/util/bip32.cpp +++ b/src/util/bip32.cpp @@ -2,12 +2,15 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <sstream> -#include <stdio.h> #include <tinyformat.h> #include <util/bip32.h> #include <util/strencodings.h> +#include <algorithm> +#include <cstdint> +#include <cstdio> +#include <sstream> + bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypath) { diff --git a/src/util/bip32.h b/src/util/bip32.h index aa4eac3791..0872bc88de 100644 --- a/src/util/bip32.h +++ b/src/util/bip32.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_UTIL_BIP32_H #define BITCOIN_UTIL_BIP32_H +#include <cstdint> #include <string> #include <vector> diff --git a/src/util/bytevectorhash.cpp b/src/util/bytevectorhash.cpp index 9054db4759..6d777613e6 100644 --- a/src/util/bytevectorhash.cpp +++ b/src/util/bytevectorhash.cpp @@ -6,6 +6,8 @@ #include <random.h> #include <util/bytevectorhash.h> +#include <vector> + ByteVectorHash::ByteVectorHash() : m_k0(GetRand<uint64_t>()), m_k1(GetRand<uint64_t>()) diff --git a/src/util/bytevectorhash.h b/src/util/bytevectorhash.h index b88c17460b..c2322b8daf 100644 --- a/src/util/bytevectorhash.h +++ b/src/util/bytevectorhash.h @@ -5,7 +5,8 @@ #ifndef BITCOIN_UTIL_BYTEVECTORHASH_H #define BITCOIN_UTIL_BYTEVECTORHASH_H -#include <stdint.h> +#include <cstdint> +#include <cstddef> #include <vector> /** diff --git a/src/util/error.cpp b/src/util/error.cpp index 22a5964279..33a35a6d59 100644 --- a/src/util/error.cpp +++ b/src/util/error.cpp @@ -5,9 +5,11 @@ #include <util/error.h> #include <tinyformat.h> -#include <util/system.h> #include <util/translation.h> +#include <cassert> +#include <string> + bilingual_str TransactionErrorString(const TransactionError err) { switch (err) { diff --git a/src/util/hasher.cpp b/src/util/hasher.cpp index c21941eb88..a80f20c894 100644 --- a/src/util/hasher.cpp +++ b/src/util/hasher.cpp @@ -2,11 +2,11 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <crypto/siphash.h> #include <random.h> +#include <span.h> #include <util/hasher.h> -#include <limits> - SaltedTxidHasher::SaltedTxidHasher() : k0(GetRand<uint64_t>()), k1(GetRand<uint64_t>()) {} SaltedOutpointHasher::SaltedOutpointHasher() : k0(GetRand<uint64_t>()), k1(GetRand<uint64_t>()) {} diff --git a/src/util/hasher.h b/src/util/hasher.h index 3d24a4d23c..426b8990e6 100644 --- a/src/util/hasher.h +++ b/src/util/hasher.h @@ -5,10 +5,16 @@ #ifndef BITCOIN_UTIL_HASHER_H #define BITCOIN_UTIL_HASHER_H +#include <crypto/common.h> #include <crypto/siphash.h> #include <primitives/transaction.h> #include <uint256.h> +#include <cstdint> +#include <cstring> + +template <typename C> class Span; + class SaltedTxidHasher { private: diff --git a/src/util/message.cpp b/src/util/message.cpp index f58876f915..d395c4b0bc 100644 --- a/src/util/message.cpp +++ b/src/util/message.cpp @@ -3,16 +3,20 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include <hash.h> // For CHashWriter -#include <key.h> // For CKey -#include <key_io.h> // For DecodeDestination() -#include <pubkey.h> // For CPubKey -#include <script/standard.h> // For CTxDestination, IsValidDestination(), PKHash -#include <serialize.h> // For SER_GETHASH +#include <hash.h> +#include <key.h> +#include <key_io.h> +#include <pubkey.h> +#include <script/standard.h> +#include <serialize.h> +#include <uint256.h> #include <util/message.h> -#include <util/strencodings.h> // For DecodeBase64() +#include <util/strencodings.h> +#include <cassert> +#include <optional> #include <string> +#include <variant> #include <vector> /** diff --git a/src/util/message.h b/src/util/message.h index b31c5f5761..1b7febe60a 100644 --- a/src/util/message.h +++ b/src/util/message.h @@ -6,11 +6,12 @@ #ifndef BITCOIN_UTIL_MESSAGE_H #define BITCOIN_UTIL_MESSAGE_H -#include <key.h> // For CKey #include <uint256.h> #include <string> +class CKey; + extern const std::string MESSAGE_MAGIC; /** The result of a signed message verification. diff --git a/src/util/moneystr.cpp b/src/util/moneystr.cpp index 8c4bc6e6f4..d9e6cef600 100644 --- a/src/util/moneystr.cpp +++ b/src/util/moneystr.cpp @@ -10,6 +10,7 @@ #include <util/strencodings.h> #include <util/string.h> +#include <cstdint> #include <optional> std::string FormatMoney(const CAmount n) diff --git a/src/util/readwritefile.cpp b/src/util/readwritefile.cpp index 628e6a3980..3ec08119e7 100644 --- a/src/util/readwritefile.cpp +++ b/src/util/readwritefile.cpp @@ -5,8 +5,9 @@ #include <fs.h> +#include <algorithm> +#include <cstdio> #include <limits> -#include <stdio.h> #include <string> #include <utility> diff --git a/src/util/serfloat.h b/src/util/serfloat.h index 4d912b0176..343ccb9d3a 100644 --- a/src/util/serfloat.h +++ b/src/util/serfloat.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UTIL_SERFLOAT_H #define BITCOIN_UTIL_SERFLOAT_H -#include <stdint.h> +#include <cstdint> /* Encode a double using the IEEE 754 binary64 format. All NaNs are encoded as x86/ARM's * positive quiet NaN with payload 0. */ diff --git a/src/util/spanparsing.cpp b/src/util/spanparsing.cpp index 8614bd1176..565c867e18 100644 --- a/src/util/spanparsing.cpp +++ b/src/util/spanparsing.cpp @@ -6,8 +6,9 @@ #include <span.h> +#include <algorithm> +#include <cstddef> #include <string> -#include <vector> namespace spanparsing { diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 675fe7d2d7..303e19beec 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -3,17 +3,18 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include <span.h> #include <util/strencodings.h> -#include <util/string.h> - -#include <tinyformat.h> #include <algorithm> #include <array> -#include <cstdlib> +#include <cassert> #include <cstring> #include <limits> #include <optional> +#include <ostream> +#include <string> +#include <vector> static const std::string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; diff --git a/src/util/strencodings.h b/src/util/strencodings.h index 9a96bbe67b..14867b21b2 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -13,11 +13,14 @@ #include <util/string.h> #include <charconv> +#include <cstddef> #include <cstdint> -#include <iterator> #include <limits> #include <optional> #include <string> +#include <string_view> +#include <system_error> +#include <type_traits> #include <vector> /** Used by SanitizeString() */ diff --git a/src/util/string.cpp b/src/util/string.cpp index d05222e8b8..dff782c330 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -6,6 +6,8 @@ #include <boost/algorithm/string/replace.hpp> +#include <string> + void ReplaceAll(std::string& in_out, std::string_view search, std::string_view substitute) { boost::replace_all(in_out, search, substitute); diff --git a/src/util/syserror.cpp b/src/util/syserror.cpp index 391ddd3560..5270f55366 100644 --- a/src/util/syserror.cpp +++ b/src/util/syserror.cpp @@ -10,6 +10,7 @@ #include <util/syserror.h> #include <cstring> +#include <string> std::string SysErrorString(int err) { diff --git a/src/util/thread.cpp b/src/util/thread.cpp index 14be668685..f9f427ba20 100644 --- a/src/util/thread.cpp +++ b/src/util/thread.cpp @@ -9,6 +9,7 @@ #include <util/threadnames.h> #include <exception> +#include <functional> void util::TraceThread(const char* thread_name, std::function<void()> thread_func) { diff --git a/src/util/time.cpp b/src/util/time.cpp index 7d9d6bcff1..2cafc55c69 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -8,16 +8,19 @@ #endif #include <compat.h> +#include <tinyformat.h> #include <util/time.h> - #include <util/check.h> -#include <atomic> #include <boost/date_time/posix_time/posix_time.hpp> + +#include <atomic> +#include <chrono> #include <ctime> +#include <locale> #include <thread> - -#include <tinyformat.h> +#include <sstream> +#include <string> void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread::sleep_for(n); } diff --git a/src/util/time.h b/src/util/time.h index 0f87d66c2e..9df69a953c 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -9,7 +9,7 @@ #include <compat.h> #include <chrono> -#include <stdint.h> +#include <cstdint> #include <string> using namespace std::chrono_literals; diff --git a/src/util/translation.h b/src/util/translation.h index aee601d9c1..07b7f43c8a 100644 --- a/src/util/translation.h +++ b/src/util/translation.h @@ -6,7 +6,9 @@ #define BITCOIN_UTIL_TRANSLATION_H #include <tinyformat.h> + #include <functional> +#include <string> /** * Bilingual messages: diff --git a/src/util/url.cpp b/src/util/url.cpp index e42d93bce8..ea9323e666 100644 --- a/src/util/url.cpp +++ b/src/util/url.cpp @@ -5,7 +5,8 @@ #include <util/url.h> #include <event2/http.h> -#include <stdlib.h> + +#include <cstdlib> #include <string> std::string urlDecode(const std::string &urlEncoded) { diff --git a/src/util/vector.h b/src/util/vector.h index dab65ded2a..ed745affe5 100644 --- a/src/util/vector.h +++ b/src/util/vector.h @@ -7,6 +7,7 @@ #include <initializer_list> #include <type_traits> +#include <utility> #include <vector> /** Construct a vector with the specified elements. |