[Clang] Check that we have the correct RecordDecl
authorBill Wendling <morbo@google.com>
Mon, 7 Oct 2024 22:25:47 +0000 (15:25 -0700)
committerTobias Hieta <tobias@hieta.se>
Fri, 11 Oct 2024 06:04:20 +0000 (08:04 +0200)
Ensure we have the correct RecordDecl before returning the Expr we're
looking for.

clang/lib/CodeGen/CGExpr.cpp

index 8d6f535bba896ef77e97a790db7fa15500e790b1..3ef22b17f7691d054874f1b89fd42df26411df60 100644 (file)
@@ -1053,7 +1053,7 @@ public:
   }
   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) {