Community
Participate
Working Groups
Build ID: I20080617-2000 Currently ASTWriterVisitor.writeLeadingComments() takes an ASTNode (which is an internal class) and the methods that call it cast their to ASTNode without testing. For example: @Override public int visit(IASTDeclaration declaration) { writeLeadingComments((ASTNode) declaration); if(!macroHandler.checkisMacroExpansionNode(declaration)) { declarationWriter.writeDeclaration(declaration); } return ASTVisitor.PROCESS_SKIP; } This works when using an AST produced from the default CDT parser, but when I use my ILanguage implementation this leads to a ClassCastException because my implementations of IASTDeclaration do not extend ASTNode. If writeLeadingComments is changed to take an IASTNode then the cast is not required and the code seems to work. More information: I've hit this problem with CDT 5.0 but the code looks the same in HEAD. A fix for CDT 5.0.x would be helpful.
Created attachment 130159 [details] Patch to remove use of ASTNode Here's a patch to remove the use of ASTNode and the unchecked casts. I reran the AstWriterTestSuite and got the same results with and without the patch (everything passes except DeclaratorTests.CPPFunctionDeclaratorTest).
Thanks, I have applied your patch. Fixed in 6.0 > 20090401.