[clang] [clang][bytecode][NFC] Avoid a getSource() call (PR #117311)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 22 02:16:46 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

This is only needed when we actually emit a diagnostic, so move the getSource() after the early return.

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


1 Files Affected:

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


``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 4af1d6f40e9017..329f1584be34bf 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1481,11 +1481,12 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
 
 bool InvalidNewDeleteExpr(InterpState &S, CodePtr OpPC, const Expr *E) {
   assert(E);
-  const auto &Loc = S.Current->getSource(OpPC);
 
   if (S.getLangOpts().CPlusPlus26)
     return true;
 
+  const auto &Loc = S.Current->getSource(OpPC);
+
   if (const auto *NewExpr = dyn_cast<CXXNewExpr>(E)) {
     const FunctionDecl *OperatorNew = NewExpr->getOperatorNew();
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/117311


More information about the cfe-commits mailing list