diff --git a/test/tools/llvm-strings/negative-char.test b/test/tools/llvm-strings/negative-char.test new file mode 100644 index 00000000000..331dde47078 --- /dev/null +++ b/test/tools/llvm-strings/negative-char.test @@ -0,0 +1,3 @@ +# RUN: echo -e "z\0\x80\0a\0" | llvm-strings --bytes 1 - | FileCheck %s +# CHECK: z{{$}} +# CHECK-NEXT: {{^}} a diff --git a/tools/llvm-strings/llvm-strings.cpp b/tools/llvm-strings/llvm-strings.cpp index 8e2d213bcc7..c355caf899d 100644 --- a/tools/llvm-strings/llvm-strings.cpp +++ b/tools/llvm-strings/llvm-strings.cpp @@ -80,7 +80,7 @@ static void strings(raw_ostream &OS, StringRef FileName, StringRef Contents) { const char *B = Contents.begin(); const char *P = nullptr, *E = nullptr, *S = nullptr; for (P = Contents.begin(), E = Contents.end(); P < E; ++P) { - if (std::isgraph(*P) || std::isblank(*P)) { + if (isPrint(*P) || *P == '\t') { if (S == nullptr) S = P; } else if (S) {