This adds strlen to LoopIdiomRecognize.cpp and also recognizes strlens with 16 bit chars. For these cases, a new intrinsic (strlen16) is used. If a strlen/strlen16 function call is only used for zero equality comparison then it is replaced with a load of the first element. If a strlen16 intrinsic cannot be folded, it is expanded back out to the canonical loop form.
Examples that this recognizes:
unsigned strlen1(char *Str) { char *Src = Str; if (!Src) return 0; for (; *Src;) Src++; return Src - Str; } unsigned strlen2(char *Str) { unsigned Len = 0; if (!Str) return 0; while(*Str) { Len++; Str++; } return Len; }
clang-tidy: warning: 'auto *Curr' can be declared as 'const auto *Curr' [llvm-qualified-auto]
not useful