[clang] 722d6b5 - [clang][bytecode] Only check expr in CheckThis() if we have to (#141951)

via cfe-commits cfe-commits at lists.llvm.org
Thu May 29 08:18:03 PDT 2025


Author: Timm Baeder
Date: 2025-05-29T17:17:59+02:00
New Revision: 722d6b55ed64678abdc6f4e8761cdd7eb224d02c

URL: https://github.com/llvm/llvm-project/commit/722d6b55ed64678abdc6f4e8761cdd7eb224d02c
DIFF: https://github.com/llvm/llvm-project/commit/722d6b55ed64678abdc6f4e8761cdd7eb224d02c.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Interp.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index fd86d70bfd245..4d1e5c6b98a8d 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;
 }


        


More information about the cfe-commits mailing list