<div dir="ltr">On Wed, Aug 21, 2013 at 9:18 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><p dir="ltr"><br>
On 20 Aug 2013 21:15, "Nick Lewycky" <<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>> wrote:<br>
><br>
> Author: nicholas<br>
> Date: Tue Aug 20 23:10:58 2013<br>
> New Revision: 188863<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=188863&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=188863&view=rev</a><br>
> Log:<br>
> Issue fixits replacing invalid character literals with the equivalent \xNN<br>
> escape code.<br>
><br>
> Added:<br>
> cfe/trunk/test/Lexer/char-literal-encoding-fixit.c<br>
> Modified:<br>
> cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
><br>
> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=188863&r1=188862&r2=188863&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=188863&r1=188862&r2=188863&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Tue Aug 20 23:10:58 2013<br>
> @@ -978,7 +978,7 @@ CharLiteralParser::CharLiteralParser(con<br>
> uint32_t largest_character_for_kind;<br>
> if (tok::wide_char_constant == Kind) {<br>
> largest_character_for_kind =<br>
> - 0xFFFFFFFFu >> (32-PP.getTargetInfo().getWCharWidth());<br>
> + 0xFFFFFFFFu >> (32 - PP.getTargetInfo().getWCharWidth());<br>
> } else if (tok::utf16_char_constant == Kind) {<br>
> largest_character_for_kind = 0xFFFF;<br>
> } else if (tok::utf32_char_constant == Kind) {<br>
> @@ -1009,7 +1009,13 @@ CharLiteralParser::CharLiteralParser(con<br>
> unsigned Msg = diag::err_bad_character_encoding;<br>
> if (NoErrorOnBadEncoding)<br>
> Msg = diag::warn_bad_character_encoding;<br>
> - PP.Diag(Loc, Msg);<br>
> + std::string escaped = llvm::utohexstr(static_cast<uint8_t>(*start));</p>
</div></div><p dir="ltr">Are we guaranteed that the character is >= 0x10 here? (utohexstr might otherwise produce only one character).</p><p dir="ltr"><br></p></blockquote><div>Yes... it's guaranteed to be >= 0x80, actually. But it would probably be a good idea to make the code clear anyway.<br>
</div></div><br></div><div class="gmail_extra">-Eli<br></div></div>