In MeasureTokenLength, the FileLoc supplied to the lexer must point to the start of the buffer, or we risk overflow.

llvm-svn: 115117
This commit is contained in:
Sebastian Redl 2010-09-30 01:03:03 +00:00
parent 2b76c66fd6
commit 517523014d
1 changed files with 2 additions and 1 deletions

View File

@ -242,7 +242,8 @@ unsigned Lexer::MeasureTokenLength(SourceLocation Loc,
return 0;
// Create a lexer starting at the beginning of this token.
Lexer TheLexer(Loc, LangOpts, Buffer.begin(), StrData, Buffer.end());
Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts,
Buffer.begin(), StrData, Buffer.end());
TheLexer.SetCommentRetentionState(true);
Token TheTok;
TheLexer.LexFromRawLexer(TheTok);