Give tokens from the scratch buffer correct source locations.

llvm-svn: 38591
This commit is contained in:
Chris Lattner 2006-06-29 06:34:53 +00:00
parent dc9f9bf80e
commit 4fb517bea8
2 changed files with 5 additions and 3 deletions

View File

@ -531,6 +531,7 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok, MacroInfo *MI) {
Tok.SetKind(tok::numeric_constant);
Tok.SetLength(Length);
Tok.SetLocation(ScratchBuf->getToken(TmpBuffer, Length, Tok.getLocation()));
Tok.SetIdentifierInfo(0);
Tok.ClearFlag(LexerToken::NeedsCleaning);
return;
} else {

View File

@ -39,13 +39,14 @@ SourceLocation ScratchBuffer::getToken(const char *Buf, unsigned Len,
// Copy the token data into the buffer.
memcpy(CurBuffer+BytesUsed, Buf, Len);
unsigned InstantiationFileID =
SourceMgr.createFileIDForMacroExp(SourceLoc, FileID);
// Create the initial SourceLocation.
SourceLocation Loc(FileID, BytesUsed);
SourceLocation Loc(InstantiationFileID, BytesUsed);
assert(BytesUsed < (1 << SourceLocation::FilePosBits) &&
"Out of range file position!");
// FIXME: Merge SourceLoc into it.
// Remember that we used these bytes.
BytesUsed += Len;