r190486 - Do not quote YAML plain string myself. Let YAMLIO do that.
Rui Ueyama
ruiu at google.com
Tue Sep 10 21:00:35 PDT 2013
Author: ruiu
Date: Tue Sep 10 23:00:35 2013
New Revision: 190486
URL: http://llvm.org/viewvc/llvm-project?rev=190486&view=rev
Log:
Do not quote YAML plain string myself. Let YAMLIO do that.
Modified:
cfe/trunk/include/clang/Tooling/ReplacementsYaml.h
cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp
Modified: cfe/trunk/include/clang/Tooling/ReplacementsYaml.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/ReplacementsYaml.h?rev=190486&r1=190485&r2=190486&view=diff
==============================================================================
--- cfe/trunk/include/clang/Tooling/ReplacementsYaml.h (original)
+++ cfe/trunk/include/clang/Tooling/ReplacementsYaml.h Tue Sep 10 23:00:35 2013
@@ -29,10 +29,7 @@ namespace yaml {
/// \brief ScalarTraits to read/write std::string objects.
template <> struct ScalarTraits<std::string> {
static void output(const std::string &Val, void *, llvm::raw_ostream &Out) {
- // We need to put quotes around the string to make sure special characters
- // in the string is not treated as YAML tokens.
- std::string NormalizedVal = std::string("\"") + Val + std::string("\"");
- Out << NormalizedVal;
+ Out << Val;
}
static StringRef input(StringRef Scalar, void *, std::string &Val) {
Modified: cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp?rev=190486&r1=190485&r2=190486&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp Tue Sep 10 23:00:35 2013
@@ -36,34 +36,34 @@ 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"
- "Context: \"some context\"\n"
+ "MainSourceFile: /path/to/source.cpp\n"
+ "Context: some context\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"
+ " ReplacementText: 'replacement #1'\n"
+ " - FilePath: /path/to/file2.h\n"
" Offset: 301\n"
" Length: 2\n"
- " ReplacementText: \"replacement #2\"\n"
+ " ReplacementText: 'replacement #2'\n"
"...\n",
YamlContentStream.str().c_str());
}
TEST(ReplacementsYamlTest, deserializesReplacements) {
std::string YamlContent = "---\n"
- "MainSourceFile: \"/path/to/source.cpp\"\n"
- "Context: \"some context\"\n"
+ "MainSourceFile: /path/to/source.cpp\n"
+ "Context: some context\n"
"Replacements:\n"
- " - 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"
+ " ReplacementText: 'replacement #1'\n"
+ " - FilePath: /path/to/file2.h\n"
" Offset: 301\n"
" Length: 2\n"
- " ReplacementText: \"replacement #2\"\n"
+ " ReplacementText: 'replacement #2'\n"
"...\n";
TranslationUnitReplacements DocActual;
yaml::Input YAML(YamlContent);
@@ -85,12 +85,12 @@ TEST(ReplacementsYamlTest, deserializesR
TEST(ReplacementsYamlTest, deserializesWithoutContext) {
// Make sure a doc can be read without the context field.
std::string YamlContent = "---\n"
- "MainSourceFile: \"/path/to/source.cpp\"\n"
+ "MainSourceFile: /path/to/source.cpp\n"
"Replacements:\n"
- " - FilePath: \"target_file.h\"\n"
+ " - FilePath: target_file.h\n"
" Offset: 1\n"
" Length: 10\n"
- " ReplacementText: \"replacement\"\n"
+ " ReplacementText: replacement\n"
"...\n";
TranslationUnitReplacements DocActual;
yaml::Input YAML(YamlContent);
More information about the cfe-commits
mailing list