<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 8, 2013 at 4:23 AM, Arnold Schwaighofer <span dir="ltr"><<a href="mailto:aschwaighofer@apple.com" target="_blank">aschwaighofer@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Alexander,<br>
<br>
This commit broke a bot. The build bot clang-x86_64-darwin11-nobootstrap-RAincremental was broken for over two hours.<br>
<br>
<a href="http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/5486" target="_blank">http://lab.llvm.org:8013/builders/clang-x86_64-darwin11-nobootstrap-RAincremental/builds/5486</a><br>
<br>
I have reverted it in r187957.<br></blockquote><div><br></div><div>Thanks! Will take a look when wake up tomorrow.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Thanks,<br>
Arnold<br>
<div class=""><div class="h5"><br>
<br>
On Aug 7, 2013, at 6:29 PM, Alexander Kornienko <<a href="mailto:alexfh@google.com">alexfh@google.com</a>> wrote:<br>
<br>
> Author: alexfh<br>
> Date: Wed Aug 7 18:29:01 2013<br>
> New Revision: 187935<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=187935&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=187935&view=rev</a><br>
> Log:<br>
> Support for double width characters.<br>
><br>
> Summary: Only works for UTF-8-encoded files.<br>
><br>
> Reviewers: djasper<br>
><br>
> Reviewed By: djasper<br>
><br>
> CC: cfe-commits, klimek<br>
><br>
> Differential Revision: <a href="http://llvm-reviews.chandlerc.com/D1311" target="_blank">http://llvm-reviews.chandlerc.com/D1311</a><br>
><br>
> Modified:<br>
> cfe/trunk/lib/Format/BreakableToken.cpp<br>
> cfe/trunk/unittests/Format/FormatTest.cpp<br>
><br>
> Modified: cfe/trunk/lib/Format/BreakableToken.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=187935&r1=187934&r2=187935&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=187935&r1=187934&r2=187935&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/BreakableToken.cpp (original)<br>
> +++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Aug 7 18:29:01 2013<br>
> @@ -20,6 +20,7 @@<br>
> #include "clang/Format/Format.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> #include "llvm/Support/Debug.h"<br>
> +#include "llvm/Support/Locale.h"<br>
> #include <algorithm><br>
><br>
> namespace clang {<br>
> @@ -38,6 +39,15 @@ static bool IsBlank(char C) {<br>
> }<br>
> }<br>
><br>
> +static unsigned columnWidth(StringRef Text, encoding::Encoding Encoding) {<br>
> + if (Encoding == encoding::Encoding_UTF8) {<br>
> + int ContentWidth = llvm::sys::locale::columnWidth(Text);<br>
> + if (ContentWidth >= 0)<br>
> + return ContentWidth;<br>
> + }<br>
> + return encoding::getCodePointCount(Text, Encoding);<br>
> +}<br>
> +<br>
> static BreakableToken::Split getCommentSplit(StringRef Text,<br>
> unsigned ContentStartColumn,<br>
> unsigned ColumnLimit,<br>
> @@ -49,9 +59,12 @@ static BreakableToken::Split getCommentS<br>
> unsigned MaxSplitBytes = 0;<br>
><br>
> for (unsigned NumChars = 0;<br>
> - NumChars < MaxSplit && MaxSplitBytes < Text.size(); ++NumChars)<br>
> - MaxSplitBytes +=<br>
> + NumChars < MaxSplit && MaxSplitBytes < Text.size();) {<br>
> + unsigned NumBytes =<br>
> encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding);<br>
> + NumChars += columnWidth(Text.substr(MaxSplitBytes, NumBytes), Encoding);<br>
> + MaxSplitBytes += NumBytes;<br>
> + }<br>
><br>
> StringRef::size_type SpaceOffset = Text.find_last_of(Blanks, MaxSplitBytes);<br>
> if (SpaceOffset == StringRef::npos ||<br>
> @@ -84,9 +97,8 @@ static BreakableToken::Split getStringSp<br>
> return BreakableToken::Split(StringRef::npos, 0);<br>
> if (ColumnLimit <= ContentStartColumn)<br>
> return BreakableToken::Split(StringRef::npos, 0);<br>
> - unsigned MaxSplit =<br>
> - std::min<unsigned>(ColumnLimit - ContentStartColumn,<br>
> - encoding::getCodePointCount(Text, Encoding) - 1);<br>
> + unsigned MaxSplit = std::min<unsigned>(ColumnLimit - ContentStartColumn,<br>
> + columnWidth(Text, Encoding) - 1);<br>
> StringRef::size_type SpaceOffset = 0;<br>
> StringRef::size_type SlashOffset = 0;<br>
> StringRef::size_type WordStartOffset = 0;<br>
> @@ -98,7 +110,7 @@ static BreakableToken::Split getStringSp<br>
> Chars += Advance;<br>
> } else {<br>
> Advance = encoding::getCodePointNumBytes(Text[0], Encoding);<br>
> - Chars += 1;<br>
> + Chars += columnWidth(Text.substr(0, Advance), Encoding);<br>
> }<br>
><br>
> if (Chars > MaxSplit)<br>
> @@ -131,7 +143,7 @@ unsigned BreakableSingleLineToken::getLi<br>
> unsigned BreakableSingleLineToken::getLineLengthAfterSplit(<br>
> unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const {<br>
> return StartColumn + Prefix.size() + Postfix.size() +<br>
> - encoding::getCodePointCount(Line.substr(Offset, Length), Encoding);<br>
> + columnWidth(Line.substr(Offset, Length), Encoding);<br>
> }<br>
><br>
> BreakableSingleLineToken::BreakableSingleLineToken(<br>
> @@ -329,8 +341,7 @@ unsigned BreakableBlockComment::getLineC<br>
> unsigned BreakableBlockComment::getLineLengthAfterSplit(<br>
> unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const {<br>
> return getContentStartColumn(LineIndex, Offset) +<br>
> - encoding::getCodePointCount(Lines[LineIndex].substr(Offset, Length),<br>
> - Encoding) +<br>
> + columnWidth(Lines[LineIndex].substr(Offset, Length), Encoding) +<br>
> // The last line gets a "*/" postfix.<br>
> (LineIndex + 1 == Lines.size() ? 2 : 0);<br>
> }<br>
><br>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=187935&r1=187934&r2=187935&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=187935&r1=187934&r2=187935&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Aug 7 18:29:01 2013<br>
> @@ -5704,15 +5704,15 @@ TEST_F(FormatTest, CountsUTF8CharactersP<br>
> verifyFormat("\"Однажды в Ñ Ñ‚ÑƒÐ´Ñ‘Ð½ÑƒÑŽ зимнюю пору...\"",<br>
> getLLVMStyleWithColumns(35));<br>
> verifyFormat("\"一 二 三 å›› 五 å<br>
> 七 å<br>
> « ä¹ å \"",<br>
> - getLLVMStyleWithColumns(21));<br>
> + getLLVMStyleWithColumns(31));<br>
> verifyFormat("// Однажды в Ñ Ñ‚ÑƒÐ´Ñ‘Ð½ÑƒÑŽ зимнюю пору...",<br>
> getLLVMStyleWithColumns(36));<br>
> verifyFormat("// 一 二 三 å›› 五 å<br>
> 七 å<br>
> « ä¹ å ",<br>
> - getLLVMStyleWithColumns(22));<br>
> + getLLVMStyleWithColumns(32));<br>
> verifyFormat("/* Однажды в Ñ Ñ‚ÑƒÐ´Ñ‘Ð½ÑƒÑŽ зимнюю пору... */",<br>
> getLLVMStyleWithColumns(39));<br>
> verifyFormat("/* 一 二 三 å›› 五 å<br>
> 七 å<br>
> « ä¹ å */",<br>
> - getLLVMStyleWithColumns(25));<br>
> + getLLVMStyleWithColumns(35));<br>
> }<br>
><br>
> TEST_F(FormatTest, SplitsUTF8Strings) {<br>
> @@ -5723,11 +5723,12 @@ TEST_F(FormatTest, SplitsUTF8Strings) {<br>
> "\"пору,\"",<br>
> format("\"Однажды, в Ñ Ñ‚ÑƒÐ´Ñ‘Ð½ÑƒÑŽ зимнюю пору,\"",<br>
> getLLVMStyleWithColumns(13)));<br>
> - EXPECT_EQ("\"一 二 三 四 \"\n"<br>
> - "\"五 å<br>
> 七 å<br>
> « \"\n"<br>
> - "\"ä¹ å \"",<br>
> - format("\"一 二 三 å›› 五 å<br>
> 七 å<br>
> « ä¹ å \"",<br>
> - getLLVMStyleWithColumns(10)));<br>
> + EXPECT_EQ("\"一 二 三 \"\n"<br>
> + "\"å›› 五å<br>
> \"\n"<br>
> + "\"七 å<br>
> « ä¹ \"\n"<br>
> + "\"å \"",<br>
> + format("\"一 二 三 å›› 五å<br>
> 七 å<br>
> « ä¹ å \"",<br>
> + getLLVMStyleWithColumns(11)));<br>
> }<br>
><br>
> TEST_F(FormatTest, SplitsUTF8LineComments) {<br>
> @@ -5739,9 +5740,9 @@ TEST_F(FormatTest, SplitsUTF8LineComment<br>
> getLLVMStyleWithColumns(13)));<br>
> EXPECT_EQ("// 一二三\n"<br>
> "// 四五å<br>
> 七\n"<br>
> - "// å<br>
> «\n"<br>
> - "// ä¹ å ",<br>
> - format("// 一二三 四五å<br>
> 七 å<br>
> « ä¹ å ", getLLVMStyleWithColumns(6)));<br>
> + "// å<br>
> « ä¹ \n"<br>
> + "// å ",<br>
> + format("// 一二三 四五å<br>
> 七 å<br>
> « ä¹ å ", getLLVMStyleWithColumns(9)));<br>
> }<br>
><br>
> TEST_F(FormatTest, SplitsUTF8BlockComments) {<br>
> @@ -5758,16 +5759,17 @@ TEST_F(FormatTest, SplitsUTF8BlockCommen<br>
> getLLVMStyleWithColumns(13)));<br>
> EXPECT_EQ("/* 一二三\n"<br>
> " * 四五å<br>
> 七\n"<br>
> - " * å<br>
> «\n"<br>
> - " * ä¹ å \n"<br>
> - " */",<br>
> - format("/* 一二三 四五å<br>
> 七 å<br>
> « ä¹ å */", getLLVMStyleWithColumns(6)));<br>
> + " * å<br>
> « ä¹ \n"<br>
> + " * å */",<br>
> + format("/* 一二三 四五å<br>
> 七 å<br>
> « ä¹ å */", getLLVMStyleWithColumns(9)));<br>
> EXPECT_EQ("/* 𠓣𠓮𠓼𠓽 𠔣𠔬𠔲𠔯\n"<br>
> " * 𠕓𠕪𠕥𠕖\n"<br>
> " * 𠖀𠕿𠕱-ð Ÿ */",<br>
> format("/* 𠓣𠓮𠓼𠓽 𠔣𠔬𠔲𠔯 𠕓𠕪𠕥𠕖 𠖀𠕿𠕱-ð Ÿ */", getLLVMStyleWithColumns(12)));<br>
> }<br>
><br>
> +#endif // _MSC_VER<br>
> +<br>
> TEST_F(FormatTest, FormatsWithWebKitStyle) {<br>
> FormatStyle Style = getWebKitStyle();<br>
><br>
> @@ -5847,7 +5849,5 @@ TEST_F(FormatTest, FormatsWithWebKitStyl<br>
> format("if (aaaaaaaaaaaaaaa || bbbbbbbbbbbbbbb) { i++; }", Style));<br>
> }<br>
><br>
> -#endif<br>
> -<br>
> } // end namespace tooling<br>
> } // end namespace clang<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" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br>
</div></div>