[llvm-commits] [llvm] r79065 - /llvm/trunk/lib/Support/FormattedStream.cpp
Artur Pietrek
pietreka at gmail.com
Mon Aug 17 02:42:45 PDT 2009
On Sat, Aug 15, 2009 at 4:02 AM, Dan Gohman <gohman at apple.com> wrote:
>
> -/// ComputeColumn - Examine the current output and figure out which
> +/// CountColumns - Examine the given char sequence and figure out which
> /// column we end up in after output.
> ///
> -void formatted_raw_ostream::ComputeColumn() {
> +static unsigned CountColumns(unsigned Column, const char *Ptr, size_t
> Size) {
> // Keep track of the current column by scanning the string for
> // special characters
>
> - // The buffer may have been allocated underneath us.
> - if (Scanned == 0 && GetNumBytesInBuffer() != 0) {
> - Scanned = begin();
> - }
> -
> - while (Scanned != end()) {
> - ++ColumnScanned;
> - if (*Scanned == '\n' || *Scanned == '\r')
> - ColumnScanned = 0;
> - else if (*Scanned == '\t')
> + for (const char *End = Ptr + Size; Ptr != End; ++Ptr) {
> + ++Column;
> + if (*Ptr == '\n' || *Ptr == '\r')
> + Column = 0;
> + else if (*Ptr == '\t')
> // Assumes tab stop = 8 characters.
> - ColumnScanned += (8 - (ColumnScanned & 0x7)) & 0x7;
> - ++Scanned;
> + Column += (8 - (Column & 0x7)) & 0x7;
> }
> +
> + return Column;
> +}
Hi all,
Is it legal to output Instruction or any Value using formatted stream like
this:
Out << *Instr;
I was using it to print commented LLVM instructions to my assembly to check
if I'm translating instructions correctly, but since the change above I get
segfault after running my backend.
Changing line:
for (const char *End = Ptr + Size; Ptr != End; ++Ptr) {
to:
+ for (const char *End = Ptr + Size; Ptr < End; ++Ptr) {
helps. Is it bug or I just should not use it that way?
Thanks,
Artur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090817/9c73eec2/attachment.html>
More information about the llvm-commits
mailing list