[clang] [clang][bytecode] Diagnose non-block pointers in __builtin_is_within_lifetime (PR #228337)
Oliver Hunt via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 3 16:11:57 PDT 2026
================
@@ -2446,6 +2446,14 @@ static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC,
return false;
}
+ if (!Ptr.isBlockPointer()) {
+ S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_access_unreadable_object)
+ << AK_Read << Ptr.toDiagnosticString(S.getASTContext());
+ noteValueLocation(S, Ptr);
----------------
ojhunt wrote:
Today in terrible wording: I mean "this changes the diagnostics produced" not "the diagnostic message content changed".
The changes to noteValueLocation introduced a direct string type check which does not seem to obviously exist in the original versions of these functions - It's possible the temporaries path in `noteValueLocation(InterpState &S, const Block *B)` previously captured this, but simply looking at the diff it looks like the `note_constexpr_temporary_here` is not gated on the string being a temporary.
So it _looks_ like the diagnostics change, beyond just the added one - I could be wrong, if `noteValueLocation(InterpState &S, const Pointer &Ptr)` is only ever called on a temporary then adding an assertion would make that clearer.
But the other point is that the check string for the diagnostic is "whose value is not known" which is shared with `note_constexpr_access_unknown_variable` and `note_constexpr_access_unreadable_object` so is insufficient to distinguish.
https://github.com/llvm/llvm-project/pull/228337
More information about the cfe-commits
mailing list