llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Mradul Sonare (SonareMradul)

<details>
<summary>Changes</summary>

Adds a fix-it for C-style casts of nullptr in google-readability-casting,
suggesting static_cast&lt;T*&gt;(nullptr).

Fixes #&lt;173147&gt;


---
Full diff: https://github.com/llvm/llvm-project/pull/173159.diff


1 Files Affected:

- (modified) clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp 
(+5) 


``````````diff
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
index 76f2030158c81..2e7fc0f364b48 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
@@ -218,6 +218,11 @@ void AvoidCStyleCastCheck::check(const 
MatchFinder::MatchResult &Result) {
       ReplaceWithNamedCast("static_cast");
     return;
   case CK_NoOp:
+  if 
(isa<CXXNullPtrLiteralExpr>(CastExpr->getSubExprAsWritten()->IgnoreImpCasts())) 
{
+  ReplaceWithNamedCast("static_cast");
+  return;
+}
+
     if (FnToFnCast) {
       ReplaceWithNamedCast("static_cast");
       return;

``````````

</details>


https://github.com/llvm/llvm-project/pull/173159
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to