[cfe-commits] r64914 - /cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
Steve Naroff
snaroff at apple.com
Wed Feb 18 08:16:22 PST 2009
Author: snaroff
Date: Wed Feb 18 10:16:20 2009
New Revision: 64914
URL: http://llvm.org/viewvc/llvm-project?rev=64914&view=rev
Log:
Fix Windows newline madness.
<rdar://problem/6596843> clang ObjC rewriter: Line endings still mixed in rewrite output
Modified:
cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=64914&r1=64913&r2=64914&view=diff
==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Wed Feb 18 10:16:20 2009
@@ -371,6 +371,15 @@
FunctionDecl *SynthBlockInitFunctionDecl(const char *name);
Stmt *SynthBlockInitExpr(BlockExpr *Exp);
+
+ void ScrubNewlines(std::string &From, std::string &To) {
+ for(unsigned i = 0; i < From.length(); i++) {
+ if (From[i] == '\n')
+ To += "\r\n";
+ else
+ To += From[i];
+ }
+ }
};
}
@@ -4551,9 +4560,15 @@
E = ProtocolExprDecls.end(); I != E; ++I)
RewriteObjCProtocolMetaData(*I, "", "", Preamble);
- InsertText(SM->getLocForStartOfFile(MainFileID),
- Preamble.c_str(), Preamble.size(), false);
-
+ if (LangOpts.Microsoft) {
+ std::string ConvertedString;
+ ScrubNewlines(Preamble, ConvertedString);
+ InsertText(SM->getLocForStartOfFile(MainFileID),
+ ConvertedString.c_str(), ConvertedString.size(), false);
+ } else {
+ InsertText(SM->getLocForStartOfFile(MainFileID),
+ Preamble.c_str(), Preamble.size(), false);
+ }
if (ClassImplementation.size() || CategoryImplementation.size())
RewriteImplementations();
@@ -4573,7 +4588,13 @@
std::string ResultStr;
SynthesizeMetaDataIntoBuffer(ResultStr);
// Emit metadata.
- *OutFile << ResultStr;
+ if (LangOpts.Microsoft) {
+ std::string ConvertedString;
+ ScrubNewlines(ResultStr, ConvertedString);
+ *OutFile << ConvertedString;
+ } else {
+ *OutFile << ResultStr;
+ }
}
OutFile->flush();
}
More information about the cfe-commits
mailing list