https://github.com/zeyi2 requested changes to this pull request.

I think this check introduces a sementic change, here is a reproducer:
```
m@n:~/.../projects/llvm-project$ cat a.cpp 
#include <iostream>
#include <string>
#include <string_view>

void f(std::string_view) {
  std::cout << "Original behavior (string_view)" << std::endl;
}

void f(const char *) {
  std::cout << "Changed behavior (const char*)" << std::endl;
}

int main() {
  f(std::string("text"));
  return 0;
}
m@n:~/.../projects/llvm-project$ ./build/bin/clang++ a.cpp -oa && ./a && rm a
Original behavior (string_view)
m@n:~/.../projects/llvm-project$ ./build/bin/clang-tidy a.cpp 
--checks="-*,performance-string-view-conversions" -fix -- -std=c++17
1 warning generated.
/home/mitchell/Documents/projects/llvm-project/a.cpp:14:5: warning: redundant 
conversion to 'std::string' (aka 'basic_string<char>') and then back to 
'__sv_type' (aka 'basic_string_view<char, std::char_traits<char>>') 
[performance-string-view-conversions]
   14 |   f(std::string("text"));
      |     ^~~~~~~~~~~~~~~~~~~
      |     "text"
/home/mitchell/Documents/projects/llvm-project/a.cpp:14:5: note: FIX-IT applied 
suggested code changes
clang-tidy applied 1 of 1 suggested fixes.
m@n:~/.../projects/llvm-project$ ./build/bin/clang++ a.cpp -ob && ./b && rm b
Changed behavior (const char*)
```

https://github.com/llvm/llvm-project/pull/174288
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to