[InterfacePrinting] Move utf8 sanitizer from SourceKit to ASTPrinter.

We sanitize comments by replacing invalid utf8 subsequence with � .

Swift SVN r30031
This commit is contained in:
Xi Ge
2015-07-09 18:26:02 +00:00
parent 16c8a3b6c0
commit 1eac2874b1
3 changed files with 32 additions and 3 deletions

View File

@@ -505,7 +505,7 @@ void ClangCommentPrinter::printDeclPre(const Decl *D) {
void ClangCommentPrinter::printDeclPost(const Decl *D) {
OtherPrinter.printDeclPost(D);
for (auto CommentText : PendingComments) {
*this << " " << CommentText;
*this << " " << ASTPrinter::sanitizeUtf8(CommentText);
}
PendingComments.clear();
if (auto ClangN = D->getClangNode())
@@ -596,7 +596,7 @@ void ClangCommentPrinter::printComment(StringRef RawText, unsigned StartCol) {
trimLeadingWhitespaceFromLines(RawText, WhitespaceToTrim, Lines);
for (auto Line : Lines) {
*this << Line << "\n";
*this << ASTPrinter::sanitizeUtf8(Line) << "\n";
printIndent();
}
}