Skip to content

Commit a5ab650

Browse files
committed
[clang] Fix a crash in constant evaluation
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. Differential Revision: https://reviews.llvm.org/D132918
1 parent b10e508 commit a5ab650

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4794,6 +4794,11 @@ static bool getDefaultInitValue(QualType T, APValue &Result) {
47944794
Result = APValue((const FieldDecl *)nullptr);
47954795
return true;
47964796
}
4797+
// Can't access properties of an incomplete type.
4798+
if (!RD->hasDefinition()) {
4799+
Result = APValue();
4800+
return false;
4801+
}
47974802
Result = APValue(APValue::UninitStruct(), RD->getNumBases(),
47984803
std::distance(RD->field_begin(), RD->field_end()));
47994804

0 commit comments

Comments
 (0)