[clang] 3834f58 - [clang][bytecode] Only call getSource() if we diagnose (#224663)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 18 20:58:56 PDT 2026
Author: Timm Baeder
Date: 2026-09-19T05:58:51+02:00
New Revision: 3834f58744a7be80b5869c07fe576ff8f23e2315
URL: https://github.com/llvm/llvm-project/commit/3834f58744a7be80b5869c07fe576ff8f23e2315
DIFF: https://github.com/llvm/llvm-project/commit/3834f58744a7be80b5869c07fe576ff8f23e2315.diff
LOG: [clang][bytecode] Only call getSource() if we diagnose (#224663)
We can avoid this if we only return false anyway. Also rename a
variable.
Added:
Modified:
clang/lib/AST/ByteCode/Interp.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index b6975f250b3c1..ab6b474503a3b 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -489,23 +489,23 @@ bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
AccessKinds AK) {
if (Ptr.isZero()) {
- const auto &Src = S.Current->getSource(OpPC);
+ const auto Loc = S.Current->getSource(OpPC);
if (Ptr.isField())
- S.FFDiag(Src, diag::note_constexpr_null_subobject) << CSK_Field;
+ S.FFDiag(Loc, diag::note_constexpr_null_subobject) << CSK_Field;
else
- S.FFDiag(Src, diag::note_constexpr_access_null) << AK;
+ S.FFDiag(Loc, diag::note_constexpr_access_null) << AK;
return false;
}
if (!Ptr.isLive()) {
- const auto &Src = S.Current->getSource(OpPC);
-
if (Ptr.isDynamic()) {
- S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
+ S.FFDiag(S.Current->getSource(OpPC),
+ diag::note_constexpr_access_deleted_object)
+ << AK;
} else if (!S.checkingPotentialConstantExpression()) {
- S.FFDiag(Src, diag::note_constexpr_access_uninit)
+ S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_access_uninit)
<< AK << /*uninitialized=*/false << S.Current->getRange(OpPC);
noteValueLocation(S, Ptr);
}
More information about the cfe-commits
mailing list