I had to verify that it really worked for me before I did reply...<br>Here are the steps:<br><br>1 - Define the new node accordingly in the file<br><div style="margin-left: 40px;"><i>CLANG_DIR</i>/include/clang/Basic/DeclNodes.td<br>
e.g. <b>def Concept : DDecl<Template>, DeclContext;</b><br><br></div>2 - Implement a class for the corresponding declaration, <br><div style="margin-left: 40px;">specifying <b>Concept</b> as the declaration's kind.<br>
e.g. <br><b>class ConceptDecl : public TemplateDecl, public DeclContext {<br></b><div style="margin-left: 40px;"><b>...<br></b></div><div style="margin-left: 40px;"><b>ConceptDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, <br>
</b></div><b>                                TemplateParameterList *ParamList,  ...)<br></b><div style="margin-left: 40px;"><b>: TemplateDecl(Concept, DC, L, Id, ParamList), DeclContext(Concept), ... { }<br>...<br></b></div>
<b>}</b><br></div><br>3 - Verify that the appropriate Visit*() and Visit*Decl() methods <br><div style="margin-left: 40px;">are implemented for every class that inherits from the DeclVisitor Class.<br>e.g. ASTImporter, DeclPrinter, ASTReaderDecl, ASTWriterDecl, RecursiveASTVisitor, etc... <br>
<br>At the very least, allow the declaration to adopt the default behavior... <br>Foremost, update your included libraries appropriately (making sure that <b>ConceptDecl</b> is visible within those files).<br><br>If anything was forgotten, the generated clang compilation errors should indicate which file needs to be updated...<br>
<br></div>4 - There a few other minor hick-ups which one should be able to figure out from observing other implementations, such as<br><div style="margin-left: 40px;">adding block of codes such as these to the implementation of the ConceptDecl class.<br>
<br><b>        // Implement isa/cast/dyncast/etc.<br>        static bool classof(const Decl *D) { return classofKind(D->getKind()); }<br>        static bool classof(const ConceptDecl *D) { return true; }<br>        static bool classofKind(Kind K) { return K == Concept; }<br>
        static DeclContext *castToDeclContext(const ConceptDecl *D) {<br>            return static_cast<DeclContext *>(const_cast<ConceptDecl*>(D));<br>        }<br>        static ConceptDecl *castFromDeclContext(const DeclContext *DC) {<br>
            return static_cast<ConceptDecl *>(const_cast<DeclContext*>(DC));<br>        }</b><br><br></div><br>There may other other stuff I missed. But then again, I'm very new to this... So, any comment/question can only help. <br>
<br>Cheers,<br><br>-- Larisse.<br><br><br><div class="gmail_quote">On Fri, Oct 29, 2010 at 9:15 AM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com">doob@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I think it would be good if you could share<br>
your solution if someone else having the same problem.<br>
<div class="im"><br>
On 2010-10-29 14:03, Larisse Voufo wrote:<br>
> Please, never mind this. I figured it out.<br>
><br>
> On Thu, Oct 28, 2010 at 6:49 PM, Larisse Voufo<br>
> <<a href="mailto:lvoufo@cs.indiana.edu">lvoufo@cs.indiana.edu</a><br>
</div><div class="im">> <mailto:<a href="mailto:lvoufo@cs.indiana.edu">lvoufo@cs.indiana.edu</a>>> wrote:<br>
><br>
>     By the way, here the exact line (bolded) of the generated<br>
>     DeclNode.inc at which it is complaining:<br>
>     -------------------------------------------<br>
>     DECL_CONTEXT(TranslationUnit)<br>
>     DECL_CONTEXT(Namespace)<br>
>     *DECL_CONTEXT(Concept)*<br>
>     DECL_CONTEXT(ObjCMethod)<br>
>     DECL_CONTEXT(LinkageSpec)<br>
>     -------------------------------------------<br>
><br>
><br>
><br>
>     On Thu, Oct 28, 2010 at 6:46 PM, Larisse Voufo<br>
>     <<a href="mailto:lvoufo@cs.indiana.edu">lvoufo@cs.indiana.edu</a><br>
</div><div><div></div><div class="h5">>     <mailto:<a href="mailto:lvoufo@cs.indiana.edu">lvoufo@cs.indiana.edu</a>>> wrote:<br>
><br>
>         Hi Folks,<br>
><br>
>         If anyone can quickly answer this question for me, it'd<br>
>         definitely help  by a great deal.<br>
>         I am trying to add a node into the AST, but it seems there is at<br>
>         least one important parameter I'm overlooking.<br>
><br>
>         I figured out that I was supposed to modify the DeclNodes.td<br>
>         file by inserting the following at some appropriate spot:<br>
>         ----------------------------------------<br>
>         def Concept : DDecl<Named, 1>, DeclContext;<br>
>         ----------------------------------------<br>
><br>
>         However, this action is breaking my builds, and I'm not sure how<br>
>         to fix it.<br>
><br>
>         --------------------------------------------------------<br>
>         llvm[2]: Compiling ParseConceptDecl.cpp for Debug+Asserts build<br>
>         In file included from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclBase.h:1187,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/Decl.h:18,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/ASTContext.h:21,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/Stmt.h:25,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/Expr.h:18,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclCXX.h:18,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclTemplate.h:17,<br>
>                           from<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclConcept.h:13,<br>
>                           from ParseConceptDecl.cpp:88:<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclNodes.inc:415:<br>
>         error: expected ‘,’ or ‘...’ before ‘*’ token<br>
>         /Users/lvoufo/llvm/tools/clang/lib/Parse/../../include/clang/AST/DeclNodes.inc:415:<br>
>         error: ISO C++ forbids declaration of ‘ConceptDecl’ with no type<br>
>         make[2]: ***<br>
>         [/Users/lvoufo/llvm/tools/clang/lib/Parse/Debug+Asserts/ParseConceptDecl.o]<br>
>         Error 1<br>
>         make[1]: *** [Parse/.makeall] Error 2<br>
>         make: *** [all] Error 1<br>
>         --------------------------------------------------------<br>
><br>
>         What am I missing?<br>
><br>
>         Thanks,<br>
><br>
>         -- Larisse.<br>
><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<font color="#888888"><br>
<br>
--<br>
/Jacob Carlborg<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></blockquote></div><br>