[clang] [clang] Fix static_cast bypassing access control (PR #132285)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 06:15:00 PDT 2025
================
@@ -1572,13 +1571,12 @@ TryCastResult TryLValueToRValueCast(Sema &Self, Expr *SrcExpr,
if (RefConv & Sema::ReferenceConversions::DerivedToBase) {
Kind = CK_DerivedToBase;
- CXXBasePaths Paths(/*FindAmbiguities=*/true, /*RecordPaths=*/true,
- /*DetectVirtual=*/true);
- if (!Self.IsDerivedFrom(SrcExpr->getBeginLoc(), SrcExpr->getType(),
- R->getPointeeType(), Paths))
- return TC_NotApplicable;
-
- Self.BuildBasePathArray(Paths, BasePath);
+ if (Self.CheckDerivedToBaseConversion(FromType, ToType,
+ SrcExpr->getBeginLoc(), OpRange,
+ &BasePath, CStyle)) {
+ msg = 0;
----------------
offsetof wrote:
Yes, `msg` defaults to `err_bad_cxx_cast_generic` but `CheckDerivedToBaseConversion` already emits a more specific diagnostic.
https://github.com/llvm/llvm-project/pull/132285
More information about the cfe-commits
mailing list