aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.cpp
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-05-29 17:17:59 +0200
committerGitHub <noreply@github.com>2025-05-29 17:17:59 +0200
commit722d6b55ed64678abdc6f4e8761cdd7eb224d02c (patch)
tree4a03779439692fe10f56e5821be14826e38dcfd8 /clang/lib/AST/ByteCode/Interp.cpp
parent4c88873be83e2d212e412459c02d05006c5f0069 (diff)
downloadllvm-722d6b55ed64678abdc6f4e8761cdd7eb224d02c.zip
llvm-722d6b55ed64678abdc6f4e8761cdd7eb224d02c.tar.gz
llvm-722d6b55ed64678abdc6f4e8761cdd7eb224d02c.tar.bz2
[clang][bytecode] Only check expr in CheckThis() if we have to (#141951)
Pre C++11, we dont't need to get the value of IsImplicit.
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r--clang/lib/AST/ByteCode/Interp.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index fd86d70..4d1e5c6 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -966,16 +966,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;
}