[clang] [clang][bytecode] Only check expr in CheckThis() if we have to (PR #141951)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Thu May 29 07:01:53 PDT 2025
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/141951
Pre C++11, we dont't need to get the value of IsImplicit.
>From 3cdc0e88a50dae1299532342fc39ccb88f9dd564 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Thu, 29 May 2025 13:48:09 +0200
Subject: [PATCH] [clang][bytecode] Only check expr in CheckThis() if we have
to
Pre C++11, we dont't need to get the value of IsImplicit.
---
clang/lib/AST/ByteCode/Interp.cpp | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index e454d9e3bc218..136ab04558403 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -959,16 +959,15 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This) {
if (!This.isZero())
return true;
- const SourceInfo &Loc = S.Current->getSource(OpPC);
-
- bool IsImplicit = false;
- if (const auto *E = dyn_cast_if_present<CXXThisExpr>(Loc.asExpr()))
- IsImplicit = E->isImplicit();
-
- if (S.getLangOpts().CPlusPlus11)
- S.FFDiag(Loc, diag::note_constexpr_this) << IsImplicit;
- else
- S.FFDiag(Loc);
+ const Expr *E = S.Current->getExpr(OpPC);
+ if (S.getLangOpts().CPlusPlus11) {
+ bool IsImplicit = false;
+ if (const auto *TE = dyn_cast<CXXThisExpr>(E))
+ IsImplicit = TE->isImplicit();
+ S.FFDiag(E, diag::note_constexpr_this) << IsImplicit;
+ } else {
+ S.FFDiag(E);
+ }
return false;
}
More information about the cfe-commits
mailing list