[clang-tools-extra] [clang-tidy] Fix invalid fixit from modernize-use-ranges for nullptr used with std::unique_ptr (PR #127162)

via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 03:33:03 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff dc79c66f2c6cc2773e38735660d8e0aaedf9702c 5bbd811547440e56eb3c2ed387833b41ce6232e3 --extensions cpp -- clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp clang-tools-extra/test/clang-tidy/checkers/modernize/use-ranges.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
index 2667099b52..f7a19cd72d 100644
--- a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
@@ -215,8 +215,8 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) {
     const auto *Call = Result.Nodes.getNodeAs<CallExpr>(Buffer);
     if (!Call)
       continue;
-    
-    // FIXME: This check specifically handles `CXXNullPtrLiteralExpr`, but 
+
+    // FIXME: This check specifically handles `CXXNullPtrLiteralExpr`, but
     // a more general solution might be needed.
     if (Function->getName() == "find") {
       const unsigned ValueArgIndex = 2;
@@ -227,7 +227,7 @@ void UseRangesCheck::check(const MatchFinder::MatchResult &Result) {
       if (isa<CXXNullPtrLiteralExpr>(ValueExpr))
         return;
     }
-    
+
     auto Diag = createDiag(*Call);
     if (auto ReplaceName = Replacer->getReplaceName(*Function))
       Diag << FixItHint::CreateReplacement(Call->getCallee()->getSourceRange(),

``````````

</details>


https://github.com/llvm/llvm-project/pull/127162


More information about the cfe-commits mailing list