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

via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 2 23:51:34 PST 2025


Author: Timm Baeder
Date: 2025-02-03T08:51:30+01:00
New Revision: c475356603cd33ead378a9db00b7e579c9da366e

URL: https://github.com/llvm/llvm-project/commit/c475356603cd33ead378a9db00b7e579c9da366e
DIFF: https://github.com/llvm/llvm-project/commit/c475356603cd33ead378a9db00b7e579c9da366e.diff

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

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 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