[PATCH] D45932: [clang-tidy][modernize-raw-string-literal] Don't replace upper ASCII with raw literals

Zinovy Nis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 23 23:30:17 PDT 2018


zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.


================
Comment at: clang-tidy/modernize/RawStringLiteralCheck.cpp:70-72
+  if (Bytes.find_if([](char C) {
+        return static_cast<unsigned char>(C) > 0x7Fu;
+      }) != StringRef::npos)
----------------
aaron.ballman wrote:
> I think you can use `isASCII()` from CharInfo.h rather than reimplement it.
Nice finding! Thanks!


================
Comment at: test/clang-tidy/modernize-raw-string-literal.cpp:44
+char const *const MultibyteSnowman("\xE2\x98\x83");
+// CHECK-FIXES: {{^}}char const *const MultibyteSnowman("\xE2\x98\x83");{{$}}
 
----------------
LegalizeAdulthood wrote:
> IIRC, the default behavior is that if no matching CHECK-FIXES line is found, then it is considered a failure.  Have you tried your test code without your change to verify that this is the case?
1. Without my fix my test fails with a Python decoder error as it cannot print Unicode symbols in Windows console. But no FileCheck errors occur:


```
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 974: ordinal not in range(128)
```


2. Regardless of my changes when I replace `"char const *const Delete("\\\177");"` with `"char const *const Delete("\000\\\177");"` (leading `\0`) test still passes! Looks like CHECK-FIXes must be explicit.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45932





More information about the cfe-commits mailing list