| Summary: | CDT Parser gives invalid comment positions when the comment is after a null statement macro in same line. | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Hyukmin Kwon <kgurals> |
| Component: | cdt-parser | Assignee: | Markus Schorn <mschorn.eclipse> |
| Status: | RESOLVED FIXED | QA Contact: | Markus Schorn <mschorn.eclipse> |
| Severity: | normal | ||
| Priority: | P3 | CC: | cdtdoug |
| Version: | 8.1.0 | ||
| Target Milestone: | 8.1.0 | ||
| Hardware: | PC | ||
| OS: | All | ||
| Whiteboard: | |||
Thanks! Added testcase and fix. *** cdt git genie on behalf of Markus Schorn ***
Bug 367827: Wrong offset for comment directly after macro expansion.
[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=7d0d64393c2da5cac378162fffb8dd0314cb0aac
|
Build Identifier: Version: 3.7.1 Build id: M20110909-1335 Get tu (an IASTTranslationUnit) by parsing following code with CDT C parser. #define NULL_STATEMENT_MACRO ; void macro_test() { int x = 1; NULL_STATEMENT_MACRO //comment1 x; //comment2 } The obtained position of 'comment1' by using tu.getComments() is incorrect. The character at the position is not '/' but ' ' (space before '/'). For the 'comment2' the obtained position is correct. Only comments after the NULL_STATEMENT_MACRO at the same line give incorrect positions. Same phenomenon is occurred for "#define NULL_BLOCK_MACRO {}". Reproducible: Always Steps to Reproduce: 1.Parse following code with CDT C parser and get an IASTTranslationUnit 'tu'. #define NULL_STATEMENT_MACRO ; void macro_test() { int x = 1; NULL_STATEMENT_MACRO //comment1 x; //comment2 } 2.Get comment list from tu.getComments() IASTComment[] cl = tu.getComments(); 3.Get node offset of comments by folowing code commentOffset[i] = cl[i].getFileLocation().getNodeOffset(); 4.If we get the character at commentOffset[i] by using IDocument.getChar() method, then commentOffset[1] is '/' but commentOffset[0] is ' ' (space) (i.e. incorrect offset). The difference with correct offset is 1.