[clang-tools-extra] [clang-tidy] Improve modernize-use-std-print diagnostic (PR #91071)
via cfe-commits
cfe-commits at lists.llvm.org
Sat May 4 09:45:29 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Mike Crowe (mikecrowe)
<details>
<summary>Changes</summary>
Include the source range of the printf function in the diagnostic so it gets underlined in the output.
---
Full diff: https://github.com/llvm/llvm-project/pull/91071.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp (+2-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index 660996aba7b70d..aa60c904a363da 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -138,7 +138,8 @@ void UseStdPrintCheck::check(const MatchFinder::MatchResult &Result) {
if (!Converter.canApply()) {
diag(PrintfCall->getBeginLoc(),
"unable to use '%0' instead of %1 because %2")
- << ReplacementFunction << OldFunction->getIdentifier()
+ << PrintfCall->getSourceRange() << ReplacementFunction
+ << OldFunction->getIdentifier()
<< Converter.conversionNotPossibleReason();
return;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/91071
More information about the cfe-commits
mailing list