class RecoveryExpr

Declaration

class RecoveryExpr : public Expr, private TrailingObjects { /* full declaration omitted */ };

Description

Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expressions. E.g. when type-checking of a binary operator fails, we cannot produce a BinaryOperator expression. Instead, we can choose to produce a recovery expression storing left and right operands. RecoveryExpr does not have any semantic meaning in C++, it is only useful to preserve expressions in AST that would otherwise be dropped. It captures subexpressions of some expression that we could not construct and source range covered by the expression. By default, RecoveryExpr uses dependence-bits to take advantage of existing machinery to deal with dependent code in C++, e.g. RecoveryExpr is preserved in `decltype( <broken -expr>)` as part of the `DependentDecltypeType`. In addition to that, clang does not report most errors on dependent expressions, so we get rid of bogus errors for free. However, note that unlike other dependent expressions, RecoveryExpr can be produced in non-template contexts. We will preserve the type in RecoveryExpr when the type is known, e.g. preserving the return type for a broken non-overloaded function call, a overloaded call where all candidates have the same return type. In this case, the expression is not type-dependent (unless the known type is itself dependent) One can also reliably suppress all bogus errors on expressions containing recovery expressions by examining results of Expr::containsErrors().

Declared at: clang/include/clang/AST/Expr.h:6421

Inherits from: Expr, TrailingObjects

Member Variables

private clang::SourceLocation BeginLoc
private clang::SourceLocation EndLoc
private unsigned int NumExprs

Inherited from Stmt:

protected

Method Overview

  • public static clang::RecoveryExpr * Create(clang::ASTContext & Ctx, clang::QualType T, clang::SourceLocation BeginLoc, clang::SourceLocation EndLoc, ArrayRef<clang::Expr *> SubExprs)
  • public static clang::RecoveryExpr * CreateEmpty(clang::ASTContext & Ctx, unsigned int NumSubExprs)
  • private RecoveryExpr(clang::ASTContext & Ctx, clang::QualType T, clang::SourceLocation BeginLoc, clang::SourceLocation EndLoc, ArrayRef<clang::Expr *> SubExprs)
  • private RecoveryExpr(clang::Stmt::EmptyShell Empty, unsigned int NumSubExprs)
  • public clang::Stmt::child_range children()
  • public static bool classof(const clang::Stmt * T)
  • public clang::SourceLocation getBeginLoc() const
  • public clang::SourceLocation getEndLoc() const
  • private size_t numTrailingObjects(OverloadToken<clang::Stmt *>) const
  • public ArrayRef<clang::Expr *> subExpressions()
  • public ArrayRef<const clang::Expr *> subExpressions() const

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

static clang::RecoveryExpr* Create(
    clang::ASTContext& Ctx,
    clang::QualType T,
    clang::SourceLocation BeginLoc,
    clang::SourceLocation EndLoc,
    ArrayRef<clang::Expr*> SubExprs)

Declared at: clang/include/clang/AST/Expr.h:6424

Parameters

clang::ASTContext& Ctx
clang::QualType T
clang::SourceLocation BeginLoc
clang::SourceLocation EndLoc
ArrayRef<clang::Expr*> SubExprs

static clang::RecoveryExpr* CreateEmpty(
    clang::ASTContext& Ctx,
    unsigned int NumSubExprs)

Declared at: clang/include/clang/AST/Expr.h:6427

Parameters

clang::ASTContext& Ctx
unsigned int NumSubExprs

RecoveryExpr(clang::ASTContext& Ctx,
             clang::QualType T,
             clang::SourceLocation BeginLoc,
             clang::SourceLocation EndLoc,
             ArrayRef<clang::Expr*> SubExprs)

Declared at: clang/include/clang/AST/Expr.h:6451

Parameters

clang::ASTContext& Ctx
clang::QualType T
clang::SourceLocation BeginLoc
clang::SourceLocation EndLoc
ArrayRef<clang::Expr*> SubExprs

RecoveryExpr(clang::Stmt::EmptyShell Empty,
             unsigned int NumSubExprs)

Declared at: clang/include/clang/AST/Expr.h:6453

Parameters

clang::Stmt::EmptyShell Empty
unsigned int NumSubExprs

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/Expr.h:6438

static bool classof(const clang::Stmt* T)

Declared at: clang/include/clang/AST/Expr.h:6446

Parameters

const clang::Stmt* T

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/Expr.h:6443

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/Expr.h:6444

size_t numTrailingObjects(
    OverloadToken<clang::Stmt*>) const

Declared at: clang/include/clang/AST/Expr.h:6456

Parameters

OverloadToken<clang::Stmt*>

ArrayRef<clang::Expr*> subExpressions()

Declared at: clang/include/clang/AST/Expr.h:6429

ArrayRef<const clang::Expr*> subExpressions()
    const

Declared at: clang/include/clang/AST/Expr.h:6434