[cfe-dev] Add new AST node

Pisit Makpaisit haoremixman at gmail.com
Sat Jul 31 19:59:21 PDT 2010


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<OmpStmt>;
def OmpBarrierStmt : DStmt<OmpStmt>;
def OmpCriticalStmt : DStmt<OmpStmt>;
def OmpFlushStmt : DStmt<OmpStmt>;
def OmpMasterStmt : DStmt<OmpStmt>;
def OmpOrderedStmt : DStmt<OmpStmt>;
def OmpParallelStmt : DStmt<OmpStmt>;
def OmpForStmt : DStmt<OmpStmt>;
def OmpSectionsStmt : DStmt<OmpStmt>;
def OmpSectionStmt : DStmt<OmpStmt>;
def OmpSingleStmt : DStmt<OmpStmt>;
def OmpTaskStmt : DStmt<OmpStmt>;
def OmpTaskwaitStmt : DStmt<OmpStmt>;
def OmpThreadprivateStmt : DStmt<OmpStmt>;

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 = <unnamed>::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
-- 
Remixman (Pisit Makpaisit)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100801/2ca37788/attachment.html>


More information about the cfe-dev mailing list