[clang] [Clang] Diagnose down casting static_cast (PR #117914)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 27 11:23:11 PST 2024
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 bbbaeb5584b5f1ab38cc86a9e8ed64ec1dc926b6 d1e2a9ac8e329d0786f41a3ef4bedb61d7f7ffe5 --extensions cpp -- clang/lib/Sema/SemaCast.cpp clang/test/Analysis/ArrayDelete.cpp clang/test/Analysis/Checkers/WebKit/call-args-safe-functions.cpp clang/test/Analysis/Checkers/WebKit/ref-cntbl-base-virtual-dtor-templates.cpp clang/test/Analysis/cast-to-struct.cpp clang/test/SemaCXX/address-space-conversion.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index dc5abe43a4..f57069aaac 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -1760,13 +1760,12 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType,
Self.BuildBasePathArray(Paths, BasePath);
Kind = CK_BaseToDerived;
- if (!CStyle && Self.LangOpts.CPlusPlus && SrcType->getAsCXXRecordDecl()->isPolymorphic()) {
+ if (!CStyle && Self.LangOpts.CPlusPlus &&
+ SrcType->getAsCXXRecordDecl()->isPolymorphic()) {
auto D = Self.Diag(OpRange.getBegin(), diag::warn_static_downcast)
- << SrcType << DestType
- << OpRange
- << Self.LangOpts.RTTI;
- if(Self.LangOpts.RTTI)
- D << FixItHint::CreateReplacement(OpRange.getBegin(), "dynamic_cast");
+ << SrcType << DestType << OpRange << Self.LangOpts.RTTI;
+ if (Self.LangOpts.RTTI)
+ D << FixItHint::CreateReplacement(OpRange.getBegin(), "dynamic_cast");
}
return TC_Success;
``````````
</details>
https://github.com/llvm/llvm-project/pull/117914
More information about the cfe-commits
mailing list