Remove abstract expression kinds from the StmtClass enum. Update a few users

appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
This commit is contained in:
John McCall 2010-02-03 00:55:45 +00:00
parent dee74e2805
commit 2adddcae7e
11 changed files with 39 additions and 37 deletions

View File

@ -1748,7 +1748,7 @@ public:
static bool classof(const Stmt *T) {
StmtClass SC = T->getStmtClass();
if (SC >= ExplicitCastExprClass && SC <= CStyleCastExprClass)
if (SC >= CStyleCastExprClass && SC <= CStyleCastExprClass)
return true;
if (SC >= CXXNamedCastExprClass && SC <= CXXFunctionalCastExprClass)
return true;

View File

@ -102,6 +102,7 @@ public:
#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class,
#define FIRST_EXPR(CLASS) firstExprConstant = CLASS##Class,
#define LAST_EXPR(CLASS) lastExprConstant = CLASS##Class
#define ABSTRACT_EXPR(CLASS, PARENT)
#include "clang/AST/StmtNodes.def"
};
private:

View File

@ -69,7 +69,6 @@ LAST_STMT(CXXTryStmt)
// Expressions.
ABSTRACT_EXPR(Expr , Stmt)
FIRST_EXPR(Expr)
EXPR(PredefinedExpr , Expr)
EXPR(DeclRefExpr , Expr)
EXPR(IntegerLiteral , Expr)
@ -83,12 +82,12 @@ EXPR(SizeOfAlignOfExpr , Expr)
EXPR(ArraySubscriptExpr , Expr)
EXPR(CallExpr , Expr)
EXPR(MemberExpr , Expr)
EXPR(CastExpr , Expr)
ABSTRACT_EXPR(CastExpr , Expr)
EXPR(BinaryOperator , Expr)
EXPR(CompoundAssignOperator, BinaryOperator)
EXPR(ConditionalOperator , Expr)
EXPR(ImplicitCastExpr , CastExpr)
EXPR(ExplicitCastExpr , CastExpr)
ABSTRACT_EXPR(ExplicitCastExpr, CastExpr)
EXPR(CStyleCastExpr , ExplicitCastExpr)
EXPR(CompoundLiteralExpr , Expr)
EXPR(ExtVectorElementExpr , Expr)
@ -153,6 +152,7 @@ EXPR(ShuffleVectorExpr , Expr)
EXPR(BlockExpr , Expr)
EXPR(BlockDeclRefExpr , Expr)
FIRST_EXPR(PredefinedExpr)
LAST_EXPR(BlockDeclRefExpr)
#undef ABSTRACT_EXPR

View File

@ -105,6 +105,7 @@ public:
// Top switch stmt: dispatch to VisitFooStmt for each FooStmt.
switch (S->getStmtClass()) {
default: assert(0 && "Unknown stmt kind!");
#define ABSTRACT_EXPR(CLASS, PARENT)
#define STMT(CLASS, PARENT) \
case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS);
#include "clang/AST/StmtNodes.def"

View File

@ -22,7 +22,6 @@
PREVISIT(ArraySubscriptExpr, Stmt)
PREVISIT(BinaryOperator, Stmt)
PREVISIT(CallExpr, Stmt)
PREVISIT(CastExpr, Stmt)
PREVISIT(CXXOperatorCallExpr, CallExpr)
PREVISIT(DeclStmt, Stmt)
PREVISIT(ObjCMessageExpr, Stmt)

View File

@ -42,7 +42,6 @@ public:
return;
case Stmt::ImplicitCastExprClass:
case Stmt::ExplicitCastExprClass:
case Stmt::CStyleCastExprClass:
static_cast<ImplClass*>(this)->PreVisitCastExpr(C,
static_cast<const CastExpr*>(S));
@ -83,15 +82,17 @@ break;
void PreVisitStmt(CheckerContext &C, const Stmt *S) {}
void PostVisitStmt(CheckerContext &C, const Stmt *S) {}
void PreVisitCastExpr(CheckerContext &C, const CastExpr *E) {
static_cast<ImplClass*>(this)->PreVisitStmt(C, E);
}
#define PREVISIT(NAME, FALLBACK) \
void PreVisit ## NAME(CheckerContext &C, const NAME* S) {\
PreVisit ## FALLBACK(C, S);\
static_cast<ImplClass*>(this)->PreVisit ## FALLBACK(C, S);\
}
#include "clang/Checker/PathSensitive/CheckerVisitor.def"
#define POSTVISIT(NAME, FALLBACK) \
void PostVisit ## NAME(CheckerContext &C, const NAME* S) {\
PostVisit ## FALLBACK(C, S);\
static_cast<ImplClass*>(this)->PostVisit ## FALLBACK(C, S);\
}
#include "clang/Checker/PathSensitive/CheckerVisitor.def"
};

View File

@ -1616,7 +1616,6 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
case Expr::BlockExprClass:
case Expr::BlockDeclRefExprClass:
case Expr::NoStmtClass:
case Expr::ExprClass:
return ICEDiag(2, E->getLocStart());
case Expr::GNUNullExprClass:
@ -1812,9 +1811,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
}
}
}
case Expr::CastExprClass:
case Expr::ImplicitCastExprClass:
case Expr::ExplicitCastExprClass:
case Expr::CStyleCastExprClass:
case Expr::CXXFunctionalCastExprClass:
case Expr::CXXNamedCastExprClass:

View File

@ -35,6 +35,7 @@ static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
// Intialize the table on the first use.
Initialized = true;
#define ABSTRACT_EXPR(CLASS, PARENT)
#define STMT(CLASS, PARENT) \
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);

View File

@ -1070,7 +1070,24 @@ void CXXNameMangler::mangleExpression(const Expr *E) {
// ::= sZ <template-param> # size of a parameter pack
// ::= <expr-primary>
switch (E->getStmtClass()) {
default: assert(false && "Unhandled expression kind!");
default:
llvm_unreachable("unexpected statement kind");
break;
case Expr::CallExprClass:
// FIXME: implement
llvm_unreachable("mangling not implemented for calls");
break;
case Expr::CXXConstructExprClass:
// FIXME: implement
llvm_unreachable("mangling not implemented for construct exprs");
break;
case Expr::SizeOfAlignOfExprClass:
// FIXME: implement
llvm_unreachable("mangling not implemented for sizeof/alignof");
break;
case Expr::UnaryOperatorClass: {
const UnaryOperator *UO = cast<UnaryOperator>(E);

View File

@ -1684,6 +1684,7 @@ Sema::OwningStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
// Transform expressions by calling TransformExpr.
#define STMT(Node, Parent)
#define ABSTRACT_EXPR(Node, Parent)
#define EXPR(Node, Parent) case Stmt::Node##Class:
#include "clang/AST/StmtNodes.def"
{
@ -1707,6 +1708,7 @@ Sema::OwningExprResult TreeTransform<Derived>::TransformExpr(Expr *E) {
switch (E->getStmtClass()) {
case Stmt::NoStmtClass: break;
#define STMT(Node, Parent) case Stmt::Node##Class: break;
#define ABSTRACT_EXPR(Node, Parent)
#define EXPR(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
#include "clang/AST/StmtNodes.def"
@ -3827,13 +3829,6 @@ TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
FirstQualifierInScope);
}
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCastExpr(CastExpr *E) {
assert(false && "Cannot transform abstract class");
return SemaRef.Owned(E->Retain());
}
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
@ -3897,13 +3892,6 @@ TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
return getDerived().TransformExpr(E->getSubExprAsWritten());
}
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformExplicitCastExpr(ExplicitCastExpr *E) {
assert(false && "Cannot transform abstract class");
return SemaRef.Owned(E->Retain());
}
template<typename Derived>
Sema::OwningExprResult
TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {

View File

@ -115,7 +115,6 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) {
K = CXCursor_UnexposedStmt;
break;
case Stmt::ExprClass:
case Stmt::PredefinedExprClass:
case Stmt::IntegerLiteralClass:
case Stmt::FloatingLiteralClass:
@ -126,12 +125,10 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, ASTUnit *TU) {
case Stmt::UnaryOperatorClass:
case Stmt::SizeOfAlignOfExprClass:
case Stmt::ArraySubscriptExprClass:
case Stmt::CastExprClass:
case Stmt::BinaryOperatorClass:
case Stmt::CompoundAssignOperatorClass:
case Stmt::ConditionalOperatorClass:
case Stmt::ImplicitCastExprClass:
case Stmt::ExplicitCastExprClass:
case Stmt::CStyleCastExprClass:
case Stmt::CompoundLiteralExprClass:
case Stmt::ExtVectorElementExprClass: