[clang] [clang][AST] fix dereference on class/struct layouts check. (PR #83686)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 2 10:04:49 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
close #<!-- -->83671.
---
Full diff: https://github.com/llvm/llvm-project/pull/83686.diff
1 Files Affected:
- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+3-3)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/83686
More information about the cfe-commits
mailing list