Author: Timm Baeder Date: 2026-08-31T06:18:32+02:00 New Revision: 4cfe874d50df6adf3eb843728f74eb53d24bb41b
URL: https://github.com/llvm/llvm-project/commit/4cfe874d50df6adf3eb843728f74eb53d24bb41b DIFF: https://github.com/llvm/llvm-project/commit/4cfe874d50df6adf3eb843728f74eb53d24bb41b.diff LOG: [clang][bytecode] Avoid `getSource()` calls in `diagnoseNonConstVariable()` (#219869) There were some cases when `Loc` was not used. Avoid calling `getSource()` in those cases. 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 896b2ab4494e7..716f3320299a3 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -155,9 +155,8 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, if (!S.diagnosing()) return; - const SourceInfo &Loc = S.Current->getSource(OpPC); if (!S.getLangOpts().CPlusPlus) { - S.FFDiag(Loc); + S.FFDiag(S.Current->getSource(OpPC)); return; } @@ -175,6 +174,7 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, return; if (VD->getType()->isIntegralOrEnumerationType()) { + SourceInfo Loc = S.Current->getSource(OpPC); if (isModification(AK)) { S.FFDiag(Loc, diag::note_constexpr_modify_global); } else { @@ -184,7 +184,7 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC, return; } - S.FFDiag(Loc, + S.FFDiag(S.Current->getSource(OpPC), S.getLangOpts().CPlusPlus11 ? diag::note_constexpr_ltor_non_constexpr : diag::note_constexpr_ltor_non_integral, 1) _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
