================
@@ -16,13 +17,13 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::modernize {
 
 static StringRef toStringViewTypeStr(StringRef Type) {
-  if (Type.contains("wchar_t"))
+  if (Type.contains("wchar_t") || Type.ends_with("wstring"))
     return "std::wstring_view";
-  if (Type.contains("char8_t"))
+  if (Type.contains("char8_t") || Type.ends_with("u8string"))
     return "std::u8string_view";
-  if (Type.contains("char16_t"))
+  if (Type.contains("char16_t") || Type.ends_with("u16string"))
     return "std::u16string_view";
-  if (Type.contains("char32_t"))
+  if (Type.contains("char32_t") || Type.ends_with("u32string"))
----------------
irishrover wrote:

I applied this check to the Chromium codebase and found that 

``MatchedDecl->getReturnType().getCanonicalType()``, ``DesugaredType`` and 
``MatchedDecl->getReturnType()`` return ``std::[w|u...]string`` and not 
``basic_string<...>``, while ``MatchedDecl->getReturnType().dump()`` prints the 
correct tree with ``basic_string...``s.

Maybe it's because of custom stdlib used in Chromium: 
https://source.chromium.org/chromium/chromium/src/+/main:third_party/libc++/src/include/__fwd/string.h;drc=d9a7d1399cb299664db77d32ba175ecc1137aade;l=48

So I decided to add a fallback for such cases.

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

Reply via email to