[PATCH] D158472: [clang][Diagnostics] Emit fix-it hint separately on overload resolution failure

Takuya Shimizu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 21 17:39:48 PDT 2023


hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, cjdb, tbaeder, shafik.
Herald added a subscriber: arphaman.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

D153359 <https://reviews.llvm.org/D153359> addressed the distant source ranges in overload resolution failure, but still clang generates distant source locations when emitting fix-it hint about the addition/deletion of `*` and `&` operators.
This patch separates the fix-it emission to another note to resolve this issue.
Code Example:

  void f(int n);
  
  
  void g(int *p) { f(p); }

Before:

  source:4:18: error: no matching function for call to 'f'
      4 | void g(int *p) { f(p); }
        |                  ^
  source:1:6: note: candidate function not viable: no known conversion from 'int *' to 'int' for 1st argument; dereference the argument with *
      1 | void f(int n);
        |      ^ ~~~~~
      2 |
      3 |
      4 | void g(int *p) { f(p); }
        |
        |                    *

After:

  source:4:18: error: no matching function for call to 'f'
      4 | void g(int *p) { f(p); }
        |                  ^
  source:1:6: note: candidate function not viable: no known conversion from 'int *' to 'int' for 1st argument
      1 | void f(int n);
        |      ^ ~~~~~
  source:4:20: note: dereference the argument with *
      4 | void g(int *p) { f(p); }
        |                    ^
        |                    *


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158472

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaOverload.cpp
  clang/test/FixIt/fixit-function-call.cpp
  clang/test/Index/fixit-sysheader-test.cpp
  clang/test/Sema/overloadable.c
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/builtin-operator-new-delete.cpp
  clang/test/SemaCXX/crashes.cpp
  clang/test/SemaCXX/for-range-dereference.cpp
  clang/test/SemaCXX/overload-member-call.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
  clang/test/SemaTemplate/instantiate-expr-4.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158472.552176.patch
Type: text/x-patch
Size: 11061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230822/94321349/attachment.bin>


More information about the cfe-commits mailing list