[clang] [clang][AST] fix dereference on class/struct layouts check. (PR #83686)
David CARLIER via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 2 10:04:22 PST 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/83686
close #83671.
>From 49c888993ee4ce566db8f5b8d4932cee81b8f701 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sat, 2 Mar 2024 18:00:10 +0000
Subject: [PATCH] [clang][AST] fix dereference on class/struct layouts check.
close #83671.
---
clang/lib/AST/RecordLayoutBuilder.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index a3b7431f7ffd6d..195f17d2e5a42f 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -205,15 +205,15 @@ void EmptySubobjectMap::ComputeEmptySubobjectSizes() {
// Check the fields.
for (const FieldDecl *FD : Class->fields()) {
+ const CXXRecordDecl *MemberDecl;
const RecordType *RT =
Context.getBaseElementType(FD->getType())->getAs<RecordType>();
- // We only care about record types.
- if (!RT)
+ // We only care about members layout.
+ if (!RT || !(MemberDecl = RT->getAsCXXRecordDecl()))
continue;
CharUnits EmptySize;
- const CXXRecordDecl *MemberDecl = RT->getAsCXXRecordDecl();
const ASTRecordLayout &Layout = Context.getASTRecordLayout(MemberDecl);
if (MemberDecl->isEmpty()) {
// If the class decl is empty, get its size.
More information about the cfe-commits
mailing list