diff --git a/.arclint b/.arclint --- a/.arclint +++ b/.arclint @@ -5,8 +5,8 @@ }, "clang-format": { "type": "clang-format", - "version": ">=10.0", - "bin": ["clang-format-10", "clang-format"], + "version": ">=11.0", + "bin": ["clang-format-11", "clang-format"], "include": "(^src/.*\\.(h|c|cpp|mm)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", diff --git a/arcanist/linter/ClangFormatLinter.php b/arcanist/linter/ClangFormatLinter.php --- a/arcanist/linter/ClangFormatLinter.php +++ b/arcanist/linter/ClangFormatLinter.php @@ -49,10 +49,10 @@ * FIXME: This is a hack to only allow for clang-format version 10.x. * The .arclint `version` field only allow to filter versions using `=`, * `>`, `<`, `>=` or `<=`. There is no facility to define that the required - * version should be >= 10.0 and < 11.0. + * version should be >= 11.0 and < 12.0. */ - if (substr($version, 0, 2) != '10') { - throw new Exception(pht('Linter %s requires clang-format version 10.x. '. + if (substr($version, 0, 2) != '11') { + throw new Exception(pht('Linter %s requires clang-format version 11.x. '. 'You have version %s.', ClangFormatLinter::class, $version)); diff --git a/contrib/teamcity/setup-debian-buster.sh b/contrib/teamcity/setup-debian-buster.sh --- a/contrib/teamcity/setup-debian-buster.sh +++ b/contrib/teamcity/setup-debian-buster.sh @@ -17,9 +17,9 @@ pip3 install -r "${TEAMCITY_DIR}"/../buildbot/requirements.txt # Make sure clang-10 has highest priority -update-alternatives --install /usr/bin/clang clang "$(command -v clang-10)" 100 -update-alternatives --install /usr/bin/clang++ clang++ "$(command -v clang++-10)" 100 -update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "$(command -v llvm-symbolizer-10)" 100 +update-alternatives --install /usr/bin/clang clang "$(command -v clang-11)" 100 +update-alternatives --install /usr/bin/clang++ clang++ "$(command -v clang++-11)" 100 +update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer "$(command -v llvm-symbolizer-11)" 100 # Set default git config so that any git operations requiring authoring, # rebasing, or cherry-picking of commits just work out of the box. diff --git a/contrib/utils/install-dependencies.sh b/contrib/utils/install-dependencies.sh --- a/contrib/utils/install-dependencies.sh +++ b/contrib/utils/install-dependencies.sh @@ -102,14 +102,14 @@ # Install llvm-8 and clang-10 apt-key add "$(dirname "$0")"/llvm.pub add-apt-repository "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-8 main" -add-apt-repository "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-10 main" +add-apt-repository "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-11 main" apt-get update LLVM_PACKAGES=( - clang-10 - clang-format-10 - clang-tidy-10 - clang-tools-10 + clang-11 + clang-format-11 + clang-tidy-11 + clang-tools-11 ) DEBIAN_FRONTEND=noninteractive apt-get install -y $(join_by ' ' "${LLVM_PACKAGES[@]}") diff --git a/src/i2p.h b/src/i2p.h --- a/src/i2p.h +++ b/src/i2p.h @@ -155,7 +155,7 @@ * @param[in] args printf(3)-like arguments that correspond to `fmt`. */ template - void Log(const std::string &fmt, const Args &... args) const; + void Log(const std::string &fmt, const Args &...args) const; /** * Send request and get a reply from the SAM proxy. diff --git a/src/i2p.cpp b/src/i2p.cpp --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -236,7 +236,7 @@ } template - void Session::Log(const std::string &fmt, const Args &... args) const { + void Session::Log(const std::string &fmt, const Args &...args) const { LogPrint(BCLog::I2P, "I2P: %s\n", tfm::format(fmt, args...)); } diff --git a/src/index/base.cpp b/src/index/base.cpp --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -23,7 +23,7 @@ constexpr int64_t SYNC_LOCATOR_WRITE_INTERVAL = 30; // seconds template -static void FatalError(const char *fmt, const Args &... args) { +static void FatalError(const char *fmt, const Args &...args) { std::string strMessage = tfm::format(fmt, args...); SetMiscWarning(Untranslated(strMessage)); LogPrintf("*** %s\n", strMessage); diff --git a/src/logging.h b/src/logging.h --- a/src/logging.h +++ b/src/logging.h @@ -179,7 +179,7 @@ template static inline void LogPrintf_(const std::string &logging_function, const std::string &source_file, - const int source_line, const char *fmt, const Args &... args) { + const int source_line, const char *fmt, const Args &...args) { if (LogInstance().Enabled()) { std::string log_msg; try { diff --git a/src/netbase.cpp b/src/netbase.cpp --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -622,7 +622,7 @@ template static void LogConnectFailure(bool manual_connection, const char *fmt, - const Args &... args) { + const Args &...args) { std::string error_message = tfm::format(fmt, args...); if (manual_connection) { LogPrintf("%s\n", error_message); diff --git a/src/netmessagemaker.h b/src/netmessagemaker.h --- a/src/netmessagemaker.h +++ b/src/netmessagemaker.h @@ -17,7 +17,7 @@ template CSerializedNetMsg Make(int nFlags, std::string msg_type, - Args &&... args) const { + Args &&...args) const { CSerializedNetMsg msg; msg.m_type = std::move(msg_type); CVectorWriter{SER_NETWORK, nFlags | nVersion, msg.data, 0, @@ -26,7 +26,7 @@ } template - CSerializedNetMsg Make(std::string msg_type, Args &&... args) const { + CSerializedNetMsg Make(std::string msg_type, Args &&...args) const { return Make(0, std::move(msg_type), std::forward(args)...); } diff --git a/src/prevector.h b/src/prevector.h --- a/src/prevector.h +++ b/src/prevector.h @@ -519,7 +519,7 @@ return first; } - template void emplace_back(Args &&... args) { + template void emplace_back(Args &&...args) { size_type new_size = size() + 1; if (capacity() < new_size) { change_capacity(new_size + (new_size >> 1)); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1381,15 +1381,13 @@ void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled) { labelWalletHDStatusIcon->setPixmap( platformStyle - ->SingleColorIcon(privkeyDisabled - ? ":/icons/eye" - : hdEnabled ? ":/icons/hd_enabled" + ->SingleColorIcon(privkeyDisabled ? ":/icons/eye" + : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled") .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); labelWalletHDStatusIcon->setToolTip( - privkeyDisabled - ? tr("Private key disabled") - : hdEnabled ? tr("HD key generation is enabled") + privkeyDisabled ? tr("Private key disabled") + : hdEnabled ? tr("HD key generation is enabled") : tr("HD key generation is disabled")); labelWalletHDStatusIcon->show(); // eventually disable the QLabel to set its opacity to 50% diff --git a/src/rcu.h b/src/rcu.h --- a/src/rcu.h +++ b/src/rcu.h @@ -103,7 +103,7 @@ /** * Construct a new object that is owned by the pointer. */ - template static RCUPtr make(Args &&... args) { + template static RCUPtr make(Args &&...args) { return RCUPtr(new T(std::forward(args)...)); } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2233,7 +2233,7 @@ } template static inline bool SetHasKeys(const std::set &set, const Tk &key, - const Args &... args) { + const Args &...args) { return (set.count(key) != 0) || SetHasKeys(set, args...); } diff --git a/src/script/sign.h b/src/script/sign.h --- a/src/script/sign.h +++ b/src/script/sign.h @@ -92,7 +92,7 @@ // the stream has the total serialized length of all of the objects followed by // all objects concatenated with each other. template -void SerializeToVector(Stream &s, const X &... args) { +void SerializeToVector(Stream &s, const X &...args) { WriteCompactSize(s, GetSerializeSizeMany(s.GetVersion(), args...)); SerializeMany(s, args...); } @@ -100,7 +100,7 @@ // Takes a stream and multiple arguments and unserializes them first as a vector // then each object individually in the order provided in the arguments. template -void UnserializeFromVector(Stream &s, X &... args) { +void UnserializeFromVector(Stream &s, X &...args) { size_t expected_size = ReadCompactSize(s); size_t remaining_before = s.size(); UnserializeMany(s, args...); diff --git a/src/seeder/messagewriter.h b/src/seeder/messagewriter.h --- a/src/seeder/messagewriter.h +++ b/src/seeder/messagewriter.h @@ -13,7 +13,7 @@ template static void WriteMessage(CDataStream &stream, std::string command, - Args &&... args) { + Args &&...args) { CSerializedNetMsg payload = CNetMsgMaker(stream.GetVersion()) .Make(command, std::forward(args)...); size_t nMessageSize = payload.data.size(); diff --git a/src/seeder/test/message_writer_tests.cpp b/src/seeder/test/message_writer_tests.cpp --- a/src/seeder/test/message_writer_tests.cpp +++ b/src/seeder/test/message_writer_tests.cpp @@ -18,7 +18,7 @@ template static void CheckMessage(CDataStream &expectedMessage, std::string command, - Args &&... args) { + Args &&...args) { CDataStream message(SER_NETWORK, PROTOCOL_VERSION); MessageWriter::WriteMessage(message, command, std::forward(args)...); BOOST_CHECK_EQUAL(message.size(), expectedMessage.size()); diff --git a/src/serialize.h b/src/serialize.h --- a/src/serialize.h +++ b/src/serialize.h @@ -1126,7 +1126,7 @@ template void SerializeMany(Stream &s) {} template -void SerializeMany(Stream &s, const Arg &arg, const Args &... args) { +void SerializeMany(Stream &s, const Arg &arg, const Args &...args) { ::Serialize(s, arg); ::SerializeMany(s, args...); } @@ -1134,20 +1134,20 @@ template inline void UnserializeMany(Stream &s) {} template -inline void UnserializeMany(Stream &s, Arg &&arg, Args &&... args) { +inline void UnserializeMany(Stream &s, Arg &&arg, Args &&...args) { ::Unserialize(s, arg); ::UnserializeMany(s, args...); } template inline void SerReadWriteMany(Stream &s, CSerActionSerialize ser_action, - const Args &... args) { + const Args &...args) { ::SerializeMany(s, args...); } template inline void SerReadWriteMany(Stream &s, CSerActionUnserialize ser_action, - Args &&... args) { + Args &&...args) { ::UnserializeMany(s, args...); } @@ -1184,7 +1184,7 @@ } template -size_t GetSerializeSizeMany(int nVersion, const T &... t) { +size_t GetSerializeSizeMany(int nVersion, const T &...t) { CSizeComputer sc(nVersion); SerializeMany(sc, t...); return sc.size(); diff --git a/src/streams.h b/src/streams.h --- a/src/streams.h +++ b/src/streams.h @@ -84,7 +84,7 @@ */ template CVectorWriter(int nTypeIn, int nVersionIn, std::vector &vchDataIn, - size_t nPosIn, Args &&... args) + size_t nPosIn, Args &&...args) : CVectorWriter(nTypeIn, nVersionIn, vchDataIn, nPosIn) { ::SerializeMany(*this, std::forward(args)...); } @@ -155,7 +155,7 @@ */ template VectorReader(int type, int version, const std::vector &data, - size_t pos, Args &&... args) + size_t pos, Args &&...args) : VectorReader(type, version, data, pos) { ::UnserializeMany(*this, std::forward(args)...); } @@ -246,7 +246,7 @@ } template - CDataStream(int nTypeIn, int nVersionIn, Args &&... args) { + CDataStream(int nTypeIn, int nVersionIn, Args &&...args) { Init(nTypeIn, nVersionIn); ::SerializeMany(*this, std::forward(args)...); } diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -803,7 +803,7 @@ // This wrapper lets the coin_add test below be shorter and less repetitive, // while still verifying that the CoinsViewCache::AddCoin implementation ignores // base values. -template static void CheckAddCoin(Args &&... args) { +template static void CheckAddCoin(Args &&...args) { for (const Amount &base_value : {ABSENT, SPENT, VALUE1}) { CheckAddCoinBase(base_value, std::forward(args)...); } diff --git a/src/test/sigencoding_tests.cpp b/src/test/sigencoding_tests.cpp --- a/src/test/sigencoding_tests.cpp +++ b/src/test/sigencoding_tests.cpp @@ -91,19 +91,17 @@ CheckTransactionECDSASignatureEncoding(invalidSig, flags, &err), !(hasStrictEnc || is64)); if (is64 || hasStrictEnc) { - BOOST_CHECK(err == (is64 - ? ScriptError::SIG_BADLENGTH - : hasForkId ? ScriptError::MUST_USE_FORKID - : ScriptError::ILLEGAL_FORKID)); + BOOST_CHECK(err == (is64 ? ScriptError::SIG_BADLENGTH + : hasForkId ? ScriptError::MUST_USE_FORKID + : ScriptError::ILLEGAL_FORKID)); } BOOST_CHECK_EQUAL( CheckTransactionSchnorrSignatureEncoding(invalidSig, flags, &err), !(hasStrictEnc || !is64)); if (!is64 || hasStrictEnc) { - BOOST_CHECK(err == (!is64 - ? ScriptError::SIG_NONSCHNORR - : hasForkId ? ScriptError::MUST_USE_FORKID - : ScriptError::ILLEGAL_FORKID)); + BOOST_CHECK(err == (!is64 ? ScriptError::SIG_NONSCHNORR + : hasForkId ? ScriptError::MUST_USE_FORKID + : ScriptError::ILLEGAL_FORKID)); } } } diff --git a/src/tinyformat.h b/src/tinyformat.h --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -1022,7 +1022,7 @@ public: #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES template - FormatListN(const Args &... args) + FormatListN(const Args &...args) : FormatList(&m_formatterStore[0], N), m_formatterStore{ FormatArg(args)...} { static_assert(sizeof...(args) == N, "Number of args must be N"); @@ -1077,7 +1077,7 @@ /// /// FormatListRef formatList = makeFormatList( /*...*/ ); template -detail::FormatListN makeFormatList(const Args &... args) { +detail::FormatListN makeFormatList(const Args &...args) { return detail::FormatListN(args...); } @@ -1108,26 +1108,26 @@ /// Format list of arguments to the stream according to given format string. template -void format(std::ostream &out, const char *fmt, const Args &... args) { +void format(std::ostream &out, const char *fmt, const Args &...args) { vformat(out, fmt, makeFormatList(args...)); } /// Format list of arguments according to the given format string and return the /// result as a string. template -std::string format(const char *fmt, const Args &... args) { +std::string format(const char *fmt, const Args &...args) { std::ostringstream oss; format(oss, fmt, args...); return oss.str(); } /// Format list of arguments to std::cout, according to the given format string -template void printf(const char *fmt, const Args &... args) { +template void printf(const char *fmt, const Args &...args) { format(std::cout, fmt, args...); } template -void printfln(const char *fmt, const Args &... args) { +void printfln(const char *fmt, const Args &...args) { format(std::cout, fmt, args...); std::cout << '\n'; } @@ -1185,7 +1185,7 @@ // Added for Bitcoin template -std::string format(const std::string &fmt, const Args &... args) { +std::string format(const std::string &fmt, const Args &...args) { std::ostringstream oss; format(oss, fmt.c_str(), args...); return oss.str(); diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -43,7 +43,7 @@ void SetupEnvironment(); bool SetupNetworking(); -template bool error(const char *fmt, const Args &... args) { +template bool error(const char *fmt, const Args &...args) { LogPrintf("ERROR: %s\n", tfm::format(fmt, args...)); return false; } diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -473,8 +473,9 @@ std::vector ArgsManager::GetArgs(const std::string &strArg) const { std::vector result; for (const util::SettingsValue &value : GetSettingsList(strArg)) { - result.push_back( - value.isFalse() ? "0" : value.isTrue() ? "1" : value.get_str()); + result.push_back(value.isFalse() ? "0" + : value.isTrue() ? "1" + : value.get_str()); } return result; } @@ -582,27 +583,26 @@ std::string ArgsManager::GetArg(const std::string &strArg, const std::string &strDefault) const { const util::SettingsValue value = GetSetting(strArg); - return value.isNull() - ? strDefault - : value.isFalse() ? "0" : value.isTrue() ? "1" : value.get_str(); + return value.isNull() ? strDefault + : value.isFalse() ? "0" + : value.isTrue() ? "1" + : value.get_str(); } int64_t ArgsManager::GetArg(const std::string &strArg, int64_t nDefault) const { const util::SettingsValue value = GetSetting(strArg); - return value.isNull() - ? nDefault - : value.isFalse() - ? 0 - : value.isTrue() ? 1 - : value.isNum() ? value.get_int64() - : atoi64(value.get_str()); + return value.isNull() ? nDefault + : value.isFalse() ? 0 + : value.isTrue() ? 1 + : value.isNum() ? value.get_int64() + : atoi64(value.get_str()); } bool ArgsManager::GetBoolArg(const std::string &strArg, bool fDefault) const { const util::SettingsValue value = GetSetting(strArg); - return value.isNull() ? fDefault - : value.isBool() ? value.get_bool() - : InterpretBool(value.get_str()); + return value.isNull() ? fDefault + : value.isBool() ? value.get_bool() + : InterpretBool(value.get_str()); } bool ArgsManager::SoftSetArg(const std::string &strArg, @@ -1047,9 +1047,9 @@ util::GetSetting(m_settings, /* section= */ "", SettingName(arg), /* ignore_default_section_config= */ false, /* get_chain_name= */ true); - return value.isNull() ? false - : value.isBool() ? value.get_bool() - : InterpretBool(value.get_str()); + return value.isNull() ? false + : value.isBool() ? value.get_bool() + : InterpretBool(value.get_str()); }; const bool fRegTest = get_net("-regtest"); diff --git a/src/util/translation.h b/src/util/translation.h --- a/src/util/translation.h +++ b/src/util/translation.h @@ -39,7 +39,7 @@ namespace tinyformat { template -bilingual_str format(const bilingual_str &fmt, const Args &... args) { +bilingual_str format(const bilingual_str &fmt, const Args &...args) { return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)}; } diff --git a/src/util/vector.h b/src/util/vector.h --- a/src/util/vector.h +++ b/src/util/vector.h @@ -18,7 +18,7 @@ */ template inline std::vector::type> -Vector(Args &&... args) { +Vector(Args &&...args) { std::vector::type> ret; ret.reserve(sizeof...(args)); // The line below uses the trick from diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -15,13 +15,13 @@ FALSE_POSITIVES = [ ("src/dbwrapper.cpp", "vsnprintf(p, limit - p, format, backup_ap)"), - ("src/index/base.cpp", "FatalError(const char *fmt, const Args &... args)"), - ("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char *fmt, const Args &... args)"), + ("src/index/base.cpp", "FatalError(const char *fmt, const Args &...args)"), + ("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char *fmt, const Args &...args)"), ("src/util/system.cpp", "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"), ("src/validationinterface.cpp", "LogPrint(BCLog::VALIDATION, fmt \"\\n\", __VA_ARGS__)"), - ("src/tinyformat.h", "printf(const char *fmt, const Args &... args)"), + ("src/tinyformat.h", "printf(const char *fmt, const Args &...args)"), ("src/tinyformat.h", "printf(const char *fmt, TINYFORMAT_VARARGS(n))"), ("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"),