From f64487bf7074eeb5247479f3896807d38059fc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 10 May 2020 20:02:29 +0200 Subject: [PATCH] Move LazyExpr's and MessageInfo's implementation to the combined TU Some of the implementations were inlined instead. --- src/CMakeLists.txt | 2 - src/catch2/internal/catch_combined_tu.cpp | 51 ++++++++++++++++++++++ src/catch2/internal/catch_decomposer.hpp | 5 ++- src/catch2/internal/catch_lazy_expr.cpp | 30 ------------- src/catch2/internal/catch_message_info.cpp | 26 ----------- src/catch2/internal/catch_message_info.hpp | 8 +++- 6 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 src/catch2/internal/catch_lazy_expr.cpp delete mode 100644 src/catch2/internal/catch_message_info.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8d7799d..dac58fab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,13 +148,11 @@ set(IMPL_SOURCES ${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp - ${SOURCES_DIR}/internal/catch_lazy_expr.cpp ${SOURCES_DIR}/internal/catch_list.cpp ${SOURCES_DIR}/matchers/catch_matchers_floating.cpp ${SOURCES_DIR}/matchers/catch_matchers_string.cpp ${SOURCES_DIR}/matchers/catch_matchers_templated.cpp ${SOURCES_DIR}/catch_message.cpp - ${SOURCES_DIR}/internal/catch_message_info.cpp ${SOURCES_DIR}/internal/catch_output_redirect.cpp ${SOURCES_DIR}/catch_registry_hub.cpp ${SOURCES_DIR}/internal/catch_combined_tu.cpp diff --git a/src/catch2/internal/catch_combined_tu.cpp b/src/catch2/internal/catch_combined_tu.cpp index c6819362..fcb05093 100644 --- a/src/catch2/internal/catch_combined_tu.cpp +++ b/src/catch2/internal/catch_combined_tu.cpp @@ -171,3 +171,54 @@ namespace Catch { Catch::LeakDetector::~LeakDetector() { Catch::cleanUp(); } + + +///////////////////////////////////////////// +// vvv formerly catch_message_info.cpp vvv // +///////////////////////////////////////////// + +#include + +namespace Catch { + + MessageInfo::MessageInfo( StringRef const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + +} // end namespace Catch + + + + +////////////////////////////////////////// +// vvv formerly catch_lazy_expr.cpp vvv // +////////////////////////////////////////// +#include +#include + +namespace Catch { + + auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { + if (lazyExpr.m_isNegated) + os << "!"; + + if (lazyExpr) { + if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + +} // namespace Catch diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 4c90091c..dc1c2d6b 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -49,7 +49,10 @@ namespace Catch { bool m_isBinaryExpression; bool m_result; - + friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) { + expr.streamReconstructedExpression(out); + return out; + } }; void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); diff --git a/src/catch2/internal/catch_lazy_expr.cpp b/src/catch2/internal/catch_lazy_expr.cpp deleted file mode 100644 index 21a33cdc..00000000 --- a/src/catch2/internal/catch_lazy_expr.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -#include - - -namespace Catch { - - namespace { - auto operator <<(std::ostream& os, ITransientExpression const& expr) -> std::ostream& { - expr.streamReconstructedExpression(os); - return os; - } - } - - auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { - if (lazyExpr.m_isNegated) - os << "!"; - - if (lazyExpr) { - if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) - os << "(" << *lazyExpr.m_transientExpression << ")"; - else - os << *lazyExpr.m_transientExpression; - } else { - os << "{** error - unchecked empty expression requested **}"; - } - return os; - } - -} // namespace Catch diff --git a/src/catch2/internal/catch_message_info.cpp b/src/catch2/internal/catch_message_info.cpp deleted file mode 100644 index 65d990ad..00000000 --- a/src/catch2/internal/catch_message_info.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#include - -namespace Catch { - - MessageInfo::MessageInfo( StringRef const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - bool MessageInfo::operator==( MessageInfo const& other ) const { - return sequence == other.sequence; - } - - bool MessageInfo::operator<( MessageInfo const& other ) const { - return sequence < other.sequence; - } - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - -} // end namespace Catch diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp index b1af4565..8845dcfd 100644 --- a/src/catch2/internal/catch_message_info.hpp +++ b/src/catch2/internal/catch_message_info.hpp @@ -20,8 +20,12 @@ namespace Catch { ResultWas::OfType type; unsigned int sequence; - bool operator == ( MessageInfo const& other ) const; - bool operator < ( MessageInfo const& other ) const; + bool operator == (MessageInfo const& other) const { + return sequence == other.sequence; + } + bool operator < (MessageInfo const& other) const { + return sequence < other.sequence; + } private: static unsigned int globalCount; };