[clang] [clang][ExprConst] Fix crash on uninitialized array subobject (PR #67817)
Takuya Shimizu via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 07:43:39 PDT 2023
================
@@ -2411,10 +2411,15 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
const FieldDecl *SubobjectDecl,
CheckedTemporaries &CheckedTemps) {
if (!Value.hasValue()) {
- assert(SubobjectDecl && "SubobjectDecl shall be non-null");
- Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << SubobjectDecl;
- Info.Note(SubobjectDecl->getLocation(),
- diag::note_constexpr_subobject_declared_here);
+ if (SubobjectDecl) {
----------------
hazohelet wrote:
I'm not worrying about `SubobjectLoc` that was used for `subobject declared here` note. https://reviews.llvm.org/D146358 introduced the explicit `nullptr` args, but it only happens on calls where invalid source location was explicitly passed before that patch. (There was one exception about base classes but it was fixed in https://reviews.llvm.org/D153969. Despite passing null `SubobjectDecl` there, the passed `APValue` is known to be `isStruct()`, so its subobjects do not inherit the nullness of `SubobjectDecl`)
So, we always had an invalid source location where we now have null`SubobjectDecl`; thus no information being lost.
https://github.com/llvm/llvm-project/pull/67817
More information about the cfe-commits
mailing list