[clang] e5fb656 - [clang][Interp] Handle RecoveryExprs
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu May 2 04:43:25 PDT 2024
Author: Timm Bäder
Date: 2024-05-02T13:43:06+02:00
New Revision: e5fb6564358f10c01d7533f2f805eedd7d663417
URL: https://github.com/llvm/llvm-project/commit/e5fb6564358f10c01d7533f2f805eedd7d663417
DIFF: https://github.com/llvm/llvm-project/commit/e5fb6564358f10c01d7533f2f805eedd7d663417.diff
LOG: [clang][Interp] Handle RecoveryExprs
Instead of checking containsErrors() for every expression, just handle
RecoveryExprs directly.
Added:
Modified:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 2dfa726cc75256..b096d4ddd88246 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2487,10 +2487,12 @@ bool ByteCodeExprGen<Emitter>::VisitPackIndexingExpr(
return this->delegate(E->getSelectedExpr());
}
-template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
- if (E->containsErrors())
- return false;
+template <class Emitter>
+bool ByteCodeExprGen<Emitter>::VisitRecoveryExpr(const RecoveryExpr *E) {
+ return this->emitError(E);
+}
+template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
OptionScope<Emitter> Scope(this, /*NewDiscardResult=*/true,
/*NewInitializing=*/false);
return this->Visit(E);
@@ -2498,9 +2500,6 @@ template <class Emitter> bool ByteCodeExprGen<Emitter>::discard(const Expr *E) {
template <class Emitter>
bool ByteCodeExprGen<Emitter>::delegate(const Expr *E) {
- if (E->containsErrors())
- return this->emitError(E);
-
// We're basically doing:
// OptionScope<Emitter> Scope(this, DicardResult, Initializing);
// but that's unnecessary of course.
@@ -2508,9 +2507,6 @@ bool ByteCodeExprGen<Emitter>::delegate(const Expr *E) {
}
template <class Emitter> bool ByteCodeExprGen<Emitter>::visit(const Expr *E) {
- if (E->containsErrors())
- return this->emitError(E);
-
if (E->getType()->isVoidType())
return this->discard(E);
diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h
index a89e37c67aa67c..0cd8cf1cb397a9 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -121,6 +121,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E);
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E);
bool VisitPackIndexingExpr(const PackIndexingExpr *E);
+ bool VisitRecoveryExpr(const RecoveryExpr *E);
protected:
bool visitExpr(const Expr *E) override;
More information about the cfe-commits
mailing list