[PATCH] D132918: [clang] Fix a crash in constant evaluation
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 30 02:01:47 PDT 2022
kadircet created this revision.
kadircet added reviewers: usaxena95, ilya-biryukov.
Herald added a project: All.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This was showing up in our internal crash collector. I have no idea how
to test it out though, open for suggestions if there are easy paths but
otherwise I'd move forward with the patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132918
Files:
clang/lib/AST/ExprConstant.cpp
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4794,6 +4794,11 @@
Result = APValue((const FieldDecl *)nullptr);
return true;
}
+ // Can't access properties of an incomplete type.
+ if (!RD->hasDefinition()) {
+ Result = APValue();
+ return false;
+ }
Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
std::distance(RD->field_begin(), RD->field_end()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132918.456571.patch
Type: text/x-patch
Size: 564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220830/e85f93e4/attachment.bin>
More information about the cfe-commits
mailing list