llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

There were some cases when `Loc` was not used. Avoid calling `getSource()` in 
those cases.

---
Full diff: https://github.com/llvm/llvm-project/pull/219869.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+3-3) 


``````````diff
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)

``````````

</details>


https://github.com/llvm/llvm-project/pull/219869
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to