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

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 03:43:29 PDT 2018


alexfh added inline comments.


================
Comment at: test/clang-tidy/modernize-raw-string-literal.cpp:42
 char const *const HexNonPrintable("\\\x03");
 char const *const Delete("\\\177");
+char const *const MultibyteSnowman("\xE2\x98\x83");
----------------
zinovy.nis wrote:
> By the way, AFAIK the lines above are not checked for fixes (and fixes absence) at all! Is it correct?
These test cases without corresponding CHECK-FIXES/CHECK-MESSAGES lines will work (that is ensure no fixes are applied to the code) under the assumption that all warnings explicitly covered by CHECK-MESSAGE lines will only contain fixes for relevant code (in most cases in the same line), and there are CHECK-FIXES for all of them.

And if there is no CHECK-MESSAGES line then `FileCheck -implicit-check-not='warning|error' -check-prefix=CHECK-MESSAGES` (used in the check_clang_tidy.py) will fail if there is an unaccounted (i.e. not covered by a CHECK-MESSAGES: pattern) warning.

The assumption won't work if the check makes distant fixes (for example, if it inserts #include directives, there should be a CHECK-FIXES line for that).

Thus there's not much value in checking these lines are left unmodified. But in case there is a warning which should contain no fix, checking that the code was not modified by clang-tidy is quite useful.

We could make this more explicit in different ways:
1. Run FileCheck on the result of `diff original-file file-processed-by-clang-tidy`. That may make tests much more verbose.
2. Run FileCheck on the result of `clang-tidy -export-fixes`. That would make the tests both more verbose and harder to verify for sanity (applying textual replacements with given byte offsets is not what a human brain does well).

Better ideas are welcome.


https://reviews.llvm.org/D45932





More information about the cfe-commits mailing list