r344359 - Make YAML quote forward slashes.

Zachary Turner via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 12 09:31:20 PDT 2018


Author: zturner
Date: Fri Oct 12 09:31:20 2018
New Revision: 344359

URL: http://llvm.org/viewvc/llvm-project?rev=344359&view=rev
Log:
Make YAML quote forward slashes.

If you have the string /usr/bin, prior to this patch it would not
be quoted by our YAML serializer.  But a string like C:\src would
be, due to the presence of a backslash.  This makes the quoting
rules of basically every single file path different depending on
the path syntax (posix vs. Windows).

While technically not required by the YAML specification to quote
forward slashes, when the behavior of paths is inconsistent it
makes it difficult to portably write FileCheck lines that will
work with either kind of path.

Differential Revision: https://reviews.llvm.org/D53169

Modified:
    cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp
    cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp

Modified: cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp?rev=344359&r1=344358&r2=344359&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp Fri Oct 12 09:31:20 2018
@@ -58,30 +58,30 @@ TEST(DiagnosticsYamlTest, serializesDiag
   YAML << TUD;
 
   EXPECT_EQ("---\n"
-            "MainSourceFile:  path/to/source.cpp\n"
+            "MainSourceFile:  'path/to/source.cpp'\n"
             "Diagnostics:     \n"
             "  - DiagnosticName:  'diagnostic#1\'\n"
             "    Message:         'message #1'\n"
             "    FileOffset:      55\n"
-            "    FilePath:        path/to/source.cpp\n"
+            "    FilePath:        'path/to/source.cpp'\n"
             "    Replacements:    \n"
-            "      - FilePath:        path/to/source.cpp\n"
+            "      - FilePath:        'path/to/source.cpp'\n"
             "        Offset:          100\n"
             "        Length:          12\n"
             "        ReplacementText: 'replacement #1'\n"
             "  - DiagnosticName:  'diagnostic#2'\n"
             "    Message:         'message #2'\n"
             "    FileOffset:      60\n"
-            "    FilePath:        path/to/header.h\n"
+            "    FilePath:        'path/to/header.h'\n"
             "    Replacements:    \n"
-            "      - FilePath:        path/to/header.h\n"
+            "      - FilePath:        'path/to/header.h'\n"
             "        Offset:          62\n"
             "        Length:          2\n"
             "        ReplacementText: 'replacement #2'\n"
             "  - DiagnosticName:  'diagnostic#3'\n"
             "    Message:         'message #3'\n"
             "    FileOffset:      72\n"
-            "    FilePath:        path/to/source2.cpp\n"
+            "    FilePath:        'path/to/source2.cpp'\n"
             "    Replacements:    \n"
             "...\n",
             YamlContentStream.str());

Modified: cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp?rev=344359&r1=344358&r2=344359&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp Fri Oct 12 09:31:20 2018
@@ -33,13 +33,13 @@ TEST(ReplacementsYamlTest, serializesRep
 
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
-               "MainSourceFile:  /path/to/source.cpp\n"
+               "MainSourceFile:  '/path/to/source.cpp'\n"
                "Replacements:    \n" // Extra whitespace here!
-               "  - FilePath:        /path/to/file1.h\n"
+               "  - FilePath:        '/path/to/file1.h'\n"
                "    Offset:          232\n"
                "    Length:          56\n"
                "    ReplacementText: 'replacement #1'\n"
-               "  - FilePath:        /path/to/file2.h\n"
+               "  - FilePath:        '/path/to/file2.h'\n"
                "    Offset:          301\n"
                "    Length:          2\n"
                "    ReplacementText: 'replacement #2'\n"




More information about the cfe-commits mailing list