diff options
-rw-r--r-- | contrib/devtools/bitcoin-tidy/example_logprintf.cpp | 18 | ||||
-rw-r--r-- | 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 3106a0c161..a12a666c08 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 <typename... Params> + 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 1690c8fde0..36beac28c8 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); |