[weak vtables] Remove a bunch of weak vtables

This patch removes most of the trivial cases of weak vtables by pinning them to
a single object file. The memory leaks in this version have been fixed. Thanks
Alexey for pointing them out.

Differential Revision: http://llvm-reviews.chandlerc.com/D2068

Reviewed by Andy

llvm-svn: 195064
diff --git a/llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h b/llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h
index 8aeea14..98e8b84 100644
--- a/llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h
+++ b/llvm/utils/unittest/googletest/include/gtest/gtest-test-part.h
@@ -142,7 +142,7 @@
 // This interface knows how to report a test part result.
 class TestPartResultReporterInterface {
  public:
-  virtual ~TestPartResultReporterInterface() {}
+  virtual ~TestPartResultReporterInterface();
 
   virtual void ReportTestPartResult(const TestPartResult& result) = 0;
 };
diff --git a/llvm/utils/unittest/googletest/include/gtest/gtest.h b/llvm/utils/unittest/googletest/include/gtest/gtest.h
index 1734c44..07ed92b 100644
--- a/llvm/utils/unittest/googletest/include/gtest/gtest.h
+++ b/llvm/utils/unittest/googletest/include/gtest/gtest.h
@@ -910,7 +910,7 @@
 class Environment {
  public:
   // The d'tor is virtual as we need to subclass Environment.
-  virtual ~Environment() {}
+  virtual ~Environment();
 
   // Override this to define how to set up the environment.
   virtual void SetUp() {}
@@ -928,7 +928,7 @@
 // the order the corresponding events are fired.
 class TestEventListener {
  public:
-  virtual ~TestEventListener() {}
+  virtual ~TestEventListener();
 
   // Fired before any test activity starts.
   virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
@@ -980,6 +980,7 @@
 // comments about each method please see the definition of TestEventListener
 // above.
 class EmptyTestEventListener : public TestEventListener {
+  virtual void anchor();
  public:
   virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
   virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
index 7bac2bd..8d53c45 100644
--- a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -79,7 +79,7 @@
   static bool Create(const char* statement, const RE* regex,
                      const char* file, int line, DeathTest** test);
   DeathTest();
-  virtual ~DeathTest() { }
+  virtual ~DeathTest();
 
   // A helper class that aborts a death test when it's deleted.
   class ReturnSentinel {
@@ -139,7 +139,7 @@
 // Factory interface for death tests.  May be mocked out for testing.
 class DeathTestFactory {
  public:
-  virtual ~DeathTestFactory() { }
+  virtual ~DeathTestFactory();
   virtual bool Create(const char* statement, const RE* regex,
                       const char* file, int line, DeathTest** test) = 0;
 };
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
index a94bf28..63f72ac 100644
--- a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
+++ b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-internal.h
@@ -105,6 +105,7 @@
 #if !GTEST_NO_LLVM_RAW_OSTREAM
 namespace llvm {
 class convertible_fwd_ostream : public std::ostream {
+  virtual void anchor();
   raw_os_ostream ros_;
 
 public:
@@ -536,7 +537,7 @@
 // of a Test object.
 class TestFactoryBase {
  public:
-  virtual ~TestFactoryBase() {}
+  virtual ~TestFactoryBase();
 
   // Creates a test instance to run. The instance is both created and destroyed
   // within TestInfoImpl::Run()
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h
index 0ef9718..3bb2ffb 100644
--- a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h
+++ b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-param-util.h
@@ -414,7 +414,7 @@
 // and calls RegisterTests() on each of them when asked.
 class ParameterizedTestCaseInfoBase {
  public:
-  virtual ~ParameterizedTestCaseInfoBase() {}
+  virtual ~ParameterizedTestCaseInfoBase();
 
   // Base part of test case name for display purposes.
   virtual const string& GetTestCaseName() const = 0;
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h
index 58f6caf..32fd9c6 100644
--- a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h
+++ b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-port.h
@@ -1116,7 +1116,7 @@
 // problem.
 class ThreadWithParamBase {
  public:
-  virtual ~ThreadWithParamBase() {}
+  virtual ~ThreadWithParamBase();
   virtual void Run() = 0;
 };
 
@@ -1290,7 +1290,7 @@
 // ThreadLocalValueHolderBase.
 class ThreadLocalValueHolderBase {
  public:
-  virtual ~ThreadLocalValueHolderBase() {}
+  virtual ~ThreadLocalValueHolderBase();
 };
 
 // Called by pthread to delete thread-local data stored by
diff --git a/llvm/utils/unittest/googletest/src/gtest-death-test.cc b/llvm/utils/unittest/googletest/src/gtest-death-test.cc
index 82453f2..314dba2 100644
--- a/llvm/utils/unittest/googletest/src/gtest-death-test.cc
+++ b/llvm/utils/unittest/googletest/src/gtest-death-test.cc
@@ -300,6 +300,9 @@
   }
 }
 
+// Pin the vtable to this file.
+DeathTest::~DeathTest() {}
+
 // Creates and returns a death test by dispatching to the current
 // death test factory.
 bool DeathTest::Create(const char* statement, const RE* regex,
@@ -1091,6 +1094,9 @@
   return true;
 }
 
+// Pin the vtable to this file.
+DeathTestFactory::~DeathTestFactory() {}
+
 // Splits a given string on a given delimiter, populating a given
 // vector with the fields.  GTEST_HAS_DEATH_TEST implies that we have
 // ::std::string, so we can use it here.
diff --git a/llvm/utils/unittest/googletest/src/gtest-internal-inl.h b/llvm/utils/unittest/googletest/src/gtest-internal-inl.h
index 6554cfc..1bae630 100644
--- a/llvm/utils/unittest/googletest/src/gtest-internal-inl.h
+++ b/llvm/utils/unittest/googletest/src/gtest-internal-inl.h
@@ -408,7 +408,7 @@
 class OsStackTraceGetterInterface {
  public:
   OsStackTraceGetterInterface() {}
-  virtual ~OsStackTraceGetterInterface() {}
+  virtual ~OsStackTraceGetterInterface();
 
   // Returns the current OS stack trace as a String.  Parameters:
   //
diff --git a/llvm/utils/unittest/googletest/src/gtest-port.cc b/llvm/utils/unittest/googletest/src/gtest-port.cc
index 7459562..94fc57f 100644
--- a/llvm/utils/unittest/googletest/src/gtest-port.cc
+++ b/llvm/utils/unittest/googletest/src/gtest-port.cc
@@ -746,5 +746,19 @@
   return value == NULL ? default_value : value;
 }
 
+// Pin the vtables to this file.
+#if GTEST_HAS_PTHREAD
+ThreadWithParamBase::~ThreadWithParamBase() {}
+ThreadLocalValueHolderBase::~ThreadLocalValueHolderBase() {}
+#endif
+TestFactoryBase::~TestFactoryBase() {}
+
 }  // namespace internal
 }  // namespace testing
+
+// Pin the vtable to this file.
+#if !GTEST_NO_LLVM_RAW_OSTREAM
+namespace llvm {
+void convertible_fwd_ostream::anchor() {}
+}
+#endif
diff --git a/llvm/utils/unittest/googletest/src/gtest.cc b/llvm/utils/unittest/googletest/src/gtest.cc
index 9891928..bf850c6 100644
--- a/llvm/utils/unittest/googletest/src/gtest.cc
+++ b/llvm/utils/unittest/googletest/src/gtest.cc
@@ -4863,4 +4863,14 @@
   internal::InitGoogleTestImpl(argc, argv);
 }
 
+// Pin the vtables to this file.
+Environment::~Environment() {}
+TestPartResultReporterInterface::~TestPartResultReporterInterface() {}
+TestEventListener::~TestEventListener() {}
+void EmptyTestEventListener::anchor() {}
+namespace internal {
+OsStackTraceGetterInterface::~OsStackTraceGetterInterface() {}
+ParameterizedTestCaseInfoBase::~ParameterizedTestCaseInfoBase() {}
+}
+
 }  // namespace testing