[cfe-commits] r38622 - /cfe/cfe/trunk/Lex/Preprocessor.cpp
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:23:17 PDT 2007
Author: sabre
Date: Wed Jul 11 11:23:17 2007
New Revision: 38622
URL: http://llvm.org/viewvc/llvm-project?rev=38622&view=rev
Log:
Implement a FIXME: correctly stringify filenames generated by __LINE__.
Modified:
cfe/cfe/trunk/Lex/Preprocessor.cpp
Modified: cfe/cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Lex/Preprocessor.cpp?rev=38622&r1=38621&r2=38622&view=diff
==============================================================================
--- cfe/cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/cfe/trunk/Lex/Preprocessor.cpp Wed Jul 11 11:23:17 2007
@@ -622,8 +622,16 @@
}
}
- // 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()));
More information about the cfe-commits
mailing list