Skip to content

Commit

Permalink
Merge pull request #1432 from offa/clang11
Browse files Browse the repository at this point in the history
Clang 11 support
  • Loading branch information
basvodde committed Oct 29, 2020
2 parents 2a89366 + 995c1dc commit 846b0ad
Show file tree
Hide file tree
Showing 49 changed files with 167 additions and 189 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -93,14 +93,14 @@ jobs:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
- compiler: clang
env: BUILD=cmake CPP_STD=17
- CC=clang-10
- CXX=clang++-10
- CC=clang-11
- CXX=clang++-11
addons:
apt:
sources:
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages: ['clang-10', 'libc++-10-dev', 'libc++abi-10-dev']
packages: ['clang-11', 'libc++-11-dev', 'libc++abi-11-dev']

# Specific other tests
- compiler: gcc
Expand Down
4 changes: 2 additions & 2 deletions include/CppUTest/TestHarness_c.h
Expand Up @@ -164,12 +164,12 @@
TEST_GROUP(group_name)

#define TEST_GROUP_C_SETUP_WRAPPER(group_name) \
void setup() { \
void setup() _override { \
group_##group_name##_setup_wrapper_c(); \
}

#define TEST_GROUP_C_TEARDOWN_WRAPPER(group_name) \
void teardown() { \
void teardown() _override { \
group_##group_name##_teardown_wrapper_c(); \
}

Expand Down
4 changes: 2 additions & 2 deletions include/CppUTest/UtestMacros.h
Expand Up @@ -50,10 +50,10 @@
TEST_GROUP_BASE(testGroup, Utest)

#define TEST_SETUP() \
virtual void setup()
virtual void setup() _override

#define TEST_TEARDOWN() \
virtual void teardown()
virtual void teardown() _override

#define TEST(testGroup, testName) \
/* External declarations for strict compilers */ \
Expand Down
3 changes: 1 addition & 2 deletions include/CppUTestExt/OrderedTest.h
Expand Up @@ -71,7 +71,7 @@ class OrderedTestInstaller
extern TEST_##testGroup##_##testName##_TestShell TEST_##testGroup##_##testName##_Instance; \
class TEST_##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
{ public: TEST_##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
void testBody(); }; \
void testBody() _override; }; \
class TEST_##testGroup##_##testName##_TestShell : public OrderedTestShell { \
virtual Utest* createTest() _override { return new TEST_##testGroup##_##testName##_Test; } \
} TEST_##testGroup##_##testName##_Instance; \
Expand All @@ -85,4 +85,3 @@ class OrderedTestInstaller
}

#endif

4 changes: 2 additions & 2 deletions tests/CppUTest/AllocLetTestFreeTest.cpp
Expand Up @@ -16,12 +16,12 @@ TEST_GROUP(AllocLetTestFree)
{
AllocLetTestFree allocLetTestFree;

void setup()
void setup() _override
{
allocLetTestFree = AllocLetTestFree_Create();
}

void teardown()
void teardown() _override
{
AllocLetTestFree_Destroy(allocLetTestFree);
}
Expand Down
5 changes: 2 additions & 3 deletions tests/CppUTest/CheatSheetTest.cpp
Expand Up @@ -9,14 +9,14 @@ static void stub(){}
TEST_GROUP(CheatSheet)
{
/* declare a setup method for the test group. Optional. */
void setup ()
void setup() _override
{
/* Set method real_one to stub. Automatically restore in teardown */
UT_PTR_SET(real_one, stub);
}

/* Declare a teardown method for the test group. Optional */
void teardown()
void teardown() _override
{
}
}; /* Do not forget semicolumn */
Expand All @@ -33,4 +33,3 @@ TEST(CheatSheet, TestName)
/* Check a string */
STRCMP_EQUAL("HelloWorld", "HelloWorld");
}

5 changes: 2 additions & 3 deletions tests/CppUTest/CommandLineArgumentsTest.cpp
Expand Up @@ -50,12 +50,12 @@ TEST_GROUP(CommandLineArguments)
CommandLineArguments* args;
OptionsPlugin* plugin;

void setup()
void setup() _override
{
plugin = new OptionsPlugin("options");
args = NULLPTR;
}
void teardown()
void teardown() _override
{
delete args;
delete plugin;
Expand Down Expand Up @@ -550,4 +550,3 @@ TEST(CommandLineArguments, setOptCrashOnFail)
CHECK(newArgumentParser(argc, argv));
CHECK(args->isCrashingOnFail());
}

19 changes: 9 additions & 10 deletions tests/CppUTest/CommandLineTestRunnerTest.cpp
Expand Up @@ -47,7 +47,7 @@ class DummyPluginWhichCountsThePlugins : public TestPlugin
{
}

virtual bool parseArguments(int, const char *const *, int)
virtual bool parseArguments(int, const char *const *, int) _override
{
/* Remove ourselves from the count */
amountOfPlugins = registry_->countPlugins() - 1;
Expand All @@ -69,19 +69,19 @@ class CommandLineTestRunnerWithStringBufferOutput : public CommandLineTestRunner
fakeConsoleOutputWhichIsReallyABuffer(NULLPTR), fakeTCOutputWhichIsReallyABuffer(NULLPTR)
{}

TestOutput* createConsoleOutput()
TestOutput* createConsoleOutput() _override
{
fakeConsoleOutputWhichIsReallyABuffer = new StringBufferTestOutput;
return fakeConsoleOutputWhichIsReallyABuffer;
}

TestOutput* createJUnitOutput(const SimpleString&)
TestOutput* createJUnitOutput(const SimpleString&) _override
{
fakeJUnitOutputWhichIsReallyABuffer_ = new StringBufferTestOutput;
return fakeJUnitOutputWhichIsReallyABuffer_;
}

TestOutput* createTeamCityOutput()
TestOutput* createTeamCityOutput() _override
{
fakeTCOutputWhichIsReallyABuffer = new StringBufferTestOutput;
return fakeTCOutputWhichIsReallyABuffer;
Expand All @@ -95,14 +95,14 @@ TEST_GROUP(CommandLineTestRunner)
UtestShell *test2;
DummyPluginWhichCountsThePlugins* pluginCountingPlugin;

void setup()
void setup() _override
{
test1 = new UtestShell("group1", "test1", "file1", 1);
test2 = new UtestShell("group2", "test2", "file2", 2);
registry.addTest(test1);
pluginCountingPlugin = new DummyPluginWhichCountsThePlugins("PluginCountingPlugin", &registry);
}
void teardown()
void teardown() _override
{
delete pluginCountingPlugin;
delete test2;
Expand Down Expand Up @@ -398,7 +398,7 @@ class RunIgnoredUtest : public Utest
{
public:
static bool Checker;
void testBody()
void testBody() _override
{
Checker = true;
}
Expand All @@ -420,13 +420,13 @@ TEST_GROUP(RunIgnoredTest)
RunIgnoredUtestShell *runIgnoredTest;
DummyPluginWhichCountsThePlugins* pluginCountingPlugin;

void setup()
void setup() _override
{
runIgnoredTest = new RunIgnoredUtestShell("group", "test", "file", 1);
registry.addTest(runIgnoredTest);
pluginCountingPlugin = new DummyPluginWhichCountsThePlugins("PluginCountingPlugin", &registry);
}
void teardown()
void teardown() _override
{
delete pluginCountingPlugin;
delete runIgnoredTest;
Expand All @@ -453,4 +453,3 @@ TEST(RunIgnoredTest, IgnoreTestWillGetRunIfOptionSpecified)

CHECK_TRUE( RunIgnoredUtest::Checker );
}

4 changes: 2 additions & 2 deletions tests/CppUTest/JUnitOutputTest.cpp
Expand Up @@ -336,7 +336,7 @@ TEST_GROUP(JUnitOutputTest)
JUnitTestOutputTestRunner *testCaseRunner;
FileForJUnitOutputTests* outputFile;

void setup()
void setup() _override
{
UT_PTR_SET(PlatformSpecificFOpen, mockFOpen);
UT_PTR_SET(PlatformSpecificFPuts, mockFPuts);
Expand All @@ -346,7 +346,7 @@ TEST_GROUP(JUnitOutputTest)
testCaseRunner = new JUnitTestOutputTestRunner(*result);
}

void teardown()
void teardown() _override
{
delete testCaseRunner;
delete result;
Expand Down
16 changes: 8 additions & 8 deletions tests/CppUTest/MemoryLeakDetectorTest.cpp
Expand Up @@ -56,12 +56,12 @@ class NewAllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator

int alloc_called;
int free_called;
char* alloc_memory(size_t size, const char*, size_t)
char* alloc_memory(size_t size, const char*, size_t) _override
{
alloc_called++;
return TestMemoryAllocator::alloc_memory(size, "file", 1);
}
void free_memory(char* memory, size_t size, const char* file, size_t line)
void free_memory(char* memory, size_t size, const char* file, size_t line) _override
{
free_called++;
TestMemoryAllocator::free_memory(memory, size, file, line);
Expand All @@ -81,24 +81,24 @@ class AllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator
int allocMemoryLeakNodeCalled;
int freeMemoryLeakNodeCalled;

char* alloc_memory(size_t size, const char* file, size_t line)
char* alloc_memory(size_t size, const char* file, size_t line) _override
{
alloc_called++;
return TestMemoryAllocator::alloc_memory(size, file, line);
}
void free_memory(char* memory, size_t size, const char* file, size_t line)
void free_memory(char* memory, size_t size, const char* file, size_t line) _override
{
free_called++;
TestMemoryAllocator::free_memory(memory, size, file, line);
}

char* allocMemoryLeakNode(size_t size)
char* allocMemoryLeakNode(size_t size) _override
{
allocMemoryLeakNodeCalled++;
return TestMemoryAllocator::alloc_memory(size, __FILE__, __LINE__);
}

void freeMemoryLeakNode(char* memory)
void freeMemoryLeakNode(char* memory) _override
{
freeMemoryLeakNodeCalled++;
TestMemoryAllocator::free_memory(memory, 0, __FILE__, __LINE__);
Expand All @@ -111,7 +111,7 @@ TEST_GROUP(MemoryLeakDetectorTest)
MemoryLeakFailureForTest *reporter;
AllocatorForMemoryLeakDetectionTest* testAllocator;

void setup()
void setup() _override
{
reporter = new MemoryLeakFailureForTest;
detector = new MemoryLeakDetector(reporter);
Expand All @@ -120,7 +120,7 @@ TEST_GROUP(MemoryLeakDetectorTest)
detector->startChecking();
reporter->message = new SimpleString();
}
void teardown()
void teardown() _override
{
delete reporter->message;
delete detector;
Expand Down
12 changes: 6 additions & 6 deletions tests/CppUTest/MemoryLeakWarningTest.cpp
Expand Up @@ -74,7 +74,7 @@ TEST_GROUP(MemoryLeakWarningTest)
DummyMemoryLeakFailure dummy;
TestTestingFixture* fixture;

void setup()
void setup() _override
{
fixture = new TestTestingFixture();
detector = new MemoryLeakDetector(&dummy);
Expand All @@ -87,7 +87,7 @@ TEST_GROUP(MemoryLeakWarningTest)
leak2 = NULLPTR;
}

void teardown()
void teardown() _override
{
detector->deallocMemory(allocator, leak1);
detector->deallocMemory(allocator, leak2);
Expand Down Expand Up @@ -195,7 +195,7 @@ TEST_GROUP(MemoryLeakWarningGlobalDetectorTest)
cpputestHasCrashed = true;
}

void setup()
void setup() _override
{
memoryAllocatorStash.save();
detector = MemoryLeakWarningPlugin::getGlobalDetector();
Expand All @@ -210,7 +210,7 @@ TEST_GROUP(MemoryLeakWarningGlobalDetectorTest)
cpputestHasCrashed = false;
}

void teardown()
void teardown() _override
{
MemoryLeakWarningPlugin::restoreNewDeleteOverloads();

Expand Down Expand Up @@ -407,7 +407,7 @@ static void StubMutexUnlock(PlatformSpecificMutex)

TEST_GROUP(MemoryLeakWarningThreadSafe)
{
void setup()
void setup() _override
{
UT_PTR_SET(PlatformSpecificMutexLock, StubMutexLock);
UT_PTR_SET(PlatformSpecificMutexUnlock, StubMutexUnlock);
Expand All @@ -416,7 +416,7 @@ TEST_GROUP(MemoryLeakWarningThreadSafe)
mutexUnlockCount = 0;
}

void teardown()
void teardown() _override
{
}
};
Expand Down
6 changes: 3 additions & 3 deletions tests/CppUTest/MemoryOperatorOverloadTest.cpp
Expand Up @@ -121,7 +121,7 @@ TEST(BasicBehavior, freeInvalidatesMemory)
TEST_GROUP(MemoryLeakOverridesToBeUsedInProductionCode)
{
MemoryLeakDetector* memLeakDetector;
void setup()
void setup() _override
{
memLeakDetector = MemoryLeakWarningPlugin::getGlobalDetector();
}
Expand Down Expand Up @@ -373,15 +373,15 @@ TEST_GROUP(OutOfMemoryTestsForOperatorNew)
{
TestMemoryAllocator* no_memory_allocator;
GlobalMemoryAllocatorStash memoryAllocatorStash;
void setup()
void setup() _override
{
memoryAllocatorStash.save();
no_memory_allocator = new NullUnknownAllocator;
setCurrentNewAllocator(no_memory_allocator);
setCurrentNewArrayAllocator(no_memory_allocator);
}

void teardown()
void teardown() _override
{
memoryAllocatorStash.restore();
delete no_memory_allocator;
Expand Down

0 comments on commit 846b0ad

Please sign in to comment.