<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 26, 2015 at 11:35 PM, Yaron Keren <span dir="ltr"><<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: yrnkrn<br>
Date: Mon Jul 27 01:35:22 2015<br>
New Revision: 243260<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243260-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=hM4kh7FcGREgWw7uV5hUCicBBLO2XAOdmsU33D1z1cg&s=SOOQ_ot6gykNifqk7bhPNBKASaQxjUCozMSK-6N7Mxk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=243260&view=rev</a><br>
Log:<br>
Rename highly-confusing isWhitespace that returns false on \n to<br>
isWhitespaceExceptNL. If that's wasn't bad enough, we have an identically<br>
named function in Basic/CharInfo.h.<br>
<br>
While at it, remove unnecessary includes, .str() calls and #ifdef.<br>
<br>
<br>
Modified:<br>
    cfe/trunk/lib/Rewrite/Rewriter.cpp<br>
<br>
Modified: cfe/trunk/lib/Rewrite/Rewriter.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Rewrite_Rewriter.cpp-3Frev-3D243260-26r1-3D243259-26r2-3D243260-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=hM4kh7FcGREgWw7uV5hUCicBBLO2XAOdmsU33D1z1cg&s=k4o9tayuGaAOi0DQufjrKPPbwUxvvPBkZ4vrCFxO8FY&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Rewriter.cpp?rev=243260&r1=243259&r2=243260&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Rewrite/Rewriter.cpp (original)<br>
+++ cfe/trunk/lib/Rewrite/Rewriter.cpp Mon Jul 27 01:35:22 2015<br>
@@ -15,11 +15,9 @@<br>
 #include "clang/Rewrite/Core/Rewriter.h"<br>
 #include "clang/Basic/Diagnostic.h"<br>
 #include "clang/Basic/DiagnosticIDs.h"<br>
-#include "clang/Basic/FileManager.h"<br>
 #include "clang/Basic/SourceManager.h"<br>
 #include "clang/Lex/Lexer.h"<br>
 #include "llvm/ADT/SmallString.h"<br>
-#include "llvm/Config/llvm-config.h"<br>
 #include "llvm/Support/FileSystem.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
 using namespace clang;<br>
@@ -33,9 +31,10 @@ raw_ostream &RewriteBuffer::write(raw_os<br>
   return os;<br>
 }<br>
<br>
+namespace {<br>
 /// \brief Return true if this character is non-new-line whitespace:<br>
 /// ' ', '\\t', '\\f', '\\v', '\\r'.<br>
-static inline bool isWhitespace(unsigned char c) {<br>
+inline bool isWhitespaceExceptNL(unsigned char c) {<br>
   switch (c) {<br>
   case ' ':<br>
   case '\t':<br>
@@ -47,6 +46,7 @@ static inline bool isWhitespace(unsigned<br>
     return false;<br>
   }<br>
 }<br>
+}<br></blockquote><div><br></div><div>Don't the coding standards say to only use anonymous namespaces for class definitions?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size,<br>
                                bool removeLineIfEmpty) {<br>
@@ -80,7 +80,7 @@ void RewriteBuffer::RemoveText(unsigned<br>
<br>
     unsigned lineSize = 0;<br>
     posI = curLineStart;<br>
-    while (posI != end() && isWhitespace(*posI)) {<br>
+    while (posI != end() && isWhitespaceExceptNL(*posI)) {<br>
       ++posI;<br>
       ++lineSize;<br>
     }<br>
@@ -256,7 +256,7 @@ bool Rewriter::InsertText(SourceLocation<br>
     StringRef indentSpace;<br>
     {<br>
       unsigned i = lineOffs;<br>
-      while (isWhitespace(MB[i]))<br>
+      while (isWhitespaceExceptNL(MB[i]))<br>
         ++i;<br>
       indentSpace = MB.substr(lineOffs, i-lineOffs);<br>
     }<br>
@@ -363,12 +363,12 @@ bool Rewriter::IncreaseIndentation(CharS<br>
   StringRef parentSpace, startSpace;<br>
   {<br>
     unsigned i = parentLineOffs;<br>
-    while (isWhitespace(MB[i]))<br>
+    while (isWhitespaceExceptNL(MB[i]))<br>
       ++i;<br>
     parentSpace = MB.substr(parentLineOffs, i-parentLineOffs);<br>
<br>
     i = startLineOffs;<br>
-    while (isWhitespace(MB[i]))<br>
+    while (isWhitespaceExceptNL(MB[i]))<br>
       ++i;<br>
     startSpace = MB.substr(startLineOffs, i-startLineOffs);<br>
   }<br>
@@ -384,7 +384,7 @@ bool Rewriter::IncreaseIndentation(CharS<br>
   for (unsigned lineNo = startLineNo; lineNo <= endLineNo; ++lineNo) {<br>
     unsigned offs = Content->SourceLineCache[lineNo];<br>
     unsigned i = offs;<br>
-    while (isWhitespace(MB[i]))<br>
+    while (isWhitespaceExceptNL(MB[i]))<br>
       ++i;<br>
     StringRef origIndent = MB.substr(offs, i-offs);<br>
     if (origIndent.startswith(startSpace))<br>
@@ -409,7 +409,7 @@ public:<br>
     TempFilename = Filename;<br>
     TempFilename += "-%%%%%%%%";<br>
     int FD;<br>
-    if (llvm::sys::fs::createUniqueFile(TempFilename.str(), FD, TempFilename)) {<br>
+    if (llvm::sys::fs::createUniqueFile(TempFilename, FD, TempFilename)) {<br>
       AllWritten = false;<br>
       Diagnostics.Report(clang::diag::err_unable_to_make_temp)<br>
         << TempFilename;<br>
@@ -421,19 +421,15 @@ public:<br>
   ~AtomicallyMovedFile() {<br>
     if (!ok()) return;<br>
<br>
-    FileStream->flush();<br>
-#ifdef LLVM_ON_WIN32<br>
-    // Win32 does not allow rename/removing opened files.<br>
-    FileStream.reset();<br>
-#endif<br>
-    if (std::error_code ec =<br>
-            llvm::sys::fs::rename(TempFilename.str(), Filename)) {<br>
+    // Close (will also flush) theFileStream.<br>
+    FileStream->close();<br>
+    if (std::error_code ec = llvm::sys::fs::rename(TempFilename, Filename)) {<br>
       AllWritten = false;<br>
       Diagnostics.Report(clang::diag::err_unable_to_rename_temp)<br>
         << TempFilename << Filename << ec.message();<br>
       // If the remove fails, there's not a lot we can do - this is already an<br>
       // error.<br>
-      llvm::sys::fs::remove(TempFilename.str());<br>
+      llvm::sys::fs::remove(TempFilename);<br>
     }<br>
   }<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">~Craig</div>
</div></div>