[PATCH] Add debug method to visualize complex source locations

Manuel Klimek klimek at google.com
Wed May 22 05:24:10 PDT 2013


  How's that?
  http://pastebin.com/SzjYDDiu

  As mentioned, note that there'll be a real file name before the first colon of the location printed in real code...

  The strategy is to print the current line in the buffer, and put an ^ in that points at the location.
  Note that we don't have a lexer so it's kinda hard to do anything more fancy.

  Loc
  |-Expansion
  | |-ExpansionStart
  | | |-ExpansionStart |C(f(M(i)))|
  | | |                 ^ :3:1,
  | | |-ExpansionEnd   |C(f(M(i)))|
  | | |                          ^ :3:10,
  | | `-Spelling       |#define C(x) c M(x)|
  | |                                  ^ :2:16,
  | |-ExpansionEnd
  | | |-ExpansionStart |C(f(M(i)))|
  | | |                 ^ :3:1,
  | | |-ExpansionEnd   |C(f(M(i)))|
  | | |                          ^ :3:10,
  | | `-Spelling       |#define C(x) c M(x)|
  | |                                     ^ :2:19,
  | `-Spelling       |#define M(x) x|
  |                                ^ :1:14,
  `-Spelling
    |-Expansion
    | |-ExpansionStart |C(f(M(i)))|
    | |                 ^ :3:1,
    | |-ExpansionEnd   |C(f(M(i)))|
    | |                          ^ :3:10,
    | `-Spelling       |#define C(x) c M(x)|
    |                                    ^ :2:18,
    `-Spelling
      |-Expansion
      | |-ExpansionStart |C(f(M(i)))|
      | |                     ^ :3:5,
      | |-ExpansionEnd   |C(f(M(i)))|
      | |                        ^ :3:8,
      | `-Spelling       |#define M(x) x|
      |                                ^ :1:14,
      `-Spelling       |C(f(M(i)))|
                              ^ :3:7

http://llvm-reviews.chandlerc.com/D768



More information about the cfe-commits mailing list