[clang-tools-extra] 7e4d16d - [clang-tidy] Improve modernize-use-std-print diagnostic (#91071)

via cfe-commits cfe-commits at lists.llvm.org
Sun May 5 08:20:35 PDT 2024


Author: Mike Crowe
Date: 2024-05-05T17:20:31+02:00
New Revision: 7e4d16d73c22079997dd59d8e7d8f41bdbac5a50

URL: https://github.com/llvm/llvm-project/commit/7e4d16d73c22079997dd59d8e7d8f41bdbac5a50
DIFF: https://github.com/llvm/llvm-project/commit/7e4d16d73c22079997dd59d8e7d8f41bdbac5a50.diff

LOG: [clang-tidy] Improve modernize-use-std-print diagnostic (#91071)

Include the source range of the printf function in the diagnostic so it
gets underlined in the output.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp

Removed: 
    


################################################################################
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;
   }


        


More information about the cfe-commits mailing list