[llvm-bugs] [Bug 41944] New: Rewriter::getRangeSize wrong on Comments

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 20 08:23:43 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41944

            Bug ID: 41944
           Summary: Rewriter::getRangeSize wrong on Comments
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: libclang
          Assignee: unassignedclangbugs at nondot.org
          Reporter: m_engel at cs.uni-kl.de
                CC: klimek at google.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

I registered a CommentHandler::HandleComment(Preprocessor & PP, SourceRange
Comment) to the preprocessor.

When it is called and I ask Rewriter::getRangeSize(Comment, /* any options */)
about the size, it is wrong if the comment is followed by another token
immediately.

Case 1: int x = 5 /* test */ ;
Case 2: int y = 5 /* test */;

In case 1, everything works fine.
In case 2, however, the semicolon is reported within the size, which is caused
by the Lexer::MeasureTokenLength call in getRangeSize.

So either Rewriter::getRangeSize or Lexer::MeasureTokenLength is messing things
up here. Unfortunately I'm not deep enough in the code to narrow it down any
further.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190520/dd1629de/attachment.html>


More information about the llvm-bugs mailing list