mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Builds almost completely cleanly with -WEverything in LLVM
This commit is contained in:
		| @@ -9,7 +9,6 @@ | ||||
| #define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED | ||||
|  | ||||
| #include "catch_config.hpp" | ||||
| #include "catch_runner_impl.hpp" | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
| @@ -42,7 +41,8 @@ namespace Catch { | ||||
|         std::string name() const { return m_name; } | ||||
|         std::string operator[]( std::size_t i ) const { return m_args[i]; } | ||||
|         std::size_t argsCount() const { return m_args.size(); } | ||||
|          | ||||
|  | ||||
|         CATCH_ATTRIBUTE_NORETURN | ||||
|         void raiseError( const std::string& message ) const { | ||||
|             std::ostringstream oss; | ||||
|             oss << "Error while parsing " << m_name << ". " << message << "."; | ||||
|   | ||||
| @@ -16,9 +16,9 @@ | ||||
| #define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) | ||||
|  | ||||
| #ifdef __GNUC__ | ||||
| #define ATTRIBUTE_NORETURN __attribute__ ((noreturn)) | ||||
| #define CATCH_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) | ||||
| #else | ||||
| #define ATTRIBUTE_NORETURN | ||||
| #define CATCH_ATTRIBUTE_NORETURN | ||||
| #endif | ||||
|  | ||||
| #include <sstream> | ||||
| @@ -32,7 +32,7 @@ namespace Catch { | ||||
| 		void operator = ( const NonCopyable& ); | ||||
| 	protected: | ||||
| 		NonCopyable() {} | ||||
| 		virtual ~NonCopyable() {} | ||||
| 		virtual ~NonCopyable(); | ||||
| 	}; | ||||
|      | ||||
|     class SafeBool { | ||||
| @@ -110,21 +110,16 @@ namespace Catch { | ||||
|         return os; | ||||
|     } | ||||
|      | ||||
|     ATTRIBUTE_NORETURN | ||||
|     inline void throwLogicError( const std::string& message, const std::string& file, std::size_t line ) { | ||||
|     CATCH_ATTRIBUTE_NORETURN | ||||
|     inline void throwLogicError( const std::string& message, const SourceLineInfo& locationInfo ) { | ||||
|         std::ostringstream oss; | ||||
|         oss << "Internal Catch error: '" << message << "' at: " << SourceLineInfo( file, line ); | ||||
|         oss << "Internal Catch error: '" << message << "' at: " << locationInfo; | ||||
|         throw std::logic_error( oss.str() ); | ||||
|     } | ||||
| } | ||||
|  | ||||
| #define CATCH_INTERNAL_ERROR( msg ) throwLogicError( msg, __FILE__, __LINE__ ); | ||||
|  | ||||
| //#ifdef __FUNCTION__ | ||||
| //#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FUNCTION__, __FILE__, __LINE__ ) | ||||
| //#else | ||||
| #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, __LINE__ ) | ||||
| //#endif | ||||
| #define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) ) | ||||
| #define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); | ||||
|  | ||||
| #endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED | ||||
|  | ||||
|   | ||||
| @@ -64,8 +64,9 @@ namespace Catch { | ||||
|     private: | ||||
|         Config( const Config& other ); | ||||
|         Config& operator = ( const Config& other ); | ||||
|         virtual void dummy(); | ||||
|     public: | ||||
|                  | ||||
|  | ||||
|         Config() | ||||
|         :   m_streambuf( NULL ), | ||||
|             m_os( std::cout.rdbuf() ) | ||||
| @@ -77,7 +78,7 @@ namespace Catch { | ||||
|             m_os( std::cout.rdbuf() ) | ||||
|         {} | ||||
|          | ||||
|         ~Config() { | ||||
|         virtual ~Config() { | ||||
|             m_os.rdbuf( std::cout.rdbuf() ); | ||||
|             delete m_streambuf; | ||||
|         } | ||||
|   | ||||
| @@ -23,11 +23,14 @@ namespace Catch { | ||||
|     struct IRunner; | ||||
|     struct IGeneratorsForTest; | ||||
|  | ||||
|     class StreamBufBase : public std::streambuf{}; | ||||
|     class StreamBufBase : public std::streambuf { | ||||
|     public: | ||||
|         virtual ~StreamBufBase(); | ||||
|     }; | ||||
|      | ||||
|     struct IContext | ||||
|     { | ||||
|         virtual ~IContext(){} | ||||
|         virtual ~IContext(); | ||||
|          | ||||
|         virtual IResultCapture& getResultCapture() = 0; | ||||
|         virtual IRunner& getRunner() = 0; | ||||
| @@ -38,6 +41,7 @@ namespace Catch { | ||||
|      | ||||
|     struct IMutableContext : IContext | ||||
|     { | ||||
|         virtual ~IMutableContext(); | ||||
|         virtual void setResultCapture( IResultCapture* resultCapture ) = 0; | ||||
|         virtual void setRunner( IRunner* runner ) = 0; | ||||
|         virtual void setConfig( const IConfig* config ) = 0; | ||||
|   | ||||
| @@ -8,6 +8,11 @@ | ||||
|  | ||||
| // Collect all the implementation files together here | ||||
| // These are the equivalent of what would usually be cpp files | ||||
|  | ||||
| #pragma clang diagnostic push | ||||
| #pragma clang diagnostic ignored "-Wweak-vtables" | ||||
|  | ||||
| #include "catch_runner.hpp" | ||||
| #include "catch_registry_hub.hpp" | ||||
| #include "catch_notimplemented_exception.hpp" | ||||
| #include "catch_context_impl.hpp" | ||||
| @@ -15,3 +20,35 @@ | ||||
| #include "catch_generators_impl.hpp" | ||||
| #include "catch_resultinfo.hpp" | ||||
| #include "catch_resultinfo_builder.hpp" | ||||
|  | ||||
| namespace Catch { | ||||
|     NonCopyable::~NonCopyable() {} | ||||
|     IShared::~IShared() {} | ||||
|     StreamBufBase::~StreamBufBase() {} | ||||
|     IContext::~IContext() {} | ||||
|     IResultCapture::~IResultCapture() {} | ||||
|     ITestCase::~ITestCase() {} | ||||
|     ITestCaseRegistry::~ITestCaseRegistry() {} | ||||
|     IRegistryHub::~IRegistryHub() {} | ||||
|     IMutableRegistryHub::~IMutableRegistryHub() {} | ||||
|     IExceptionTranslator::~IExceptionTranslator() {} | ||||
|     IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} | ||||
|     IReporter::~IReporter() {} | ||||
|     IReporterFactory::~IReporterFactory() {} | ||||
|     IReporterRegistry::~IReporterRegistry() {} | ||||
|     BasicReporter::~BasicReporter() {} | ||||
|     IRunner::~IRunner() {} | ||||
|     IMutableContext::~IMutableContext() {} | ||||
|     IConfig::~IConfig() {} | ||||
|     XmlReporter::~XmlReporter() {} | ||||
|     JunitReporter::~JunitReporter() {} | ||||
|     TestRegistry::~TestRegistry() {} | ||||
|     FreeFunctionTestCase::~FreeFunctionTestCase() {} | ||||
|     IGeneratorInfo::~IGeneratorInfo() {} | ||||
|     IGeneratorsForTest::~IGeneratorsForTest() {} | ||||
|  | ||||
|     void Config::dummy() {} | ||||
|  | ||||
| } | ||||
|  | ||||
| #pragma clang diagnostic pop | ||||
|   | ||||
| @@ -21,7 +21,7 @@ namespace Catch { | ||||
|  | ||||
|     struct IResultCapture { | ||||
|      | ||||
|         virtual ~IResultCapture(){} | ||||
|         virtual ~IResultCapture(); | ||||
|          | ||||
|         virtual void testEnded( const ResultInfo& result ) = 0; | ||||
|         virtual bool sectionStarted(    const std::string& name,  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ namespace Catch { | ||||
|  | ||||
|     struct IConfig { | ||||
|      | ||||
|         virtual ~IConfig(){} | ||||
|         virtual ~IConfig(); | ||||
|          | ||||
|         virtual bool allowThrows() const = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -16,12 +16,12 @@ namespace Catch { | ||||
|     typedef std::string(*exceptionTranslateFunction)(); | ||||
|  | ||||
|     struct IExceptionTranslator { | ||||
|         virtual ~IExceptionTranslator(){} | ||||
|         virtual ~IExceptionTranslator(); | ||||
|         virtual std::string translate() const = 0; | ||||
|     }; | ||||
|      | ||||
|     struct IExceptionTranslatorRegistry { | ||||
|         virtual ~IExceptionTranslatorRegistry(){} | ||||
|         virtual ~IExceptionTranslatorRegistry(); | ||||
|          | ||||
|         virtual std::string translateActiveException() const = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -13,13 +13,13 @@ | ||||
| namespace Catch { | ||||
|  | ||||
|     struct IGeneratorInfo { | ||||
|         virtual ~IGeneratorInfo(){} | ||||
|         virtual ~IGeneratorInfo(); | ||||
|         virtual bool moveNext() = 0; | ||||
|         virtual std::size_t getCurrentIndex() const = 0; | ||||
|     }; | ||||
|      | ||||
|     struct IGeneratorsForTest { | ||||
|         virtual ~IGeneratorsForTest() {} | ||||
|         virtual ~IGeneratorsForTest(); | ||||
|  | ||||
|         virtual IGeneratorInfo& getGeneratorInfo( const std::string& fileInfo, std::size_t size ) = 0; | ||||
|         virtual bool moveNext() = 0; | ||||
|   | ||||
| @@ -24,7 +24,7 @@ namespace Catch { | ||||
|     struct IExceptionTranslator; | ||||
|  | ||||
|     struct IRegistryHub { | ||||
|         virtual ~IRegistryHub(){} | ||||
|         virtual ~IRegistryHub(); | ||||
|  | ||||
|         virtual const IReporterRegistry& getReporterRegistry() const = 0; | ||||
|         virtual const ITestCaseRegistry& getTestCaseRegistry() const = 0; | ||||
| @@ -32,7 +32,7 @@ namespace Catch { | ||||
|     }; | ||||
|  | ||||
|     struct IMutableRegistryHub { | ||||
|         virtual ~IMutableRegistryHub(){} | ||||
|         virtual ~IMutableRegistryHub(); | ||||
|         virtual void registerReporter( const std::string& name, IReporterFactory* factory ) = 0; | ||||
|         virtual void registerTest( const TestCaseInfo& testInfo ) = 0; | ||||
|         virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; | ||||
|   | ||||
| @@ -37,7 +37,7 @@ namespace Catch | ||||
|     class ResultInfo; | ||||
|      | ||||
|     struct IReporter : IShared { | ||||
|         virtual ~IReporter() {}         | ||||
|         virtual ~IReporter(); | ||||
|         virtual bool shouldRedirectStdout() const = 0;         | ||||
|         virtual void StartTesting() = 0;         | ||||
|         virtual void EndTesting( const Totals& totals ) = 0;         | ||||
| @@ -52,7 +52,7 @@ namespace Catch | ||||
|     }; | ||||
|      | ||||
|     struct IReporterFactory { | ||||
|         virtual ~IReporterFactory() {}         | ||||
|         virtual ~IReporterFactory(); | ||||
|         virtual IReporter* create( const ReporterConfig& config ) const = 0; | ||||
|         virtual std::string getDescription() const = 0; | ||||
|     }; | ||||
| @@ -60,7 +60,7 @@ namespace Catch | ||||
|     struct IReporterRegistry { | ||||
|         typedef std::map<std::string, IReporterFactory*> FactoryMap; | ||||
|  | ||||
|         virtual ~IReporterRegistry() {} | ||||
|         virtual ~IReporterRegistry(); | ||||
|         virtual IReporter* create( const std::string& name, const ReporterConfig& config ) const = 0;         | ||||
|         virtual const FactoryMap& getFactories() const = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -16,7 +16,7 @@ namespace Catch { | ||||
|     class TestCaseInfo; | ||||
|      | ||||
|     struct IRunner { | ||||
|         virtual ~IRunner() {}         | ||||
|         virtual ~IRunner(); | ||||
|         virtual void runAll( bool runHiddenTests = false ) = 0;         | ||||
|         virtual std::size_t runMatching( const std::string& rawTestSpec ) = 0;         | ||||
|         virtual Totals getTotals() const = 0; | ||||
|   | ||||
| @@ -12,7 +12,7 @@ | ||||
|  | ||||
| namespace Catch { | ||||
|     struct ITestCase { | ||||
|         virtual ~ITestCase(){} | ||||
|         virtual ~ITestCase(); | ||||
|         virtual void invoke () const = 0;         | ||||
|         virtual ITestCase* clone() const = 0;         | ||||
|         virtual bool operator == ( const ITestCase& other ) const = 0;         | ||||
| @@ -22,7 +22,7 @@ namespace Catch { | ||||
|     class TestCaseInfo; | ||||
|  | ||||
|     struct ITestCaseRegistry { | ||||
|         virtual ~ITestCaseRegistry(){} | ||||
|         virtual ~ITestCaseRegistry(); | ||||
|         virtual const std::vector<TestCaseInfo>& getAllTests() const = 0; | ||||
|         virtual std::vector<TestCaseInfo> getMatchingTestCases( const std::string& rawTestSpec ) const = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -74,7 +74,7 @@ namespace Catch { | ||||
|     }; | ||||
|      | ||||
|     struct IShared : NonCopyable { | ||||
|         virtual ~IShared(){} | ||||
|         virtual ~IShared(); | ||||
|         virtual void addRef() = 0; | ||||
|         virtual void release() = 0; | ||||
|     }; | ||||
|   | ||||
| @@ -18,7 +18,7 @@ namespace Catch { | ||||
|      | ||||
|     public: | ||||
|          | ||||
|         ~ReporterRegistry() { | ||||
|         virtual ~ReporterRegistry() { | ||||
|             deleteAllValues( m_factories ); | ||||
|         } | ||||
|          | ||||
|   | ||||
| @@ -22,7 +22,7 @@ namespace Catch { | ||||
|                     const SourceLineInfo& lineInfo, | ||||
|                     const char* macroName, | ||||
|                    const char* message ); | ||||
|         virtual ~ResultInfo(); | ||||
|         ~ResultInfo(); | ||||
|          | ||||
|         bool ok() const; | ||||
|         ResultWas::OfType getResultType() const; | ||||
|   | ||||
| @@ -70,7 +70,7 @@ namespace Catch { | ||||
|             m_reporter->StartTesting(); | ||||
|         } | ||||
|          | ||||
|         ~Runner() { | ||||
|         virtual ~Runner() { | ||||
|             m_reporter->EndTesting( m_totals ); | ||||
|             m_context.setRunner( m_prevRunner ); | ||||
|             m_context.setConfig( NULL ); | ||||
|   | ||||
| @@ -19,6 +19,7 @@ namespace Catch { | ||||
|     class TestRegistry : public ITestCaseRegistry { | ||||
|     public: | ||||
|         TestRegistry() : m_unnamedCount( 0 ) {} | ||||
|         virtual ~TestRegistry(); | ||||
|          | ||||
|         virtual void registerTest( const TestCaseInfo& testInfo ) { | ||||
|             if( testInfo.getName() == "" ) { | ||||
| @@ -71,6 +72,7 @@ namespace Catch { | ||||
|     public: | ||||
|  | ||||
|         FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} | ||||
|         virtual ~FreeFunctionTestCase(); | ||||
|          | ||||
|         virtual void invoke() const { | ||||
|             m_fun(); | ||||
|   | ||||
| @@ -81,7 +81,7 @@ private: | ||||
|  | ||||
| /////////////////////////////////////////////////////////////////////////////// | ||||
| #define INTERNAL_CATCH_TESTCASE_NORETURN( Name, Desc ) \ | ||||
|     static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() ATTRIBUTE_NORETURN; \ | ||||
|     static void INTERNAL_CATCH_UNIQUE_NAME( TestCaseFunction_catch_internal_ )() CATCH_ATTRIBUTE_NORETURN; \ | ||||
|     namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ ), Name, Desc, CATCH_INTERNAL_LINEINFO ); }\ | ||||
|     static void INTERNAL_CATCH_UNIQUE_NAME(  TestCaseFunction_catch_internal_ )() | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash