[llvm] r202842 - [Modules] Move the LeakDetector header into the IR library where the
Chandler Carruth
chandlerc at gmail.com
Tue Mar 4 04:46:07 PST 2014
Author: chandlerc
Date: Tue Mar 4 06:46:06 2014
New Revision: 202842
URL: http://llvm.org/viewvc/llvm-project?rev=202842&view=rev
Log:
[Modules] Move the LeakDetector header into the IR library where the
source file had already been moved. Also move the unittest into the IR
unittest library.
This may seem an odd thing to put in the IR library but we only really
use this with instructions and it needs the LLVM context to work, so it
is intrinsically tied to the IR library.
Added:
llvm/trunk/include/llvm/IR/LeakDetector.h
- copied, changed from r202840, llvm/trunk/include/llvm/Support/LeakDetector.h
llvm/trunk/unittests/IR/LeakDetectorTest.cpp
- copied, changed from r202840, llvm/trunk/unittests/Support/LeakDetectorTest.cpp
Removed:
llvm/trunk/include/llvm/Support/LeakDetector.h
llvm/trunk/unittests/Support/LeakDetectorTest.cpp
Modified:
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
llvm/trunk/lib/IR/BasicBlock.cpp
llvm/trunk/lib/IR/Function.cpp
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/IR/Instruction.cpp
llvm/trunk/lib/IR/LeakDetector.cpp
llvm/trunk/lib/IR/Metadata.cpp
llvm/trunk/lib/IR/Module.cpp
llvm/trunk/lib/IR/Value.cpp
llvm/trunk/unittests/IR/CMakeLists.txt
llvm/trunk/unittests/Support/CMakeLists.txt
Copied: llvm/trunk/include/llvm/IR/LeakDetector.h (from r202840, llvm/trunk/include/llvm/Support/LeakDetector.h)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LeakDetector.h?p2=llvm/trunk/include/llvm/IR/LeakDetector.h&p1=llvm/trunk/include/llvm/Support/LeakDetector.h&r1=202840&r2=202842&rev=202842&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/LeakDetector.h (original)
+++ llvm/trunk/include/llvm/IR/LeakDetector.h Tue Mar 4 06:46:06 2014
@@ -1,4 +1,4 @@
-//===-- llvm/Support/LeakDetector.h - Provide leak detection ----*- C++ -*-===//
+//===- LeakDetector.h - Provide leak detection ------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -19,8 +19,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_SUPPORT_LEAKDETECTOR_H
-#define LLVM_SUPPORT_LEAKDETECTOR_H
+#ifndef LLVM_IR_LEAKDETECTOR_H
+#define LLVM_IR_LEAKDETECTOR_H
#include <string>
Removed: llvm/trunk/include/llvm/Support/LeakDetector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/LeakDetector.h?rev=202841&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/LeakDetector.h (original)
+++ llvm/trunk/include/llvm/Support/LeakDetector.h (removed)
@@ -1,92 +0,0 @@
-//===-- llvm/Support/LeakDetector.h - Provide leak detection ----*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines a class that can be used to provide very simple memory leak
-// checks for an API. Basically LLVM uses this to make sure that Instructions,
-// for example, are deleted when they are supposed to be, and not leaked away.
-//
-// When compiling with NDEBUG (Release build), this class does nothing, thus
-// adding no checking overhead to release builds. Note that this class is
-// implemented in a very simple way, requiring completely manual manipulation
-// and checking for garbage, but this is intentional: users should not be using
-// this API, only other APIs should.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_LEAKDETECTOR_H
-#define LLVM_SUPPORT_LEAKDETECTOR_H
-
-#include <string>
-
-namespace llvm {
-
-class LLVMContext;
-class Value;
-
-struct LeakDetector {
- /// addGarbageObject - Add a pointer to the internal set of "garbage" object
- /// pointers. This should be called when objects are created, or if they are
- /// taken out of an owning collection.
- ///
- static void addGarbageObject(void *Object) {
-#ifndef NDEBUG
- addGarbageObjectImpl(Object);
-#endif
- }
-
- /// removeGarbageObject - Remove a pointer from our internal representation of
- /// our "garbage" objects. This should be called when an object is added to
- /// an "owning" collection.
- ///
- static void removeGarbageObject(void *Object) {
-#ifndef NDEBUG
- removeGarbageObjectImpl(Object);
-#endif
- }
-
- /// checkForGarbage - Traverse the internal representation of garbage
- /// pointers. If there are any pointers that have been add'ed, but not
- /// remove'd, big obnoxious warnings about memory leaks are issued.
- ///
- /// The specified message will be printed indicating when the check was
- /// performed.
- ///
- static void checkForGarbage(LLVMContext &C, const std::string &Message) {
-#ifndef NDEBUG
- checkForGarbageImpl(C, Message);
-#endif
- }
-
- /// Overload the normal methods to work better with Value*'s because they are
- /// by far the most common in LLVM. This does not affect the actual
- /// functioning of this class, it just makes the warning messages nicer.
- ///
- static void addGarbageObject(const Value *Object) {
-#ifndef NDEBUG
- addGarbageObjectImpl(Object);
-#endif
- }
- static void removeGarbageObject(const Value *Object) {
-#ifndef NDEBUG
- removeGarbageObjectImpl(Object);
-#endif
- }
-
-private:
- // If we are debugging, the actual implementations will be called...
- static void addGarbageObjectImpl(const Value *Object);
- static void removeGarbageObjectImpl(const Value *Object);
- static void addGarbageObjectImpl(void *Object);
- static void removeGarbageObjectImpl(void *Object);
- static void checkForGarbageImpl(LLVMContext &C, const std::string &Message);
-};
-
-} // End llvm namespace
-
-#endif
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Mar 4 06:46:06 2014
@@ -24,10 +24,10 @@
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
Modified: llvm/trunk/lib/IR/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/BasicBlock.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/BasicBlock.cpp (original)
+++ llvm/trunk/lib/IR/BasicBlock.cpp Tue Mar 4 06:46:06 2014
@@ -19,8 +19,8 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Type.h"
-#include "llvm/Support/LeakDetector.h"
#include <algorithm>
using namespace llvm;
Modified: llvm/trunk/lib/IR/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Function.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Function.cpp (original)
+++ llvm/trunk/lib/IR/Function.cpp Tue Mar 4 06:46:06 2014
@@ -23,8 +23,8 @@
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Module.h"
-#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/RWMutex.h"
#include "llvm/Support/StringPool.h"
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Tue Mar 4 06:46:06 2014
@@ -18,9 +18,9 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/LeakDetector.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Tue Mar 4 06:46:06 2014
@@ -15,10 +15,10 @@
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
-#include "llvm/Support/LeakDetector.h"
using namespace llvm;
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Modified: llvm/trunk/lib/IR/LeakDetector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LeakDetector.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LeakDetector.cpp (original)
+++ llvm/trunk/lib/IR/LeakDetector.cpp Tue Mar 4 06:46:06 2014
@@ -11,7 +11,7 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Support/LeakDetector.h"
+#include "llvm/IR/LeakDetector.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/IR/Value.h"
Modified: llvm/trunk/lib/IR/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Metadata.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Metadata.cpp (original)
+++ llvm/trunk/lib/IR/Metadata.cpp Tue Mar 4 06:46:06 2014
@@ -22,9 +22,9 @@
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueHandle.h"
-#include "llvm/Support/LeakDetector.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/lib/IR/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Module.cpp (original)
+++ llvm/trunk/lib/IR/Module.cpp Tue Mar 4 06:46:06 2014
@@ -22,7 +22,7 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/LLVMContext.h"
-#include "llvm/Support/LeakDetector.h"
+#include "llvm/IR/LeakDetector.h"
#include <algorithm>
#include <cstdarg>
#include <cstdlib>
Modified: llvm/trunk/lib/IR/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Value.cpp?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Value.cpp (original)
+++ llvm/trunk/lib/IR/Value.cpp Tue Mar 4 06:46:06 2014
@@ -21,13 +21,13 @@
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LeakDetector.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/ManagedStatic.h"
#include <algorithm>
using namespace llvm;
Modified: llvm/trunk/unittests/IR/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/CMakeLists.txt?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/CMakeLists.txt (original)
+++ llvm/trunk/unittests/IR/CMakeLists.txt Tue Mar 4 06:46:06 2014
@@ -13,6 +13,7 @@ set(IRSources
DominatorTreeTest.cpp
IRBuilderTest.cpp
InstructionsTest.cpp
+ LeakDetectorTest.cpp
LegacyPassManagerTest.cpp
MDBuilderTest.cpp
MetadataTest.cpp
Copied: llvm/trunk/unittests/IR/LeakDetectorTest.cpp (from r202840, llvm/trunk/unittests/Support/LeakDetectorTest.cpp)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/LeakDetectorTest.cpp?p2=llvm/trunk/unittests/IR/LeakDetectorTest.cpp&p1=llvm/trunk/unittests/Support/LeakDetectorTest.cpp&r1=202840&r2=202842&rev=202842&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/LeakDetectorTest.cpp (original)
+++ llvm/trunk/unittests/IR/LeakDetectorTest.cpp Tue Mar 4 06:46:06 2014
@@ -1,4 +1,4 @@
-//===- llvm/unittest/LeakDetector/LeakDetector.cpp - LeakDetector tests ---===//
+//===- LeakDetectorTest.cpp -----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/IR/LeakDetector.h"
#include "gtest/gtest.h"
-#include "llvm/Support/LeakDetector.h"
using namespace llvm;
Modified: llvm/trunk/unittests/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/CMakeLists.txt?rev=202842&r1=202841&r2=202842&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/CMakeLists.txt (original)
+++ llvm/trunk/unittests/Support/CMakeLists.txt Tue Mar 4 06:46:06 2014
@@ -17,7 +17,6 @@ add_llvm_unittest(SupportTests
ErrorOrTest.cpp
FileOutputBufferTest.cpp
LEB128Test.cpp
- LeakDetectorTest.cpp
LineIteratorTest.cpp
LockFileManagerTest.cpp
ManagedStatic.cpp
Removed: llvm/trunk/unittests/Support/LeakDetectorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/LeakDetectorTest.cpp?rev=202841&view=auto
==============================================================================
--- llvm/trunk/unittests/Support/LeakDetectorTest.cpp (original)
+++ llvm/trunk/unittests/Support/LeakDetectorTest.cpp (removed)
@@ -1,31 +0,0 @@
-//===- llvm/unittest/LeakDetector/LeakDetector.cpp - LeakDetector tests ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "gtest/gtest.h"
-#include "llvm/Support/LeakDetector.h"
-
-using namespace llvm;
-
-namespace {
-
-#ifdef GTEST_HAS_DEATH_TEST
-#ifndef NDEBUG
-TEST(LeakDetector, Death1) {
- LeakDetector::addGarbageObject((void*) 1);
- LeakDetector::addGarbageObject((void*) 2);
-
- EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 1),
- ".*Ts.count\\(o\\) == 0 && \"Object already in set!\"");
- EXPECT_DEATH(LeakDetector::addGarbageObject((void*) 2),
- "Cache != o && \"Object already in set!\"");
-}
-#endif
-#endif
-
-}
More information about the llvm-commits
mailing list