diff options
author | Ahmed Charles <ahmedcharles@gmail.com> | 2014-03-06 05:51:42 +0000 |
---|---|---|
committer | Ahmed Charles <ahmedcharles@gmail.com> | 2014-03-06 05:51:42 +0000 |
commit | 56440fd8203f581b9aded68db3631ea11a72ccf2 (patch) | |
tree | 7f80c03b91a2d762573379b2624e3f1de93e6ab6 /llvm/lib/Transforms | |
parent | 47c254beb732a4434f814c4415cbc60503dd331a (diff) | |
download | llvm-56440fd8203f581b9aded68db3631ea11a72ccf2.zip llvm-56440fd8203f581b9aded68db3631ea11a72ccf2.tar.gz llvm-56440fd8203f581b9aded68db3631ea11a72ccf2.tar.bz2 |
Replace OwningPtr<T> with std::unique_ptr<T>.
This compiles with no changes to clang/lld/lldb with MSVC and includes
overloads to various functions which are used by those projects and llvm
which have OwningPtr's as parameters. This should allow out of tree
projects some time to move. There are also no changes to libs/Target,
which should help out of tree targets have time to move, if necessary.
llvm-svn: 203083
Diffstat (limited to 'llvm/lib/Transforms')
9 files changed, 20 insertions, 24 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index beeb494..e8d2e0a 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DepthFirstIterator.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -349,7 +348,7 @@ struct AddressSanitizer : public FunctionPass { Function *AsanHandleNoReturnFunc; Function *AsanCovFunction; Function *AsanPtrCmpFunction, *AsanPtrSubFunction; - OwningPtr<SpecialCaseList> BL; + std::unique_ptr<SpecialCaseList> BL; // This array is indexed by AccessIsWrite and log2(AccessSize). Function *AsanErrorCallback[2][kNumberOfAccessSizes]; // This array is indexed by AccessIsWrite. @@ -386,7 +385,7 @@ class AddressSanitizerModule : public ModulePass { bool CheckInitOrder; SmallString<64> BlacklistFile; - OwningPtr<SpecialCaseList> BL; + std::unique_ptr<SpecialCaseList> BL; SetOfDynamicallyInitializedGlobals DynamicallyInitializedGlobals; Type *IntptrTy; LLVMContext *C; diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index dd44a00..3f473a9 100644 --- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -190,7 +190,7 @@ class DataFlowSanitizer : public ModulePass { Constant *DFSanSetLabelFn; Constant *DFSanNonzeroLabelFn; MDNode *ColdCallWeights; - OwningPtr<SpecialCaseList> ABIList; + std::unique_ptr<SpecialCaseList> ABIList; DenseMap<Value *, Function *> UnwrappedFnMap; AttributeSet ReadOnlyNoneAttrs; diff --git a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp index 241baba..45e2c11 100644 --- a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp +++ b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp @@ -503,7 +503,7 @@ bool DebugIR::updateExtension(StringRef NewExtension) { return true; } -void DebugIR::generateFilename(OwningPtr<int> &fd) { +void DebugIR::generateFilename(std::unique_ptr<int> &fd) { SmallVector<char, 16> PathVec; fd.reset(new int); sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec); @@ -524,7 +524,7 @@ std::string DebugIR::getPath() { } void DebugIR::writeDebugBitcode(const Module *M, int *fd) { - OwningPtr<raw_fd_ostream> Out; + std::unique_ptr<raw_fd_ostream> Out; std::string error; if (!fd) { @@ -542,12 +542,12 @@ void DebugIR::writeDebugBitcode(const Module *M, int *fd) { Out->close(); } -void DebugIR::createDebugInfo(Module &M, OwningPtr<Module> &DisplayM) { +void DebugIR::createDebugInfo(Module &M, std::unique_ptr<Module> &DisplayM) { if (M.getFunctionList().size() == 0) // no functions -- no debug info needed return; - OwningPtr<ValueToValueMapTy> VMap; + std::unique_ptr<ValueToValueMapTy> VMap; if (WriteSourceToDisk && (HideDebugIntrinsics || HideDebugMetadata)) { VMap.reset(new ValueToValueMapTy); @@ -566,7 +566,7 @@ void DebugIR::createDebugInfo(Module &M, OwningPtr<Module> &DisplayM) { bool DebugIR::isMissingPath() { return Filename.empty() || Directory.empty(); } bool DebugIR::runOnModule(Module &M) { - OwningPtr<int> fd; + std::unique_ptr<int> fd; if (isMissingPath() && !getSourceInfo(M)) { if (!WriteSourceToDisk) @@ -585,7 +585,7 @@ bool DebugIR::runOnModule(Module &M) { // file name from the DICompileUnit descriptor. DebugMetadataRemover::process(M, !ParsedPath); - OwningPtr<Module> DisplayM; + std::unique_ptr<Module> DisplayM; createDebugInfo(M, DisplayM); if (WriteSourceToDisk) { Module *OutputM = DisplayM.get() ? DisplayM.get() : &M; diff --git a/llvm/lib/Transforms/Instrumentation/DebugIR.h b/llvm/lib/Transforms/Instrumentation/DebugIR.h index a6852bf..3f57da5 100644 --- a/llvm/lib/Transforms/Instrumentation/DebugIR.h +++ b/llvm/lib/Transforms/Instrumentation/DebugIR.h @@ -16,7 +16,6 @@ #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H #define LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H -#include "llvm/ADT/OwningPtr.h" #include "llvm/Pass.h" namespace llvm { @@ -79,11 +78,11 @@ private: bool updateExtension(llvm::StringRef NewExtension); /// Generate a temporary filename and open an fd - void generateFilename(llvm::OwningPtr<int> &fd); + void generateFilename(std::unique_ptr<int> &fd); /// Creates DWARF CU/Subroutine metadata void createDebugInfo(llvm::Module &M, - llvm::OwningPtr<llvm::Module> &DisplayM); + std::unique_ptr<llvm::Module> &DisplayM); /// Returns true if either Directory or Filename is missing, false otherwise. bool isMissingPath(); diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp index d990de2..d04a5bf 100644 --- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -687,7 +687,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable( Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx); ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize); - OwningArrayPtr<Constant *> EdgeTable(new Constant*[TableSize]); + std::unique_ptr<Constant * []> EdgeTable(new Constant *[TableSize]); Constant *NullValue = Constant::getNullValue(Int64PtrTy); for (size_t i = 0; i != TableSize; ++i) EdgeTable[i] = NullValue; diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 9f7f729..b4ae443 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -272,7 +272,7 @@ class MemorySanitizer : public FunctionPass { /// \brief Path to blacklist file. SmallString<64> BlacklistFile; /// \brief The blacklist. - OwningPtr<SpecialCaseList> BL; + std::unique_ptr<SpecialCaseList> BL; /// \brief An empty volatile inline asm that prevents callback merge. InlineAsm *EmptyAsm; @@ -489,7 +489,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { MemorySanitizer &MS; SmallVector<PHINode *, 16> ShadowPHINodes, OriginPHINodes; ValueMap<Value*, Value*> ShadowMap, OriginMap; - OwningPtr<VarArgHelper> VAHelper; + std::unique_ptr<VarArgHelper> VAHelper; // The following flags disable parts of MSan instrumentation based on // blacklist contents and command-line options. diff --git a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index bc022600..fed7508 100644 --- a/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -99,7 +99,7 @@ struct ThreadSanitizer : public FunctionPass { const DataLayout *DL; Type *IntptrTy; SmallString<64> BlacklistFile; - OwningPtr<SpecialCaseList> BL; + std::unique_ptr<SpecialCaseList> BL; IntegerType *OrdTy; // Callbacks to run-time library are computed in doInitialization. Function *TsanFuncEntry; diff --git a/llvm/lib/Transforms/Scalar/SampleProfile.cpp b/llvm/lib/Transforms/Scalar/SampleProfile.cpp index dcb9376..d48e43d 100644 --- a/llvm/lib/Transforms/Scalar/SampleProfile.cpp +++ b/llvm/lib/Transforms/Scalar/SampleProfile.cpp @@ -26,7 +26,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" @@ -240,7 +239,7 @@ public: static char ID; SampleProfileLoader(StringRef Name = SampleProfileFile) - : FunctionPass(ID), Profiler(0), Filename(Name) { + : FunctionPass(ID), Profiler(), Filename(Name) { initializeSampleProfileLoaderPass(*PassRegistry::getPassRegistry()); } @@ -261,7 +260,7 @@ public: protected: /// \brief Profile reader object. - OwningPtr<SampleModuleProfile> Profiler; + std::unique_ptr<SampleModuleProfile> Profiler; /// \brief Name of the profile file to load. StringRef Filename; @@ -399,7 +398,7 @@ void SampleModuleProfile::dump() { /// profiles for large programs, as the representation is extremely /// inefficient. void SampleModuleProfile::loadText() { - OwningPtr<MemoryBuffer> Buffer; + std::unique_ptr<MemoryBuffer> Buffer; error_code EC = MemoryBuffer::getFile(Filename, Buffer); if (EC) report_fatal_error("Could not open file " + Filename + ": " + EC.message()); diff --git a/llvm/lib/Transforms/Utils/SpecialCaseList.cpp b/llvm/lib/Transforms/Utils/SpecialCaseList.cpp index a177c82..c318560 100644 --- a/llvm/lib/Transforms/Utils/SpecialCaseList.cpp +++ b/llvm/lib/Transforms/Utils/SpecialCaseList.cpp @@ -15,7 +15,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/SpecialCaseList.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" @@ -55,7 +54,7 @@ SpecialCaseList *SpecialCaseList::create( const StringRef Path, std::string &Error) { if (Path.empty()) return new SpecialCaseList(); - OwningPtr<MemoryBuffer> File; + std::unique_ptr<MemoryBuffer> File; if (error_code EC = MemoryBuffer::getFile(Path, File)) { Error = (Twine("Can't open file '") + Path + "': " + EC.message()).str(); return 0; @@ -65,7 +64,7 @@ SpecialCaseList *SpecialCaseList::create( SpecialCaseList *SpecialCaseList::create( const MemoryBuffer *MB, std::string &Error) { - OwningPtr<SpecialCaseList> SCL(new SpecialCaseList()); + std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList()); if (!SCL->parse(MB, Error)) return 0; return SCL.release(); |