[PATCH] D16529: [clang-tidy] Add modernize-raw-string-literal check
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 22 06:55:16 PDT 2016
aaron.ballman added a comment.
When running the tests from this patch locally (Win10, MSVC 2015, debug, x64), I get:
1>------ Build started: Project: intrinsics_gen, Configuration: Debug x64 ------
2>------ Build started: Project: ClangDiagnosticLex, Configuration: Debug x64 ------
3>------ Build started: Project: ClangDiagnosticParse, Configuration: Debug x64 ------
4>------ Build started: Project: ClangDiagnosticSema, Configuration: Debug x64 ------
5>------ Build started: Project: ClangDiagnosticSerialization, Configuration: Debug x64 ------
6>------ Build started: Project: ClangDiagnosticIndexName, Configuration: Debug x64 ------
7>------ Build started: Project: ClangDiagnosticGroups, Configuration: Debug x64 ------
8>------ Build started: Project: ClangStmtNodes, Configuration: Debug x64 ------
9>------ Build started: Project: ClangARMNeon, Configuration: Debug x64 ------
10>------ Build started: Project: ClangAttrClasses, Configuration: Debug x64 ------
11>------ Build started: Project: ClangAttrDump, Configuration: Debug x64 ------
12>------ Build started: Project: ClangAttrHasAttributeImpl, Configuration: Debug x64 ------
13>------ Build started: Project: ClangAttrImpl, Configuration: Debug x64 ------
14>------ Build started: Project: ClangAttrList, Configuration: Debug x64 ------
15>------ Build started: Project: ClangAttrPCHRead, Configuration: Debug x64 ------
16>------ Build started: Project: ClangAttrPCHWrite, Configuration: Debug x64 ------
17>------ Build started: Project: ClangAttrParsedAttrImpl, Configuration: Debug x64 ------
18>------ Build started: Project: ClangAttrParsedAttrKinds, Configuration: Debug x64 ------
19>------ Build started: Project: ClangAttrParsedAttrList, Configuration: Debug x64 ------
20>------ Build started: Project: ClangAttrParserStringSwitches, Configuration: Debug x64 ------
21>------ Build started: Project: ClangAttrSpellingListIndex, Configuration: Debug x64 ------
22>------ Build started: Project: ClangAttrTemplateInstantiate, Configuration: Debug x64 ------
23>------ Build started: Project: ClangAttrVisitor, Configuration: Debug x64 ------
24>------ Build started: Project: ClangCommentCommandInfo, Configuration: Debug x64 ------
25>------ Build started: Project: ClangCommentCommandList, Configuration: Debug x64 ------
26>------ Build started: Project: ClangCommentHTMLNamedCharacterReferences, Configuration: Debug x64 ------
27>------ Build started: Project: ClangCommentHTMLTags, Configuration: Debug x64 ------
28>------ Build started: Project: ClangCommentHTMLTagsProperties, Configuration: Debug x64 ------
29>------ Build started: Project: ClangCommentNodes, Configuration: Debug x64 ------
30>------ Build started: Project: ClangDeclNodes, Configuration: Debug x64 ------
31>------ Build started: Project: ClangDiagnosticAST, Configuration: Debug x64 ------
32>------ Build started: Project: ClangDiagnosticAnalysis, Configuration: Debug x64 ------
33>------ Build started: Project: ClangDiagnosticComment, Configuration: Debug x64 ------
34>------ Build started: Project: ClangDiagnosticCommon, Configuration: Debug x64 ------
35>------ Build started: Project: ClangDiagnosticDriver, Configuration: Debug x64 ------
36>------ Build started: Project: ClangDiagnosticFrontend, Configuration: Debug x64 ------
37>------ Build started: Project: AttributeCompatFuncTableGen, Configuration: Debug x64 ------
38>------ Build started: Project: ClangDriverOptions, Configuration: Debug x64 ------
39>------ Build started: Project: clang-headers, Configuration: Debug x64 ------
2> Updating DiagnosticLexKinds.inc...
8> Updating StmtNodes.inc...
5> Updating DiagnosticSerializationKinds.inc...
9> Updating arm_neon.inc...
1> Updating Attributes.inc...
40>------ Build started: Project: AMDGPUCommonTableGen, Configuration: Debug x64 ------
41>------ Build started: Project: AArch64CommonTableGen, Configuration: Debug x64 ------
42>------ Build started: Project: XCoreCommonTableGen, Configuration: Debug x64 ------
43>------ Build started: Project: ARMCommonTableGen, Configuration: Debug x64 ------
44>------ Build started: Project: X86CommonTableGen, Configuration: Debug x64 ------
45>------ Build started: Project: MSP430CommonTableGen, Configuration: Debug x64 ------
46>------ Build started: Project: HexagonCommonTableGen, Configuration: Debug x64 ------
47>------ Build started: Project: SparcCommonTableGen, Configuration: Debug x64 ------
48>------ Build started: Project: SystemZCommonTableGen, Configuration: Debug x64 ------
49>------ Build started: Project: PowerPCCommonTableGen, Configuration: Debug x64 ------
50>------ Build started: Project: BPFCommonTableGen, Configuration: Debug x64 ------
51>------ Build started: Project: NVPTXCommonTableGen, Configuration: Debug x64 ------
52>------ Build started: Project: MipsCommonTableGen, Configuration: Debug x64 ------
24> Updating CommentCommandInfo.inc...
20> Updating AttrParserStringSwitches.inc...
25> Updating CommentCommandList.inc...
26> Updating CommentHTMLNamedCharacterReferences.inc...
27> Updating CommentHTMLTags.inc...
29> Updating CommentNodes.inc...
28> Updating CommentHTMLTagsProperties.inc...
30> Updating DeclNodes.inc...
31> Updating DiagnosticASTKinds.inc...
32> Updating DiagnosticAnalysisKinds.inc...
34> Updating DiagnosticCommonKinds.inc...
33> Updating DiagnosticCommentKinds.inc...
35> Updating DiagnosticDriverKinds.inc...
36> Updating DiagnosticFrontendKinds.inc...
37> Updating AttributesCompatFunc.inc...
39> Updating arm_neon.h...
43> Updating ARMGenMCPseudoLowering.inc...
41> Updating AArch64GenRegisterInfo.inc...
42> Updating XCoreGenRegisterInfo.inc...
53>------ Build started: Project: ClangSACheckers, Configuration: Debug x64 ------
50> Updating BPFGenRegisterInfo.inc...
49> Updating PPCGenAsmMatcher.inc...
45> Updating MSP430GenRegisterInfo.inc...
48> Updating SystemZGenAsmMatcher.inc...
44> Updating X86GenRegisterInfo.inc...
40> Updating AMDGPUGenRegisterInfo.inc...
46> Updating HexagonGenAsmMatcher.inc...
47> Updating SparcGenRegisterInfo.inc...
51> Updating NVPTXGenRegisterInfo.inc...
52> Updating MipsGenRegisterInfo.inc...
39> Copying clang's arm_neon.h...
53> Updating Checkers.inc...
43> Updating ARMGenAsmMatcher.inc...
50> Updating X86GenAsmMatcher.inc...
42> Updating XCoreGenCallingConv.inc...
41> Updating AArch64GenMCPseudoLowering.inc...
45> Updating MSP430GenDAGISel.inc...
44> Updating X86GenAsmMatcher.inc...
48> Updating SystemZGenCallingConv.inc...
49> Updating PPCGenRegisterInfo.inc...
47> Updating SparcGenAsmMatcher.inc...
40> Updating AMDGPUGenCallingConv.inc...
46> Updating HexagonGenCallingConv.inc...
51> Updating NVPTXGenSubtargetInfo.inc...
52> Updating MipsGenCallingConv.inc...
43> Updating ARMGenCallingConv.inc...
50> Updating BPFGenCallingConv.inc...
42> Updating XCoreGenSubtargetInfo.inc...
41> Updating AArch64GenFastISel.inc...
45> Updating MSP430GenCallingConv.inc...
44> Updating X86GenFastISel.inc...
48> Updating SystemZGenRegisterInfo.inc...
49> Updating PPCGenFastISel.inc...
47> Updating SparcGenDAGISel.inc...
40> Updating AMDGPUGenSubtargetInfo.inc...
46> Updating HexagonGenDFAPacketizer.inc...
52> Updating MipsGenMCPseudoLowering.inc...
50> Updating BPFGenSubtargetInfo.inc...
41> Updating AArch64GenCallingConv.inc...
45> Updating MSP430GenSubtargetInfo.inc...
44> Updating X86GenCallingConv.inc...
48> Updating SystemZGenSubtargetInfo.inc...
49> Updating PPCGenCallingConv.inc...
47> Updating SparcGenCallingConv.inc...
40> Updating AMDGPUGenIntrinsics.inc...
46> Updating HexagonGenRegisterInfo.inc...
49> Updating PPCGenSubtargetInfo.inc...
44> Updating X86GenSubtargetInfo.inc...
40> Updating AMDGPUGenDFAPacketizer.inc...
46> Updating HexagonGenSubtargetInfo.inc...
54>------ Build started: Project: check-clang-tools, Configuration: Debug x64 ------
54> Running the Clang extra tools' regression tests
54> -- Testing: 244 tests, 32 threads --
54> FAIL: Clang Tools :: clang-tidy/modernize-raw-string-literal.cpp (114 of 244)
54> ******************** TEST 'Clang Tools :: clang-tidy/modernize-raw-string-literal.cpp' FAILED ********************
54> Script:
54> --
54> D:/Python27/python.exe E:/llvm/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py E:\llvm\llvm\tools\clang\tools\extra\test\clang-tidy\modernize-raw-string-literal.cpp modernize-raw-string-literal E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp
54> --
54> Exit Code: 1
54>
54> Command Output (stdout):
54> --
54> Command 0: "D:/Python27/python.exe" "E:/llvm/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py" "E:\llvm\llvm\tools\clang\tools\extra\test\clang-tidy\modernize-raw-string-literal.cpp" "modernize-raw-string-literal" "E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp"
54> Command 0 Result: 1
54> Command 0 Output:
54> Running ['clang-tidy', 'E:\\llvm\\2015\\tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\modernize-raw-string-literal.cpp.tmp.cpp', '-fix', '--checks=-*,modernize-raw-string-literal', '--', '--std=c++11']...
54> ------------------------ clang-tidy output -----------------------
54> 28 warnings and 8 errors generated.
54>
54> Error while processing E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp.
54>
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:3:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const BackSlash{"goink\\frob"};
54> ^
54> R"(goink\frob)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:49:1: error: unknown type name 'char16_t' [clang-diagnostic-error]
54> char16_t const *const UTF16Literal{u"foobie\\bletch"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:49:10: error: expected unqualified-id [clang-diagnostic-error]
54> char16_t const *const UTF16Literal{u"foobie\\bletch"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:50:1: error: unknown type name 'char16_t' [clang-diagnostic-error]
54> char16_t const *const UTF16RawLiteral{uR"(foobie\\bletch)"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:50:10: error: expected unqualified-id [clang-diagnostic-error]
54> char16_t const *const UTF16RawLiteral{uR"(foobie\\bletch)"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:51:1: error: unknown type name 'char32_t' [clang-diagnostic-error]
54> char32_t const *const UTF32Literal{U"foobie\\bletch"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:51:10: error: expected unqualified-id [clang-diagnostic-error]
54> char32_t const *const UTF32Literal{U"foobie\\bletch"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:52:1: error: unknown type name 'char32_t' [clang-diagnostic-error]
54> char32_t const *const UTF32RawLiteral{UR"(foobie\\bletch)"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:52:10: error: expected unqualified-id [clang-diagnostic-error]
54> char32_t const *const UTF32RawLiteral{UR"(foobie\\bletch)"};
54> ^
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:56:31: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const SingleQuote{"goink\'frob"};
54> ^
54> R"(goink'frob)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:60:31: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const DoubleQuote{"goink\"frob"};
54> ^
54> R"(goink"frob)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:64:32: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const QuestionMark{"goink\?frob"};
54> ^
54> R"(goink?frob)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:68:25: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const RegEx{"goink\\(one|two\\)\\\\\\?.*\\nfrob"};
54> ^
54> R"(goink\(one|two\)\\\?.*\nfrob)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:72:24: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const Path{"C:\\Program Files\\Vendor\\Application\\Application.exe"};
54> ^
54> R"(C:\Program Files\Vendor\Application\Application.exe)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:76:36: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const ContainsSentinel{"who\\ops)\""};
54> ^
54> R"lit(who\ops)")lit"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:80:33: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const ContainsDelim{"whoops)\")lit\""};
54> ^
54> R"lit1(whoops)")lit")lit1"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:84:34: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const OctalPrintable{"\100\\"};
54> ^
54> R"(@\)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:88:32: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const HexPrintable{"\x40\\"};
54> ^
54> R"(@\)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:104:25: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const Str{"foo\\bar"};
54> ^
54> R"(foo\bar)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:111:25: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> char const *const Str{"foo\\bar"};
54> ^
54> R"(foo\bar)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:117:11: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> fn<int>("foo\\bar");
54> ^
54> R"(foo\bar)"
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:120:14: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
54> fn<double>("foo\\bar");
54> ^
54> R"(foo\bar)"
54> Found compiler errors, but -fix-errors was not specified.
54>
54> Fixes have NOT been applied.
54>
54>
54>
54>
54> ------------------------------------------------------------------
54> ------------------------------ Fixes -----------------------------
54>
54> ------------------------------------------------------------------
54> FileCheck failed:
54> E:\llvm\llvm\tools\clang\tools\extra\test\clang-tidy\modernize-raw-string-literal.cpp:5:17: error: expected string not found in input
54>
54> // CHECK-FIXES: {{^}}char const *const BackSlash{R"(goink\frob)"};{{$}}
54>
54> ^
54>
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:1:1: note: scanning from here
54>
54> // RUN: %check_clang_tidy %s modernize-raw-string-literal %t
54>
54> ^
54>
54> E:\llvm\2015\tools\clang\tools\extra\test\clang-tidy\Output\modernize-raw-string-literal.cpp.tmp.cpp:3:1: note: possible intended match here
54>
54> char const *const BackSlash{"goink\\frob"};
54>
54> ^
54>
54>
54>
54>
54> Command 0 Stderr:
54> Traceback (most recent call last):
54>
54> File "E:/llvm/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py", line 135, in <module>
54>
54> main()
54>
54> File "E:/llvm/llvm/tools/clang/tools/extra/test/../test\clang-tidy\check_clang_tidy.py", line 116, in main
54>
54> stderr=subprocess.STDOUT)
54>
54> File "D:\Python27\lib\subprocess.py", line 573, in check_output
54>
54> raise CalledProcessError(retcode, cmd, output=output)
54>
54> subprocess.CalledProcessError: Command '['FileCheck', '-input-file=E:\\llvm\\2015\\tools\\clang\\tools\\extra\\test\\clang-tidy\\Output\\modernize-raw-string-literal.cpp.tmp.cpp', 'E:\\llvm\\llvm\\tools\\clang\\tools\\extra\\test\\clang-tidy\\modernize-raw-string-literal.cpp', '-check-prefix=CHECK-FIXES', '-strict-whitespace']' returned non-zero exit status 1
54>
54>
54>
54>
54> --
54>
54> ********************
54>
54> Testing Time: 6.68s
54> ********************
54> Failing Tests (1):
54> Clang Tools :: clang-tidy/modernize-raw-string-literal.cpp
54>
54> Expected Passes : 242
54> Unsupported Tests : 1
54> Unexpected Failures: 1
54>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error MSB6006: "cmd.exe" exited with code 1.
Build: 53 succeeded, 1 failed, 161 up-to-date, 0 skipped
--------------------------------------------------------
http://reviews.llvm.org/D16529
More information about the cfe-commits
mailing list