[cfe-dev] Add new AST node

Sean Hunt rideau3 at gmail.com
Sat Jul 31 20:12:55 PDT 2010


On 07/31/2010 08:59 PM, Pisit Makpaisit wrote:
> 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?

Did you make the OmpStmt class inherit from Stmt?

Sean



More information about the cfe-dev mailing list