Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributes

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103072 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Hunt 2010-05-05 04:13:52 +00:00
Родитель 28a43a4361
Коммит 9d90d62e16
14 изменённых файлов: 643 добавлений и 668 удалений

Просмотреть файл

@ -1468,13 +1468,10 @@ public:
}
static bool classof(const Stmt *T) {
return T->getStmtClass() == CallExprClass ||
T->getStmtClass() == CXXOperatorCallExprClass ||
T->getStmtClass() == CXXMemberCallExprClass;
return T->getStmtClass() >= firstCallExprConstant &&
T->getStmtClass() <= lastCallExprConstant;
}
static bool classof(const CallExpr *) { return true; }
static bool classof(const CXXOperatorCallExpr *) { return true; }
static bool classof(const CXXMemberCallExpr *) { return true; }
// Iterators
virtual child_iterator child_begin();
@ -1933,14 +1930,8 @@ public:
const CXXBaseSpecifierArray& getBasePath() const { return BasePath; }
static bool classof(const Stmt *T) {
StmtClass SC = T->getStmtClass();
if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass)
return true;
if (SC >= ImplicitCastExprClass && SC <= CStyleCastExprClass)
return true;
return false;
return T->getStmtClass() >= firstCastExprConstant &&
T->getStmtClass() <= lastCastExprConstant;
}
static bool classof(const CastExpr *) { return true; }
@ -2037,13 +2028,8 @@ public:
QualType getTypeAsWritten() const { return TInfo->getType(); }
static bool classof(const Stmt *T) {
StmtClass SC = T->getStmtClass();
if (SC >= CStyleCastExprClass && SC <= CStyleCastExprClass)
return true;
if (SC >= CXXStaticCastExprClass && SC <= CXXFunctionalCastExprClass)
return true;
return false;
return T->getStmtClass() >= firstExplicitCastExprConstant &&
T->getStmtClass() <= lastExplicitCastExprConstant;
}
static bool classof(const ExplicitCastExpr *) { return true; }
};
@ -2198,8 +2184,8 @@ public:
bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; }
static bool classof(const Stmt *S) {
return S->getStmtClass() == BinaryOperatorClass ||
S->getStmtClass() == CompoundAssignOperatorClass;
return S->getStmtClass() >= firstBinaryOperatorConstant &&
S->getStmtClass() <= lastBinaryOperatorConstant;
}
static bool classof(const BinaryOperator *) { return true; }

Просмотреть файл

@ -0,0 +1,13 @@
LEVEL = ../../../../..
BUILT_SOURCES = StmtNodes.inc
TABLEGEN_INC_FILES_COMMON = 1
include $(LEVEL)/Makefile.common
INPUT_TDS = $(PROJ_SRC_DIR)/StmtNodes.td
$(ObjDir)/StmtNodes.inc.tmp : StmtNodes.td $(TBLGEN) $(ObjDir)/.dir
$(Echo) "Building Clang statement node tables with tblgen"
$(Verb) $(TableGen) -gen-clang-stmt-nodes -o $(call SYSPATH, $@) $<

Просмотреть файл

@ -99,11 +99,24 @@ public:
NoStmtClass = 0,
#define STMT(CLASS, PARENT) CLASS##Class,
#define FIRST_STMT(CLASS) firstStmtConstant = CLASS##Class,
#define LAST_STMT(CLASS) lastStmtConstant = CLASS##Class,
// LAST_STMT will always come last
#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"
#define LAST_EXPR(CLASS) lastExprConstant = CLASS##Class,
#define FIRST_CALLEXPR(CLASS) firstCallExprConstant = CLASS##Class,
#define LAST_CALLEXPR(CLASS) lastCallExprConstant = CLASS##Class,
#define FIRST_CASTEXPR(CLASS) firstCastExprConstant = CLASS##Class,
#define LAST_CASTEXPR(CLASS) lastCastExprConstant = CLASS##Class,
#define FIRST_EXPLICITCASTEXPR(CLASS) firstExplicitCastExprConstant = \
CLASS##Class,
#define LAST_EXPLICITCASTEXPR(CLASS) lastExplicitCastExprConstant = \
CLASS##Class,
#define FIRST_BINARYOPERATOR(CLASS) firstBinaryOperatorConstant = \
CLASS##Class,
#define LAST_BINARYOPERATOR(CLASS) lastBinaryOperatorConstant = \
CLASS##Class,
#define ABSTRACT(STMT)
#include "clang/AST/StmtNodes.inc"
};
private:
/// \brief The statement class.

Просмотреть файл

@ -1,165 +0,0 @@
//===-- StmtNodes.def - Metadata about Stmt AST nodes -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the AST Node info database.
//
//===---------------------------------------------------------------------===//
#ifndef FIRST_STMT
#define FIRST_STMT(CLASS)
#define LAST_STMT(CLASS)
#endif
#ifndef FIRST_EXPR
#define FIRST_EXPR(CLASS)
#define LAST_EXPR(CLASS)
#endif
#ifndef EXPR
# define EXPR(Type, Base) STMT(Type, Base)
#endif
#ifndef ABSTRACT_EXPR
# define ABSTRACT_EXPR(Type, Base) EXPR(Type, Base)
#endif
// Normal Statements.
STMT(NullStmt , Stmt)
FIRST_STMT(NullStmt)
STMT(CompoundStmt , Stmt)
STMT(CaseStmt , SwitchCase)
STMT(DefaultStmt , SwitchCase)
STMT(LabelStmt , Stmt)
STMT(IfStmt , Stmt)
STMT(SwitchStmt , Stmt)
STMT(WhileStmt , Stmt)
STMT(DoStmt , Stmt)
STMT(ForStmt , Stmt)
STMT(GotoStmt , Stmt)
STMT(IndirectGotoStmt, Stmt)
STMT(ContinueStmt , Stmt)
STMT(BreakStmt , Stmt)
STMT(ReturnStmt , Stmt)
STMT(DeclStmt , Stmt)
STMT(SwitchCase , Stmt)
// GNU Stmt Extensions
STMT(AsmStmt , Stmt)
// Obj-C statements
STMT(ObjCAtTryStmt , Stmt)
STMT(ObjCAtCatchStmt , Stmt)
STMT(ObjCAtFinallyStmt , Stmt)
STMT(ObjCAtThrowStmt , Stmt)
STMT(ObjCAtSynchronizedStmt , Stmt)
// Obj-C2 statements
STMT(ObjCForCollectionStmt, Stmt)
// C++ statements
STMT(CXXCatchStmt, Stmt)
STMT(CXXTryStmt , Stmt)
LAST_STMT(CXXTryStmt)
// Expressions.
ABSTRACT_EXPR(Expr , Stmt)
EXPR(PredefinedExpr , Expr)
EXPR(DeclRefExpr , Expr)
EXPR(IntegerLiteral , Expr)
EXPR(FloatingLiteral , Expr)
EXPR(ImaginaryLiteral , Expr)
EXPR(StringLiteral , Expr)
EXPR(CharacterLiteral , Expr)
EXPR(ParenExpr , Expr)
EXPR(UnaryOperator , Expr)
EXPR(OffsetOfExpr , Expr)
EXPR(SizeOfAlignOfExpr , Expr)
EXPR(ArraySubscriptExpr , Expr)
EXPR(CallExpr , Expr)
EXPR(MemberExpr , Expr)
ABSTRACT_EXPR(CastExpr , Expr)
EXPR(BinaryOperator , Expr)
EXPR(CompoundAssignOperator, BinaryOperator)
EXPR(ConditionalOperator , Expr)
EXPR(ImplicitCastExpr , CastExpr)
ABSTRACT_EXPR(ExplicitCastExpr, CastExpr)
EXPR(CStyleCastExpr , ExplicitCastExpr)
EXPR(CompoundLiteralExpr , Expr)
EXPR(ExtVectorElementExpr , Expr)
EXPR(InitListExpr , Expr)
EXPR(DesignatedInitExpr , Expr)
EXPR(ImplicitValueInitExpr , Expr)
EXPR(ParenListExpr , Expr)
EXPR(VAArgExpr , Expr)
// GNU Extensions.
EXPR(AddrLabelExpr , Expr)
EXPR(StmtExpr , Expr)
EXPR(TypesCompatibleExpr , Expr)
EXPR(ChooseExpr , Expr)
EXPR(GNUNullExpr , Expr)
// C++ Expressions.
EXPR(CXXOperatorCallExpr , CallExpr)
EXPR(CXXMemberCallExpr , CallExpr)
ABSTRACT_EXPR(CXXNamedCastExpr , ExplicitCastExpr)
EXPR(CXXStaticCastExpr , CXXNamedCastExpr)
EXPR(CXXDynamicCastExpr , CXXNamedCastExpr)
EXPR(CXXReinterpretCastExpr , CXXNamedCastExpr)
EXPR(CXXConstCastExpr , CXXNamedCastExpr)
EXPR(CXXFunctionalCastExpr , ExplicitCastExpr)
EXPR(CXXTypeidExpr , Expr)
EXPR(CXXBoolLiteralExpr , Expr)
EXPR(CXXNullPtrLiteralExpr , Expr)
EXPR(CXXThisExpr , Expr)
EXPR(CXXThrowExpr , Expr)
EXPR(CXXDefaultArgExpr , Expr)
EXPR(CXXZeroInitValueExpr , Expr)
EXPR(CXXNewExpr , Expr)
EXPR(CXXDeleteExpr , Expr)
EXPR(CXXPseudoDestructorExpr, Expr)
EXPR(UnresolvedLookupExpr , Expr)
EXPR(UnaryTypeTraitExpr , Expr)
EXPR(DependentScopeDeclRefExpr , Expr)
EXPR(CXXConstructExpr , Expr)
EXPR(CXXBindTemporaryExpr , Expr)
EXPR(CXXBindReferenceExpr , Expr)
EXPR(CXXExprWithTemporaries , Expr)
EXPR(CXXTemporaryObjectExpr , CXXConstructExpr)
EXPR(CXXUnresolvedConstructExpr, Expr)
EXPR(CXXDependentScopeMemberExpr, Expr)
EXPR(UnresolvedMemberExpr , Expr)
// Obj-C Expressions.
EXPR(ObjCStringLiteral , Expr)
EXPR(ObjCEncodeExpr , Expr)
EXPR(ObjCMessageExpr , Expr)
EXPR(ObjCSelectorExpr , Expr)
EXPR(ObjCProtocolExpr , Expr)
EXPR(ObjCIvarRefExpr , Expr)
EXPR(ObjCPropertyRefExpr , Expr)
EXPR(ObjCImplicitSetterGetterRefExpr , Expr)
EXPR(ObjCSuperExpr , Expr)
EXPR(ObjCIsaExpr , Expr)
// Clang Extensions.
EXPR(ShuffleVectorExpr , Expr)
EXPR(BlockExpr , Expr)
EXPR(BlockDeclRefExpr , Expr)
FIRST_EXPR(PredefinedExpr)
LAST_EXPR(BlockDeclRefExpr)
#undef ABSTRACT_EXPR
#undef EXPR
#undef STMT
#undef FIRST_STMT
#undef LAST_STMT
#undef FIRST_EXPR
#undef LAST_EXPR

Просмотреть файл

@ -0,0 +1,127 @@
class Stmt<bit abstract = 0> {
bit Abstract = abstract;
}
class DStmt<Stmt base, bit abstract = 0> : Stmt<abstract> {
Stmt Base = base;
}
// Statements
def NullStmt : Stmt;
def CompoundStmt : Stmt;
def LabelStmt : Stmt;
def IfStmt : Stmt;
def SwitchStmt : Stmt;
def WhileStmt : Stmt;
def DoStmt : Stmt;
def ForStmt : Stmt;
def GotoStmt : Stmt;
def IndirectGotoStmt : Stmt;
def ContinueStmt : Stmt;
def BreakStmt : Stmt;
def ReturnStmt : Stmt;
def DeclStmt : Stmt;
def SwitchCase : Stmt;
def CaseStmt : DStmt<SwitchCase>;
def DefaultStmt : DStmt<SwitchCase>;
// GNU Extensions
def AsmStmt : Stmt;
// Obj-C statements
def ObjCAtTryStmt : Stmt;
def ObjCAtCatchStmt : Stmt;
def ObjCAtFinallyStmt : Stmt;
def ObjCAtThrowStmt : Stmt;
def ObjCAtSynchronizedStmt : Stmt;
def ObjCForCollectionStmt : Stmt;
// C++ statments
def CXXCatchStmt : Stmt;
def CXXTryStmt : Stmt;
// Expressions
def Expr : Stmt<1>;
def PredefinedExpr : DStmt<Expr>;
def DeclRefExpr : DStmt<Expr>;
def IntegerLiteral : DStmt<Expr>;
def FloatingLiteral : DStmt<Expr>;
def ImaginaryLiteral : DStmt<Expr>;
def StringLiteral : DStmt<Expr>;
def CharacterLiteral : DStmt<Expr>;
def ParenExpr : DStmt<Expr>;
def UnaryOperator : DStmt<Expr>;
def OffsetOfExpr : DStmt<Expr>;
def SizeOfAlignOfExpr : DStmt<Expr>;
def ArraySubscriptExpr : DStmt<Expr>;
def CallExpr : DStmt<Expr>;
def MemberExpr : DStmt<Expr>;
def CastExpr : DStmt<Expr, 1>;
def BinaryOperator : DStmt<Expr>;
def CompoundAssignOperator : DStmt<BinaryOperator>;
def ConditionalOperator : DStmt<Expr>;
def ImplicitCastExpr : DStmt<CastExpr>;
def ExplicitCastExpr : DStmt<CastExpr, 1>;
def CStyleCastExpr : DStmt<ExplicitCastExpr>;
def CompoundLiteralExpr : DStmt<Expr>;
def ExtVectorElementExpr : DStmt<Expr>;
def InitListExpr : DStmt<Expr>;
def DesignatedInitExpr : DStmt<Expr>;
def ImplicitValueInitExpr : DStmt<Expr>;
def ParenListExpr : DStmt<Expr>;
def VAArgExpr : DStmt<Expr>;
// GNU Extensions.
def AddrLabelExpr : DStmt<Expr>;
def StmtExpr : DStmt<Expr>;
def TypesCompatibleExpr : DStmt<Expr>;
def ChooseExpr : DStmt<Expr>;
def GNUNullExpr : DStmt<Expr>;
// C++ Expressions.
def CXXOperatorCallExpr : DStmt<CallExpr>;
def CXXMemberCallExpr : DStmt<CallExpr>;
def CXXNamedCastExpr : DStmt<ExplicitCastExpr, 1>;
def CXXStaticCastExpr : DStmt<CXXNamedCastExpr>;
def CXXDynamicCastExpr : DStmt<CXXNamedCastExpr>;
def CXXReinterpretCastExpr : DStmt<CXXNamedCastExpr>;
def CXXConstCastExpr : DStmt<CXXNamedCastExpr>;
def CXXFunctionalCastExpr : DStmt<ExplicitCastExpr>;
def CXXTypeidExpr : DStmt<Expr>;
def CXXBoolLiteralExpr : DStmt<Expr>;
def CXXNullPtrLiteralExpr : DStmt<Expr>;
def CXXThisExpr : DStmt<Expr>;
def CXXThrowExpr : DStmt<Expr>;
def CXXDefaultArgExpr : DStmt<Expr>;
def CXXZeroInitValueExpr : DStmt<Expr>;
def CXXNewExpr : DStmt<Expr>;
def CXXDeleteExpr : DStmt<Expr>;
def CXXPseudoDestructorExpr : DStmt<Expr>;
def UnresolvedLookupExpr : DStmt<Expr>;
def UnaryTypeTraitExpr : DStmt<Expr>;
def DependentScopeDeclRefExpr : DStmt<Expr>;
def CXXConstructExpr : DStmt<Expr>;
def CXXBindTemporaryExpr : DStmt<Expr>;
def CXXBindReferenceExpr : DStmt<Expr>;
def CXXExprWithTemporaries : DStmt<Expr>;
def CXXTemporaryObjectExpr : DStmt<CXXConstructExpr>;
def CXXUnresolvedConstructExpr : DStmt<Expr>;
def CXXDependentScopeMemberExpr : DStmt<Expr>;
def UnresolvedMemberExpr : DStmt<Expr>;
// Obj-C Expressions.
def ObjCStringLiteral : DStmt<Expr>;
def ObjCEncodeExpr : DStmt<Expr>;
def ObjCMessageExpr : DStmt<Expr>;
def ObjCSelectorExpr : DStmt<Expr>;
def ObjCProtocolExpr : DStmt<Expr>;
def ObjCIvarRefExpr : DStmt<Expr>;
def ObjCPropertyRefExpr : DStmt<Expr>;
def ObjCImplicitSetterGetterRefExpr : DStmt<Expr>;
def ObjCSuperExpr : DStmt<Expr>;
def ObjCIsaExpr : DStmt<Expr>;
// Clang Extensions.
def ShuffleVectorExpr : DStmt<Expr>;
def BlockExpr : DStmt<Expr>;
def BlockDeclRefExpr : DStmt<Expr>;

Просмотреть файл

@ -105,10 +105,10 @@ 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 ABSTRACT(STMT)
#define STMT(CLASS, PARENT) \
case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS);
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
}
}
@ -116,7 +116,7 @@ public:
// back on VisitExpr or whatever else is the superclass.
#define STMT(CLASS, PARENT) \
RetTy Visit ## CLASS(CLASS *S) { DISPATCH(PARENT, PARENT); }
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
// If the implementation doesn't implement binary operator methods, fall back
// on VisitBinaryOperator.

Просмотреть файл

@ -1,2 +1,3 @@
add_subdirectory(AST)
add_subdirectory(Basic)
add_subdirectory(Driver)

Просмотреть файл

@ -1,5 +1,5 @@
LEVEL = ../../../..
DIRS := Basic Driver
DIRS := AST Basic Driver
include $(LEVEL)/Makefile.common

Просмотреть файл

@ -1810,7 +1810,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
switch (E->getStmtClass()) {
#define STMT(Node, Base) case Expr::Node##Class:
#define EXPR(Node, Base)
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
case Expr::PredefinedExprClass:
case Expr::FloatingLiteralClass:
case Expr::ImaginaryLiteralClass:

Просмотреть файл

@ -27,7 +27,7 @@ static struct StmtClassNameTable {
const char *Name;
unsigned Counter;
unsigned Size;
} StmtClassInfo[Stmt::lastExprConstant+1];
} StmtClassInfo[Stmt::lastStmtConstant+1];
static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
static bool Initialized = false;
@ -36,11 +36,11 @@ static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {
// Intialize the table on the first use.
Initialized = true;
#define ABSTRACT_EXPR(CLASS, PARENT)
#define ABSTRACT(STMT)
#define STMT(CLASS, PARENT) \
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Name = #CLASS; \
StmtClassInfo[(unsigned)Stmt::CLASS##Class].Size = sizeof(CLASS);
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
return StmtClassInfo[E];
}
@ -55,13 +55,13 @@ void Stmt::PrintStats() {
unsigned sum = 0;
fprintf(stderr, "*** Stmt/Expr Stats:\n");
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
if (StmtClassInfo[i].Name == 0) continue;
sum += StmtClassInfo[i].Counter;
}
fprintf(stderr, " %d stmts/exprs total.\n", sum);
sum = 0;
for (int i = 0; i != Stmt::lastExprConstant+1; i++) {
for (int i = 0; i != Stmt::lastStmtConstant+1; i++) {
if (StmtClassInfo[i].Name == 0) continue;
if (StmtClassInfo[i].Counter == 0) continue;
fprintf(stderr, " %d %s, %d each (%d bytes)\n",

Просмотреть файл

@ -89,7 +89,7 @@ namespace {
void VisitStmt(Stmt *Node);
#define STMT(CLASS, PARENT) \
void Visit##CLASS(CLASS *Node);
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
};
}

Просмотреть файл

@ -36,7 +36,7 @@ namespace {
void VisitStmt(Stmt *S);
#define STMT(Node, Base) void Visit##Node(Node *S);
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
/// \brief Visit a declaration that is referenced within an expression
/// or statement.

Просмотреть файл

@ -1369,7 +1369,7 @@ void CXXNameMangler::mangleExpression(const Expr *E) {
#define EXPR(Type, Base)
#define STMT(Type, Base) \
case Expr::Type##Class:
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
llvm_unreachable("unexpected statement kind");
break;

Просмотреть файл

@ -344,8 +344,8 @@ public:
OwningStmtResult Transform##Node(Node *S);
#define EXPR(Node, Parent) \
OwningExprResult Transform##Node(Node *E);
#define ABSTRACT_EXPR(Node, Parent)
#include "clang/AST/StmtNodes.def"
#define ABSTRACT(Stmt)
#include "clang/AST/StmtNodes.inc"
/// \brief Build a new pointer type given its pointee type.
///
@ -1966,13 +1966,13 @@ Sema::OwningStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
#define STMT(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
#define EXPR(Node, Parent)
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
// Transform expressions by calling TransformExpr.
#define STMT(Node, Parent)
#define ABSTRACT_EXPR(Node, Parent)
#define ABSTRACT(Stmt)
#define EXPR(Node, Parent) case Stmt::Node##Class:
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
{
Sema::OwningExprResult E = getDerived().TransformExpr(cast<Expr>(S));
if (E.isInvalid())
@ -1994,10 +1994,10 @@ 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 ABSTRACT(Stmt)
#define EXPR(Node, Parent) \
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
#include "clang/AST/StmtNodes.def"
#include "clang/AST/StmtNodes.inc"
}
return SemaRef.Owned(E->Retain());