Page MenuHomePhabricator

Show location info with a new line in diagnostics
Needs ReviewPublic

Authored by ken-matsui on May 7 2022, 12:09 PM.

Details

Reviewers
jdoerfert
Summary

I implemented a feature to show location info with a new line in diagnostics.

This patch intends to make diagnostics much clearer by displaying location info with a new line and putting a line break between each diagnostic.

Before this patch:

test2.c:4:12: error: expected identifier or '('
  int [5] *;
           ^
test2.c:4:12: error: brackets are not allowed here; to declare an array, place the brackets after the identifier
  int [5] *;
      ~~~~ ^
          ()[5]
2 errors generated.

This patch brings it to:

error: expected identifier or '('
  --> test2.c:4:12
  int [5] *;
           ^

error: brackets are not allowed here; to declare an array, place the brackets after the identifier
  --> test2.c:4:12
  int [5] *;
      ~~~~ ^
          ()[5]

2 errors generated.

Also, if this patch is used with -fdiagnostics-show-line-numbers which is implemented in https://reviews.llvm.org/D125078:

error: expected identifier or '('
  --> test2.c:4:12
   4  |   int [5] *;
      |            ^

error: brackets are not allowed here; to declare an array, place the brackets after the identifier
  --> test2.c:4:12
   4  |   int [5] *;
      |       ~~~~ ^
      |           ()[5]

2 errors generated.

Diff Detail