I don't think that's it, because '\n' is printed out and doesn't cause a 
literal newline to be printed.

On Apr 28, 2012, at 5:30 AM, Matthieu Monrocq wrote:

> 
> 
> On Fri, Apr 27, 2012 at 2:17 AM, Seth Cantrell <[email protected]> 
> wrote:
> Okay, thanks. Without understanding exactly how the scratch buffer is used, 
> it seems to me like the right solution is to make the scratch buffer or the 
> source manager understand where the actual used portion of the buffer ends. 
> I'll take a look and see if I can make that work or think of anything else.
> 
> I'm not sure I understand your comment about embedded newlines. A new line 
> character constitutes the end of a line, and so can never be embedded inside 
> a line. And emitSnippetAndCaret takes a SourceLocation and outputs in a 
> diagnostic with just the line containing that source location.
> 
> 
> Hi Seth,
> 
> I believe Nico is referring to something like:    printf("%s", "Hello 
> Seth\n");
> 
> This statement has a newline character embedded, which should be rendered as 
> '\n' and not cause a newline character to be printed.
> 
> -- Matthieu
>  
> On Apr 26, 2012, at 5:37 PM, Nico Weber wrote:
> 
> > Hi Seth,
> >
> > On Tue, Apr 17, 2012 at 7:44 PM, Seth Cantrell <[email protected]> 
> > wrote:
> >> Author: socantre
> >> Date: Tue Apr 17 21:44:48 2012
> >> New Revision: 154981
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=154981&view=rev
> >> Log:
> >> fix display of source lines with null characters
> >>
> >> Added:
> >>    cfe/trunk/test/Misc/wnull-character.cpp
> >> Modified:
> >>    cfe/trunk/lib/Frontend/TextDiagnostic.cpp
> >>
> >> Modified: cfe/trunk/lib/Frontend/TextDiagnostic.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnostic.cpp?rev=154981&r1=154980&r2=154981&view=diff
> >> ==============================================================================
> >> --- cfe/trunk/lib/Frontend/TextDiagnostic.cpp (original)
> >> +++ cfe/trunk/lib/Frontend/TextDiagnostic.cpp Tue Apr 17 21:44:48 2012
> >> @@ -839,10 +839,13 @@
> >>
> >>   // Get information about the buffer it points into.
> >>   bool Invalid = false;
> >> -  const char *BufStart = SM.getBufferData(FID, &Invalid).data();
> >> +  StringRef BufData = SM.getBufferData(FID, &Invalid);
> >>   if (Invalid)
> >>     return;
> >>
> >> +  const char *BufStart = BufData.data();
> >> +  const char *BufEnd = BufStart + BufData.size();
> >> +
> >>   unsigned LineNo = SM.getLineNumber(FID, FileOffset);
> >>   unsigned ColNo = SM.getColumnNumber(FID, FileOffset);
> >>   unsigned CaretEndColNo
> >> @@ -856,7 +859,7 @@
> >>   // Compute the line end.  Scan forward from the error position to the 
> >> end of
> >>   // the line.
> >>   const char *LineEnd = TokPtr;
> >> -  while (*LineEnd != '\n' && *LineEnd != '\r' && *LineEnd != '\0')
> >> +  while (*LineEnd != '\n' && *LineEnd != '\r' && LineEnd!=BufEnd)
> >
> > this caused PR12674. I can't think of a good fix, so I'll revert this,
> > with a test that shows what went wrong. Note that even with this CL,
> > strings with embedded newline characters weren't printed correctly.
> >
> > Nico
> >
> >>     ++LineEnd;
> >>
> >>   // FIXME: This shouldn't be necessary, but the CaretEndColNo can extend 
> >> past
> >>
> >> Added: cfe/trunk/test/Misc/wnull-character.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/wnull-character.cpp?rev=154981&view=auto
> >> ==============================================================================
> >> Binary files cfe/trunk/test/Misc/wnull-character.cpp (added) and 
> >> cfe/trunk/test/Misc/wnull-character.cpp Tue Apr 17 21:44:48 2012 differ
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> [email protected]
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to