[clang] [clang][bytecode][NFC] Avoid a getSource() call (PR #117311)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 22 02:16:14 PST 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/117311
This is only needed when we actually emit a diagnostic, so move the getSource() after the early return.
>From bf0c37684268d7afa41beb6035aa137d633ea596 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Fri, 22 Nov 2024 10:56:47 +0100
Subject: [PATCH] [clang][bytecode][NFC] Avoid a getSource() call
This is only needed when we actually emit a diagnostic, so move the
getSource() after the early return.
---
clang/lib/AST/ByteCode/Interp.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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();
More information about the cfe-commits
mailing list