From 1936cd507a38d3085fa13016fb40a9a7df35a821 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 7 Oct 2024 15:25:47 -0700 Subject: [PATCH] [Clang] Check that we have the correct RecordDecl Ensure we have the correct RecordDecl before returning the Expr we're looking for. --- clang/lib/CodeGen/CGExpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 52d2f6d52abf9..451442765620f 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1096,7 +1096,7 @@ class StructAccessBase } const Expr *VisitCastExpr(const CastExpr *E) { if (E->getCastKind() == CK_LValueToRValue) - return E; + return IsExpectedRecordDecl(E) ? E : nullptr; return Visit(E->getSubExpr()); } const Expr *VisitParenExpr(const ParenExpr *E) {