[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-06 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui created this revision.
Herald added a project: All.
ken-matsui requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

I implemented a feature to show line numbers with left margins in diagnostics 
like GCC-9 does. Ref: 
https://developers.redhat.com/blog/2019/03/08/usability-improvements-in-gcc-9


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125078

Files:
  clang/include/clang/Basic/DiagnosticOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/TextDiagnostic.cpp
  clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
  clang/test/FixIt/fixit-newline-style.c
  clang/test/FixIt/fixit-unicode-with-utf8-output.c
  clang/test/FixIt/fixit-unicode.c
  clang/test/Frontend/diag-show-line-numbers.c
  clang/test/Frontend/source-col-map.c
  clang/test/Lexer/header.cpp
  clang/test/Lexer/string-literal-errors.cpp
  clang/test/Misc/caret-diags-macros.c
  clang/test/Misc/caret-diags-multiline.cpp
  clang/test/Misc/diag-macro-backtrace.c
  clang/test/Misc/message-length.c
  clang/test/Misc/tabstop.c
  clang/test/Misc/unnecessary-elipses.cpp
  clang/test/Misc/unprintable.c
  clang/test/Misc/wrong-encoding.c
  clang/test/Parser/brackets.c
  clang/test/Parser/brackets.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/SemaCXX/struct-class-redecl.cpp

Index: clang/test/SemaCXX/struct-class-redecl.cpp
===
--- clang/test/SemaCXX/struct-class-redecl.cpp
+++ clang/test/SemaCXX/struct-class-redecl.cpp
@@ -87,113 +87,113 @@
 /*
 *** 'X' messages ***
 CHECK: warning: struct 'X' was previously declared as a class
-CHECK: {{^}}typedef struct X * X_t;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}4 | typedef struct X * X_t;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class X;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}3 | class X;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: error: use of 'X' with tag type that does not match previous declaration
-CHECK: {{^}}union X { int x; float y; };
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}class{{$}}
+CHECK: {{^}}5 | union X { int x; float y; };
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | class{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class X;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}3 | class X;
+CHECK: {{^}}  |   ^{{$}}
 *** 'Y' messages ***
 CHECK: warning: 'Y' defined as a class template here but
   previously declared as a struct template
-CHECK: {{^}}template class Y { };
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}8 | template class Y { };
+CHECK: {{^}}  |   ^{{$}}
 CHECK: note: did you mean class here?
-CHECK: {{^}}template struct Y;
-CHECK: {{^}} ^~{{$}}
-CHECK: {{^}} class{{$}}
+CHECK: {{^}}7 | template struct Y;
+CHECK: {{^}}  |  ^~{{$}}
+CHECK: {{^}}  |  class{{$}}
 *** 'A' messages ***
 CHECK: warning: struct 'A' was previously declared as a class
-CHECK: {{^}}struct A;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   18 | struct A;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class A;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   17 | class A;
+CHECK: {{^}}  |   ^{{$}}
 *** 'B' messages ***
 CHECK: warning: struct 'B' was previously declared as a class
-CHECK: {{^}}struct B;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   23 | struct B;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class B;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   21 | class B;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: 'B' defined as a struct here but previously declared as a class
-CHECK: {{^}}struct B {};
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   24 | struct B {};
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: did you mean struct here?
-CHECK: {{^}}class B;
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}struct{{$}}
+CHECK: {{^}}   21 | class B;
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | struct{{$}}
 CHECK: note: did you mean struct here?
-CHECK: {{^}}class B;
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}struct{{$}}
+CHECK: {{^}}   20 | class B;
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | struct{{$}}
 *** 'C' messages ***
 CHECK: warning: struct 'C' was previously declared as a class
-CHECK: {{^}}struct C;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   27 | struct C;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class C;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   26 | class C;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: warning: class 'C' was previously declared as a struct
-CHECK: {{^}}class C;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   30 | class C;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}struct C;
-CHECK: {{^}}   ^{{$}}
+CHECK: {{^}}   27 | struct C;
+CHECK: {{^}}  |^{{$}}
 CHECK: warnin

[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-06 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui updated this revision to Diff 427546.
ken-matsui added a comment.

Remove unnecessary includes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

Files:
  clang/include/clang/Basic/DiagnosticOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/TextDiagnostic.cpp
  clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
  clang/test/FixIt/fixit-newline-style.c
  clang/test/FixIt/fixit-unicode-with-utf8-output.c
  clang/test/FixIt/fixit-unicode.c
  clang/test/Frontend/diag-show-line-numbers.c
  clang/test/Frontend/source-col-map.c
  clang/test/Lexer/header.cpp
  clang/test/Lexer/string-literal-errors.cpp
  clang/test/Misc/caret-diags-macros.c
  clang/test/Misc/caret-diags-multiline.cpp
  clang/test/Misc/diag-macro-backtrace.c
  clang/test/Misc/message-length.c
  clang/test/Misc/tabstop.c
  clang/test/Misc/unnecessary-elipses.cpp
  clang/test/Misc/unprintable.c
  clang/test/Misc/wrong-encoding.c
  clang/test/Parser/brackets.c
  clang/test/Parser/brackets.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/SemaCXX/struct-class-redecl.cpp

Index: clang/test/SemaCXX/struct-class-redecl.cpp
===
--- clang/test/SemaCXX/struct-class-redecl.cpp
+++ clang/test/SemaCXX/struct-class-redecl.cpp
@@ -87,113 +87,113 @@
 /*
 *** 'X' messages ***
 CHECK: warning: struct 'X' was previously declared as a class
-CHECK: {{^}}typedef struct X * X_t;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}4 | typedef struct X * X_t;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class X;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}3 | class X;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: error: use of 'X' with tag type that does not match previous declaration
-CHECK: {{^}}union X { int x; float y; };
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}class{{$}}
+CHECK: {{^}}5 | union X { int x; float y; };
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | class{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class X;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}3 | class X;
+CHECK: {{^}}  |   ^{{$}}
 *** 'Y' messages ***
 CHECK: warning: 'Y' defined as a class template here but
   previously declared as a struct template
-CHECK: {{^}}template class Y { };
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}8 | template class Y { };
+CHECK: {{^}}  |   ^{{$}}
 CHECK: note: did you mean class here?
-CHECK: {{^}}template struct Y;
-CHECK: {{^}} ^~{{$}}
-CHECK: {{^}} class{{$}}
+CHECK: {{^}}7 | template struct Y;
+CHECK: {{^}}  |  ^~{{$}}
+CHECK: {{^}}  |  class{{$}}
 *** 'A' messages ***
 CHECK: warning: struct 'A' was previously declared as a class
-CHECK: {{^}}struct A;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   18 | struct A;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class A;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   17 | class A;
+CHECK: {{^}}  |   ^{{$}}
 *** 'B' messages ***
 CHECK: warning: struct 'B' was previously declared as a class
-CHECK: {{^}}struct B;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   23 | struct B;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class B;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   21 | class B;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: 'B' defined as a struct here but previously declared as a class
-CHECK: {{^}}struct B {};
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   24 | struct B {};
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: did you mean struct here?
-CHECK: {{^}}class B;
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}struct{{$}}
+CHECK: {{^}}   21 | class B;
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | struct{{$}}
 CHECK: note: did you mean struct here?
-CHECK: {{^}}class B;
-CHECK: {{^}}^{{$}}
-CHECK: {{^}}struct{{$}}
+CHECK: {{^}}   20 | class B;
+CHECK: {{^}}  | ^{{$}}
+CHECK: {{^}}  | struct{{$}}
 *** 'C' messages ***
 CHECK: warning: struct 'C' was previously declared as a class
-CHECK: {{^}}struct C;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   27 | struct C;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}class C;
-CHECK: {{^}}  ^{{$}}
+CHECK: {{^}}   26 | class C;
+CHECK: {{^}}  |   ^{{$}}
 CHECK: warning: class 'C' was previously declared as a struct
-CHECK: {{^}}class C;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   30 | class C;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{^}}struct C;
-CHECK: {{^}}   ^{{$}}
+CHECK: {{^}}   27 | struct C;
+CHECK: {{^}}  |^{{$}}
 CHECK: warning: struct 'C' was previously declared as a class
-CHECK: {{^}}struct C;
-CHECK: {{^}}^{{$}}
+CHECK: {{^}}   32 | struct C;
+CHECK: {{^}}  | ^{{$}}
 CHECK: note: previous use is here
-CHECK: {{

[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-09 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added subscribers: rsmith, cjdb.
cjdb added a comment.

I'm in favour of this, but @rsmith warned me a little while ago that we 
mightn't be able to have stuff like this on by default because scripts probably 
depend on specific compiler output. Hyrum's Law  
strikes again :(

(I personally think we should have it on by default and give a way to opt out, 
rather than opt in.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D125078#3501061 , @cjdb wrote:

> I'm in favour of this, but @rsmith warned me a little while ago that we 
> mightn't be able to have stuff like this on by default because scripts 
> probably depend on specific compiler output. Hyrum's Law 
>  strikes again :(
>
> (I personally think we should have it on by default and give a way to opt 
> out, rather than opt in.)

I believe even more tools depend on gcc and gcc devs were able to turn it on by 
default, so kinda bad excuse, especially with opt out flag.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-10 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

This feature is already implemented in GCC, so in my opinion, it would be great 
if we could turn this on by default.

I also added a feature to separate location info and a message in 
https://reviews.llvm.org/D125175.
Should its feature be avoided from turning on by default as well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-10 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I support turning it on by default. I'm simply passing on the message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-10 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

Thank you :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D125078#3503921 , @cjdb wrote:

> I support turning it on by default. I'm simply passing on the message.

+1, I support on by default as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125078: Implement a feature to show line numbers in diagnostics

2022-05-10 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

Thank you all so much :)))


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125078/new/

https://reviews.llvm.org/D125078

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits