classof implementations for all classes
This commit is contained in:
8
Makefile
8
Makefile
@@ -196,7 +196,7 @@ YACC=bison -d -v -t
|
||||
|
||||
CXX_SRC=ast.cpp builtins.cpp cbackend.cpp ctx.cpp decl.cpp expr.cpp func.cpp \
|
||||
ispc.cpp llvmutil.cpp main.cpp module.cpp opt.cpp stmt.cpp sym.cpp \
|
||||
type.cpp util.cpp test_class_of.cpp
|
||||
type.cpp util.cpp
|
||||
HEADERS=ast.h builtins.h ctx.h decl.h expr.h func.h ispc.h llvmutil.h module.h \
|
||||
opt.h stmt.h sym.h type.h util.h
|
||||
TARGETS=avx2-i64x4 avx11-i64x4 avx1-i64x4 avx1 avx1-x2 avx11 avx11-x2 avx2 avx2-x2 \
|
||||
@@ -261,11 +261,7 @@ doxygen:
|
||||
|
||||
ispc: print_llvm_src dirs $(OBJS)
|
||||
@echo Creating ispc executable
|
||||
@$(CXX) $(OPT) $(LDFLAGS) -o $@ $(filter-out objs/test_class_of.o, $(OBJS)) $(ISPC_LIBS)
|
||||
|
||||
tcof: print_llvm_src dirs $(OBJS)
|
||||
@echo Creating test_class_of executable
|
||||
@$(CXX) $(OPT) $(LDFLAGS) -o tcof $(filter-out objs/main.o, $(OBJS)) $(ISPC_LIBS)
|
||||
@$(CXX) $(OPT) $(LDFLAGS) -o $@ $(OBJS) $(ISPC_LIBS)
|
||||
|
||||
# Use clang as a default compiler, instead of gcc
|
||||
# This is default now.
|
||||
|
||||
2
ast.h
2
ast.h
@@ -102,6 +102,8 @@ public:
|
||||
SyncExprID,
|
||||
TypeCastExprID,
|
||||
UnaryExprID,
|
||||
/* This is a convenience separator to shorten classof implementations */
|
||||
MaxExprID,
|
||||
/* For classes inherited from Stmt */
|
||||
AssertStmtID,
|
||||
BreakStmtID,
|
||||
|
||||
11
expr.cpp
11
expr.cpp
@@ -1112,7 +1112,6 @@ UnaryExpr::UnaryExpr(Op o, Expr *e, SourcePos p)
|
||||
expr = e;
|
||||
}
|
||||
|
||||
|
||||
llvm::Value *
|
||||
UnaryExpr::GetValue(FunctionEmitContext *ctx) const {
|
||||
if (expr == NULL)
|
||||
@@ -4725,6 +4724,11 @@ public:
|
||||
StructMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue);
|
||||
|
||||
static inline bool classof(StructMemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == StructMemberExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
int getElementNumber() const;
|
||||
@@ -4892,6 +4896,11 @@ public:
|
||||
VectorMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue);
|
||||
|
||||
static inline bool classof(VectorMemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == VectorMemberExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext* ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext* ctx) const;
|
||||
const Type *GetType() const;
|
||||
|
||||
117
expr.h
117
expr.h
@@ -49,6 +49,11 @@ class Expr : public ASTNode {
|
||||
public:
|
||||
Expr(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
|
||||
|
||||
static inline bool classof(Expr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() < MaxExprID;
|
||||
}
|
||||
|
||||
/** This is the main method for Expr implementations to implement. It
|
||||
should call methods in the FunctionEmitContext to emit LLVM IR
|
||||
instructions to the current basic block in order to generate an
|
||||
@@ -111,6 +116,11 @@ public:
|
||||
|
||||
UnaryExpr(Op op, Expr *expr, SourcePos pos);
|
||||
|
||||
static inline bool classof(UnaryExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == UnaryExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -152,7 +162,12 @@ public:
|
||||
};
|
||||
|
||||
BinaryExpr(Op o, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
|
||||
static inline bool classof(BinaryExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == BinaryExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -186,6 +201,11 @@ public:
|
||||
|
||||
AssignExpr(Op o, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
static inline bool classof(AssignExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AssignExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -207,6 +227,11 @@ class SelectExpr : public Expr {
|
||||
public:
|
||||
SelectExpr(Expr *test, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
static inline bool classof(SelectExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SelectExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -218,7 +243,6 @@ public:
|
||||
Expr *test, *expr1, *expr2;
|
||||
};
|
||||
|
||||
|
||||
/** @brief A list of expressions.
|
||||
|
||||
These are mostly used for representing curly-brace delimited
|
||||
@@ -230,6 +254,11 @@ public:
|
||||
ExprList(SourcePos p) : Expr(p, ExprListID) { }
|
||||
ExprList(Expr *e, SourcePos p) : Expr(p, ExprListID) { exprs.push_back(e); }
|
||||
|
||||
static inline bool classof(ExprList const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ExprListID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -250,6 +279,11 @@ public:
|
||||
bool isLaunch = false,
|
||||
Expr *launchCountExpr[3] = NULL);
|
||||
|
||||
static inline bool classof(FunctionCallExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == FunctionCallExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -276,6 +310,11 @@ class IndexExpr : public Expr {
|
||||
public:
|
||||
IndexExpr(Expr *baseExpr, Expr *index, SourcePos p);
|
||||
|
||||
static inline bool classof(IndexExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == IndexExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -304,6 +343,13 @@ public:
|
||||
static MemberExpr *create(Expr *expr, const char *identifier,
|
||||
SourcePos pos, SourcePos identifierPos,
|
||||
bool derefLvalue);
|
||||
|
||||
static inline bool classof(MemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return ((N->getValueID() == StructMemberExprID) ||
|
||||
(N->getValueID() == VectorMemberExprID));
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -402,6 +448,11 @@ public:
|
||||
but at the given position. */
|
||||
ConstExpr(ConstExpr *old, SourcePos pos);
|
||||
|
||||
static inline bool classof(ConstExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ConstExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -459,6 +510,11 @@ class TypeCastExpr : public Expr {
|
||||
public:
|
||||
TypeCastExpr(const Type *t, Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(TypeCastExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == TypeCastExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -481,6 +537,11 @@ class ReferenceExpr : public Expr {
|
||||
public:
|
||||
ReferenceExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(ReferenceExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ReferenceExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -500,6 +561,13 @@ class DerefExpr : public Expr {
|
||||
public:
|
||||
DerefExpr(Expr *e, SourcePos p, unsigned scid = DerefExprID);
|
||||
|
||||
static inline bool classof(DerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return ((N->getValueID() == DerefExprID) ||
|
||||
(N->getValueID() == PtrDerefExprID) ||
|
||||
(N->getValueID() == RefDerefExprID));
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -516,6 +584,11 @@ class PtrDerefExpr : public DerefExpr {
|
||||
public:
|
||||
PtrDerefExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(PtrDerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == PtrDerefExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -529,6 +602,11 @@ class RefDerefExpr : public DerefExpr {
|
||||
public:
|
||||
RefDerefExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(RefDerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == RefDerefExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -541,6 +619,11 @@ class AddressOfExpr : public Expr {
|
||||
public:
|
||||
AddressOfExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(AddressOfExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AddressOfExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -562,6 +645,11 @@ public:
|
||||
SizeOfExpr(Expr *e, SourcePos p);
|
||||
SizeOfExpr(const Type *t, SourcePos p);
|
||||
|
||||
static inline bool classof(SizeOfExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SizeOfExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -581,6 +669,11 @@ class SymbolExpr : public Expr {
|
||||
public:
|
||||
SymbolExpr(Symbol *s, SourcePos p);
|
||||
|
||||
static inline bool classof(SymbolExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SymbolExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -604,6 +697,11 @@ public:
|
||||
FunctionSymbolExpr(const char *name, const std::vector<Symbol *> &candFuncs,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(FunctionSymbolExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == FunctionSymbolExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Symbol *GetBaseSymbol() const;
|
||||
@@ -660,6 +758,11 @@ class SyncExpr : public Expr {
|
||||
public:
|
||||
SyncExpr(SourcePos p) : Expr(p, SyncExprID) { }
|
||||
|
||||
static inline bool classof(SyncExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SyncExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -674,6 +777,11 @@ class NullPointerExpr : public Expr {
|
||||
public:
|
||||
NullPointerExpr(SourcePos p) : Expr(p, NullPointerExprID) { }
|
||||
|
||||
static inline bool classof(NullPointerExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == NullPointerExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -692,6 +800,11 @@ public:
|
||||
NewExpr(int typeQual, const Type *type, Expr *initializer, Expr *count,
|
||||
SourcePos tqPos, SourcePos p);
|
||||
|
||||
static inline bool classof(NewExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == NewExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Expr *TypeCheck();
|
||||
|
||||
110
stmt.h
110
stmt.h
@@ -50,6 +50,11 @@ class Stmt : public ASTNode {
|
||||
public:
|
||||
Stmt(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
|
||||
|
||||
static inline bool classof(Stmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() > MaxExprID;
|
||||
}
|
||||
|
||||
/** Emit LLVM IR for the statement, using the FunctionEmitContext to create the
|
||||
necessary instructions.
|
||||
*/
|
||||
@@ -73,6 +78,11 @@ class ExprStmt : public Stmt {
|
||||
public:
|
||||
ExprStmt(Expr *expr, SourcePos pos);
|
||||
|
||||
static inline bool classof(ExprStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ExprStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -97,6 +107,11 @@ class DeclStmt : public Stmt {
|
||||
public:
|
||||
DeclStmt(const std::vector<VariableDeclaration> &v, SourcePos pos);
|
||||
|
||||
static inline bool classof(DeclStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DeclStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -115,6 +130,11 @@ public:
|
||||
IfStmt(Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts,
|
||||
bool doAllCheck, SourcePos pos);
|
||||
|
||||
static inline bool classof(IfStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == IfStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -155,6 +175,11 @@ public:
|
||||
DoStmt(Expr *testExpr, Stmt *bodyStmts, bool doCoherentCheck,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(DoStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DoStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -175,6 +200,11 @@ public:
|
||||
ForStmt(Stmt *initializer, Expr *testExpr, Stmt *stepStatements,
|
||||
Stmt *bodyStatements, bool doCoherentCheck, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -201,6 +231,11 @@ class BreakStmt : public Stmt {
|
||||
public:
|
||||
BreakStmt(SourcePos pos);
|
||||
|
||||
static inline bool classof(BreakStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == BreakStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -215,6 +250,11 @@ class ContinueStmt : public Stmt {
|
||||
public:
|
||||
ContinueStmt(SourcePos pos);
|
||||
|
||||
static inline bool classof(ContinueStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ContinueStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -232,6 +272,11 @@ public:
|
||||
const std::vector<Expr *> &endExprs,
|
||||
Stmt *bodyStatements, bool tiled, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -252,6 +297,11 @@ class ForeachActiveStmt : public Stmt {
|
||||
public:
|
||||
ForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachActiveStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachActiveStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -271,6 +321,11 @@ public:
|
||||
ForeachUniqueStmt(const char *iterName, Expr *expr, Stmt *stmts,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachUniqueStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachUniqueStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -289,6 +344,11 @@ class UnmaskedStmt : public Stmt {
|
||||
public:
|
||||
UnmaskedStmt(Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(UnmaskedStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == UnmaskedStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -306,6 +366,11 @@ class ReturnStmt : public Stmt {
|
||||
public:
|
||||
ReturnStmt(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(ReturnStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ReturnStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -323,6 +388,11 @@ class CaseStmt : public Stmt {
|
||||
public:
|
||||
CaseStmt(int value, Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(CaseStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == CaseStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -341,6 +411,11 @@ class DefaultStmt : public Stmt {
|
||||
public:
|
||||
DefaultStmt(Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(DefaultStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DefaultStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -356,6 +431,11 @@ class SwitchStmt : public Stmt {
|
||||
public:
|
||||
SwitchStmt(Expr *expr, Stmt *stmts, SourcePos pos);
|
||||
|
||||
static inline bool classof(SwitchStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SwitchStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -374,6 +454,11 @@ class GotoStmt : public Stmt {
|
||||
public:
|
||||
GotoStmt(const char *label, SourcePos gotoPos, SourcePos idPos);
|
||||
|
||||
static inline bool classof(GotoStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == GotoStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -393,6 +478,11 @@ class LabeledStmt : public Stmt {
|
||||
public:
|
||||
LabeledStmt(const char *label, Stmt *stmt, SourcePos p);
|
||||
|
||||
static inline bool classof(LabeledStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == LabeledStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -413,6 +503,11 @@ class StmtList : public Stmt {
|
||||
public:
|
||||
StmtList(SourcePos p) : Stmt(p, StmtListID) { }
|
||||
|
||||
static inline bool classof(StmtList const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == StmtListID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -438,6 +533,11 @@ class PrintStmt : public Stmt {
|
||||
public:
|
||||
PrintStmt(const std::string &f, Expr *v, SourcePos p);
|
||||
|
||||
static inline bool classof(PrintStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == PrintStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -464,6 +564,11 @@ class AssertStmt : public Stmt {
|
||||
public:
|
||||
AssertStmt(const std::string &msg, Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(AssertStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AssertStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -483,6 +588,11 @@ class DeleteStmt : public Stmt {
|
||||
public:
|
||||
DeleteStmt(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(DeleteStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DeleteStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "ispc.h"
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
};
|
||||
6
type.cpp
6
type.cpp
@@ -1603,7 +1603,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
if (at == NULL)
|
||||
return type;
|
||||
|
||||
ExprList *exprList = llvm::dyn_cast<ExprList>(initExpr);
|
||||
ExprList *exprList = llvm::dyn_cast_or_null<ExprList>(initExpr);
|
||||
if (exprList == NULL || exprList->exprs.size() == 0)
|
||||
return type;
|
||||
|
||||
@@ -1618,7 +1618,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
// now. Otherwise we'll use the first one to size the next dimension
|
||||
// (after checking below that it has the same length as all of the
|
||||
// other ones.
|
||||
ExprList *nextList = llvm::dyn_cast<ExprList>(exprList->exprs[0]);
|
||||
ExprList *nextList = llvm::dyn_cast_or_null<ExprList>(exprList->exprs[0]);
|
||||
if (nextList == NULL)
|
||||
return type;
|
||||
|
||||
@@ -1638,7 +1638,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExprList *el = llvm::dyn_cast<ExprList>(exprList->exprs[i]);
|
||||
ExprList *el = llvm::dyn_cast_or_null<ExprList>(exprList->exprs[i]);
|
||||
if (el == NULL || el->exprs.size() != nextSize) {
|
||||
Error(Union(exprList->exprs[0]->pos, exprList->exprs[i]->pos),
|
||||
"Inconsistent initializer expression list lengths "
|
||||
|
||||
Reference in New Issue
Block a user