[cfe-dev] Bug: Lexer::getLocForEndOfToken() returns a position too far for a token which include backslash-newline pairs

Marcin Kowalczyk qrczak at google.com
Tue Apr 5 06:41:34 PDT 2011


On Mon, Apr 4, 2011 at 7:27 PM, John McCall <rjmccall at apple.com> wrote:

>> I guess that MeasureTokenLength() includes any backslash-newline
>> pairs, but AdvanceToTokenCharacter() skips them. I'm not sure in which
>> direction this should be fixed.
>
> I *think* the right solution here is for getLocForEndOfToken to just use
> getFileLocWithOffset instead of AdvanceToTokenCharacter.  Would
> you mind writing that up and testing it?

Yes, results look fine with this change.

---
/tmp/g4-89926/cache/depot/google3/third_party/llvm/trunk/tools/clang/lib/Lex/Lexer.cpp#33
2011-03-22 01:58:24.000000000 +0100
+++
/home/qrczak/qrczak-janitor/google3/third_party/llvm/trunk/tools/clang/lib/Lex/Lexer.cpp
2011-04-05 13:02:09.557044000 +0200
@@ -674,7 +674,7 @@
  else
    return Loc;

-  return AdvanceToTokenCharacter(Loc, Len, SM, Features);
+  return Loc.getFileLocWithOffset(Len);
}

//===----------------------------------------------------------------------===//

-- 
Marcin Kowalczyk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110405/1f049cd0/attachment.html>


More information about the cfe-dev mailing list