llvm-project/clang/lib/Frontend
Chris Lattner 44219f3e58 implement a new -fprint-source-range-info option, which
defaults to off.  When enabled, it emits range info along
with the file/line/col information for a diagnostic.  This
allows tools that textually parse the output of clang to know
where the ranges are, even if they span multiple lines.  For 
example, with:

$ clang exprs.c -fprint-source-range-info

We now produce:

exprs.c:21:11:{21:12-21:13}: warning: use of unary operator that may be intended as compound assignment (+=)
      var =+ 5;  // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
          ^~
exprs.c:22:11:{22:12-22:13}: warning: use of unary operator that may be intended as compound assignment (-=)
      var =- 5;  // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
          ^~
exprs.c:36:13:{36:3-36:12}: error: assignment to cast is illegal, lvalue casts are not supported
  (float*)X = P;   // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
  ~~~~~~~~~ ^
exprs.c:41:4:{41:3-41:4}: error: called object type 'int' is not a function or function pointer
  X();  // expected-error {{called object type 'int' is not a function or function pointer}}
  ~^
exprs.c:45:15:{45:8-45:14}{45:17-45:24}: error: invalid operands to binary expression ('int *' and '_Complex float')
   P = (P-42) + Gamma*4;  // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
       ~~~~~~ ^ ~~~~~~~
exprs.c:61:7:{61:16-61:22}: error: invalid application of '__alignof' to bitfield
  R = __alignof(P->x);  // expected-error {{invalid application of '__alignof' to bitfield}} expected-warning {{extension used}}
      ^        ~~~~~~

Note the range info after the column in the initial diagnostic.

This is obviously really annoying if you're not a tool parsing the 
output of clang, which is why it is off by default.

llvm-svn: 66862
2009-03-13 01:08:23 +00:00
..
CMakeLists.txt Rename lib/Driver (etc) to lib/Frontend in prep for the *actual* 2009-03-02 06:16:29 +00:00
HTMLDiagnostics.cpp BugReporter: 2009-03-10 05:16:17 +00:00
InitHeaderSearch.cpp improve compatibility with GCC 4.4, patch by Michel Salim (PR3697) 2009-03-02 22:20:04 +00:00
Makefile Fix name. 2009-03-02 19:50:00 +00:00
ManagerRegistry.cpp Rename lib/Driver (etc) to lib/Frontend in prep for the *actual* 2009-03-02 06:16:29 +00:00
PlistDiagnostics.cpp PathDiagnostics: 2009-03-12 18:41:53 +00:00
TextDiagnosticBuffer.cpp Rename lib/Driver (etc) to lib/Frontend in prep for the *actual* 2009-03-02 06:16:29 +00:00
TextDiagnosticPrinter.cpp implement a new -fprint-source-range-info option, which 2009-03-13 01:08:23 +00:00