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

Hi, I tried running the patched clang-tidy on the original issue. It seems that 
it still gives invalid codegen on macOS's libc++:

```
$ projects/llvm-project% cat /tmp/pr208762-std-string-repro.cpp
#include <string>

void f(const std::string &s, unsigned &n) {
  if (s.size() > n)
    n = s.size();
}
$ projects/llvm-project% /tmp/llvm-pr-210768-review/build/bin/clang-tidy 
-checks='-*,readability-use-std-min-max' -fix 
/tmp/pr208762-std-string-repro.cpp -- -std=c++17 -isysroot "$(xcrun 
--show-sdk-path)" -isystem "$(xcrun --show-sdk-path)/usr/include/c++/v1"
1 warning generated.
/tmp/pr208762-std-string-repro.cpp:4:3: warning: use `std::max` instead of `>` 
[readability-use-std-min-max]
    1 | #include <string>
    2 | 
    3 | void f(const std::string &s, unsigned &n) {
    4 |   if (s.size() > n)
      |   ^~~~~~~~~~~~~~~~~
      |   n = std::max<__size_type<allocator_type, difference_type>>(s.size(), 
n);
    5 |     n = s.size();
      |     ~~~~~~~~~~~~~
/tmp/pr208762-std-string-repro.cpp:1:1: note: FIX-IT applied suggested code 
changes
    1 | #include <string>
      | ^
/tmp/pr208762-std-string-repro.cpp:4:3: note: FIX-IT applied suggested code 
changes
    4 |   if (s.size() > n)
      |   ^
clang-tidy applied 2 of 2 suggested fixes.
$ projects/llvm-project% cat /tmp/pr208762-std-string-repro.cpp 
#include <algorithm>
#include <string>

void f(const std::string &s, unsigned &n) {
  n = std::max<__size_type<allocator_type, difference_type>>(s.size(), n);
}
$ projects/llvm-project% /usr/bin/clang++ -std=c++17 -fsyntax-only 
/tmp/pr208762-std-string-repro.cpp
/tmp/pr208762-std-string-repro.cpp:5:28: error: use of undeclared identifier 
'allocator_type'
    5 |   n = std::max<__size_type<allocator_type, difference_type>>(s.size(), 
n);
      |                            ^~~~~~~~~~~~~~
1 error generated.
$ projects/llvm-project% 
```

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

Reply via email to