Implement a FIXME: correctly stringify filenames generated by __LINE__.

llvm-svn: 38622
This commit is contained in:
Chris Lattner 2006-07-03 01:07:01 +00:00
parent 4d5e1a72f4
commit 0766e592ce
1 changed files with 10 additions and 2 deletions

View File

@ -622,8 +622,16 @@ void Preprocessor::ExpandBuiltinMacro(LexerToken &Tok) {
}
}
// FIXME: Escape this filename correctly.
std::string FN = '"' + SourceMgr.getSourceName(Loc) + '"';
// Escape this filename. Turn '\' -> '\\' '"' -> '\"'
std::string FN = SourceMgr.getSourceName(Loc);
for (unsigned i = 0, e = FN.size(); i != e; ++i)
if (FN[i] == '\\' || FN[i] == '"') {
FN.insert(FN.begin()+i, '\\');
++i; ++e;
}
// Add quotes.
FN = '"' + FN + '"';
Tok.SetKind(tok::string_literal);
Tok.SetLength(FN.size());
Tok.SetLocation(ScratchBuf->getToken(&FN[0], FN.size(), Tok.getLocation()));