Add new AST node

I want to add the AST node for OpenMP statement. I create OmpStmt class that inherit from Stmt class and add the definition in StmtNodes.td as follow

def OmpStmt : Stmt<1>;
def OmpAtomicStmt : DStmt;
def OmpBarrierStmt : DStmt;
def OmpCriticalStmt : DStmt;
def OmpFlushStmt : DStmt;
def OmpMasterStmt : DStmt;
def OmpOrderedStmt : DStmt;
def OmpParallelStmt : DStmt;
def OmpForStmt : DStmt;
def OmpSectionsStmt : DStmt;
def OmpSectionStmt : DStmt;
def OmpSingleStmt : DStmt;
def OmpTaskStmt : DStmt;
def OmpTaskwaitStmt : DStmt;
def OmpThreadprivateStmt : DStmt;

when I build project, it show error like

In file included from /home/remixman/Desktop/llvm/tools/clang/lib/AST/…/…/include/clang/AST/StmtVisitor.h:111,
from ASTImporter.cpp:21:
/home/remixman/Desktop/llvm/tools/clang/lib/AST/…/…/include/clang/AST/StmtNodes.inc: In member function ‘RetTy clang::StmtVisitor<ImplClass, RetTy>::Visit(clang::Stmt*) [with ImplClass = ::ASTNodeImporter, RetTy = clang::Stmt*]’:
ASTImporter.cpp:3045: instantiated from here
/home/remixman/Desktop/llvm/tools/clang/lib/AST/…/…/include/clang/AST/StmtNodes.inc:617: error: invalid static_cast from type ‘clang::Stmt*’ to type ‘clang::OmpAtomicStmt*’
/home/remixman/Desktop/llvm/tools/clang/lib/AST/…/…/include/clang/AST/StmtNodes.inc:623: error: invalid static_cast from type ‘clang::Stmt*’ to type ‘clang::OmpBarrierStmt*’
/home/remixman/Desktop/llvm/tools/clang/lib/AST/…/…/include/clang/AST/StmtNodes.inc:629: error: invalid static_cast from type ‘clang::Stmt*’ to type ‘clang::OmpCriticalStmt*’

OmpAtomicStmt and other OpenMP Stmt class is inherit from OmpStmt. Why the error show that? How can I fixed?

Thanks in advance

Did you make the OmpStmt class inherit from Stmt?

Sean

Yes, OmpStmt inherit from Stmt and other omp stmt inherit from OmpStmt.