[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

Takuya Shimizu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 20 08:15:00 PDT 2023


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

Now that clang supports printing of multiple lines of code snippet in diagnostics, source ranges in diagnostics that are located in different lines from the diagnosed source location get to be printed if the gap happened to be less than the maximum number of lines clang is allowed to print in.
Many of the bad-conversion notes in overload resolution failures have their source location in the function declaration and source range in the argument of function call. This can cause an unnecessarily many lines of snippet printing.
e.g.

  void func(int num);
  
  
  void test() { func("hello"); }

Live demo: https://godbolt.org/z/fdj6WWsef

This patch fixes it by changing the source range from function callsite to the problematic parameter in function declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153359

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-overload-cand-ranges.cpp
  clang/test/Misc/diag-overload-cand-ranges.mm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153359.532926.patch
Type: text/x-patch
Size: 12355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230620/a1bca8d8/attachment-0001.bin>


More information about the cfe-commits mailing list