<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hi Nico,<br></div>
<div><br></div>
<div>By any chance have you had a time to merge this change?<br></div>
<div><br></div>
<div>Thanks,<br></div>
<div>Denis Gladkikh</div>
<div><br></div>
<div><br></div>
<div>On Fri, Mar 10, 2017, at 05:25 PM, via cfe-dev wrote:<br></div>
<blockquote type="cite"><div>Of course, I also updated documentation to include that Cpp11 modes actually enabled C++14 and C++17 as well. Added two unit tests, one where Cpp03 works as before, and Cpp11 mode recognizes utf8 literal character. <br></div>
<div>Thank you for looking into this so quickly!<br></div>
<div>I would assume that it is too late to include this change in clang 4.0.0, but maybe later this change will be merged also into 4.0.1 or something.<br></div>
<div><br></div>
<div><div>Index: docs/ClangFormatStyleOptions.rst<br></div>
<div>===================================================================<br></div>
<div>--- docs/ClangFormatStyleOptions.rst<span style="white-space:pre;"> </span>(revision 297506)<br></div>
<div>+++ docs/ClangFormatStyleOptions.rst<span style="white-space:pre;"> </span>(working copy)<br></div>
<div>@@ -944,7 +944,8 @@<br></div>
<div> Use C++03-compatible syntax.<br></div>
<div> <br></div>
<div> * ``LS_Cpp11`` (in configuration: ``Cpp11``)<br></div>
<div>- Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).<br></div>
<div>+ Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of <br></div>
<div>+ ``A<A<int> >``).<br></div>
<div> <br></div>
<div> * ``LS_Auto`` (in configuration: ``Auto``)<br></div>
<div> Automatic detection based on the input.<br></div>
<div>Index: include/clang/Format/Format.h<br></div>
<div>===================================================================<br></div>
<div>--- include/clang/Format/Format.h<span style="white-space:pre;"> </span>(revision 297506)<br></div>
<div>+++ include/clang/Format/Format.h<span style="white-space:pre;"> </span>(working copy)<br></div>
<div>@@ -786,7 +786,8 @@<br></div>
<div> enum LanguageStandard {<br></div>
<div> /// Use C++03-compatible syntax.<br></div>
<div> LS_Cpp03,<br></div>
<div>- /// Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).<br></div>
<div>+ /// Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of<br></div>
<div>+ /// ``A<A<int> >``).<br></div>
<div> LS_Cpp11,<br></div>
<div> /// Automatic detection based on the input.<br></div>
<div> LS_Auto<br></div>
<div>Index: lib/Format/Format.cpp<br></div>
<div>===================================================================<br></div>
<div>--- lib/Format/Format.cpp<span style="white-space:pre;"> </span>(revision 297506)<br></div>
<div>+++ lib/Format/Format.cpp<span style="white-space:pre;"> </span>(working copy)<br></div>
<div>@@ -1893,6 +1893,7 @@<br></div>
<div> LangOpts.CPlusPlus = 1;<br></div>
<div> LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;<br></div>
<div> LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;<br></div>
<div>+ LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;<br></div>
<div> LangOpts.LineComment = 1;<br></div>
<div> bool AlternativeOperators = Style.IsCpp();<br></div>
<div> LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;<br></div>
<div>Index: unittests/Format/FormatTest.cpp<br></div>
<div>===================================================================<br></div>
<div>--- unittests/Format/FormatTest.cpp<span style="white-space:pre;"> </span>(revision 297506)<br></div>
<div>+++ unittests/Format/FormatTest.cpp<span style="white-space:pre;"> </span>(working copy)<br></div>
<div>@@ -10111,6 +10111,19 @@<br></div>
<div> EXPECT_EQ(Expected, *Result);<br></div>
<div> }<br></div>
<div> <br></div>
<div>+TEST_F(FormatTest, UTF8CharacterLiteralCpp03) {<br></div>
<div>+ format::FormatStyle Style = format::getLLVMStyle();<br></div>
<div>+ Style.Standard = FormatStyle::LS_Cpp03;<br></div>
<div>+ // cpp03 recognize this string as identifier u8 and literal character 'a'<br></div>
<div>+ EXPECT_EQ("auto c = u8 'a';", format("auto c = u8'a';", Style));<br></div>
<div>+}<br></div>
<div>+<br></div>
<div>+TEST_F(FormatTest, UTF8CharacterLiteralCpp11) {<br></div>
<div>+ // u8'a' is a C++17 feature, utf8 literal character, LS_Cpp11 covers<br></div>
<div>+ // all modes, including C++11, C++14 and C++17<br></div>
<div>+ EXPECT_EQ("auto c = u8'a';", format("auto c = u8'a';"));<br></div>
<div>+}<br></div>
<div>+<br></div>
<div> } // end namespace<br></div>
<div> } // end namespace format<br></div>
<div> } // end namespace clang<br></div>
</div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><blockquote type="cite"><div>On Mar 10, 2017, at 3:03 PM, Nico Weber <<a href="mailto:thakis@chromium.org">thakis@chromium.org</a>> wrote:<br></div>
<div><br></div>
<div><div dir="ltr"><div>The patch you posted looks good to me. Can you add a test to unittests/Format/FormatTest.cpp too? (Run tests with `ninja FormatTests && ./tools/clang/unittests/Format/FormatTests`).<br></div>
<div><div><br></div>
</div>
</div>
<div><div><br></div>
<div defang_data-gmailquote="yes"><div>On Fri, Mar 10, 2017 at 4:52 PM, via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>></span> wrote:<br></div>
<blockquote defang_data-gmailquote="yes" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;"><div style="word-wrap:break-word;"><div>Seems like fix is very simple, clang-format currently does not respect c++1z at all. With patch below I could verify that it can recognize u8'a' as utf8 character literal. Without it it recognize it as two tokens: identifier and character literal. <br></div>
<div>My guess that .clang-format should allow to specify LanguageStandard: LS_Cpp17 now, does it sound good? I can try to contribute to clang-format - that will be the first time for me - will be happy to try it out. <br></div>
<div><br></div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span class="highlight" style="background-color:rgb(228, 228, 228)"><span class="colour" style="color:rgb(68, 68, 68)">tools/clang </span></span><span style="font-variant-ligatures:no-common-ligatures;"> </span><span class="highlight" style="background-color:rgb(228, 228, 228)"><span class="colour" style="color:rgb(68, 68, 68)"> ✓</span></span><span class="highlight" style="background-color:rgb(228, 228, 228)"> </span><span class="highlight" style="background-color:rgb(238, 238, 238)"><span class="colour" style="color:rgb(68, 68, 68)"> 13:45:12 </span></span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">╰─ svn diff</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">Index: lib/Format/Format.cpp</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">==============================<wbr>==============================<wbr>=======</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">--- lib/Format/Format.cpp<span style="white-space:pre-wrap;"> </span>(revision 297506)</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">+++ lib/Format/Format.cpp<span style="white-space:pre-wrap;"> </span>(working copy)</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">@@ -1893,6 +1893,7 @@</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> LangOpts.CPlusPlus = 1;</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">+ LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> LangOpts.LineComment = 1;</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> bool AlternativeOperators = Style.IsCpp();</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;"> LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;</span><br></div>
</div>
<div><br></div>
<div><br></div>
<div><br></div>
<div><blockquote type="cite"><div><div><div>On Mar 10, 2017, at 11:09 AM, via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div>
<div><br></div>
</div>
</div>
<div><div><div><div style="word-wrap:break-word;"><div>Hi all,<br></div>
<div><br></div>
<div>clang-format does not work well with character literal u8 ' c-char '. Example<br></div>
<div><br></div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">clang-format <<END</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">auto c1 = u8'a';</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">auto c2 = u'a';</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">END</span><br></div>
</div>
<div><br></div>
<div>Produces<br></div>
<div><br></div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">auto c1 = u8 'a';</span><br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255, 255, 255);"><span style="font-variant-ligatures:no-common-ligatures;">auto c2 = u'a';</span><br></div>
</div>
<div><br></div>
<div>As you can see clang-format adds an additional space between u8 and 'a'.<br></div>
<div><br></div>
<div><div>clang-format --version<br></div>
<div>clang-format version 4.0.0 (<a href="http://llvm.org/git/clang.git">http://llvm.org/git/clang.git</a> 559aa046fe3260d8640791f2249d7b<wbr>0d458b5700) (<a href="http://llvm.org/git/llvm.git">http://llvm.org/git/llvm.git</a> 4423e351176a92975739dd4ea43c2f<wbr>f5877236ae)<br></div>
</div>
<div><br></div>
<div>Not sure if this is the best place to report a bug.<br></div>
<div><br></div>
<div>Thanks,<br></div>
<div>Denis Gladkikh<br></div>
</div>
</div>
</div>
<div>______________________________<wbr>_________________<br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br></div>
<div><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br></div>
</div>
</blockquote></div>
<div><br></div>
</div>
<div><br></div>
<div>______________________________<wbr>_________________<br></div>
<div> cfe-dev mailing list<br></div>
<div> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br></div>
<div> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br></div>
<div> <br></div>
</blockquote></div>
<div><br></div>
</div>
</div>
</blockquote></div>
<div><br></div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br></div>
<div><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br></div>
</blockquote><div><br></div>
</body>
</html>