[PATCH] D147875: [clang][Diagnostics] WIP: Show line numbers when printing code snippets

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 11 05:24:27 PDT 2023


tbaeder marked an inline comment as done.
tbaeder added a comment.

Wow, in `FixIt/fixits-function-call`, this output:

  ./array.cpp:123:3: error: no matching function for call to 'f1'
    f1(a + 1);
    ^~
  ./array.cpp:114:6: note: candidate function not viable: no known conversion from 'intTy2 *' (aka 'int *') to 'intTy &' (aka 'int &') for 1st argument; dereference the argument with *
  void f1(intTy &a);
       ^
  fix-it:"./array.cpp":{123:6-123:6}:"*("
  fix-it:"./array.cpp":{123:11-123:11}:")"

now (with increased snippet line limit) prints:

  ./array.cpp:123:3: error: no matching function for call to 'f1'
    123 |   f1(a + 1);
        |   ^~
  ./array.cpp:114:6: note: candidate function not viable: no known conversion from 'intTy2 *' (aka 'int *') to 'intTy &' (aka 'int &') for 1st argument; dereference the argument with *
    114 | void f1(intTy &a);
        |      ^
    116 | void f2(intTy2 *a) {
    117 | // CHECK: error: no matching function for call to 'f1
    118 | // CHECK: dereference the argument with *
    119 | // CHECK: void f1(intTy &a);
    120 | // CHECK: fix-it{{.*}}*(
    121 | // CHECK-NEXT: fix-it{{.*}})
    122 | // CHECK: void f1(double *a);
    123 |   f1(a + 1);
        |      ~~~~~
        |      *(   )
  fix-it:"./array.cpp":{123:6-123:6}:"*("
  fix-it:"./array.cpp":{123:11-123:11}:")"

Is this actually what we want? It somehow makes sense but also doesn't. It's weird that the test ensures the parseable fixits but the output doesn't show the fixit at all (in the first case).


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

https://reviews.llvm.org/D147875



More information about the cfe-commits mailing list