Author: tkrasnukha Date: Thu Aug 9 04:42:28 2018 New Revision: 339328 URL: http://llvm.org/viewvc/llvm-project?rev=339328&view=rev Log: Remove unused type Either from Utility library.
Modified: lldb/trunk/include/lldb/Utility/Either.h lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/include/lldb/Utility/Either.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Either.h?rev=339328&r1=339327&r2=339328&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/Either.h (original) +++ lldb/trunk/include/lldb/Utility/Either.h Thu Aug 9 04:42:28 2018 @@ -12,115 +12,61 @@ #include "llvm/ADT/Optional.h" -#include <functional> - namespace lldb_utility { -template <typename T1, typename T2> class Either { -private: - enum class Selected { One, Two }; - - Selected m_selected; - union { - T1 m_t1; - T2 m_t2; - }; - -public: - Either(const T1 &t1) { - m_t1 = t1; - m_selected = Selected::One; - } - - Either(const T2 &t2) { - m_t2 = t2; - m_selected = Selected::Two; - } - - Either(const Either<T1, T2> &rhs) { - switch (rhs.m_selected) { - case Selected::One: - m_t1 = rhs.GetAs<T1>().getValue(); - m_selected = Selected::One; - break; - case Selected::Two: - m_t2 = rhs.GetAs<T2>().getValue(); - m_selected = Selected::Two; - break; - } - } - - template <class X, typename std::enable_if<std::is_same<T1, X>::value>::type - * = nullptr> - llvm::Optional<T1> GetAs() const { - switch (m_selected) { - case Selected::One: - return m_t1; - default: - return llvm::Optional<T1>(); - } - } - - template <class X, typename std::enable_if<std::is_same<T2, X>::value>::type - * = nullptr> - llvm::Optional<T2> GetAs() const { - switch (m_selected) { - case Selected::Two: - return m_t2; - default: - return llvm::Optional<T2>(); - } - } - - template <class ResultType> - ResultType Apply(std::function<ResultType(T1)> if_T1, - std::function<ResultType(T2)> if_T2) const { - switch (m_selected) { - case Selected::One: - return if_T1(m_t1); - case Selected::Two: - return if_T2(m_t2); - } - } - - bool operator==(const Either<T1, T2> &rhs) { - return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>()); - } - - explicit operator bool() { - switch (m_selected) { - case Selected::One: - return (bool)m_t1; - case Selected::Two: - return (bool)m_t2; - } - } - - Either<T1, T2> &operator=(const Either<T1, T2> &rhs) { - switch (rhs.m_selected) { - case Selected::One: - m_t1 = rhs.GetAs<T1>().getValue(); - m_selected = Selected::One; - break; - case Selected::Two: - m_t2 = rhs.GetAs<T2>().getValue(); - m_selected = Selected::Two; - break; - } - return *this; - } - - ~Either() { - switch (m_selected) { - case Selected::One: - m_t1.T1::~T1(); - break; - case Selected::Two: - m_t2.T2::~T2(); - break; - } - } -}; - + template <typename T1, typename T2> + class Either { + private: + enum class Selected { + One, Two + }; + + Selected m_selected; + union { + T1 m_t1; + T2 m_t2; + }; + + public: + Either(const T1& t1) + { + m_t1 = t1; + m_selected = Selected::One; + } + + Either(const T2& t2) + { + m_t2 = t2; + m_selected = Selected::Two; + } + + template <class X, typename std::enable_if<std::is_same<T1,X>::value>::type * = nullptr > + llvm::Optional<T1> + GetAs() + { + switch (m_selected) + { + case Selected::One: + return m_t1; + default: + return llvm::Optional<T1>(); + } + } + + template <class X, typename std::enable_if<std::is_same<T2,X>::value>::type * = nullptr > + llvm::Optional<T2> + GetAs() + { + switch (m_selected) + { + case Selected::Two: + return m_t2; + default: + return llvm::Optional<T2>(); + } + } + }; + } // namespace lldb_utility #endif // #ifndef liblldb_Either_h_ + Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=339328&r1=339327&r2=339328&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Aug 9 04:42:28 2018 @@ -1777,7 +1777,6 @@ 26CFDCA2186163A4000E63E5 /* Editline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Editline.cpp; sourceTree = "<group>"; }; 26CFDCA01861638D000E63E5 /* Editline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Editline.h; path = include/lldb/Host/Editline.h; sourceTree = "<group>"; }; 2326CF511BDD693B00A5CEAC /* EditlineTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EditlineTest.cpp; sourceTree = "<group>"; }; - 9481FE6B1B5F2D9200DED357 /* Either.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Either.h; path = include/lldb/Utility/Either.h; sourceTree = "<group>"; }; 26D9FDC812F784FD0003F2EE /* EmulateInstruction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EmulateInstruction.cpp; path = source/Core/EmulateInstruction.cpp; sourceTree = "<group>"; }; 26D9FDC612F784E60003F2EE /* EmulateInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulateInstruction.h; path = include/lldb/Core/EmulateInstruction.h; sourceTree = "<group>"; }; 9A22A15D135E30370024DDC3 /* EmulateInstructionARM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmulateInstructionARM.cpp; sourceTree = "<group>"; }; @@ -4510,7 +4509,6 @@ 49CA96E81E6AAC6600C03FEE /* DataEncoder.cpp */, 49CA96F41E6AAC8E00C03FEE /* DataExtractor.h */, 49CA96E91E6AAC6600C03FEE /* DataExtractor.cpp */, - 9481FE6B1B5F2D9200DED357 /* Either.h */, 26BC7DD310F1B7D500F91463 /* Endian.h */, AFC2DCE61E6E2ED000283714 /* FastDemangle.cpp */, AFC2DCED1E6E2F9800283714 /* FastDemangle.h */, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits