summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2013-11-19 03:08:35 +0000
committerJuergen Ributzka <juergen@apple.com>2013-11-19 03:08:35 +0000
commitba0f991a78706068cc2e6a1c4ef4b0d8f7ce748b (patch)
tree92f96f6c5615bd64c6f734f1534a7aa29a47c67a /unittests
parent36c7806f4eacd676932ba630246f88e0e37b1cd4 (diff)
downloadllvm-ba0f991a78706068cc2e6a1c4ef4b0d8f7ce748b.tar.gz
llvm-ba0f991a78706068cc2e6a1c4ef4b0d8f7ce748b.tar.bz2
llvm-ba0f991a78706068cc2e6a1c4ef4b0d8f7ce748b.tar.xz
[weak vtables] Place class definitions into anonymous namespaces to prevent weak vtables.
This patch places class definitions in implementation files into anonymous namespaces to prevent weak vtables. This eliminates the need of providing an out-of-line definition to pin the vtable explicitly to the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/IntrusiveRefCntPtrTest.cpp11
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp21
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp10
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITTest.cpp12
4 files changed, 20 insertions, 34 deletions
diff --git a/unittests/ADT/IntrusiveRefCntPtrTest.cpp b/unittests/ADT/IntrusiveRefCntPtrTest.cpp
index a74e05e7b2..c67ec13091 100644
--- a/unittests/ADT/IntrusiveRefCntPtrTest.cpp
+++ b/unittests/ADT/IntrusiveRefCntPtrTest.cpp
@@ -10,14 +10,13 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "gtest/gtest.h"
-namespace llvm {
-
-struct VirtualRefCounted : public RefCountedBaseVPTR {
- virtual void f();
+namespace {
+struct VirtualRefCounted : public llvm::RefCountedBaseVPTR {
+ virtual void f() {}
};
+}
-// Provide out-of-line definition to prevent weak vtable.
-void VirtualRefCounted::f() {}
+namespace llvm {
// Run this test with valgrind to detect memory leaks.
TEST(IntrusiveRefCntPtr, RefCountedBaseVPTRCopyDoesNotLeak) {
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
index 15c58c480a..46d6d9b8a9 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp
@@ -59,6 +59,7 @@ static void roundTripDestroy(void *object) {
delete static_cast<SectionMemoryManager*>(object);
}
+namespace {
class MCJITCAPITest : public testing::Test, public MCJITTestAPICommon {
protected:
MCJITCAPITest() {
@@ -83,8 +84,14 @@ protected:
UnsupportedOSs.push_back(Triple::Cygwin);
}
- virtual void SetUp();
-
+ virtual void SetUp() {
+ didCallAllocateCodeSection = false;
+ Module = 0;
+ Function = 0;
+ Engine = 0;
+ Error = 0;
+ }
+
virtual void TearDown() {
if (Engine)
LLVMDisposeExecutionEngine(Engine);
@@ -150,15 +157,7 @@ protected:
LLVMExecutionEngineRef Engine;
char *Error;
};
-
-// Provide out-of-line definition to prevent weak vtable.
-void MCJITCAPITest::SetUp() {
- didCallAllocateCodeSection = false;
- Module = 0;
- Function = 0;
- Engine = 0;
- Error = 0;
-}
+} // end anonymous namespace
TEST_F(MCJITCAPITest, simple_function) {
SKIP_UNSUPPORTED_PLATFORM;
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
index cea6274656..7c3239ea25 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITMultipleModuleTest.cpp
@@ -18,16 +18,10 @@
using namespace llvm;
-class MCJITMultipleModuleTest : public testing::Test, public MCJITTestBase {
-public:
- virtual ~MCJITMultipleModuleTest();
-};
-
-// Provide out-of-line definition to prevent weak vtable.
-MCJITMultipleModuleTest::~MCJITMultipleModuleTest() {}
-
namespace {
+class MCJITMultipleModuleTest : public testing::Test, public MCJITTestBase {};
+
// FIXME: ExecutionEngine has no support empty modules
/*
TEST_F(MCJITMultipleModuleTest, multiple_empty_modules) {
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
index 9786befd72..fab81551fa 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITTest.cpp
@@ -18,19 +18,13 @@
using namespace llvm;
+namespace {
+
class MCJITTest : public testing::Test, public MCJITTestBase {
protected:
-
- virtual void SetUp();
+ virtual void SetUp() { M.reset(createEmptyModule("<main>")); }
};
-// Provide out-of-line definition to prevent weak vtable.
-void MCJITTest::SetUp() {
- M.reset(createEmptyModule("<main>"));
-}
-
-namespace {
-
// FIXME: Ensure creating an execution engine does not crash when constructed
// with a null module.
/*