[PATCH] D23213: Allow SmallVector to be used as a yaml sequence
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 5 11:05:47 PDT 2016
majnemer added inline comments.
================
Comment at: include/llvm/Support/YAMLTraits.h:1362-1382
@@ -1361,1 +1361,23 @@
+template <typename T> struct SequenceTraitsImpl {
+ typedef typename T::value_type _type;
+ static size_t size(IO &io, T &seq) { return seq.size(); }
+ static _type &element(IO &io, T &seq, size_t index) {
+ if (index >= seq.size())
+ seq.resize(index + 1);
+ return seq[index];
+ }
+};
+
+template <typename T> struct FlowSequenceTraitsImpl {
+ typedef typename T::value_type _type;
+ static size_t size(IO &io, T &seq) { return seq.size(); }
+ static _type &element(IO &io, T &seq, size_t index) {
+ (void)flow; /* Remove this workaround after PR17897 is fixed */
+ if (index >= seq.size())
+ seq.resize(index + 1);
+ return seq[index];
+ }
+ static const bool flow = true;
+};
+
----------------
Is this formatted right? it looks funny to me for some reason.
================
Comment at: include/llvm/Support/YAMLTraits.h:1381
@@ +1380,3 @@
+ }
+ static const bool flow = true;
+};
----------------
Where is flow used?
================
Comment at: include/llvm/Support/YAMLTraits.h:1406
@@ +1405,3 @@
+ namespace yaml { \
+ template <int N> \
+ struct SequenceTraits<SmallVector<_type, N>> \
----------------
Shouldn't this be `unsigned` to match `SmallVector`'s template?
================
Comment at: include/llvm/Support/YAMLTraits.h:1420
@@ +1419,3 @@
+ namespace yaml { \
+ template <int N> \
+ struct DocumentListTraits<SmallVector<_type, N>> \
----------------
Ditto.
https://reviews.llvm.org/D23213
More information about the llvm-commits
mailing list