From: Timm Bäder Date: Mon, 31 Oct 2022 11:58:27 +0000 (+0100) Subject: [clang][Interp][NFC] Avoid a getSource() call in the common case X-Git-Tag: upstream/17.0.6~28365 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8341a66159703de242ab8de362b59548cdda71e;p=platform%2Fupstream%2Fllvm.git [clang][Interp][NFC] Avoid a getSource() call in the common case In the common (successful) case, we don't need the getSource() call, so move it to the two if statement bodies instead. --- diff --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp index a5984a2..b22756a 100644 --- a/clang/lib/AST/Interp/Interp.cpp +++ b/clang/lib/AST/Interp/Interp.cpp @@ -201,8 +201,8 @@ bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr) { bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, AccessKinds AK) { - const auto &Src = S.Current->getSource(OpPC); if (Ptr.isZero()) { + const auto &Src = S.Current->getSource(OpPC); if (Ptr.isField()) S.FFDiag(Src, diag::note_constexpr_null_subobject) << CSK_Field; @@ -213,6 +213,7 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr, } if (!Ptr.isLive()) { + const auto &Src = S.Current->getSource(OpPC); bool IsTemp = Ptr.isTemporary(); S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;