<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">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. </div><div class="">Thank you for looking into this so quickly!</div><div class="">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.</div><div class=""><br class=""></div><div class=""><div class="">Index: docs/ClangFormatStyleOptions.rst</div><div class="">===================================================================</div><div class="">--- docs/ClangFormatStyleOptions.rst<span class="Apple-tab-span" style="white-space:pre">   </span>(revision 297506)</div><div class="">+++ docs/ClangFormatStyleOptions.rst<span class="Apple-tab-span" style="white-space:pre">     </span>(working copy)</div><div class="">@@ -944,7 +944,8 @@</div><div class="">     Use C++03-compatible syntax.</div><div class=""> </div><div class="">   * ``LS_Cpp11`` (in configuration: ``Cpp11``)</div><div class="">-    Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).</div><div class="">+    Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of </div><div class="">+    ``A<A<int> >``).</div><div class=""> </div><div class="">   * ``LS_Auto`` (in configuration: ``Auto``)</div><div class="">     Automatic detection based on the input.</div><div class="">Index: include/clang/Format/Format.h</div><div class="">===================================================================</div><div class="">--- include/clang/Format/Format.h<span class="Apple-tab-span" style="white-space:pre">     </span>(revision 297506)</div><div class="">+++ include/clang/Format/Format.h<span class="Apple-tab-span" style="white-space:pre">        </span>(working copy)</div><div class="">@@ -786,7 +786,8 @@</div><div class="">   enum LanguageStandard {</div><div class="">     /// Use C++03-compatible syntax.</div><div class="">     LS_Cpp03,</div><div class="">-    /// Use features of C++11 (e.g. ``A<A<int>>`` instead of ``A<A<int> >``).</div><div class="">+    /// Use features of C++11, C++14 and C++1z (e.g. ``A<A<int>>`` instead of</div><div class="">+    /// ``A<A<int> >``).</div><div class="">     LS_Cpp11,</div><div class="">     /// Automatic detection based on the input.</div><div class="">     LS_Auto</div><div class="">Index: lib/Format/Format.cpp</div><div class="">===================================================================</div><div class="">--- lib/Format/Format.cpp<span class="Apple-tab-span" style="white-space:pre">  </span>(revision 297506)</div><div class="">+++ lib/Format/Format.cpp<span class="Apple-tab-span" style="white-space:pre">        </span>(working copy)</div><div class="">@@ -1893,6 +1893,7 @@</div><div class="">   LangOpts.CPlusPlus = 1;</div><div class="">   LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</div><div class="">   LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</div><div class="">+  LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</div><div class="">   LangOpts.LineComment = 1;</div><div class="">   bool AlternativeOperators = Style.IsCpp();</div><div class="">   LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;</div><div class="">Index: unittests/Format/FormatTest.cpp</div><div class="">===================================================================</div><div class="">--- unittests/Format/FormatTest.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 297506)</div><div class="">+++ unittests/Format/FormatTest.cpp<span class="Apple-tab-span" style="white-space:pre">      </span>(working copy)</div><div class="">@@ -10111,6 +10111,19 @@</div><div class="">   EXPECT_EQ(Expected, *Result);</div><div class=""> }</div><div class=""> </div><div class="">+TEST_F(FormatTest, UTF8CharacterLiteralCpp03) {</div><div class="">+  format::FormatStyle Style = format::getLLVMStyle();</div><div class="">+  Style.Standard = FormatStyle::LS_Cpp03;</div><div class="">+  // cpp03 recognize this string as identifier u8 and literal character 'a'</div><div class="">+  EXPECT_EQ("auto c = u8 'a';", format("auto c = u8'a';", Style));</div><div class="">+}</div><div class="">+</div><div class="">+TEST_F(FormatTest, UTF8CharacterLiteralCpp11) {</div><div class="">+  // u8'a' is a C++17 feature, utf8 literal character, LS_Cpp11 covers</div><div class="">+  // all modes, including C++11, C++14 and C++17</div><div class="">+  EXPECT_EQ("auto c = u8'a';", format("auto c = u8'a';"));</div><div class="">+}</div><div class="">+</div><div class=""> } // end namespace</div><div class=""> } // end namespace format</div><div class=""> } // end namespace clang</div></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 10, 2017, at 3:03 PM, Nico Weber <<a href="mailto:thakis@chromium.org" class="">thakis@chromium.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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`).<div class=""><div class=""><br class=""></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Mar 10, 2017 at 4:52 PM, via cfe-dev <span dir="ltr" class=""><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">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. </div><div class="">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. </div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#e4e4e4" class="">tools/clang </span><span style="font-variant-ligatures:no-common-ligatures" class="">                                                                                                                      </span><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#e4e4e4" class=""> ✓</span><span style="font-variant-ligatures:no-common-ligatures;background-color:#e4e4e4" class=""> </span><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#eeeeee" class=""> 13:45:12 </span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">╰─ svn diff</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">Index: lib/Format/Format.cpp</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">==============================<wbr class="">==============================<wbr class="">=======</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">--- lib/Format/Format.cpp<span class="m_-8209006175848329941Apple-tab-span" style="white-space:pre-wrap">      </span>(revision 297506)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">+++ lib/Format/Format.cpp<span class="m_-8209006175848329941Apple-tab-span" style="white-space:pre-wrap"> </span>(working copy)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">@@ -1893,6 +1893,7 @@</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   LangOpts.CPlusPlus = 1;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">+  LangOpts.CPlusPlus1z = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   LangOpts.LineComment = 1;</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   bool AlternativeOperators = Style.IsCpp();</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">   LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;</span></div></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On Mar 10, 2017, at 11:09 AM, via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="m_-8209006175848329941Apple-interchange-newline"></div></div><div class=""><div class=""><div class="h5"><div style="word-wrap:break-word" class=""><div class="">Hi all,</div><div class=""><br class=""></div><div class="">clang-format does not work well with character literal u8 ' c-char '. Example</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">clang-format <<END</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">auto c1 = u8'a';</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">auto c2 = u'a';</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">END</span></div></div><div class=""><br class=""></div><div class="">Produces</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">auto c1 = u8 'a';</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)" class=""><span style="font-variant-ligatures:no-common-ligatures" class="">auto c2 = u'a';</span></div></div><div class=""><br class=""></div><div class="">As you can see clang-format adds an additional space between u8 and 'a'.</div><div class=""><br class=""></div><div class=""><div class="">clang-format --version</div><div class="">clang-format version 4.0.0 (<a href="http://llvm.org/git/clang.git" target="_blank" class="">http://llvm.org/git/clang.git</a> 559aa046fe3260d8640791f2249d7b<wbr class="">0d458b5700) (<a href="http://llvm.org/git/llvm.git" target="_blank" class="">http://llvm.org/git/llvm.git</a> 4423e351176a92975739dd4ea43c2f<wbr class="">f5877236ae)</div></div><div class=""><br class=""></div><div class="">Not sure if this is the best place to report a bug.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Denis Gladkikh</div></div></div></div>______________________________<wbr class="">_________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-dev</a><br class=""></div></blockquote></div><br class=""></div><br class="">______________________________<wbr class="">_________________<br class="">
cfe-dev mailing list<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/cfe-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>