[llvm-commits] [llvm] r158798 - in /llvm/trunk/unittests: Support/IRBuilderTest.cpp Transforms/Utils/Cloning.cpp

Chandler Carruth chandlerc at gmail.com
Wed Jun 20 01:39:27 PDT 2012


Author: chandlerc
Date: Wed Jun 20 03:39:27 2012
New Revision: 158798

URL: http://llvm.org/viewvc/llvm-project?rev=158798&view=rev
Log:
Fix inappropriate use of anonymous namespaces in unittests.

The TEST_F macros actually declare *subclasses* of the test fixtures.
Even if they didn't we don't want them to declare external functions.
The entire unit test, including both the fixture class and the fixture
test cases should be wrapped in the anonymous namespace.

This issue was caught by the new '-Winternal-linkage-in-inline' warning.

Modified:
    llvm/trunk/unittests/Support/IRBuilderTest.cpp
    llvm/trunk/unittests/Transforms/Utils/Cloning.cpp

Modified: llvm/trunk/unittests/Support/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/IRBuilderTest.cpp?rev=158798&r1=158797&r2=158798&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/Support/IRBuilderTest.cpp Wed Jun 20 03:39:27 2012
@@ -20,6 +20,7 @@
 using namespace llvm;
 
 namespace {
+
 class IRBuilderTest : public testing::Test {
 protected:
   virtual void SetUp() {
@@ -38,7 +39,6 @@
   OwningPtr<Module> M;
   BasicBlock *BB;
 };
-}
 
 TEST_F(IRBuilderTest, Lifetime) {
   IRBuilder<> Builder(BB);
@@ -70,3 +70,5 @@
   ASSERT_TRUE(II_End1 != NULL);
   EXPECT_EQ(II_End1->getIntrinsicID(), Intrinsic::lifetime_end);
 }
+
+}

Modified: llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Cloning.cpp?rev=158798&r1=158797&r2=158798&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/Cloning.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/Cloning.cpp Wed Jun 20 03:39:27 2012
@@ -18,6 +18,7 @@
 using namespace llvm;
 
 namespace {
+
 class CloneInstruction : public ::testing::Test {
 protected:
   virtual void SetUp() {
@@ -48,7 +49,6 @@
   LLVMContext context;
   Value *V;
 };
-}
 
 TEST_F(CloneInstruction, OverflowBits) {
   V = new Argument(Type::getInt32Ty(context));
@@ -142,3 +142,5 @@
   SDiv->setIsExact(true);
   EXPECT_TRUE(this->clone(SDiv)->isExact());
 }
+
+}





More information about the llvm-commits mailing list