diff options
author | Nick Kledzik <kledzik@apple.com> | 2013-01-04 19:32:00 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2013-01-04 19:32:00 +0000 |
commit | 50c30427405142f1b587edee846606184ae6af8e (patch) | |
tree | d54ca0e131c2122dfe5a9d6f2eb850229ffd1e91 /include/llvm/Support/YAMLTraits.h | |
parent | f53b78f5bf28dff9536687245239f6aa200add86 (diff) | |
download | llvm-50c30427405142f1b587edee846606184ae6af8e.tar.gz llvm-50c30427405142f1b587edee846606184ae6af8e.tar.bz2 llvm-50c30427405142f1b587edee846606184ae6af8e.tar.xz |
Fix how YAML I/O detects flow sequences.
Update test case to verify flow sequence is
written as a flow sequence.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171514 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/YAMLTraits.h')
-rw-r--r-- | include/llvm/Support/YAMLTraits.h | 56 |
1 files changed, 21 insertions, 35 deletions
diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 3fb1f09063..821333bf2f 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -276,20 +276,9 @@ public: // Test if SequenceTraits<T> is defined on type T -// and SequenceTraits<T>::flow is *not* defined. template<typename T> struct has_SequenceTraits : public llvm::integral_constant<bool, - has_SequenceMethodTraits<T>::value - && !has_FlowTraits<T>::value > { }; - - -// Test if SequenceTraits<T> is defined on type T -// and SequenceTraits<T>::flow is defined. -template<typename T> -struct has_FlowSequenceTraits : public llvm::integral_constant<bool, - has_SequenceMethodTraits<T>::value - && has_FlowTraits<T>::value > { }; - + has_SequenceMethodTraits<T>::value > { }; // Test if DocumentListTraits<T> is defined on type T @@ -318,7 +307,6 @@ struct missingTraits : public llvm::integral_constant<bool, && !has_ScalarTraits<T>::value && !has_MappingTraits<T>::value && !has_SequenceTraits<T>::value - && !has_FlowSequenceTraits<T>::value && !has_DocumentListTraits<T>::value > {}; @@ -510,35 +498,33 @@ yamlize(IO &io, T &Val, bool) { template<typename T> typename llvm::enable_if_c<has_SequenceTraits<T>::value,void>::type yamlize(IO &io, T &Seq, bool) { - unsigned incount = io.beginSequence(); - unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incount; - for(unsigned i=0; i < count; ++i) { - void *SaveInfo; - if ( io.preflightElement(i, SaveInfo) ) { - yamlize(io, SequenceTraits<T>::element(io, Seq, i), true); - io.postflightElement(SaveInfo); + if ( has_FlowTraits< SequenceTraits<T> >::value ) { + unsigned incnt = io.beginFlowSequence(); + unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt; + for(unsigned i=0; i < count; ++i) { + void *SaveInfo; + if ( io.preflightFlowElement(i, SaveInfo) ) { + yamlize(io, SequenceTraits<T>::element(io, Seq, i), true); + io.postflightFlowElement(SaveInfo); + } } + io.endFlowSequence(); } - io.endSequence(); -} - -template<typename T> -typename llvm::enable_if_c<has_FlowSequenceTraits<T>::value,void>::type -yamlize(IO &io, T &Seq, bool) { - unsigned incount = io.beginFlowSequence(); - unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incount; - for(unsigned i=0; i < count; ++i) { - void *SaveInfo; - if ( io.preflightFlowElement(i, SaveInfo) ) { - yamlize(io, SequenceTraits<T>::element(io, Seq, i), true); - io.postflightFlowElement(SaveInfo); + else { + unsigned incnt = io.beginSequence(); + unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt; + for(unsigned i=0; i < count; ++i) { + void *SaveInfo; + if ( io.preflightElement(i, SaveInfo) ) { + yamlize(io, SequenceTraits<T>::element(io, Seq, i), true); + io.postflightElement(SaveInfo); + } } + io.endSequence(); } - io.endFlowSequence(); } - template<> struct ScalarTraits<bool> { static void output(const bool &, void*, llvm::raw_ostream &); |