<p dir="ltr">BTW, should I have looked into the date of the message before selecting the appropriate semantic parser and and reply generator? ;)</p>
<div class="gmail_quote">On Apr 2, 2013 12:04 AM, "Alexander Kornienko" <<a href="mailto:alexfh@google.com">alexfh@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p dir="ltr"><br>
On Apr 1, 2013 6:21 PM, "Manuel Klimek" <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
><br>
> On Thu, Mar 28, 2013 at 7:40 PM, Alexander Kornienko <<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>> wrote:<br>
>><br>
>> Author: alexfh<br>
>> Date: Thu Mar 28 13:40:55 2013<br>
>> New Revision: 178261<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=178261&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=178261&view=rev</a><br>
>> Log:<br>
>> Fixed handling of comments before preprocessor directives.<br>
>><br>
>> Comments before preprocessor directives used to be stored with InPPDirective<br>
>> flag set, which prevented correct comment splitting in this case. Fixed by<br>
>> flushing comments before switching on InPPDirective. Added a new test and fixed<br>
>> one of the existing tests.<br>
>><br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
>>     cfe/trunk/unittests/Format/FormatTest.cpp<br>
>><br>
>> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=178261&r1=178260&r2=178261&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=178261&r1=178260&r2=178261&view=diff</a><br>


>> ==============================================================================<br>
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)<br>
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Mar 28 13:40:55 2013<br>
>> @@ -822,6 +822,7 @@ void UnwrappedLineParser::readToken() {<br>
>>      while (!Line->InPPDirective && <a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::hash) &&<br>
>>             ((FormatTok.NewlinesBefore > 0 && FormatTok.HasUnescapedNewline) ||<br>
>>              FormatTok.IsFirst)) {<br>
><br>
><br>
> Please add a comment indicating why we need this.</p>
<p dir="ltr">By "this" you mean the flushComments call I suppose? I wanted to add a comment, but "flush comments before starting to parse the preprocessor directive" seems like rephrasing the code. Or you can suggest a better comment?</p>


<p dir="ltr">>  <br>
>><br>
>> +      flushComments(FormatTok.NewlinesBefore > 0);<br>
>>        // If there is an unfinished unwrapped line, we flush the preprocessor<br>
>>        // directives only after that unwrapped line was finished later.<br>
>>        bool SwitchToPreprocessorLines =<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=178261&r1=178260&r2=178261&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=178261&r1=178260&r2=178261&view=diff</a><br>


>> ==============================================================================<br>
>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Mar 28 13:40:55 2013<br>
>> @@ -699,6 +699,13 @@ TEST_F(FormatTest, SplitsLongCxxComments<br>
>>        "//Don't add leading\n"<br>
>>        "//whitespace",<br>
>>        format("//Don't add leading whitespace", getLLVMStyleWithColumns(20)));<br>
>> +  EXPECT_EQ("// A comment before\n"<br>
>> +            "// a macro\n"<br>
>> +            "// definition\n"<br>
>> +            "#define a b",<br>
>> +            format("// A comment before a macro definition\n"<br>
>> +                   "#define a b",<br>
>> +                   getLLVMStyleWithColumns(20)));<br>
>>  }<br>
>><br>
>>  TEST_F(FormatTest, SplitsLongLinesInComments) {<br>
>> @@ -1203,13 +1210,13 @@ TEST_F(FormatTest, IndentsPPDirectiveInR<br>
>>  }<br>
>><br>
>>  TEST_F(FormatTest, HandlePreprocessorDirectiveContext) {<br>
>> -  EXPECT_EQ("// some comment\n"<br>
>> +  EXPECT_EQ("// somecomment\n"<br>
><br>
><br>
> What's the reason for this part of the change?</p>
<p dir="ltr">This is the smallest change possible to make this test pass after we started breaking long line comments. There are many alternative solutions, of course.</p>
<p dir="ltr">>  <br>
>><br>
>>              "#include \"a.h\"\n"<br>
>>              "#define A(  \\\n"<br>
>>              "    A, B)\n"<br>
>>              "#include \"b.h\"\n"<br>
>>              "// somecomment\n",<br>
>> -            format("  // some comment\n"<br>
>> +            format("  // somecomment\n"<br>
>>                     "  #include \"a.h\"\n"<br>
>>                     "#define A(A,\\\n"<br>
>>                     "    B)\n"<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">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>
><br>
</p>
</blockquote></div>