diff options
author | Zachary Turner <zturner@google.com> | 2017-03-15 17:47:39 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-03-15 17:47:39 +0000 |
commit | 84efd4deb640023f1ea15ef0751bf8ebc5600cfb (patch) | |
tree | b181ba6035ee188ef2848ed63966008200082480 /llvm/lib | |
parent | 9d53b6ab4891aec25444a82dd76c686da01357d6 (diff) | |
download | bcm5719-llvm-84efd4deb640023f1ea15ef0751bf8ebc5600cfb.tar.gz bcm5719-llvm-84efd4deb640023f1ea15ef0751bf8ebc5600cfb.zip |
[YAML] When outputting, provide the ability to write default values.
Previously, if you attempted to write a key/value pair and the
value was equal to the key's default value, we would not output
the value. Sometimes it is useful to be able to see this value
in the output anyway.
llvm-svn: 297864
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/YAMLTraits.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp index 9849b3aa1ce..c410b1d5608 100644 --- a/llvm/lib/Support/YAMLTraits.cpp +++ b/llvm/lib/Support/YAMLTraits.cpp @@ -398,17 +398,10 @@ bool Input::canElideEmptySequence() { //===----------------------------------------------------------------------===// Output::Output(raw_ostream &yout, void *context, int WrapColumn) - : IO(context), - Out(yout), - WrapColumn(WrapColumn), - Column(0), - ColumnAtFlowStart(0), - ColumnAtMapFlowStart(0), - NeedBitValueComma(false), - NeedFlowSequenceComma(false), - EnumerationMatchFound(false), - NeedsNewLine(false) { -} + : IO(context), Out(yout), WrapColumn(WrapColumn), Column(0), + ColumnAtFlowStart(0), ColumnAtMapFlowStart(0), NeedBitValueComma(false), + NeedFlowSequenceComma(false), EnumerationMatchFound(false), + NeedsNewLine(false), WriteDefaultValues(false) {} Output::~Output() { } @@ -462,7 +455,7 @@ std::vector<StringRef> Output::keys() { bool Output::preflightKey(const char *Key, bool Required, bool SameAsDefault, bool &UseDefault, void *&) { UseDefault = false; - if (Required || !SameAsDefault) { + if (Required || !SameAsDefault || WriteDefaultValues) { auto State = StateStack.back(); if (State == inFlowMapFirstKey || State == inFlowMapOtherKey) { flowKey(Key); |