Builds almost completely cleanly with -WEverything in LLVM

This commit is contained in:
Phil Nash 2012-08-13 07:46:10 +01:00
parent cdc64a138b
commit a695eb9006
37 changed files with 1045 additions and 966 deletions

View File

@ -9,6 +9,12 @@
#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_HPP_INCLUDED
#pragma clang diagnostic ignored "-Wno-global-constructors"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#include "internal/catch_notimplemented_exception.h"
#include "internal/catch_context.h"
#include "internal/catch_test_registry.hpp"
@ -29,7 +35,6 @@
#endif
#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
#include "catch_runner.hpp"
#include "internal/catch_impl.hpp"
#endif
@ -127,4 +132,6 @@
using Catch::Detail::Approx;
#pragma clang diagnostic pop
#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED

View File

@ -8,12 +8,14 @@
#ifndef TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED
#include "internal/catch_commandline.hpp"
#include "internal/catch_list.hpp"
#include "reporters/catch_reporter_basic.hpp"
#include "reporters/catch_reporter_xml.hpp"
#include "reporters/catch_reporter_junit.hpp"
#include "internal/catch_commandline.hpp"
#include "internal/catch_list.hpp"
#include "internal/catch_runner_impl.hpp"
#include <fstream>
#include <stdlib.h>
#include <limits>

View File

@ -1,4 +1,4 @@
/*
/*
* Created by Phil on 01/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*

View File

@ -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 << ".";

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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,

View File

@ -12,7 +12,7 @@ namespace Catch {
struct IConfig {
virtual ~IConfig(){}
virtual ~IConfig();
virtual bool allowThrows() const = 0;
};

View File

@ -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;
};

View File

@ -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;

View File

@ -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;

View File

@ -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;
};

View File

@ -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;

View File

@ -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;
};

View File

@ -74,7 +74,7 @@ namespace Catch {
};
struct IShared : NonCopyable {
virtual ~IShared(){}
virtual ~IShared();
virtual void addRef() = 0;
virtual void release() = 0;
};

View File

@ -18,7 +18,7 @@ namespace Catch {
public:
~ReporterRegistry() {
virtual ~ReporterRegistry() {
deleteAllValues( m_factories );
}

View File

@ -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;

View File

@ -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 );

View File

@ -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();

View File

@ -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_ )()

View File

@ -35,7 +35,7 @@ namespace Catch {
class BasicReporter : public SharedImpl<IReporter> {
struct SpanInfo {
SpanInfo()
: emitted( false )
{}
@ -60,6 +60,8 @@ namespace Catch {
m_firstSectionInTestCase( true ),
m_aborted( false )
{}
virtual ~BasicReporter();
static std::string getDescription() {
return "Reports test results as lines of text";
@ -222,7 +224,6 @@ namespace Catch {
case ResultWas::FailureBit:
case ResultWas::ExpressionFailed:
case ResultWas::Exception:
default:
if( !resultInfo.hasExpression() ) {
if( resultInfo.ok() ) {
TextColour colour( TextColour::Success );

View File

@ -61,7 +61,8 @@ namespace Catch {
: m_config( config ),
m_testSuiteStats( "AllTests" ),
m_currentStats( &m_testSuiteStats )
{}
{}
virtual ~JunitReporter();
static std::string getDescription() {
return "Reports test results in an XML format that looks like Ant's junitreport target";
@ -131,8 +132,6 @@ namespace Catch {
case ResultWas::FailureBit:
case ResultWas::Exception:
case ResultWas::DidntThrowException:
default:
stats.m_element = "unknown";
break;
}
testCaseStats.m_testStats.push_back( stats );

View File

@ -21,6 +21,7 @@ namespace Catch {
static std::string getDescription() {
return "Reports test results as an XML document";
}
virtual ~XmlReporter();
private: // IReporter
@ -116,7 +117,6 @@ namespace Catch {
case ResultWas::ExpressionFailed:
case ResultWas::Exception:
case ResultWas::DidntThrowException:
default:
break;
}
if( resultInfo.hasExpression() )

View File

@ -1,13 +1,9 @@
/*
* ApproxTests.cpp
* Catch - Test
*
* Created by Phil on 28/04/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#include "catch.hpp"

View File

@ -1,13 +1,9 @@
/*
* ClassTests.cpp
* Catch - Test
*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#include "catch.hpp"

View File

@ -1,14 +1,11 @@
/*
* ConditionTests.cpp
* Catch - Test
*
* Created by Phil on 08/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#pragma clang diagnostic ignored "-Wpadded"
#include "catch.hpp"

View File

@ -1,15 +1,13 @@
/*
* ExceptionTests.cpp
* Catch - Test
*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#pragma clang diagnostic ignored "-Wpadded"
#include "catch.hpp"
#include <string>
@ -19,7 +17,7 @@
namespace
{
ATTRIBUTE_NORETURN
CATCH_ATTRIBUTE_NORETURN
int thisThrows();
int thisThrows()
@ -41,6 +39,7 @@ TEST_CASE( "./succeeding/exceptions/explicit", "When checked exceptions are thro
REQUIRE_THROWS( thisThrows() );
}
CATCH_ATTRIBUTE_NORETURN
TEST_CASE( "./failing/exceptions/explicit", "When checked exceptions are thrown they can be expected or unexpected" )
{
CHECK_THROWS_AS( thisThrows(), std::string );

View File

@ -1,13 +1,9 @@
/*
* GeneratorTests.cpp
* Catch - Test
*
* Created by Phil on 28/01/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
// This define means we have to prefix all the CATCH macros with CATCH_

View File

@ -1,13 +1,9 @@
/*
* MessageTests.cpp
* Catch - Test
*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#include "catch.hpp"

View File

@ -1,14 +1,11 @@
/*
* MiscTests.cpp
* Catch - Test
*
* Created by Phil on 29/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#pragma clang diagnostic ignored "-Wpadded"
#include "catch.hpp"
#include "catch_self_test.hpp"

View File

@ -5,6 +5,8 @@
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#pragma clang diagnostic ignored "-Wpadded"
#include "catch_self_test.hpp"
TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results" ) {
@ -54,6 +56,8 @@ TEST_CASE( "meta/Misc/Sections", "looped tests" ) {
CHECK( runner.getTotals().assertions.failed == 1 );
}
#pragma clang diagnostic ignored "-Wweak-vtables"
#include "../../include/internal/catch_commandline.hpp"
#include "../../include/reporters/catch_reporter_basic.hpp"
#include "../../include/reporters/catch_reporter_xml.hpp"

View File

@ -1,15 +1,13 @@
/*
* TrickyTests.cpp
* Catch - Test
*
* Created by Phil on 09/11/2010.
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#pragma clang diagnostic ignored "-Wpadded"
#include "catch.hpp"
namespace Catch

View File

@ -1,15 +1,13 @@
/*
* catch_self_test.cpp
* Catch
*
* Created by Phil on 14/02/2012.
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
*/
#pragma clang diagnostic ignored "-Wpadded"
#define CATCH_CONFIG_MAIN
#include "catch_self_test.hpp"
@ -69,9 +67,6 @@ namespace Catch{
case ResultWas::Exception:
m_log << "Exception";
break;
default:
m_log << "{unrecognised ResultType enum value}";
break;
}
if( resultInfo.hasExpression() )

View File

@ -465,14 +465,28 @@
4A6D0C2B149B3D3B00DB3EAA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = (
"-Weverything",
"-Wno-disabled-macro-expansion",
"-Wno-global-constructors",
);
};
name = Debug;
};
4A6D0C2C149B3D3B00DB3EAA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = NO;
PRODUCT_NAME = "$(TARGET_NAME)";
WARNING_CFLAGS = (
"-Weverything",
"-Wno-disabled-macro-expansion",
"-Wno-global-constructors",
);
};
name = Release;
};

File diff suppressed because it is too large Load Diff