diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/MC/MCModuleYAML.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/MC/MCModuleYAML.cpp b/llvm/lib/MC/MCModuleYAML.cpp index 102971b7320..432652b0db9 100644 --- a/llvm/lib/MC/MCModuleYAML.cpp +++ b/llvm/lib/MC/MCModuleYAML.cpp @@ -162,12 +162,14 @@ template <> struct ScalarTraits<MCModuleYAML::Operand> { static void output(const MCModuleYAML::Operand &, void *, llvm::raw_ostream &); static StringRef input(StringRef, void *, MCModuleYAML::Operand &); + static bool mustQuote(StringRef) { return false; } }; template <> struct ScalarTraits<MCModuleYAML::OpcodeEnum> { static void output(const MCModuleYAML::OpcodeEnum &, void *, llvm::raw_ostream &); static StringRef input(StringRef, void *, MCModuleYAML::OpcodeEnum &); + static bool mustQuote(StringRef) { return false; } }; void ScalarEnumerationTraits<MCAtom::AtomKind>::enumeration( diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index f46f140abd8..e5f94947ff8 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -285,7 +285,7 @@ void Input::endBitSetScalar() { } } -void Input::scalarString(StringRef &S) { +void Input::scalarString(StringRef &S, bool) { if (ScalarHNode *SN = dyn_cast<ScalarHNode>(CurrentNode)) { S = SN->value(); } else { @@ -541,10 +541,7 @@ void Output::endBitSetScalar() { this->outputUpToEndOfLine(" ]"); } -void Output::scalarString(StringRef &S) { - const char ScalarSafeChars[] = "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-/^., \t"; - +void Output::scalarString(StringRef &S, bool MustQuote) { this->newLineCheck(); if (S.empty()) { // Print '' for the empty string because leaving the field empty is not @@ -552,11 +549,8 @@ void Output::scalarString(StringRef &S) { this->outputUpToEndOfLine("''"); return; } - bool isOctalString = S.front() == '0' && S.size() > 2 && !S.startswith("0x"); - if (S.find_first_not_of(ScalarSafeChars) == StringRef::npos && - !isspace(S.front()) && !isspace(S.back()) && !isOctalString) { - // If the string consists only of safe characters, print it out without - // quotes. + if (!MustQuote) { + // Only quote if we must. this->outputUpToEndOfLine(S); return; } |