<div dir="ltr">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><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 10, 2017 at 4:52 PM, via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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. </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. </div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255)"><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#e4e4e4">tools/clang </span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#e4e4e4"> ✓</span><span style="font-variant-ligatures:no-common-ligatures;background-color:#e4e4e4"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#444444;background-color:#eeeeee"> 13:45:12 </span></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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 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)"><span style="font-variant-ligatures:no-common-ligatures">+++ 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)"><span style="font-variant-ligatures:no-common-ligatures">@@ -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)"><span style="font-variant-ligatures:no-common-ligatures"> LangOpts.CPlusPlus = 1;</span></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div></div><div><br></div><div><br></div><br><div><blockquote type="cite"><div><div class="h5"><div>On Mar 10, 2017, at 11:09 AM, via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="m_-8209006175848329941Apple-interchange-newline"></div></div><div><div><div class="h5"><div style="word-wrap:break-word"><div>Hi all,</div><div><br></div><div>clang-format does not work well with character literal u8 ' c-char '. Example</div><div><br></div><div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div><div style="margin: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></div></div><div><br></div><div>Produces</div><div><br></div><div><div style="margin: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></div><div style="margin: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></div></div><div><br></div><div>As you can see clang-format adds an additional space between u8 and 'a'.</div><div><br></div><div><div>clang-format --version</div><div>clang-format version 4.0.0 (<a href="http://llvm.org/git/clang.git" target="_blank">http://llvm.org/git/clang.git</a> 559aa046fe3260d8640791f2249d7b<wbr>0d458b5700) (<a href="http://llvm.org/git/llvm.git" target="_blank">http://llvm.org/git/llvm.git</a> 4423e351176a92975739dd4ea43c2f<wbr>f5877236ae)</div></div><div><br></div><div>Not sure if this is the best place to report a bug.</div><div><br></div><div>Thanks,</div><div>Denis Gladkikh</div></div></div></div>______________________________<wbr>_________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br></div></blockquote></div><br></div><br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>