|
@@ -10,7 +10,6 @@
|
|
#ifndef LLVM_SUPPORT_YAMLTRAITS_H
|
|
#ifndef LLVM_SUPPORT_YAMLTRAITS_H
|
|
#define LLVM_SUPPORT_YAMLTRAITS_H
|
|
#define LLVM_SUPPORT_YAMLTRAITS_H
|
|
|
|
|
|
-
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/ADT/DenseMapInfo.h"
|
|
#include "llvm/ADT/DenseMapInfo.h"
|
|
#include "llvm/ADT/Optional.h"
|
|
#include "llvm/ADT/Optional.h"
|
|
@@ -29,7 +28,6 @@
|
|
namespace llvm {
|
|
namespace llvm {
|
|
namespace yaml {
|
|
namespace yaml {
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// to/from a YAML mapping. For example:
|
|
/// to/from a YAML mapping. For example:
|
|
///
|
|
///
|
|
@@ -52,7 +50,6 @@ struct MappingTraits {
|
|
// static const bool flow = true;
|
|
// static const bool flow = true;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by any integral type that converts
|
|
/// This class should be specialized by any integral type that converts
|
|
/// to/from a YAML scalar where there is a one-to-one mapping between
|
|
/// to/from a YAML scalar where there is a one-to-one mapping between
|
|
/// in-memory values and a string in YAML. For example:
|
|
/// in-memory values and a string in YAML. For example:
|
|
@@ -70,7 +67,6 @@ struct ScalarEnumerationTraits {
|
|
// static void enumeration(IO &io, T &value);
|
|
// static void enumeration(IO &io, T &value);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by any integer type that is a union
|
|
/// This class should be specialized by any integer type that is a union
|
|
/// of bit values and the YAML representation is a flow sequence of
|
|
/// of bit values and the YAML representation is a flow sequence of
|
|
/// strings. For example:
|
|
/// strings. For example:
|
|
@@ -88,7 +84,6 @@ struct ScalarBitSetTraits {
|
|
// static void bitset(IO &io, T &value);
|
|
// static void bitset(IO &io, T &value);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by type that requires custom conversion
|
|
/// This class should be specialized by type that requires custom conversion
|
|
/// to/from a yaml scalar. For example:
|
|
/// to/from a yaml scalar. For example:
|
|
///
|
|
///
|
|
@@ -149,7 +144,6 @@ struct BlockScalarTraits {
|
|
// static StringRef input(StringRef Scalar, void *ctxt, T &Value);
|
|
// static StringRef input(StringRef Scalar, void *ctxt, T &Value);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// to/from a YAML sequence. For example:
|
|
/// to/from a YAML sequence. For example:
|
|
///
|
|
///
|
|
@@ -175,7 +169,6 @@ struct SequenceTraits {
|
|
// static const bool flow = true;
|
|
// static const bool flow = true;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// This class should be specialized by any type that needs to be converted
|
|
/// to/from a list of YAML documents.
|
|
/// to/from a list of YAML documents.
|
|
template<typename T>
|
|
template<typename T>
|
|
@@ -185,7 +178,6 @@ struct DocumentListTraits {
|
|
// static T::value_type& element(IO &io, T &seq, size_t index);
|
|
// static T::value_type& element(IO &io, T &seq, size_t index);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Only used by compiler if both template types are the same
|
|
// Only used by compiler if both template types are the same
|
|
template <typename T, T>
|
|
template <typename T, T>
|
|
struct SameType;
|
|
struct SameType;
|
|
@@ -194,8 +186,6 @@ struct SameType;
|
|
template <typename T>
|
|
template <typename T>
|
|
struct MissingTrait;
|
|
struct MissingTrait;
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// Test if ScalarEnumerationTraits<T> is defined on type T.
|
|
// Test if ScalarEnumerationTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_ScalarEnumerationTraits
|
|
struct has_ScalarEnumerationTraits
|
|
@@ -213,7 +203,6 @@ public:
|
|
(sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
|
|
(sizeof(test<ScalarEnumerationTraits<T> >(nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Test if ScalarBitSetTraits<T> is defined on type T.
|
|
// Test if ScalarBitSetTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_ScalarBitSetTraits
|
|
struct has_ScalarBitSetTraits
|
|
@@ -230,7 +219,6 @@ public:
|
|
static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
|
|
static bool const value = (sizeof(test<ScalarBitSetTraits<T> >(nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Test if ScalarTraits<T> is defined on type T.
|
|
// Test if ScalarTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_ScalarTraits
|
|
struct has_ScalarTraits
|
|
@@ -252,7 +240,6 @@ public:
|
|
(sizeof(test<ScalarTraits<T>>(nullptr, nullptr, nullptr)) == 1);
|
|
(sizeof(test<ScalarTraits<T>>(nullptr, nullptr, nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Test if BlockScalarTraits<T> is defined on type T.
|
|
// Test if BlockScalarTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_BlockScalarTraits
|
|
struct has_BlockScalarTraits
|
|
@@ -272,7 +259,6 @@ public:
|
|
(sizeof(test<BlockScalarTraits<T>>(nullptr, nullptr)) == 1);
|
|
(sizeof(test<BlockScalarTraits<T>>(nullptr, nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Test if MappingTraits<T> is defined on type T.
|
|
// Test if MappingTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_MappingTraits
|
|
struct has_MappingTraits
|
|
@@ -305,8 +291,6 @@ public:
|
|
static bool const value = (sizeof(test<MappingTraits<T> >(nullptr)) == 1);
|
|
static bool const value = (sizeof(test<MappingTraits<T> >(nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// Test if SequenceTraits<T> is defined on type T.
|
|
// Test if SequenceTraits<T> is defined on type T.
|
|
template <class T>
|
|
template <class T>
|
|
struct has_SequenceMethodTraits
|
|
struct has_SequenceMethodTraits
|
|
@@ -323,7 +307,6 @@ public:
|
|
static bool const value = (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
|
|
static bool const value = (sizeof(test<SequenceTraits<T> >(nullptr)) == 1);
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// has_FlowTraits<int> will cause an error with some compilers because
|
|
// has_FlowTraits<int> will cause an error with some compilers because
|
|
// it subclasses int. Using this wrapper only instantiates the
|
|
// it subclasses int. Using this wrapper only instantiates the
|
|
// real has_FlowTraits only if the template type is a class.
|
|
// real has_FlowTraits only if the template type is a class.
|
|
@@ -353,14 +336,11 @@ public:
|
|
static bool const value = sizeof(f<Derived>(nullptr)) == 2;
|
|
static bool const value = sizeof(f<Derived>(nullptr)) == 2;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// Test if SequenceTraits<T> is defined on type T
|
|
// Test if SequenceTraits<T> is defined on type T
|
|
template<typename T>
|
|
template<typename T>
|
|
struct has_SequenceTraits : public std::integral_constant<bool,
|
|
struct has_SequenceTraits : public std::integral_constant<bool,
|
|
has_SequenceMethodTraits<T>::value > { };
|
|
has_SequenceMethodTraits<T>::value > { };
|
|
|
|
|
|
-
|
|
|
|
// Test if DocumentListTraits<T> is defined on type T
|
|
// Test if DocumentListTraits<T> is defined on type T
|
|
template <class T>
|
|
template <class T>
|
|
struct has_DocumentListTraits
|
|
struct has_DocumentListTraits
|
|
@@ -453,7 +433,6 @@ inline bool needsQuotes(StringRef S) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
template<typename T>
|
|
template<typename T>
|
|
struct missingTraits : public std::integral_constant<bool,
|
|
struct missingTraits : public std::integral_constant<bool,
|
|
!has_ScalarEnumerationTraits<T>::value
|
|
!has_ScalarEnumerationTraits<T>::value
|
|
@@ -654,8 +633,6 @@ private:
|
|
void *Ctxt;
|
|
void *Ctxt;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
template<typename T>
|
|
template<typename T>
|
|
typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
|
|
typename std::enable_if<has_ScalarEnumerationTraits<T>::value,void>::type
|
|
yamlize(IO &io, T &Val, bool) {
|
|
yamlize(IO &io, T &Val, bool) {
|
|
@@ -676,7 +653,6 @@ yamlize(IO &io, T &Val, bool) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
template<typename T>
|
|
template<typename T>
|
|
typename std::enable_if<has_ScalarTraits<T>::value,void>::type
|
|
typename std::enable_if<has_ScalarTraits<T>::value,void>::type
|
|
yamlize(IO &io, T &Val, bool) {
|
|
yamlize(IO &io, T &Val, bool) {
|
|
@@ -791,7 +767,6 @@ yamlize(IO &io, T &Seq, bool) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
template<>
|
|
template<>
|
|
struct ScalarTraits<bool> {
|
|
struct ScalarTraits<bool> {
|
|
static void output(const bool &, void*, llvm::raw_ostream &);
|
|
static void output(const bool &, void*, llvm::raw_ostream &);
|
|
@@ -883,8 +858,6 @@ struct ScalarTraits<double> {
|
|
static bool mustQuote(StringRef) { return false; }
|
|
static bool mustQuote(StringRef) { return false; }
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// Utility for use within MappingTraits<>::mapping() method
|
|
// Utility for use within MappingTraits<>::mapping() method
|
|
// to [de]normalize an object for use with YAML conversion.
|
|
// to [de]normalize an object for use with YAML conversion.
|
|
template <typename TNorm, typename TFinal>
|
|
template <typename TNorm, typename TFinal>
|
|
@@ -917,14 +890,12 @@ private:
|
|
TFinal &Result;
|
|
TFinal &Result;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// Utility for use within MappingTraits<>::mapping() method
|
|
// Utility for use within MappingTraits<>::mapping() method
|
|
// to [de]normalize an object for use with YAML conversion.
|
|
// to [de]normalize an object for use with YAML conversion.
|
|
template <typename TNorm, typename TFinal>
|
|
template <typename TNorm, typename TFinal>
|
|
struct MappingNormalizationHeap {
|
|
struct MappingNormalizationHeap {
|
|
MappingNormalizationHeap(IO &i_o, TFinal &Obj)
|
|
MappingNormalizationHeap(IO &i_o, TFinal &Obj)
|
|
- : io(i_o), BufPtr(NULL), Result(Obj) {
|
|
|
|
|
|
+ : io(i_o), BufPtr(nullptr), Result(Obj) {
|
|
if ( io.outputting() ) {
|
|
if ( io.outputting() ) {
|
|
BufPtr = new (&Buffer) TNorm(io, Obj);
|
|
BufPtr = new (&Buffer) TNorm(io, Obj);
|
|
}
|
|
}
|
|
@@ -953,8 +924,6 @@ private:
|
|
TFinal &Result;
|
|
TFinal &Result;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
///
|
|
///
|
|
/// The Input class is used to parse a yaml document into in-memory structs
|
|
/// The Input class is used to parse a yaml document into in-memory structs
|
|
/// and vectors.
|
|
/// and vectors.
|
|
@@ -1083,7 +1052,6 @@ private:
|
|
void setError(HNode *hnode, const Twine &message);
|
|
void setError(HNode *hnode, const Twine &message);
|
|
void setError(Node *node, const Twine &message);
|
|
void setError(Node *node, const Twine &message);
|
|
|
|
|
|
-
|
|
|
|
public:
|
|
public:
|
|
// These are only used by operator>>. They could be private
|
|
// These are only used by operator>>. They could be private
|
|
// if those templated things could be made friends.
|
|
// if those templated things could be made friends.
|
|
@@ -1105,9 +1073,6 @@ private:
|
|
bool ScalarMatchFound;
|
|
bool ScalarMatchFound;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
///
|
|
///
|
|
/// The Output class is used to generate a yaml document from in-memory structs
|
|
/// The Output class is used to generate a yaml document from in-memory structs
|
|
/// and vectors.
|
|
/// and vectors.
|
|
@@ -1181,9 +1146,6 @@ private:
|
|
bool NeedsNewLine;
|
|
bool NeedsNewLine;
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/// YAML I/O does conversion based on types. But often native data types
|
|
/// YAML I/O does conversion based on types. But often native data types
|
|
/// are just a typedef of built in intergral types (e.g. int). But the C++
|
|
/// are just a typedef of built in intergral types (e.g. int). But the C++
|
|
/// type matching system sees through the typedef and all the typedefed types
|
|
/// type matching system sees through the typedef and all the typedefed types
|
|
@@ -1206,8 +1168,6 @@ private:
|
|
_base value; \
|
|
_base value; \
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
///
|
|
///
|
|
/// Use these types instead of uintXX_t in any mapping to have
|
|
/// Use these types instead of uintXX_t in any mapping to have
|
|
/// its yaml output formatted as hexadecimal.
|
|
/// its yaml output formatted as hexadecimal.
|
|
@@ -1217,7 +1177,6 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, Hex16)
|
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, Hex32)
|
|
LLVM_YAML_STRONG_TYPEDEF(uint32_t, Hex32)
|
|
LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
|
|
LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
|
|
|
|
|
|
-
|
|
|
|
template<>
|
|
template<>
|
|
struct ScalarTraits<Hex8> {
|
|
struct ScalarTraits<Hex8> {
|
|
static void output(const Hex8 &, void*, llvm::raw_ostream &);
|
|
static void output(const Hex8 &, void*, llvm::raw_ostream &);
|
|
@@ -1246,7 +1205,6 @@ struct ScalarTraits<Hex64> {
|
|
static bool mustQuote(StringRef) { return false; }
|
|
static bool mustQuote(StringRef) { return false; }
|
|
};
|
|
};
|
|
|
|
|
|
-
|
|
|
|
// Define non-member operator>> so that Input can stream in a document list.
|
|
// Define non-member operator>> so that Input can stream in a document list.
|
|
template <typename T>
|
|
template <typename T>
|
|
inline
|
|
inline
|
|
@@ -1303,7 +1261,6 @@ operator>>(Input &yin, T &docSeq) {
|
|
return yin;
|
|
return yin;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// Define non-member operator<< so that Output can stream out document list.
|
|
// Define non-member operator<< so that Output can stream out document list.
|
|
template <typename T>
|
|
template <typename T>
|
|
inline
|
|
inline
|
|
@@ -1372,11 +1329,9 @@ operator<<(Output &yout, T &seq) {
|
|
return yout;
|
|
return yout;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
} // namespace yaml
|
|
} // namespace yaml
|
|
} // namespace llvm
|
|
} // namespace llvm
|
|
|
|
|
|
-
|
|
|
|
/// Utility for declaring that a std::vector of a particular type
|
|
/// Utility for declaring that a std::vector of a particular type
|
|
/// should be considered a YAML sequence.
|
|
/// should be considered a YAML sequence.
|
|
#define LLVM_YAML_IS_SEQUENCE_VECTOR(_type) \
|
|
#define LLVM_YAML_IS_SEQUENCE_VECTOR(_type) \
|
|
@@ -1436,6 +1391,4 @@ operator<<(Output &yout, T &seq) {
|
|
} \
|
|
} \
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#endif // LLVM_SUPPORT_YAMLTRAITS_H
|
|
#endif // LLVM_SUPPORT_YAMLTRAITS_H
|