From fa60fa3b0cba4a30726af8e0e9d1e84e14849eda Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 16 Aug 2023 14:55:19 +0200 Subject: [PATCH] bitcoin-tidy: Apply bitcoin-unterminated-logprintf to spkm as well --- .../bitcoin-tidy/example_logprintf.cpp | 18 ++++++++++++++++++ contrib/devtools/bitcoin-tidy/logprintf.cpp | 2 -- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/contrib/devtools/bitcoin-tidy/example_logprintf.cpp b/contrib/devtools/bitcoin-tidy/example_logprintf.cpp index 3106a0c161f..a12a666c086 100644 --- a/contrib/devtools/bitcoin-tidy/example_logprintf.cpp +++ b/contrib/devtools/bitcoin-tidy/example_logprintf.cpp @@ -43,6 +43,20 @@ public: }; }; +struct ScriptPubKeyMan +{ + std::string GetDisplayName() const + { + return "default wallet"; + } + + template + void WalletLogPrintf(const char* fmt, Params... parameters) const + { + LogPrintf(("%s " + std::string{fmt}).c_str(), GetDisplayName(), parameters...); + }; +}; + void good_func() { LogPrintf("hello world!\n"); @@ -51,6 +65,8 @@ void good_func2() { CWallet wallet; wallet.WalletLogPrintf("hi\n"); + ScriptPubKeyMan spkm; + spkm.WalletLogPrintf("hi\n"); const CWallet& walletref = wallet; walletref.WalletLogPrintf("hi\n"); @@ -80,6 +96,8 @@ void bad_func5() { CWallet wallet; wallet.WalletLogPrintf("hi"); + ScriptPubKeyMan spkm; + spkm.WalletLogPrintf("hi"); const CWallet& walletref = wallet; walletref.WalletLogPrintf("hi"); diff --git a/contrib/devtools/bitcoin-tidy/logprintf.cpp b/contrib/devtools/bitcoin-tidy/logprintf.cpp index 1690c8fde0a..36beac28c86 100644 --- a/contrib/devtools/bitcoin-tidy/logprintf.cpp +++ b/contrib/devtools/bitcoin-tidy/logprintf.cpp @@ -36,14 +36,12 @@ void LogPrintfCheck::registerMatchers(clang::ast_matchers::MatchFinder* finder) this); /* - CWallet wallet; auto walletptr = &wallet; wallet.WalletLogPrintf("foo"); wallet->WalletLogPrintf("foo"); */ finder->addMatcher( cxxMemberCallExpr( - thisPointerType(qualType(hasDeclaration(cxxRecordDecl(hasName("CWallet"))))), callee(cxxMethodDecl(hasName("WalletLogPrintf"))), hasArgument(0, stringLiteral(unterminated()).bind("logstring"))), this);