Source range error

Hi,

Clang currently produces quite a wide source range for this particular
format error:

clang -fsyntax-only foo1.c

foo1.c(5) : warning: invalid conversion specifier '!' [-Wformat]
  printf("Format %d, is %! %f", 1, 2, 4.4);
                   ~~~~~~^
1 warning generated.

The source range spans from the end of the last formatter to the end of the
current one.

In ParsePrintfSpecifier you have:

  if (k == ConversionSpecifier::InvalidSpecifier) {
    // Assume the conversion takes one argument.
    return !H.HandleInvalidPrintfConversionSpecifier(FS, Beg, I - Beg);
  }

...whereas I think what you mean is:

  if (k == ConversionSpecifier::InvalidSpecifier) {
    // Assume the conversion takes one argument.
    return !H.HandleInvalidPrintfConversionSpecifier(FS, Start, I - Start);
  }

With this patch (sorry, it's so small I just can't bring myself to attach
one) you now get:

clang -fsyntax-only -Wall foo1.c

foo1.c(5) : warning: invalid conversion specifier '!' [-Wformat]
  printf("Format %d, is %! %f", 1, 2, 4.4);
                        ~^
1 warning generated.

This is more appropriate, IMO. It certainly is when expanding source ranges
in an IDE.

Regards,

Hi Paul,

Thanks for spotting this. Fixed here:

http://llvm.org/viewvc/llvm-project?view=rev&revision=120735