diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:01:25 +0000 |
| commit | d8e91e46262bc44006913e6796843909f1ac7bcd (patch) | |
| tree | 7d0c143d9b38190e0fa0180805389da22cd834c5 /include/llvm/Support/JSON.h | |
| parent | b7eb8e35e481a74962664b63dfb09483b200209a (diff) | |
Notes
Diffstat (limited to 'include/llvm/Support/JSON.h')
| -rw-r--r-- | include/llvm/Support/JSON.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/llvm/Support/JSON.h b/include/llvm/Support/JSON.h index da3c5ea0b25d..7a04fd52bc50 100644 --- a/include/llvm/Support/JSON.h +++ b/include/llvm/Support/JSON.h @@ -294,9 +294,13 @@ public: Value(json::Array &&Elements) : Type(T_Array) { create<json::Array>(std::move(Elements)); } + template <typename Elt> + Value(const std::vector<Elt> &C) : Value(json::Array(C)) {} Value(json::Object &&Properties) : Type(T_Object) { create<json::Object>(std::move(Properties)); } + template <typename Elt> + Value(const std::map<std::string, Elt> &C) : Value(json::Object(C)) {} // Strings: types with value semantics. Must be valid UTF-8. Value(std::string V) : Type(T_String) { if (LLVM_UNLIKELY(!isUTF8(V))) { @@ -452,7 +456,10 @@ private: new (reinterpret_cast<T *>(Union.buffer)) T(std::forward<U>(V)...); } template <typename T> T &as() const { - return *reinterpret_cast<T *>(Union.buffer); + // Using this two-step static_cast via void * instead of reinterpret_cast + // silences a -Wstrict-aliasing false positive from GCC6 and earlier. + void *Storage = static_cast<void *>(Union.buffer); + return *static_cast<T *>(Storage); } template <typename Indenter> |
