[clang] [clang][bytecode][NFC] Only call getSource() when necessary (PR #125419)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 2 08:45:44 PST 2025


https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/125419

None

>From 6b3952c8fc1ba420e27ea376e01113c1160b4dc2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 2 Feb 2025 17:44:19 +0100
Subject: [PATCH] [clang][bytecode][NFC] Only call getSource() when necessary

---
 clang/lib/AST/ByteCode/Interp.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index f91820e16fac52..1123ced99eb069 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -65,17 +65,17 @@ static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
                                      const ValueDecl *VD);
 static bool diagnoseUnknownDecl(InterpState &S, CodePtr OpPC,
                                 const ValueDecl *D) {
-  const SourceInfo &E = S.Current->getSource(OpPC);
 
   if (isa<ParmVarDecl>(D)) {
     if (D->getType()->isReferenceType())
       return false;
 
+    const SourceInfo &Loc = S.Current->getSource(OpPC);
     if (S.getLangOpts().CPlusPlus11) {
-      S.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << D;
+      S.FFDiag(Loc, diag::note_constexpr_function_param_value_unknown) << D;
       S.Note(D->getLocation(), diag::note_declared_at) << D->getSourceRange();
     } else {
-      S.FFDiag(E);
+      S.FFDiag(Loc);
     }
     return false;
   }



More information about the cfe-commits mailing list