llvm.org GIT mirror llvm / f4ccd11
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203083 91177308-0d34-0410-b5e6-96231b3b80d8 Ahmed Charles 5 years ago
167 changed file(s) with 557 addition(s) and 655 deletion(s). Raw diff Collapse all Expand all
9595 LLVMContext Context;
9696
9797 // Create some module to put our function into it.
98 OwningPtr M(new Module("test", Context));
98 std::unique_ptr M(new Module("test", Context));
9999
100100 // We are about to create the "fib" function:
101101 Function *FibF = CreateFibFunction(M.get(), Context);
714714 // This file isn't in our cache
715715 return NULL;
716716 }
717 OwningPtr IRObjectBuffer;
717 std::unique_ptr IRObjectBuffer;
718718 MemoryBuffer::getFile(IRCacheFile.c_str(), IRObjectBuffer, -1, false);
719719 // MCJIT will want to write into this buffer, and we don't want that
720720 // because the file has probably just been mmapped. Instead we make
738738 // This file isn't in our cache
739739 return NULL;
740740 }
741 OwningPtr IRObjectBuffer;
741 std::unique_ptr IRObjectBuffer;
742742 MemoryBuffer::getFile(IRCacheFile.c_str(), IRObjectBuffer, -1, false);
743743 // MCJIT will want to write into this buffer, and we don't want that
744744 // because the file has probably just been mmapped. Instead we make
5252 #define LLVM_ANALYSIS_CALLGRAPH_H
5353
5454 #include "llvm/ADT/GraphTraits.h"
55 #include "llvm/ADT/OwningPtr.h"
5655 #include "llvm/ADT/STLExtras.h"
5756 #include "llvm/IR/CallSite.h"
5857 #include "llvm/IR/Function.h"
313312 /// call graph interface is entirelly a wrapper around a \c CallGraph object
314313 /// which is stored internally for each module.
315314 class CallGraphWrapperPass : public ModulePass {
316 OwningPtr G;
315 std::unique_ptr G;
317316
318317 public:
319318 static char ID; // Class identification, replacement for typeinfo
1414 #define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
1515
1616 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/PointerIntPair.h"
1918 #include "llvm/ADT/SmallPtrSet.h"
2019 #include "llvm/Analysis/AliasAnalysis.h"
324323 AliasAnalysis *AA;
325324 const DataLayout *DL;
326325 DominatorTree *DT;
327 OwningPtr PredCache;
326 std::unique_ptr PredCache;
327
328328 public:
329329 MemoryDependenceAnalysis();
330330 ~MemoryDependenceAnalysis();
1414 #ifndef LLVM_BITCODE_BITSTREAMREADER_H
1515 #define LLVM_BITCODE_BITSTREAMREADER_H
1616
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/Bitcode/BitCodes.h"
1918 #include "llvm/Support/Endian.h"
2019 #include "llvm/Support/StreamableMemoryObject.h"
4342 std::vector > RecordNames;
4443 };
4544 private:
46 OwningPtr BitcodeBytes;
45 std::unique_ptr BitcodeBytes;
4746
4847 std::vector BlockInfoRecords;
4948
2828 class MachineBlockFrequencyInfo;
2929 class MachineFunction;
3030 class TargetRegisterInfo;
31 template class OwningPtr;
3231
3332 typedef PBQP::RegAlloc::Graph PBQPRAGraph;
3433
157156 PBQP::PBQPNum benefit);
158157 };
159158
160 FunctionPass* createPBQPRegisterAllocator(OwningPtr &builder,
161 char *customPassID=0);
159 FunctionPass *
160 createPBQPRegisterAllocator(std::unique_ptr &builder,
161 char *customPassID = 0);
162162 }
163163
164164 #endif /* LLVM_CODEGEN_REGALLOCPBQP_H */
1414 #ifndef LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
1515 #define LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
1616
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/SmallVector.h"
1918 #include "llvm/Support/MemoryBuffer.h"
2019 #include "llvm/Support/raw_ostream.h"
4847
4948 protected:
5049 // The memory contained in an ObjectBuffer
51 OwningPtr Buffer;
50 std::unique_ptr Buffer;
5251 };
5352
5453 /// ObjectBufferStream - This class encapsulates the SmallVector and
2727 virtual void anchor();
2828
2929 protected:
30 OwningPtr Buffer;
30 std::unique_ptr Buffer;
3131
3232 public:
3333 ObjectImage(ObjectBuffer *Input) : Buffer(Input) {}
1414 #ifndef LLVM_IR_MODULE_H
1515 #define LLVM_IR_MODULE_H
1616
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/IR/DataLayout.h"
1918 #include "llvm/IR/Function.h"
2019 #include "llvm/IR/GlobalAlias.h"
196195 NamedMDListType NamedMDList; ///< The named metadata in the module
197196 std::string GlobalScopeAsm; ///< Inline Asm at global scope.
198197 ValueSymbolTable *ValSymTab; ///< Symbol table for values
199 OwningPtr Materializer; ///< Used to materialize GlobalValues
198 std::unique_ptr
199 Materializer; ///< Used to materialize GlobalValues
200200 std::string ModuleID; ///< Human readable identifier for the module
201201 std::string TargetTriple; ///< Platform target triple Module compiled on
202202 void *NamedMDSymTab; ///< NamedMDNode names.
1414 #define LTO_MODULE_H
1515
1616 #include "llvm-c/lto.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/StringMap.h"
1918 #include "llvm/IR/Mangler.h"
2019 #include "llvm/IR/Module.h"
4746 const llvm::GlobalValue *symbol;
4847 };
4948
50 llvm::OwningPtr _module;
51 llvm::OwningPtr _target;
49 std::unique_ptr _module;
50 std::unique_ptr _target;
5251 llvm::MCObjectFileInfo ObjFileInfo;
5352 StringSet _linkeropt_strings;
5453 std::vector _deplibs;
110110 private:
111111 std::string Prompt;
112112 std::string HistoryPath;
113 OwningPtr Data;
113 std::unique_ptr Data;
114114
115115 struct CompleterConcept {
116116 virtual ~CompleterConcept();
144144 T Value;
145145 };
146146
147 llvm::OwningPtr Completer;
147 std::unique_ptr Completer;
148148 };
149149
150150 }
5555 };
5656
5757 /// Constructor - Performs initial setup for the disassembler.
58 MCDisassembler(const MCSubtargetInfo &STI) : GetOpInfo(0), SymbolLookUp(0),
59 DisInfo(0), Ctx(0),
60 STI(STI), Symbolizer(0),
61 CommentStream(0) {}
58 MCDisassembler(const MCSubtargetInfo &STI)
59 : GetOpInfo(0), SymbolLookUp(0), DisInfo(0), Ctx(0), STI(STI),
60 Symbolizer(), CommentStream(0) {}
6261
6362 virtual ~MCDisassembler();
6463
101100 protected:
102101 // Subtarget information, for instruction decoding predicates if required.
103102 const MCSubtargetInfo &STI;
104 OwningPtr Symbolizer;
103 std::unique_ptr Symbolizer;
105104
106105 public:
107106 // Helpers around MCSymbolizer
114113
115114 /// Set \p Symzer as the current symbolizer.
116115 /// This takes ownership of \p Symzer, and deletes the previously set one.
117 void setSymbolizer(OwningPtr &Symzer);
116 void setSymbolizer(std::unique_ptr &Symzer);
118117
119118 /// Sets up an external symbolizer that uses the C API callbacks.
120119 void setupForSymbolicDisassembly(LLVMOpInfoCallback GetOpInfo,
1717
1818 #include "llvm-c/Disassembler.h"
1919 #include "llvm/MC/MCSymbolizer.h"
20 #include
2021
2122 namespace llvm {
2223
3738
3839 public:
3940 MCExternalSymbolizer(MCContext &Ctx,
40 OwningPtr &RelInfo,
41 std::unique_ptr &RelInfo,
4142 LLVMOpInfoCallback getOpInfo,
42 LLVMSymbolLookupCallback symbolLookUp,
43 void *disInfo)
44 : MCSymbolizer(Ctx, RelInfo),
45 GetOpInfo(getOpInfo), SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
43 LLVMSymbolLookupCallback symbolLookUp, void *disInfo)
44 : MCSymbolizer(Ctx, RelInfo), GetOpInfo(getOpInfo),
45 SymbolLookUp(symbolLookUp), DisInfo(disInfo) {}
4646
4747 bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &CommentStream,
4848 int64_t Value,
1010 #define LLVM_MC_MCMACHOBJECTWRITER_H
1111
1212 #include "llvm/ADT/DenseMap.h"
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/ADT/SmallString.h"
1514 #include "llvm/MC/MCExpr.h"
1615 #include "llvm/MC/MCObjectWriter.h"
9190 };
9291
9392 /// The target specific Mach-O writer instance.
94 llvm::OwningPtr TargetObjectWriter;
93 std::unique_ptr TargetObjectWriter;
9594
9695 /// @name Relocation Data
9796 /// @{
1515 #ifndef LLVM_MC_MCMODULEYAML_H
1616 #define LLVM_MC_MCMODULEYAML_H
1717
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/ADT/StringRef.h"
2019 #include "llvm/MC/MCModule.h"
2120 #include "llvm/Support/raw_ostream.h"
3231
3332 /// \brief Creates a new module and returns it in \p MCM.
3433 /// \returns The empty string on success, an error message on failure.
35 StringRef yaml2mcmodule(OwningPtr &MCM, StringRef YamlContent,
34 StringRef yaml2mcmodule(std::unique_ptr &MCM, StringRef YamlContent,
3635 const MCInstrInfo &MII, const MCRegisterInfo &MRI);
3736
3837 } // end namespace llvm
1515 #define LLVM_MC_MCOBJECTDISASSEMBLER_H
1616
1717 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/ADT/StringRef.h"
2019 #include "llvm/Support/DataTypes.h"
2120 #include "llvm/Support/MemoryObject.h"
6665 /// \brief Set the region on which to fallback if disassembly was requested
6766 /// somewhere not accessible in the object file.
6867 /// This is used for dynamic disassembly (see RawMemoryObject).
69 void setFallbackRegion(OwningPtr &Region) {
68 void setFallbackRegion(std::unique_ptr &Region) {
7069 FallbackRegion.reset(Region.release());
7170 }
7271
112111 MCObjectSymbolizer *MOS;
113112
114113 /// \brief The fallback memory region, outside the object file.
115 OwningPtr FallbackRegion;
114 std::unique_ptr FallbackRegion;
116115
117116 /// \brief Return a memory region suitable for reading starting at \p Addr.
118117 /// In most cases, this returns a StringRefMemoryObject backed by the
4040 const object::RelocationRef *findRelocationAt(uint64_t Addr);
4141 const object::SectionRef *findSectionContaining(uint64_t Addr);
4242
43 MCObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo,
43 MCObjectSymbolizer(MCContext &Ctx, std::unique_ptr &RelInfo,
4444 const object::ObjectFile *Obj);
4545
4646 public:
6262
6363 /// \brief Create an object symbolizer for \p Obj.
6464 static MCObjectSymbolizer *
65 createObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo,
66 const object::ObjectFile *Obj);
65 createObjectSymbolizer(MCContext &Ctx,
66 std::unique_ptr &RelInfo,
67 const object::ObjectFile *Obj);
6768
6869 private:
6970 typedef DenseMap AddrToRelocMap;
129129 void emitCurrentConstantPool();
130130
131131 private:
132 OwningPtr ConstantPools;
132 std::unique_ptr ConstantPools;
133133 };
134134
135135 /// MCStreamer - Streaming machine code generation interface. This interface
143143 ///
144144 class MCStreamer {
145145 MCContext &Context;
146 OwningPtr TargetStreamer;
146 std::unique_ptr TargetStreamer;
147147
148148 MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION;
149149 MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION;
1515 #ifndef LLVM_MC_MCSYMBOLIZER_H
1616 #define LLVM_MC_MCSYMBOLIZER_H
1717
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/MC/MCRelocationInfo.h"
2019 #include "llvm/Support/Compiler.h"
2120 #include "llvm/Support/DataTypes.h"
21 #include
2222
2323 namespace llvm {
2424
4141
4242 protected:
4343 MCContext &Ctx;
44 OwningPtr RelInfo;
44 std::unique_ptr RelInfo;
4545
4646 public:
4747 /// \brief Construct an MCSymbolizer, taking ownership of \p RelInfo.
48 MCSymbolizer(MCContext &Ctx, OwningPtr &RelInfo);
48 MCSymbolizer(MCContext &Ctx, std::unique_ptr &RelInfo);
4949 virtual ~MCSymbolizer();
5050
5151 /// \brief Try to add a symbolic operand instead of \p Value to the MCInst.
2222
2323 namespace object {
2424 class IRObjectFile : public SymbolicFile {
25 OwningPtr M;
26 OwningPtr Mang;
25 std::unique_ptr M;
26 std::unique_ptr Mang;
27
2728 public:
2829 IRObjectFile(MemoryBuffer *Object, error_code &EC, LLVMContext &Context,
2930 bool BufferOwned);
1313 #ifndef LLVM_OBJECT_MACHOUNIVERSAL_H
1414 #define LLVM_OBJECT_MACHOUNIVERSAL_H
1515
16 #include "llvm/ADT/OwningPtr.h"
1716 #include "llvm/ADT/StringRef.h"
1817 #include "llvm/ADT/Triple.h"
1918 #include "llvm/Object/Binary.h"
5251 ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); }
5352 uint32_t getCPUType() const { return Header.cputype; }
5453
55 error_code getAsObjectFile(OwningPtr &Result) const;
54 error_code getAsObjectFile(std::unique_ptr &Result) const;
5655 };
5756
5857 class object_iterator {
9493 }
9594
9695 error_code getObjectForArch(Triple::ArchType Arch,
97 OwningPtr &Result) const;
96 std::unique_ptr &Result) const;
9897 };
9998
10099 }
1414 #define LLVM_SUPPORT_COMPRESSION_H
1515
1616 #include "llvm/Support/DataTypes.h"
17 #include
1718
1819 namespace llvm {
1920
2021 class MemoryBuffer;
21 template class OwningPtr;
2222 class StringRef;
2323
2424 namespace zlib {
4242 bool isAvailable();
4343
4444 Status compress(StringRef InputBuffer,
45 OwningPtr &CompressedBuffer,
45 std::unique_ptr &CompressedBuffer,
4646 CompressionLevel Level = DefaultCompression);
4747
4848 Status uncompress(StringRef InputBuffer,
49 OwningPtr &UncompressedBuffer,
49 std::unique_ptr &UncompressedBuffer,
5050 size_t UncompressedSize);
5151
5252 uint32_t crc32(StringRef Buffer);
2727 #define LLVM_SUPPORT_FILESYSTEM_H
2828
2929 #include "llvm/ADT/IntrusiveRefCntPtr.h"
30 #include "llvm/ADT/OwningPtr.h"
3130 #include "llvm/ADT/SmallString.h"
3231 #include "llvm/ADT/Twine.h"
3332 #include "llvm/Support/DataTypes.h"
1010 #ifndef LLVM_SUPPORT_STREAMABLEMEMORYOBJECT_H
1111 #define LLVM_SUPPORT_STREAMABLEMEMORYOBJECT_H
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/Support/Compiler.h"
1514 #include "llvm/Support/DataStream.h"
1615 #include "llvm/Support/MemoryObject.h"
16 #include
17 #include
1718 #include
1819
1920 namespace llvm {
136137 private:
137138 const static uint32_t kChunkSize = 4096 * 4;
138139 mutable std::vector Bytes;
139 OwningPtr Streamer;
140 std::unique_ptr Streamer;
140141 mutable size_t BytesRead; // Bytes read from stream
141142 size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header)
142143 mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached
3737 #ifndef LLVM_SUPPORT_YAMLPARSER_H
3838 #define LLVM_SUPPORT_YAMLPARSER_H
3939
40 #include "llvm/ADT/OwningPtr.h"
4140 #include "llvm/ADT/SmallString.h"
4241 #include "llvm/ADT/StringRef.h"
4342 #include "llvm/Support/Allocator.h"
9594 void printError(Node *N, const Twine &Msg);
9695
9796 private:
98 OwningPtr scanner;
99 OwningPtr CurrentDoc;
97 std::unique_ptr scanner;
98 std::unique_ptr CurrentDoc;
10099
101100 friend class Document;
102101 };
114113 NK_Alias
115114 };
116115
117 Node(unsigned int Type, OwningPtr &, StringRef Anchor,
116 Node(unsigned int Type, std::unique_ptr &, StringRef Anchor,
118117 StringRef Tag);
119118
120119 /// @brief Get the value of the anchor attached to this node. If it does not
155154 }
156155
157156 protected:
158 OwningPtr &Doc;
157 std::unique_ptr &Doc;
159158 SMRange SourceRange;
160159
161160 void operator delete(void *) throw() {}
176175 class NullNode : public Node {
177176 void anchor() override;
178177 public:
179 NullNode(OwningPtr &D)
178 NullNode(std::unique_ptr &D)
180179 : Node(NK_Null, D, StringRef(), StringRef()) {}
181180
182181 static inline bool classof(const Node *N) {
192191 class ScalarNode : public Node {
193192 void anchor() override;
194193 public:
195 ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Tag,
194 ScalarNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
196195 StringRef Val)
197196 : Node(NK_Scalar, D, Anchor, Tag), Value(Val) {
198197 SMLoc Start = SMLoc::getFromPointer(Val.begin());
234233 class KeyValueNode : public Node {
235234 void anchor() override;
236235 public:
237 KeyValueNode(OwningPtr &D)
238 : Node(NK_KeyValue, D, StringRef(), StringRef())
239 , Key(0)
240 , Value(0)
241 {}
236 KeyValueNode(std::unique_ptr &D)
237 : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(0), Value(0) {}
242238
243239 /// @brief Parse and return the key.
244240 ///
352348 MT_Inline ///< An inline mapping node is used for "[key: value]".
353349 };
354350
355 MappingNode(OwningPtr &D, StringRef Anchor, StringRef Tag,
351 MappingNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
356352 MappingType MT)
357353 : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
358354 IsAtEnd(false), CurrentEntry(0) {}
409405 ST_Indentless
410406 };
411407
412 SequenceNode(OwningPtr &D, StringRef Anchor, StringRef Tag,
408 SequenceNode(std::unique_ptr &D, StringRef Anchor, StringRef Tag,
413409 SequenceType ST)
414410 : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
415411 IsAtEnd(false),
452448 class AliasNode : public Node {
453449 void anchor() override;
454450 public:
455 AliasNode(OwningPtr &D, StringRef Val)
456 : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {}
451 AliasNode(std::unique_ptr &D, StringRef Val)
452 : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {}
457453
458454 StringRef getName() const { return Name; }
459455 Node *getTarget();
530526 class document_iterator {
531527 public:
532528 document_iterator() : Doc(0) {}
533 document_iterator(OwningPtr &D) : Doc(&D) {}
529 document_iterator(std::unique_ptr &D) : Doc(&D) {}
534530
535531 bool operator ==(const document_iterator &Other) {
536532 if (isAtEnd() || Other.isAtEnd())
557553 return *Doc->get();
558554 }
559555
560 OwningPtr &operator ->() {
561 return *Doc;
562 }
556 std::unique_ptr &operator->() { return *Doc; }
563557
564558 private:
565559 bool isAtEnd() const {
566560 return !Doc || !*Doc;
567561 }
568562
569 OwningPtr *Doc;
563 std::unique_ptr *Doc;
570564 };
571565
572566 }
851851 void nextDocument();
852852
853853 private:
854 llvm::SourceMgr SrcMgr; // must be before Strm
855 OwningPtr Strm;
856 OwningPtr TopNode;
857 llvm::error_code EC;
858 llvm::BumpPtrAllocator StringAllocator;
859 llvm::yaml::document_iterator DocIterator;
860 std::vector BitValuesUsed;
861 HNode *CurrentNode;
862 bool ScalarMatchFound;
854 llvm::SourceMgr SrcMgr; // must be before Strm
855 std::unique_ptr Strm;
856 std::unique_ptr TopNode;
857 llvm::error_code EC;
858 llvm::BumpPtrAllocator StringAllocator;
859 llvm::yaml::document_iterator DocIterator;
860 std::vector BitValuesUsed;
861 HNode *CurrentNode;
862 bool ScalarMatchFound;
863863 };
864864
865865
5858 "Memory Dependence Analysis", false, true)
5959
6060 MemoryDependenceAnalysis::MemoryDependenceAnalysis()
61 : FunctionPass(ID), PredCache(0) {
61 : FunctionPass(ID), PredCache() {
6262 initializeMemoryDependenceAnalysisPass(*PassRegistry::getPassRegistry());
6363 }
6464 MemoryDependenceAnalysis::~MemoryDependenceAnalysis() {
1212
1313 #include "llvm/AsmParser/Parser.h"
1414 #include "LLParser.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/IR/Module.h"
1716 #include "llvm/Support/MemoryBuffer.h"
1817 #include "llvm/Support/SourceMgr.h"
3332 return LLParser(F, SM, Err, M).Run() ? 0 : M;
3433
3534 // Otherwise create a new module.
36 OwningPtr M2(new Module(F->getBufferIdentifier(), Context));
35 std::unique_ptr M2(new Module(F->getBufferIdentifier(), Context));
3736 if (LLParser(F, SM, Err, M2.get()).Run())
3837 return 0;
3938 return M2.release();
4140
4241 Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
4342 LLVMContext &Context) {
44 OwningPtr File;
43 std::unique_ptr File;
4544 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
4645 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
4746 "Could not open input file: " + ec.message());
126126 Module *TheModule;
127127 MemoryBuffer *Buffer;
128128 bool BufferOwned;
129 OwningPtr StreamFile;
129 std::unique_ptr StreamFile;
130130 BitstreamCursor Stream;
131131 DataStreamer *LazyStreamer;
132132 uint64_t NextUnreadBit;
1212
1313 #define DEBUG_TYPE "asm-printer"
1414 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/SmallString.h"
1716 #include "llvm/ADT/Twine.h"
1817 #include "llvm/CodeGen/MachineBasicBlock.h"
117116 // Tell SrcMgr about this buffer, it takes ownership of the buffer.
118117 SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
119118
120 OwningPtr Parser(createMCAsmParser(SrcMgr,
121 OutContext, OutStreamer,
122 *MAI));
119 std::unique_ptr Parser(
120 createMCAsmParser(SrcMgr, OutContext, OutStreamer, *MAI));
123121
124122 // Initialize the parser with a fresh subtarget info. It is better to use a
125123 // new STI here because the parser may modify it and we do not want those
126124 // modifications to persist after parsing the inlineasm. The modifications
127125 // made by the parser will be seen by the code emitters because it passes
128126 // the current STI down to the EncodeInstruction() method.
129 OwningPtr STI(TM.getTarget().createMCSubtargetInfo(
127 std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo(
130128 TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString()));
131129
132130 // Preserve a copy of the original STI because the parser may modify it. For
135133 // emitInlineAsmEnd().
136134 MCSubtargetInfo STIOrig = *STI;
137135
138 OwningPtr
139 TAP(TM.getTarget().createMCAsmParser(*STI, *Parser, *MII));
136 std::unique_ptr TAP(
137 TM.getTarget().createMCAsmParser(*STI, *Parser, *MII));
140138 if (!TAP)
141139 report_fatal_error("Inline asm not supported by this streamer because"
142140 " we don't have an asm parser for this target\n");
1717 #include "DwarfDebug.h"
1818 #include "llvm/ADT/DenseMap.h"
1919 #include "llvm/ADT/Optional.h"
20 #include "llvm/ADT/OwningPtr.h"
2120 #include "llvm/ADT/StringMap.h"
2221 #include "llvm/IR/DIBuilder.h"
2322 #include "llvm/IR/DebugInfo.h"
7069 DICompileUnit CUNode;
7170
7271 /// Unit debug information entry.
73 const OwningPtr UnitDie;
72 const std::unique_ptr UnitDie;
7473
7574 /// Offset of the UnitDie from beginning of debug info section.
7675 unsigned DebugInfoOffset;
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Target/TargetMachine.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/CodeGen/AsmPrinter.h"
1615 #include "llvm/CodeGen/MachineFunctionAnalysis.h"
1716 #include "llvm/CodeGen/MachineModuleInfo.h"
173172 const MCRegisterInfo &MRI = *getRegisterInfo();
174173 const MCInstrInfo &MII = *getInstrInfo();
175174 const MCSubtargetInfo &STI = getSubtarget();
176 OwningPtr AsmStreamer;
175 std::unique_ptr AsmStreamer;
177176
178177 switch (FileType) {
179178 case CGFT_AssemblyFile: {
280279 if (MCE == 0 || MAB == 0)
281280 return true;
282281
283 OwningPtr AsmStreamer;
282 std::unique_ptr AsmStreamer;
284283 AsmStreamer.reset(getTarget().createMCObjectStreamer(
285284 getTargetTriple(), *Ctx, *MAB, Out, MCE, STI, hasMCRelaxAll(),
286285 hasMCNoExecStack()));
6666 Matrix[i].clear();
6767 // No need to clear Queries here, since LiveIntervalUnion::Query doesn't
6868 // have anything important to clear and LiveRegMatrix's runOnFunction()
69 // does a OwningPtr::reset anyways.
69 // does a std::unique_ptr::reset anyways.
7070 }
7171 }
7272
1414 #define DEBUG_TYPE "misched"
1515
1616 #include "llvm/CodeGen/MachineScheduler.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/PriorityQueue.h"
1918 #include "llvm/Analysis/AliasAnalysis.h"
2019 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
320319
321320 // Instantiate the selected scheduler for this target, function, and
322321 // optimization level.
323 OwningPtr Scheduler(createMachineScheduler());
322 std::unique_ptr Scheduler(createMachineScheduler());
324323 scheduleRegions(*Scheduler);
325324
326325 DEBUG(LIS->dump());
341340
342341 // Instantiate the selected scheduler for this target, function, and
343342 // optimization level.
344 OwningPtr Scheduler(createPostMachineScheduler());
343 std::unique_ptr Scheduler(createPostMachineScheduler());
345344 scheduleRegions(*Scheduler);
346345
347346 if (VerifyScheduling)
3636 #ifndef LLVM_CODEGEN_REGALLOCBASE
3737 #define LLVM_CODEGEN_REGALLOCBASE
3838
39 #include "llvm/ADT/OwningPtr.h"
4039 #include "llvm/CodeGen/LiveInterval.h"
4140 #include "llvm/CodeGen/RegisterClassInfo.h"
4241
6363 MachineFunction *MF;
6464
6565 // state
66 OwningPtr SpillerInstance;
66 std::unique_ptr SpillerInstance;
6767 std::priority_queue,
6868 CompSpillWeight> Queue;
6969
100100 LiveDebugVariables *DebugVars;
101101
102102 // state
103 OwningPtr SpillerInstance;
103 std::unique_ptr SpillerInstance;
104104 PQueue Queue;
105105 unsigned NextCascade;
106106
195195 };
196196
197197 // splitting state.
198 OwningPtr SA;
199 OwningPtr SE;
198 std::unique_ptr SA;
199 std::unique_ptr SE;
200200
201201 /// Cached per-block interference maps
202202 InterferenceCache IntfCache;
3333 #include "llvm/CodeGen/RegAllocPBQP.h"
3434 #include "RegisterCoalescer.h"
3535 #include "Spiller.h"
36 #include "llvm/ADT/OwningPtr.h"
3736 #include "llvm/Analysis/AliasAnalysis.h"
3837 #include "llvm/CodeGen/CalcSpillWeights.h"
3938 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
8786 static char ID;
8887
8988 /// Construct a PBQP register allocator.
90 RegAllocPBQP(OwningPtr &b, char *cPassID=0)
89 RegAllocPBQP(std::unique_ptr &b, char *cPassID=0)
9190 : MachineFunctionPass(ID), builder(b.release()), customPassID(cPassID) {
9291 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
9392 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
116115 typedef std::map CoalesceMap;
117116 typedef std::set RegSet;
118117
119
120 OwningPtr builder;
118 std::unique_ptr builder;
121119
122120 char *customPassID;
123121
128126 MachineRegisterInfo *mri;
129127 const MachineBlockFrequencyInfo *mbfi;
130128
131 OwningPtr spiller;
129 std::unique_ptr spiller;
132130 LiveIntervals *lis;
133131 LiveStacks *lss;
134132 VirtRegMap *vrm;
190188 MachineRegisterInfo *mri = &mf->getRegInfo();
191189 const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo();
192190
193 OwningPtr p(new PBQPRAProblem());
191 std::unique_ptr p(new PBQPRAProblem());
194192 PBQPRAGraph &g = p->getGraph();
195193 RegSet pregs;
196194
313311 const MachineBlockFrequencyInfo *mbfi,
314312 const RegSet &vregs) {
315313
316 OwningPtr p(PBQPBuilder::build(mf, lis, mbfi, vregs));
314 std::unique_ptr p(PBQPBuilder::build(mf, lis, mbfi, vregs));
317315 PBQPRAGraph &g = p->getGraph();
318316
319317 const TargetMachine &tm = mf->getTarget();
586584 while (!pbqpAllocComplete) {
587585 DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n");
588586
589 OwningPtr problem(
590 builder->build(mf, lis, mbfi, vregsToAlloc));
587 std::unique_ptr problem(
588 builder->build(mf, lis, mbfi, vregsToAlloc));
591589
592590 #ifndef NDEBUG
593591 if (pbqpDumpGraphs) {
621619 return true;
622620 }
623621
624 FunctionPass* llvm::createPBQPRegisterAllocator(
625 OwningPtr &builder,
626 char *customPassID) {
622 FunctionPass *
623 llvm::createPBQPRegisterAllocator(std::unique_ptr &builder,
624 char *customPassID) {
627625 return new RegAllocPBQP(builder, customPassID);
628626 }
629627
630628 FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {
631 OwningPtr Builder;
629 std::unique_ptr Builder;
632630 if (pbqpCoalescing)
633631 Builder.reset(new PBQPBuilderWithCoalescing());
634632 else
1414
1515 #define DEBUG_TYPE "regalloc"
1616 #include "RegisterCoalescer.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/STLExtras.h"
1918 #include "llvm/ADT/SmallSet.h"
2019 #include "llvm/ADT/Statistic.h"
1414 #define DEBUG_TYPE "tailduplication"
1515 #include "llvm/CodeGen/Passes.h"
1616 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/SetVector.h"
1918 #include "llvm/ADT/SmallSet.h"
2019 #include "llvm/ADT/Statistic.h"
6463 const MachineBranchProbabilityInfo *MBPI;
6564 MachineModuleInfo *MMI;
6665 MachineRegisterInfo *MRI;
67 OwningPtr RS;
66 std::unique_ptr RS;
6867 bool PreRegAlloc;
6968
7069 // SSAUpdateVRs - A list of virtual registers for which to update SSA form.
300300 const DataExtractor &DIData = DataExtractor(getInfoSection().Data,
301301 isLittleEndian(), 0);
302302 while (DIData.isValidOffset(offset)) {
303 OwningPtr CU(new DWARFCompileUnit(
303 std::unique_ptr CU(new DWARFCompileUnit(
304304 getDebugAbbrev(), getInfoSection().Data, getAbbrevSection(),
305305 getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
306306 &getInfoSection().Relocs, isLittleEndian()));
320320 const DataExtractor &DIData =
321321 DataExtractor(I->second.Data, isLittleEndian(), 0);
322322 while (DIData.isValidOffset(offset)) {
323 OwningPtr TU(new DWARFTypeUnit(
323 std::unique_ptr TU(new DWARFTypeUnit(
324324 getDebugAbbrev(), I->second.Data, getAbbrevSection(),
325325 getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
326326 &I->second.Relocs, isLittleEndian()));
337337 const DataExtractor &DIData =
338338 DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);
339339 while (DIData.isValidOffset(offset)) {
340 OwningPtr DWOCU(new DWARFCompileUnit(
340 std::unique_ptr DWOCU(new DWARFCompileUnit(
341341 getDebugAbbrevDWO(), getInfoDWOSection().Data, getAbbrevDWOSection(),
342342 getRangeDWOSection(), getStringDWOSection(),
343343 getStringOffsetDWOSection(), getAddrSection(),
358358 const DataExtractor &DIData =
359359 DataExtractor(I->second.Data, isLittleEndian(), 0);
360360 while (DIData.isValidOffset(offset)) {
361 OwningPtr TU(new DWARFTypeUnit(
361 std::unique_ptr TU(new DWARFTypeUnit(
362362 getDebugAbbrevDWO(), I->second.Data, getAbbrevDWOSection(),
363363 getRangeDWOSection(), getStringDWOSection(),
364364 getStringOffsetDWOSection(), getAddrSection(), &I->second.Relocs,
628628 if (!zlib::isAvailable() ||
629629 !consumeCompressedDebugSectionHeader(data, OriginalSize))
630630 continue;
631 OwningPtr UncompressedSection;
631 std::unique_ptr UncompressedSection;
632632 if (zlib::uncompress(data, UncompressedSection, OriginalSize) !=
633633 zlib::StatusOK)
634634 continue;
1717 #include "DWARFDebugRangeList.h"
1818 #include "DWARFTypeUnit.h"
1919 #include "llvm/ADT/MapVector.h"
20 #include "llvm/ADT/OwningPtr.h"
2120 #include "llvm/ADT/SmallVector.h"
2221 #include "llvm/DebugInfo/DIContext.h"
2322
3029 class DWARFContext : public DIContext {
3130 SmallVector CUs;
3231 SmallVector TUs;
33 OwningPtr Abbrev;
34 OwningPtr Loc;
35 OwningPtr Aranges;
36 OwningPtr Line;
37 OwningPtr DebugFrame;
32 std::unique_ptr Abbrev;
33 std::unique_ptr Loc;
34 std::unique_ptr Aranges;
35 std::unique_ptr Line;
36 std::unique_ptr DebugFrame;
3837
3938 SmallVector DWOCUs;
4039 SmallVector DWOTUs;
41 OwningPtr AbbrevDWO;
40 std::unique_ptr AbbrevDWO;
4241
4342 DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION;
4443 DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION;
1313 #include "DWARFDebugInfoEntry.h"
1414 #include "DWARFDebugRangeList.h"
1515 #include "DWARFRelocMap.h"
16 #include "llvm/ADT/OwningPtr.h"
1716 #include
1817
1918 namespace llvm {
4948 std::vector DieArray;
5049
5150 class DWOHolder {
52 OwningPtr DWOFile;
53 OwningPtr DWOContext;
51 std::unique_ptr DWOFile;
52 std::unique_ptr DWOContext;
5453 DWARFUnit *DWOU;
5554 public:
5655 DWOHolder(object::ObjectFile *DWOFile);
5756 DWARFUnit *getUnit() const { return DWOU; }
5857 };
59 OwningPtr DWO;
58 std::unique_ptr DWO;
6059
6160 protected:
6261 virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);
442442 }
443443
444444 ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
445 OwningPtr TheTM(TM); // Take ownership.
445 std::unique_ptr TheTM(TM); // Take ownership.
446446
447447 // Make sure we can resolve symbols in the program as well. The zero arg
448448 // to the function tells DynamicLibrary to load the program, not a library.
1919 #include "llvm/IR/Function.h"
2020 #include "llvm/IR/Metadata.h"
2121 #include "llvm/ADT/DenseMap.h"
22 #include "llvm/ADT/OwningPtr.h"
2322 #include "llvm/CodeGen/MachineFunction.h"
2423 #include "llvm/DebugInfo/DIContext.h"
2524 #include "llvm/ExecutionEngine/ObjectImage.h"
3938 class IntelJITEventListener : public JITEventListener {
4039 typedef DenseMap MethodIDMap;
4140
42 OwningPtr Wrapper;
41 std::unique_ptr Wrapper;
4342 MethodIDMap MethodIDs;
4443 FilenameCache Filenames;
4544
1414 #define DEBUG_TYPE "jit"
1515 #include "JIT.h"
1616 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/SmallPtrSet.h"
1918 #include "llvm/ADT/SmallVector.h"
2019 #include "llvm/ADT/Statistic.h"
145145 PM.add(new DataLayoutPass(M));
146146
147147 // The RuntimeDyld will take ownership of this shortly
148 OwningPtr CompiledObject(new ObjectBufferStream());
148 std::unique_ptr CompiledObject(new ObjectBufferStream());
149149
150150 // Turn the machine code intermediate representation into bytes in memory
151151 // that may be executed.
163163 if (ObjCache) {
164164 // MemoryBuffer is a thin wrapper around the actual memory, so it's OK
165165 // to create a temporary object here and delete it after the call.
166 OwningPtr MB(CompiledObject->getMemBuffer());
166 std::unique_ptr MB(CompiledObject->getMemBuffer());
167167 ObjCache->notifyObjectCompiled(M, MB.get());
168168 }
169169
182182 if (OwnedModules.hasModuleBeenLoaded(M))
183183 return;
184184
185 OwningPtr ObjectToLoad;
185 std::unique_ptr ObjectToLoad;
186186 // Try to load the pre-compiled object from cache if possible
187187 if (0 != ObjCache) {
188 OwningPtr PreCompiledObject(ObjCache->getObject(M));
188 std::unique_ptr PreCompiledObject(ObjCache->getObject(M));
189189 if (0 != PreCompiledObject.get())
190190 ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release()));
191191 }
303303 // Look for our symbols in each Archive
304304 object::Archive::child_iterator ChildIt = A->findSym(Name);
305305 if (ChildIt != A->child_end()) {
306 OwningPtr ChildBin;
306 std::unique_ptr ChildBin;
307307 // FIXME: Support nested archives?
308308 if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) {
309309 object::ObjectFile *OF = reinterpret_cast(
7575
7676 private:
7777 MCJIT *ParentEngine;
78 OwningPtr ClientMM;
78 std::unique_ptr ClientMM;
7979 };
8080
8181 // About Module states: added->loaded->finalized.
1717 #define DEBUG_TYPE "oprofile-jit-event-listener"
1818 #include "llvm/IR/DebugInfo.h"
1919 #include "llvm/IR/Function.h"
20 #include "llvm/ADT/OwningPtr.h"
2120 #include "llvm/CodeGen/MachineFunction.h"
2221 #include "llvm/ExecutionEngine/ObjectImage.h"
2322 #include "llvm/ExecutionEngine/OProfileWrapper.h"
228227
229228 namespace llvm {
230229 JITEventListener *JITEventListener::createOProfileJITEventListener() {
231 static OwningPtr JITProfilingWrapper(new OProfileWrapper);
230 static std::unique_ptr JITProfilingWrapper(
231 new OProfileWrapper);
232232 return new OProfileJITEventListener(*JITProfilingWrapper);
233233 }
234234
9595 ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
9696 MutexGuard locked(lock);
9797
98 OwningPtr Obj(InputObject);
98 std::unique_ptr Obj(InputObject);
9999 if (!Obj)
100100 return NULL;
101101
1515 #include "JITRegistrar.h"
1616 #include "ObjectImageCommon.h"
1717 #include "llvm/ADT/IntervalMap.h"
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/ADT/STLExtras.h"
2019 #include "llvm/ADT/StringRef.h"
2120 #include "llvm/ADT/Triple.h"
1212
1313 #define DEBUG_TYPE "dyld"
1414 #include "RuntimeDyldMachO.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/STLExtras.h"
1716 #include "llvm/ADT/StringRef.h"
1817 using namespace llvm;
1515 #define LLVM_IR_ASSEMBLYWRITER_H
1616
1717 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/IR/Attributes.h"
2019 #include "llvm/IR/Instructions.h"
2120 #include "llvm/IR/TypeFinder.h"
6665 const Module *TheModule;
6766
6867 private:
69 OwningPtr ModuleSlotTracker;
68 std::unique_ptr ModuleSlotTracker;
7069 SlotTracker &Machine;
7170 TypePrinting TypePrinter;
7271 AssemblyAnnotationWriter *AnnotationWriter;
25352535 LLVMMemoryBufferRef *OutMemBuf,
25362536 char **OutMessage) {
25372537
2538 OwningPtr MB;
2538 std::unique_ptr MB;
25392539 error_code ec;
25402540 if (!(ec = MemoryBuffer::getFile(Path, MB))) {
25412541 *OutMemBuf = wrap(MB.release());
25482548
25492549 LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
25502550 char **OutMessage) {
2551 OwningPtr MB;
2551 std::unique_ptr MB;
25522552 error_code ec;
25532553 if (!(ec = MemoryBuffer::getSTDIN(MB))) {
25542554 *OutMemBuf = wrap(MB.release());
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/Support/GCOV.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/STLExtras.h"
1716 #include "llvm/Support/Debug.h"
1817 #include "llvm/Support/FileSystem.h"
471470 for (StringMap::const_iterator I = LineInfo.begin(),
472471 E = LineInfo.end(); I != E; ++I) {
473472 StringRef Filename = I->first();
474 OwningPtr Buff;
473 std::unique_ptr Buff;
475474 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
476475 errs() << Filename << ": " << ec.message() << "\n";
477476 return;
4242 //
4343
4444 Module::Module(StringRef MID, LLVMContext &C)
45 : Context(C), Materializer(NULL), ModuleID(MID), DL("") {
45 : Context(C), Materializer(), ModuleID(MID), DL("") {
4646 ValSymTab = new ValueSymbolTable();
4747 NamedMDSymTab = new StringMap();
4848 Context.addModule(this);
99 #include "llvm/IRReader/IRReader.h"
1010 #include "llvm-c/Core.h"
1111 #include "llvm-c/IRReader.h"
12 #include "llvm/ADT/OwningPtr.h"
1312 #include "llvm/AsmParser/Parser.h"
1413 #include "llvm/Bitcode/ReaderWriter.h"
1514 #include "llvm/IR/LLVMContext.h"
5251
5352 Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err,
5453 LLVMContext &Context) {
55 OwningPtr File;
54 std::unique_ptr File;
5655 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
5756 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
5857 "Could not open input file: " + ec.message());
8584
8685 Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
8786 LLVMContext &Context) {
88 OwningPtr File;
87 std::unique_ptr File;
8988 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) {
9089 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
9190 "Could not open input file: " + ec.message());
263263 delete NativeObjectFile;
264264
265265 // read .o file into memory buffer
266 OwningPtr BuffPtr;
266 std::unique_ptr BuffPtr;
267267 if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
268268 errMsg = ec.message();
269269 sys::fs::remove(NativeObjectPath);
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/LTO/LTOModule.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/Triple.h"
1716 #include "llvm/Bitcode/ReaderWriter.h"
1817 #include "llvm/IR/Constants.h"
7978
8079 bool LTOModule::isBitcodeFileForTarget(const char *path,
8180 const char *triplePrefix) {
82 OwningPtr buffer;
81 std::unique_ptr buffer;
8382 if (MemoryBuffer::getFile(path, buffer))
8483 return false;
8584 return isTargetMatch(buffer.release(), triplePrefix);
9796 /// the buffer.
9897 LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
9998 std::string &errMsg) {
100 OwningPtr buffer;
99 std::unique_ptr buffer;
101100 if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
102101 errMsg = ec.message();
103102 return NULL;
116115 off_t offset,
117116 TargetOptions options,
118117 std::string &errMsg) {
119 OwningPtr buffer;
118 std::unique_ptr buffer;
120119 if (error_code ec =
121120 MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
122121 errMsg = ec.message();
128127 LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
129128 TargetOptions options,
130129 std::string &errMsg, StringRef path) {
131 OwningPtr buffer(makeBuffer(mem, length, path));
130 std::unique_ptr buffer(makeBuffer(mem, length, path));
132131 if (!buffer)
133132 return NULL;
134133 return makeLTOModule(buffer.release(), options, errMsg);
145144 delete buffer;
146145 return NULL;
147146 }
148 OwningPtr m(ModuleOrErr.get());
147 std::unique_ptr m(ModuleOrErr.get());
149148
150149 std::string TripleStr = m->getTargetTriple();
151150 if (TripleStr.empty())
724723 if (inlineAsm.empty())
725724 return false;
726725
727 OwningPtr Streamer(new RecordStreamer(_context));
726 std::unique_ptr Streamer(new RecordStreamer(_context));
728727 MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm);
729728 SourceMgr SrcMgr;
730729 SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
731 OwningPtr Parser(createMCAsmParser(SrcMgr,
732 _context, *Streamer,
733 *_target->getMCAsmInfo()));
730 std::unique_ptr Parser(
731 createMCAsmParser(SrcMgr, _context, *Streamer, *_target->getMCAsmInfo()));
734732 const Target &T = _target->getTarget();
735 OwningPtr MCII(T.createMCInstrInfo());
736 OwningPtr
737 STI(T.createMCSubtargetInfo(_target->getTargetTriple(),
738 _target->getTargetCPU(),
739 _target->getTargetFeatureString()));
740 OwningPtr TAP(T.createMCAsmParser(*STI, *Parser.get(), *MCII));
733 std::unique_ptr MCII(T.createMCInstrInfo());
734 std::unique_ptr STI(T.createMCSubtargetInfo(
735 _target->getTargetTriple(), _target->getTargetCPU(),
736 _target->getTargetFeatureString()));
737 std::unique_ptr TAP(
738 T.createMCAsmParser(*STI, *Parser.get(), *MCII));
741739 if (!TAP) {
742740 errMsg = "target " + std::string(T.getName()) +
743741 " does not define AsmParser.";
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/MC/MCELFObjectWriter.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/ADT/STLExtras.h"
1615 #include "llvm/ADT/SmallPtrSet.h"
1716 #include "llvm/ADT/SmallString.h"
7877 };
7978
8079 /// The target specific ELF writer instance.
81 llvm::OwningPtr TargetObjectWriter;
80 std::unique_ptr TargetObjectWriter;
8281
8382 SmallPtrSet UsedInReloc;
8483 SmallPtrSet WeakrefUsedInReloc;
77 //===----------------------------------------------------------------------===//
88
99 #include "llvm/MC/MCStreamer.h"
10 #include "llvm/ADT/OwningPtr.h"
1110 #include "llvm/ADT/SmallString.h"
1211 #include "llvm/ADT/StringExtras.h"
1312 #include "llvm/ADT/Twine.h"
4039 formatted_raw_ostream &OS;
4140 const MCAsmInfo *MAI;
4241 private:
43 OwningPtr InstPrinter;
44 OwningPtr Emitter;
45 OwningPtr AsmBackend;
42 std::unique_ptr InstPrinter;
43 std::unique_ptr Emitter;
44 std::unique_ptr AsmBackend;
4645
4746 SmallString<128> CommentToEmit;
4847 raw_svector_ostream CommentStream;
7676 if (!DisAsm)
7777 return 0;
7878
79 OwningPtr RelInfo(
80 TheTarget->createMCRelocationInfo(Triple, *Ctx));
79 std::unique_ptr RelInfo(
80 TheTarget->createMCRelocationInfo(Triple, *Ctx));
8181 if (!RelInfo)
8282 return 0;
8383
84 OwningPtr Symbolizer(
85 TheTarget->createMCSymbolizer(Triple, GetOpInfo, SymbolLookUp, DisInfo,
86 Ctx, RelInfo.release()));
84 std::unique_ptr Symbolizer(TheTarget->createMCSymbolizer(
85 Triple, GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo.release()));
8786 DisAsm->setSymbolizer(Symbolizer);
8887 DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo,
8988 Ctx, RelInfo);
1717 #define LLVM_MC_DISASSEMBLER_H
1818
1919 #include "llvm-c/Disassembler.h"
20 #include "llvm/ADT/OwningPtr.h"
2120 #include "llvm/ADT/SmallString.h"
2221 #include "llvm/Support/raw_ostream.h"
2322 #include
5554 // LLVMDisasmInstruction().
5655 //
5756 // The LLVM target corresponding to the disassembler.
58 // FIXME: using llvm::OwningPtr causes a malloc error
57 // FIXME: using std::unique_ptr causes a malloc error
5958 // when this LLVMDisasmContext is deleted.
6059 const Target *TheTarget;
6160 // The assembly information for the target architecture.
62 llvm::OwningPtr MAI;
61 std::unique_ptr MAI;
6362 // The register information for the target architecture.
64 llvm::OwningPtr MRI;
63 std::unique_ptr MRI;
6564 // The subtarget information for the target architecture.
66 llvm::OwningPtr MSI;
65 std::unique_ptr MSI;
6766 // The instruction information for the target architecture.
68 llvm::OwningPtr MII;
67 std::unique_ptr MII;
6968 // The assembly context for creating symbols and MCExprs.
70 llvm::OwningPtr Ctx;
69 std::unique_ptr Ctx;
7170 // The disassembler for the target architecture.
72 llvm::OwningPtr DisAsm;
71 std::unique_ptr DisAsm;
7372 // The instruction printer for the target architecture.
74 llvm::OwningPtr IP;
73 std::unique_ptr IP;
7574 // The options used to set up the disassembler.
7675 uint64_t Options;
7776 // The CPU string.
1515 MCDisassembler::~MCDisassembler() {
1616 }
1717
18 void
19 MCDisassembler::setupForSymbolicDisassembly(
20 LLVMOpInfoCallback GetOpInfo,
21 LLVMSymbolLookupCallback SymbolLookUp,
22 void *DisInfo,
23 MCContext *Ctx,
24 OwningPtr &RelInfo) {
18 void MCDisassembler::setupForSymbolicDisassembly(
19 LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp,
20 void *DisInfo, MCContext *Ctx, std::unique_ptr &RelInfo) {
2521 this->GetOpInfo = GetOpInfo;
2622 this->SymbolLookUp = SymbolLookUp;
2723 this->DisInfo = DisInfo;
3228 SymbolLookUp, DisInfo));
3329 }
3430
35 void
36 MCDisassembler::setupForSymbolicDisassembly(
37 LLVMOpInfoCallback GetOpInfo,
38 LLVMSymbolLookupCallback SymbolLookUp,
39 void *DisInfo,
40 MCContext *Ctx,
41 std::unique_ptr &RelInfo) {
42 OwningPtr MCRI;
31 void MCDisassembler::setupForSymbolicDisassembly(
32 LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp,
33 void *DisInfo, MCContext *Ctx, OwningPtr &RelInfo) {
34 std::unique_ptr MCRI;
4335 setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo, Ctx, MCRI);
44 RelInfo = MCRI.take_unique();
36 RelInfo = std::move(MCRI);
4537 }
4638
4739 bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value,
6254 Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address);
6355 }
6456
65 void MCDisassembler::setSymbolizer(OwningPtr &Symzer) {
57 void MCDisassembler::setSymbolizer(std::unique_ptr &Symzer) {
6658 Symbolizer.reset(Symzer.release());
6759 }
190190 MCRelocationInfo *RelInfo) {
191191 assert(Ctx != 0 && "No MCContext given for symbolic disassembly");
192192
193 OwningPtr RelInfoOwingPtr(RelInfo);
193 std::unique_ptr RelInfoOwingPtr(RelInfo);
194194 return new MCExternalSymbolizer(*Ctx, RelInfoOwingPtr, GetOpInfo,
195195 SymbolLookUp, DisInfo);
196196 }
441441 return "";
442442 }
443443
444 StringRef yaml2mcmodule(OwningPtr &MCM, StringRef YamlContent,
444 StringRef yaml2mcmodule(std::unique_ptr &MCM, StringRef YamlContent,
445445 const MCInstrInfo &MII, const MCRegisterInfo &MRI) {
446446 MCM.reset(new MCModule);
447447 YAML2MCModule Parser(*MCM);
3333 uint64_t StubsIndSymIndex;
3434
3535 public:
36 MCMachObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo,
36 MCMachObjectSymbolizer(MCContext &Ctx,
37 std::unique_ptr &RelInfo,
3738 const MachOObjectFile *MOOF);
3839
3940 StringRef findExternalFunctionAt(uint64_t Addr) override;
4344 };
4445 } // End unnamed namespace
4546
46
47 MCMachObjectSymbolizer::
48 MCMachObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo,
49 const MachOObjectFile *MOOF)
50 : MCObjectSymbolizer(Ctx, RelInfo, MOOF), MOOF(MOOF),
51 StubsStart(0), StubsCount(0), StubSize(0), StubsIndSymIndex(0) {
47 MCMachObjectSymbolizer::MCMachObjectSymbolizer(
48 MCContext &Ctx, std::unique_ptr &RelInfo,
49 const MachOObjectFile *MOOF)
50 : MCObjectSymbolizer(Ctx, RelInfo, MOOF), MOOF(MOOF), StubsStart(0),
51 StubsCount(0), StubSize(0), StubsIndSymIndex(0) {
5252
5353 for (section_iterator SI = MOOF->section_begin(), SE = MOOF->section_end();
5454 SI != SE; ++SI) {
119119
120120 //===- MCObjectSymbolizer -------------------------------------------------===//
121121
122 MCObjectSymbolizer::MCObjectSymbolizer(MCContext &Ctx,
123 OwningPtr &RelInfo,
124 const ObjectFile *Obj)
125 : MCSymbolizer(Ctx, RelInfo), Obj(Obj), SortedSections(), AddrToReloc() {
126 }
122 MCObjectSymbolizer::MCObjectSymbolizer(
123 MCContext &Ctx, std::unique_ptr &RelInfo,
124 const ObjectFile *Obj)
125 : MCSymbolizer(Ctx, RelInfo), Obj(Obj), SortedSections(), AddrToReloc() {}
127126
128127 bool MCObjectSymbolizer::
129128 tryAddingSymbolicOperand(MCInst &MI, raw_ostream &cStream,
187186 return StringRef();
188187 }
189188
190 MCObjectSymbolizer *
191 MCObjectSymbolizer::createObjectSymbolizer(MCContext &Ctx,
192 OwningPtr &RelInfo,
193 const ObjectFile *Obj) {
189 MCObjectSymbolizer *MCObjectSymbolizer::createObjectSymbolizer(
190 MCContext &Ctx, std::unique_ptr &RelInfo,
191 const ObjectFile *Obj) {
194192 if (const MachOObjectFile *MOOF = dyn_cast(Obj))
195193 return new MCMachObjectSymbolizer(Ctx, RelInfo, MOOF);
196194 return new MCObjectSymbolizer(Ctx, RelInfo, Obj);
1111
1212 using namespace llvm;
1313
14 MCSymbolizer::MCSymbolizer(MCContext &Ctx, OwningPtr &RelInfo)
15 : Ctx(Ctx), RelInfo(RelInfo.release()) {
16 }
14 MCSymbolizer::MCSymbolizer(MCContext &Ctx,
15 std::unique_ptr &RelInfo)
16 : Ctx(Ctx), RelInfo(RelInfo.release()) {}
1717
1818 MCSymbolizer::~MCSymbolizer() {
1919 }
1414
1515 #include "llvm/MC/MCWinCOFFObjectWriter.h"
1616 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/StringMap.h"
1918 #include "llvm/ADT/StringRef.h"
2019 #include "llvm/ADT/Twine.h"
124123 typedef DenseMap symbol_map;
125124 typedef DenseMap section_map;
126125
127 llvm::OwningPtr TargetObjectWriter;
126 std::unique_ptr TargetObjectWriter;
128127
129128 // Root level file contents.
130129 COFF::header Header;
4242
4343 ErrorOr object::createBinary(MemoryBuffer *Source,
4444 LLVMContext *Context) {
45 OwningPtr scopedSource(Source);
45 std::unique_ptr scopedSource(Source);
4646 sys::fs::file_magic Type = sys::fs::identify_magic(Source->getBuffer());
4747
4848 switch (Type) {
7979 }
8080
8181 ErrorOr object::createBinary(StringRef Path) {
82 OwningPtr File;
82 std::unique_ptr File;
8383 if (error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File))
8484 return EC;
8585 return createBinary(File.release());
10671067 ErrorOr ObjectFile::createCOFFObjectFile(MemoryBuffer *Object,
10681068 bool BufferOwned) {
10691069 error_code EC;
1070 OwningPtr Ret(new COFFObjectFile(Object, EC, BufferOwned));
1070 std::unique_ptr Ret(
1071 new COFFObjectFile(Object, EC, BufferOwned));
10711072 if (EC)
10721073 return EC;
10731074 return Ret.release();
2323 1ULL << countTrailingZeros(uintptr_t(Obj->getBufferStart()));
2424
2525 error_code EC;
26 OwningPtr R;
26 std::unique_ptr R;
2727 if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB)
2828 #if !LLVM_IS_UNALIGNED_ACCESS_FAST
2929 if (MaxAlignment >= 4)
143143 ErrorOr llvm::object::SymbolicFile::createIRObjectFile(
144144 MemoryBuffer *Object, LLVMContext &Context, bool BufferOwned) {
145145 error_code EC;
146 OwningPtr Ret(
146 std::unique_ptr Ret(
147147 new IRObjectFile(Object, EC, Context, BufferOwned));
148148 if (EC)
149149 return EC;
15481548 bool BufferOwned) {
15491549 StringRef Magic = Buffer->getBuffer().slice(0, 4);
15501550 error_code EC;
1551 OwningPtr Ret;
1551 std::unique_ptr Ret;
15521552 if (Magic == "\xFE\xED\xFA\xCE")
15531553 Ret.reset(new MachOObjectFile(Buffer, false, false, EC, BufferOwned));
15541554 else if (Magic == "\xCE\xFA\xED\xFE")
7171 }
7272
7373 error_code MachOUniversalBinary::ObjectForArch::getAsObjectFile(
74 OwningPtr &Result) const {
74 std::unique_ptr &Result) const {
7575 if (Parent) {
7676 StringRef ParentData = Parent->getData();
7777 StringRef ObjectData = ParentData.substr(Header.offset, Header.size);
9494 ErrorOr
9595 MachOUniversalBinary::create(MemoryBuffer *Source) {
9696 error_code EC;
97 OwningPtr Ret(new MachOUniversalBinary(Source, EC));
97 std::unique_ptr Ret(
98 new MachOUniversalBinary(Source, EC));
9899 if (EC)
99100 return EC;
100101 return Ret.release();
133134 }
134135 }
135136
136 error_code
137 MachOUniversalBinary::getObjectForArch(Triple::ArchType Arch,
138 OwningPtr &Result) const {
137 error_code MachOUniversalBinary::getObjectForArch(
138 Triple::ArchType Arch, std::unique_ptr &Result) const {
139139 MachO::CPUType CTM;
140140 if (!getCTMForArch(Arch, CTM))
141141 return object_error::arch_not_found;
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Object/ObjectFile.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/Support/ErrorHandling.h"
1615 #include "llvm/Support/FileSystem.h"
1716 #include "llvm/Support/MemoryBuffer.h"
8685 }
8786
8887 ErrorOr ObjectFile::createObjectFile(StringRef ObjectPath) {
89 OwningPtr File;
88 std::unique_ptr File;
9089 if (error_code EC = MemoryBuffer::getFile(ObjectPath, File))
9190 return EC;
9291 return createObjectFile(File.release());
1717
1818 #include "llvm/Support/CommandLine.h"
1919 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/OwningPtr.h"
2120 #include "llvm/ADT/SmallPtrSet.h"
2221 #include "llvm/ADT/SmallString.h"
2322 #include "llvm/ADT/StringMap.h"
619618 static bool ExpandResponseFile(const char *FName, StringSaver &Saver,
620619 TokenizerCallback Tokenizer,
621620 SmallVectorImpl &NewArgv) {
622 OwningPtr MemBuf;
621 std::unique_ptr MemBuf;
623622 if (MemoryBuffer::getFile(FName, MemBuf))
624623 return false;
625624 StringRef Str(MemBuf->getBufferStart(), MemBuf->getBufferSize());
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/Compression.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/ADT/StringRef.h"
1615 #include "llvm/Config/config.h"
1716 #include "llvm/Support/Compiler.h"
4746
4847 bool zlib::isAvailable() { return true; }
4948 zlib::Status zlib::compress(StringRef InputBuffer,
50 OwningPtr &CompressedBuffer,
49 std::unique_ptr &CompressedBuffer,
5150 CompressionLevel Level) {
5251 unsigned long CompressedSize = ::compressBound(InputBuffer.size());
53 OwningArrayPtr> TmpBuffer(new char[CompressedSize]);
52 std::unique_ptr> TmpBuffer(new char[CompressedSize]);
5453 int CLevel = encodeZlibCompressionLevel(Level);
5554 Status Res = encodeZlibReturnValue(::compress2(
5655 (Bytef *)TmpBuffer.get(), &CompressedSize,
6564 }
6665
6766 zlib::Status zlib::uncompress(StringRef InputBuffer,
68 OwningPtr &UncompressedBuffer,
67 std::unique_ptr &UncompressedBuffer,
6968 size_t UncompressedSize) {
70 OwningArrayPtr> TmpBuffer(new char[UncompressedSize]);
69 std::unique_ptr> TmpBuffer(new char[UncompressedSize]);
7170 Status Res = encodeZlibReturnValue(
7271 ::uncompress((Bytef *)TmpBuffer.get(), (uLongf *)&UncompressedSize,
7372 (const Bytef *)InputBuffer.data(), InputBuffer.size()));
8786 #else
8887 bool zlib::isAvailable() { return false; }
8988 zlib::Status zlib::compress(StringRef InputBuffer,
90 OwningPtr &CompressedBuffer,
89 std::unique_ptr &CompressedBuffer,
9190 CompressionLevel Level) {
9291 return zlib::StatusUnsupported;
9392 }
9493 zlib::Status zlib::uncompress(StringRef InputBuffer,
95 OwningPtr &UncompressedBuffer,
94 std::unique_ptr &UncompressedBuffer,
9695 size_t UncompressedSize) {
9796 return zlib::StatusUnsupported;
9897 }
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "llvm/Support/FileUtilities.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/SmallString.h"
1716 #include "llvm/Support/MemoryBuffer.h"
1817 #include "llvm/Support/Path.h"
176175 std::string *Error) {
177176 // Now its safe to mmap the files into memory because both files
178177 // have a non-zero size.
179 OwningPtr F1;
178 std::unique_ptr F1;
180179 if (error_code ec = MemoryBuffer::getFile(NameA, F1)) {
181180 if (Error)
182181 *Error = ec.message();
183182 return 2;
184183 }
185 OwningPtr F2;
184 std::unique_ptr F2;
186185 if (error_code ec = MemoryBuffer::getFile(NameB, F2)) {
187186 if (Error)
188187 *Error = ec.message();
3535
3636 // Read the owning host and PID out of the lock file. If it appears that the
3737 // owning process is dead, the lock file is invalid.
38 OwningPtr MB;
38 std::unique_ptr MB;
3939 if (MemoryBuffer::getFile(LockFileName, MB))
4040 return None;
4141
1313 //===----------------------------------------------------------------------===//
1414
1515 #include "llvm/Support/SourceMgr.h"
16 #include "llvm/ADT/OwningPtr.h"
1716 #include "llvm/ADT/SmallString.h"
1817 #include "llvm/ADT/Twine.h"
1918 #include "llvm/Support/Locale.h"
5453 size_t SourceMgr::AddIncludeFile(const std::string &Filename,
5554 SMLoc IncludeLoc,
5655 std::string &IncludedFile) {
57 OwningPtr NewBuf;
56 std::unique_ptr NewBuf;
5857 IncludedFile = Filename;
5958 MemoryBuffer::getFile(IncludedFile.c_str(), NewBuf);
6059
99 #include "llvm/ADT/StringRef.h"
1010 #include "llvm/ADT/APInt.h"
1111 #include "llvm/ADT/Hashing.h"
12 #include "llvm/ADT/OwningPtr.h"
1312 #include "llvm/ADT/edit_distance.h"
1413 #include
1514
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Support/Timer.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/ADT/StringMap.h"
1615 #include "llvm/Support/CommandLine.h"
1716 #include "llvm/Support/Debug.h"
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "WindowsSupport.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/Support/FileSystem.h"
1615 #include
1716 #include
186185 }
187186
188187 // Now build the command line.
189 OwningArrayPtr> command(new char[len+1]);
188 std::unique_ptr> command(new char[len+1]);
190189 char *p = command.get();
191190
192191 for (unsigned i = 0; args[i]; i++) {
15601560 }
15611561
15621562 Stream::Stream(StringRef Input, SourceMgr &SM)
1563 : scanner(new Scanner(Input, SM))
1564 , CurrentDoc(0) {}
1563 : scanner(new Scanner(Input, SM)), CurrentDoc() {}
15651564
15661565 Stream::Stream(MemoryBuffer *InputBuffer, SourceMgr &SM)
1567 : scanner(new Scanner(InputBuffer, SM))
1568 , CurrentDoc(0) {}
1566 : scanner(new Scanner(InputBuffer, SM)), CurrentDoc() {}
15691567
15701568 Stream::~Stream() {}
15711569
16001598 i->skip();
16011599 }
16021600
1603 Node::Node(unsigned int Type, OwningPtr &D, StringRef A, StringRef T)
1604 : Doc(D)
1605 , TypeID(Type)
1606 , Anchor(A)
1607 , Tag(T) {
1601 Node::Node(unsigned int Type, std::unique_ptr &D, StringRef A,
1602 StringRef T)
1603 : Doc(D), TypeID(Type), Anchor(A), Tag(T) {
16081604 SMLoc Start = SMLoc::getFromPointer(peekNext().Range.begin());
16091605 SourceRange = SMRange(Start, Start);
16101606 }
1515 //===----------------------------------------------------------------------===//
1616
1717 #include "TGParser.h"
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/Support/CommandLine.h"
2019 #include "llvm/Support/MemoryBuffer.h"
2120 #include "llvm/Support/ToolOutputFile.h"
8079 RecordKeeper Records;
8180
8281 // Parse the input file.
83 OwningPtr File;
82 std::unique_ptr File;
8483 if (error_code ec =
8584 MemoryBuffer::getFileOrSTDIN(InputFilename, File)) {
8685 errs() << "Could not open input file '" << InputFilename << "': "
1818 #include "llvm/ADT/ArrayRef.h"
1919 #include "llvm/ADT/DenseMap.h"
2020 #include "llvm/ADT/DepthFirstIterator.h"
21 #include "llvm/ADT/OwningPtr.h"
2221 #include "llvm/ADT/SmallSet.h"
2322 #include "llvm/ADT/SmallString.h"
2423 #include "llvm/ADT/SmallVector.h"
348347 Function *AsanHandleNoReturnFunc;
349348 Function *AsanCovFunction;
350349 Function *AsanPtrCmpFunction, *AsanPtrSubFunction;
351 OwningPtr BL;
350 std::unique_ptr BL;
352351 // This array is indexed by AccessIsWrite and log2(AccessSize).
353352 Function *AsanErrorCallback[2][kNumberOfAccessSizes];
354353 // This array is indexed by AccessIsWrite.
385384 bool CheckInitOrder;
386385 SmallString<64> BlacklistFile;
387386
388 OwningPtr BL;
387 std::unique_ptr BL;
389388 SetOfDynamicallyInitializedGlobals DynamicallyInitializedGlobals;
390389 Type *IntptrTy;
391390 LLVMContext *C;
189189 Constant *DFSanSetLabelFn;
190190 Constant *DFSanNonzeroLabelFn;
191191 MDNode *ColdCallWeights;
192 OwningPtr ABIList;
192 std::unique_ptr ABIList;
193193 DenseMap UnwrappedFnMap;
194194 AttributeSet ReadOnlyNoneAttrs;
195195
502502 return true;
503503 }
504504
505 void DebugIR::generateFilename(OwningPtr &fd) {
505 void DebugIR::generateFilename(std::unique_ptr &fd) {
506506 SmallVector PathVec;
507507 fd.reset(new int);
508508 sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec);
523523 }
524524
525525 void DebugIR::writeDebugBitcode(const Module *M, int *fd) {
526 OwningPtr Out;
526 std::unique_ptr Out;
527527 std::string error;
528528
529529 if (!fd) {
541541 Out->close();
542542 }
543543
544 void DebugIR::createDebugInfo(Module &M, OwningPtr &DisplayM) {
544 void DebugIR::createDebugInfo(Module &M, std::unique_ptr &DisplayM) {
545545 if (M.getFunctionList().size() == 0)
546546 // no functions -- no debug info needed
547547 return;
548548
549 OwningPtr VMap;
549 std::unique_ptr VMap;
550550
551551 if (WriteSourceToDisk && (HideDebugIntrinsics || HideDebugMetadata)) {
552552 VMap.reset(new ValueToValueMapTy);
565565 bool DebugIR::isMissingPath() { return Filename.empty() || Directory.empty(); }
566566
567567 bool DebugIR::runOnModule(Module &M) {
568 OwningPtr fd;
568 std::unique_ptr fd;
569569
570570 if (isMissingPath() && !getSourceInfo(M)) {
571571 if (!WriteSourceToDisk)
584584 // file name from the DICompileUnit descriptor.
585585 DebugMetadataRemover::process(M, !ParsedPath);
586586
587 OwningPtr DisplayM;
587 std::unique_ptr DisplayM;
588588 createDebugInfo(M, DisplayM);
589589 if (WriteSourceToDisk) {
590590 Module *OutputM = DisplayM.get() ? DisplayM.get() : &M;
1515 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H
1616 #define LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H
1717
18 #include "llvm/ADT/OwningPtr.h"
1918 #include "llvm/Pass.h"
2019
2120 namespace llvm {
7877 bool updateExtension(llvm::StringRef NewExtension);
7978
8079 /// Generate a temporary filename and open an fd
81 void generateFilename(llvm::OwningPtr &fd);
80 void generateFilename(std::unique_ptr &fd);
8281
8382 /// Creates DWARF CU/Subroutine metadata
8483 void createDebugInfo(llvm::Module &M,
85 llvm::OwningPtr &DisplayM);
84 std::unique_ptr &DisplayM);
8685
8786 /// Returns true if either Directory or Filename is missing, false otherwise.
8887 bool isMissingPath();
686686 Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx);
687687 ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize);
688688
689 OwningArrayPtr EdgeTable(new Constant*[TableSize]);
689 std::unique_ptr EdgeTable(new Constant *[TableSize]);
690690 Constant *NullValue = Constant::getNullValue(Int64PtrTy);
691691 for (size_t i = 0; i != TableSize; ++i)
692692 EdgeTable[i] = NullValue;
271271 /// \brief Path to blacklist file.
272272 SmallString<64> BlacklistFile;
273273 /// \brief The blacklist.
274 OwningPtr BL;
274 std::unique_ptr BL;
275275 /// \brief An empty volatile inline asm that prevents callback merge.
276276 InlineAsm *EmptyAsm;
277277
488488 MemorySanitizer &MS;
489489 SmallVector ShadowPHINodes, OriginPHINodes;
490490 ValueMap ShadowMap, OriginMap;
491 OwningPtr VAHelper;
491 std::unique_ptr VAHelper;
492492
493493 // The following flags disable parts of MSan instrumentation based on
494494 // blacklist contents and command-line options.
9898 const DataLayout *DL;
9999 Type *IntptrTy;
100100 SmallString<64> BlacklistFile;
101 OwningPtr BL;
101 std::unique_ptr BL;
102102 IntegerType *OrdTy;
103103 // Callbacks to run-time library are computed in doInitialization.
104104 Function *TsanFuncEntry;
2525
2626 #include "llvm/Transforms/Scalar.h"
2727 #include "llvm/ADT/DenseMap.h"
28 #include "llvm/ADT/OwningPtr.h"
2928 #include "llvm/ADT/SmallPtrSet.h"
3029 #include "llvm/ADT/SmallSet.h"
3130 #include "llvm/ADT/StringMap.h"
239238 static char ID;
240239
241240 SampleProfileLoader(StringRef Name = SampleProfileFile)
242 : FunctionPass(ID), Profiler(0), Filename(Name) {
241 : FunctionPass(ID), Profiler(), Filename(Name) {
243242 initializeSampleProfileLoaderPass(*PassRegistry::getPassRegistry());
244243 }
245244
260259
261260 protected:
262261 /// \brief Profile reader object.
263 OwningPtr Profiler;
262 std::unique_ptr Profiler;
264263
265264 /// \brief Name of the profile file to load.
266265 StringRef Filename;
398397 /// profiles for large programs, as the representation is extremely
399398 /// inefficient.
400399 void SampleModuleProfile::loadText() {
401 OwningPtr Buffer;
400 std::unique_ptr Buffer;
402401 error_code EC = MemoryBuffer::getFile(Filename, Buffer);
403402 if (EC)
404403 report_fatal_error("Could not open file " + Filename + ": " + EC.message());
1414 //===----------------------------------------------------------------------===//
1515
1616 #include "llvm/Transforms/Utils/SpecialCaseList.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/STLExtras.h"
1918 #include "llvm/ADT/SmallVector.h"
2019 #include "llvm/ADT/StringExtras.h"
5453 const StringRef Path, std::string &Error) {
5554 if (Path.empty())
5655 return new SpecialCaseList();
57 OwningPtr File;
56 std::unique_ptr File;
5857 if (error_code EC = MemoryBuffer::getFile(Path, File)) {
5958 Error = (Twine("Can't open file '") + Path + "': " + EC.message()).str();
6059 return 0;
6463
6564 SpecialCaseList *SpecialCaseList::create(
6665 const MemoryBuffer *MB, std::string &Error) {
67 OwningPtr SCL(new SpecialCaseList());
66 std::unique_ptr SCL(new SpecialCaseList());
6867 if (!SCL->parse(MB, Error))
6968 return 0;
7069 return SCL.release();
121121 outs() << "Read input file : '" << Filenames[0] << "'\n";
122122
123123 for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
124 OwningPtr M(ParseInputFile(Filenames[i], Context));
124 std::unique_ptr M(ParseInputFile(Filenames[i], Context));
125125 if (M.get() == 0) return true;
126126
127127 outs() << "Linking in input file: '" << Filenames[i] << "'\n";
127127 // Ok, so now we know that the prefix passes work, try running the suffix
128128 // passes on the result of the prefix passes.
129129 //
130 OwningPtr PrefixOutput(ParseInputFile(BitcodeResult,
131 BD.getContext()));
130 std::unique_ptr PrefixOutput(
131 ParseInputFile(BitcodeResult, BD.getContext()));
132132 if (!PrefixOutput) {
133133 errs() << BD.getToolName() << ": Error reading bitcode file '"
134134 << BitcodeResult << "'!\n";
144144 << "' passes compile correctly after the '"
145145 << getPassesString(Prefix) << "' passes: ";
146146
147 OwningPtr OriginalInput(BD.swapProgramIn(PrefixOutput.release()));
147 std::unique_ptr OriginalInput(
148 BD.swapProgramIn(PrefixOutput.release()));
148149 if (BD.runPasses(BD.getProgram(), Suffix, BitcodeResult, false/*delete*/,
149150 true/*quiet*/)) {
150151 errs() << " Error running this sequence of passes"
1313
1414 #include "llvm/Config/config.h" // plugin-api.h requires HAVE_STDINT_H
1515 #include "llvm-c/lto.h"
16 #include "llvm/ADT/OwningPtr.h"
1716 #include "llvm/ADT/StringSet.h"
1817 #include "llvm/Support/Errno.h"
1918 #include "llvm/Support/FileSystem.h"
245244 int *claimed) {
246245 lto_module_t M;
247246 const void *view;
248 OwningPtr buffer;
247 std::unique_ptr buffer;
249248 if (get_view) {
250249 if (get_view(file->handle, &view) != LDPS_OK) {
251250 (*message)(LDPL_ERROR, "Failed to get a view of %s", file->name);
205205 static int compileModule(char **argv, LLVMContext &Context) {
206206 // Load the module to be compiled...
207207 SMDiagnostic Err;
208 OwningPtr M;
208 std::unique_ptr M;
209209 Module *mod = 0;
210210 Triple TheTriple;
211211
265265 TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
266266 Options.DisableIntegratedAS = NoIntegratedAssembler;
267267
268 OwningPtr
269 target(TheTarget->createTargetMachine(TheTriple.getTriple(),
270 MCPU, FeaturesStr, Options,
271 RelocModel, CMModel, OLvl));
268 std::unique_ptr target(
269 TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
270 Options, RelocModel, CMModel, OLvl));
272271 assert(target.get() && "Could not allocate target machine!");
273272 assert(mod && "Should have exited after outputting help!");
274273 TargetMachine &Target = *target.get();
283282 FloatABIForCalls = FloatABI::Soft;
284283
285284 // Figure out where we are going to send the output.
286 OwningPtr Out
287 (GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]));
285 std::unique_ptr Out(
286 GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]));
288287 if (!Out) return 1;
289288
290289 // Build up all of the passes that we want to do to the module.
283283 if (!getCacheFilename(ModuleID, CacheName))
284284 return NULL;
285285 // Load the object from the cache filename
286 OwningPtr IRObjectBuffer;
286 std::unique_ptr IRObjectBuffer;
287287 MemoryBuffer::getFile(CacheName.c_str(), IRObjectBuffer, -1, false);
288288 // If the file isn't there, that's OK.
289289 if (!IRObjectBuffer)
536536 }
537537
538538 for (unsigned i = 0, e = ExtraArchives.size(); i != e; ++i) {
539 OwningPtr ArBuf;
539 std::unique_ptr ArBuf;
540540 error_code ec;
541541 ec = MemoryBuffer::getFileOrSTDIN(ExtraArchives[i], ArBuf);
542542 if (ec) {
661661 // address space, assign the section addresses to resolve any relocations,
662662 // and send it to the target.
663663
664 OwningPtr Target;
664 std::unique_ptr Target;
665665 if (!ChildExecPath.empty()) { // Remote execution on a child process
666666 #ifndef LLVM_ON_UNIX
667667 // FIXME: Remove this pointless fallback mode which causes tests to "pass"
769769 MemberBuffers.resize(NewMembers.size());
770770
771771 for (unsigned I = 0, N = NewMembers.size(); I < N; ++I) {
772 OwningPtr MemberBuffer;
772 std::unique_ptr MemberBuffer;
773773 NewArchiveIterator &Member = NewMembers[I];
774774
775775 if (Member.isNewMember()) {
937937
938938 static int performOperation(ArchiveOperation Operation) {
939939 // Create or open the archive object.
940 OwningPtr Buf;
940 std::unique_ptr Buf;
941941 error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false);
942942 if (EC && EC != llvm::errc::no_such_file_or_directory) {
943943 errs() << ToolName << ": error opening '" << ArchiveName
6868 }
6969
7070 std::string ErrorInfo;
71 OwningPtr Out(new tool_output_file(
72 OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
71 std::unique_ptr Out(
72 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
7373 if (!ErrorInfo.empty()) {
7474 errs() << ErrorInfo << '\n';
7575 exit(1);
9292
9393 // Parse the file now...
9494 SMDiagnostic Err;
95 OwningPtr M(ParseAssemblyFile(InputFilename, Err, Context));
95 std::unique_ptr M(ParseAssemblyFile(InputFilename, Err, Context));
9696 if (M.get() == 0) {
9797 Err.print(argv[0], errs());
9898 return 1;
2626 //
2727 //===----------------------------------------------------------------------===//
2828
29 #include "llvm/ADT/OwningPtr.h"
3029 #include "llvm/Bitcode/BitstreamReader.h"
3130 #include "llvm/Bitcode/LLVMBitCodes.h"
3231 #include "llvm/Bitcode/ReaderWriter.h"
478477 /// AnalyzeBitcode - Analyze the bitcode file specified by InputFilename.
479478 static int AnalyzeBitcode() {
480479 // Read the input file.
481 OwningPtr MemBuf;
480 std::unique_ptr MemBuf;
482481
483482 if (error_code ec =
484483 MemoryBuffer::getFileOrSTDIN(InputFilename, MemBuf))
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/ADT/SmallString.h"
1514 #include "llvm/Support/CommandLine.h"
1615 #include "llvm/Support/FileSystem.h"
9594
9695 GCOVFile GF;
9796
98 OwningPtr GCNO_Buff;
97 std::unique_ptr GCNO_Buff;
9998 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
10099 errs() << InputGCNO << ": " << ec.message() << "\n";
101100 return 1;
106105 return 1;
107106 }
108107
109 OwningPtr GCDA_Buff;
108 std::unique_ptr GCDA_Buff;
110109 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
111110 if (ec != errc::no_such_file_or_directory) {
112111 errs() << InputGCDA << ": " << ec.message() << "\n";
122122 cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
123123
124124 std::string ErrorMessage;
125 OwningPtr M;
125 std::unique_ptr M;
126126
127127 // Use the bitcode streaming interface
128128 DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
170170 }
171171
172172 std::string ErrorInfo;
173 OwningPtr Out(new tool_output_file(
174 OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
173 std::unique_ptr Out(
174 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None));
175175 if (!ErrorInfo.empty()) {
176176 errs() << ErrorInfo << '\n';
177177 return 1;
178178 }
179179
180 OwningPtr Annotator;
180 std::unique_ptr Annotator;
181181 if (ShowAnnotations)
182182 Annotator.reset(new CommentWriter());
183183
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/ADT/STLExtras.h"
1514 #include "llvm/ADT/Triple.h"
1615 #include "llvm/DebugInfo/DIContext.h"
8685 }
8786
8887 static void DumpInput(const StringRef &Filename) {
89 OwningPtr Buff;
88 std::unique_ptr Buff;
9089
9190 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
9291 errs() << Filename << ": " << ec.message() << "\n";
9897 errs() << Filename << ": " << EC.message() << '\n';
9998 return;
10099 }
101 OwningPtr Obj(ObjOrErr.get());
100 std::unique_ptr Obj(ObjOrErr.get());
102101
103 OwningPtr DICtx(DIContext::getDWARFContext(Obj.get()));
102 std::unique_ptr DICtx(DIContext::getDWARFContext(Obj.get()));
104103
105104 if (Address == -1ULL) {
106105 outs() << Filename
9999
100100 // Use lazy loading, since we only care about selected global values.
101101 SMDiagnostic Err;
102 OwningPtr M;
102 std::unique_ptr M;
103103 M.reset(getLazyIRFileModule(InputFilename, Err, Context));
104104
105105 if (M.get() == 0) {
1414
1515 #include "llvm/IR/LLVMContext.h"
1616 #include "../../lib/ExecutionEngine/IntelJITEvents/IntelJITEventsWrapper.h"
17 #include "llvm/ADT/OwningPtr.h"
1817 #include "llvm/ADT/Triple.h"
1918 #include "llvm/ExecutionEngine/JITEventListener.h"
2019 #include "llvm/ExecutionEngine/JITMemoryManager.h"
162161 LLVMContext Context; // Global ownership
163162 Module *TheModule; // Owned by ExecutionEngine.
164163 JITMemoryManager *JMM; // Owned by ExecutionEngine.
165 OwningPtr TheJIT;
164 std::unique_ptr TheJIT;
166165
167166 public:
168167 void ProcessInput(const std::string &Filename) {
169168 InitEE(Filename);
170169
171 llvm::OwningPtr Listener(JITEventListener::createIntelJITEventListener(
172 new IntelJITEventsWrapper(NotifyEvent, 0,
173 IsProfilingActive, 0, 0,
174 GetNewMethodID)));
170 std::unique_ptr Listener(
171 JITEventListener::createIntelJITEventListener(new IntelJITEventsWrapper(
172 NotifyEvent, 0, IsProfilingActive, 0, 0, GetNewMethodID)));
175173
176174 TheJIT->RegisterJITEventListener(Listener.get());
177175
8181 unsigned BaseArg = 0;
8282 std::string ErrorMessage;
8383
84 OwningPtr Composite(LoadFile(argv[0],
85 InputFilenames[BaseArg], Context));
84 std::unique_ptr Composite(
85 LoadFile(argv[0], InputFilenames[BaseArg], Context));
8686 if (Composite.get() == 0) {
8787 errs() << argv[0] << ": error loading file '"
8888 << InputFilenames[BaseArg] << "'\n";
9191
9292 Linker L(Composite.get(), SuppressWarnings);
9393 for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
94 OwningPtr M(LoadFile(argv[0], InputFilenames[i], Context));
94 std::unique_ptr M(LoadFile(argv[0], InputFilenames[i], Context));
9595 if (M.get() == 0) {
9696 errs() << argv[0] << ": error loading file '" <
9797 return 1;
9494
9595 for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
9696 std::string error;
97 OwningPtr Module(LTOModule::makeLTOModule(InputFilenames[i].c_str(),
98 Options, error));
97 std::unique_ptr Module(
98 LTOModule::makeLTOModule(InputFilenames[i].c_str(), Options, error));
9999 if (!error.empty()) {
100100 errs() << argv[0] << ": error loading file '" << InputFilenames[i]
101101 << "': " << error << "\n";
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "Disassembler.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/Triple.h"
1716 #include "llvm/MC/MCDisassembler.h"
1817 #include "llvm/MC/MCInst.h"
158157 MemoryBuffer &Buffer,
159158 SourceMgr &SM,
160159 raw_ostream &Out) {
161 OwningPtr DisAsm(T.createMCDisassembler(STI));
160 std::unique_ptr DisAsm(T.createMCDisassembler(STI));
162161 if (!DisAsm) {
163162 errs() << "error: no disassembler for target " << Triple << "\n";
164163 return -1;
1212 //===----------------------------------------------------------------------===//
1313
1414 #include "Disassembler.h"
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/MC/MCAsmBackend.h"
1716 #include "llvm/MC/MCAsmInfo.h"
1817 #include "llvm/MC/MCContext.h"
319318 static int AssembleInput(const char *ProgName, const Target *TheTarget,
320319 SourceMgr &SrcMgr, MCContext &Ctx, MCStreamer &Str,
321320 MCAsmInfo &MAI, MCSubtargetInfo &STI, MCInstrInfo &MCII) {
322 OwningPtr Parser(createMCAsmParser(SrcMgr, Ctx,
323 Str, MAI));
324 OwningPtr TAP(TheTarget->createMCAsmParser(STI, *Parser, MCII));
321 std::unique_ptr Parser(createMCAsmParser(SrcMgr, Ctx, Str, MAI));
322 std::unique_ptr TAP(
323 TheTarget->createMCAsmParser(STI, *Parser, MCII));
325324 if (!TAP) {
326325 errs() << ProgName
327326 << ": error: this target does not support assembly parsing.\n";
362361 if (!TheTarget)
363362 return 1;
364363
365 OwningPtr BufferPtr;
364 std::unique_ptr BufferPtr;
366365 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, BufferPtr)) {
367366 errs() << ProgName << ": " << ec.message() << '\n';
368367 return 1;
378377 // it later.
379378 SrcMgr.setIncludeDirs(IncludeDirs);
380379
381 llvm::OwningPtr MRI(TheTarget->createMCRegInfo(TripleName));
380 std::unique_ptr MRI(TheTarget->createMCRegInfo(TripleName));
382381 assert(MRI && "Unable to create target register info!");
383382
384 llvm::OwningPtr MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
383 std::unique_ptr MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
385384 assert(MAI && "Unable to create target asm info!");
386385
387386 // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
388387 // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
389 OwningPtr MOFI(new MCObjectFileInfo());
388 std::unique_ptr MOFI(new MCObjectFileInfo());
390389 MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
391390 MOFI->InitMCObjectFileInfo(TripleName, RelocModel, CMModel, Ctx);
392391
412411 FeaturesStr = Features.getString();
413412 }
414413
415 OwningPtr Out(GetOutputStream());
414 std::unique_ptr Out(GetOutputStream());
416415 if (!Out)
417416 return 1;
418417
419418 formatted_raw_ostream FOS(Out->os());
420 OwningPtr Str;
421
422 OwningPtr MCII(TheTarget->createMCInstrInfo());
423 OwningPtr
424 STI(TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
419 std::unique_ptr Str;
420
421 std::unique_ptr MCII(TheTarget->createMCInstrInfo());
422 std::unique_ptr STI(
423 TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
425424
426425 MCInstPrinter *IP = NULL;
427426 if (FileType == OFT_AssemblyFile) {
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/Support/CommandLine.h"
1514 #include "llvm/Support/Format.h"
1615 #include "llvm/Support/ManagedStatic.h"
135134 }
136135
137136 static void parseMCMarkup(StringRef Filename) {
138 OwningPtr BufferPtr;
137 std::unique_ptr BufferPtr;
139138 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, BufferPtr)) {
140139 errs() << ToolName << ": " << ec.message() << '\n';
141140 return;
517517 }
518518
519519 static void dumpSymbolNamesFromFile(std::string &Filename) {
520 OwningPtr Buffer;
520 std::unique_ptr Buffer;
521521 if (error(MemoryBuffer::getFileOrSTDIN(Filename, Buffer), Filename))
522522 return;
523523
525525 ErrorOr BinaryOrErr = createBinary(Buffer.release(), &Context);
526526 if (error(BinaryOrErr.getError(), Filename))
527527 return;
528 OwningPtr Bin(BinaryOrErr.get());
528 std::unique_ptr Bin(BinaryOrErr.get());
529529
530530 if (Archive *A = dyn_cast(Bin.get())) {
531531 if (ArchiveMap) {
551551
552552 for (Archive::child_iterator I = A->child_begin(), E = A->child_end();
553553 I != E; ++I) {
554 OwningPtr Child;
554 std::unique_ptr Child;
555555 if (I->getAsBinary(Child, &Context))
556556 continue;
557557 if (SymbolicFile *O = dyn_cast(Child.get())) {
565565 for (MachOUniversalBinary::object_iterator I = UB->begin_objects(),
566566 E = UB->end_objects();
567567 I != E; ++I) {
568 OwningPtr Obj;
568 std::unique_ptr Obj;
569569 if (!I->getAsObjectFile(Obj)) {
570570 outs() << Obj->getFileName() << ":\n";
571571 dumpSymbolNamesFromObject(Obj.get());
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm-objdump.h"
14 #include "llvm/ADT/OwningPtr.h"
1514 #include "llvm/ADT/STLExtras.h"
1615 #include "llvm/ADT/StringExtras.h"
1716 #include "llvm/ADT/Triple.h"
200199 MachOObjectFile *MachOOF);
201200
202201 void llvm::DisassembleInputMachO(StringRef Filename) {
203 OwningPtr Buff;
202 std::unique_ptr Buff;
204203
205204 if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) {
206205 errs() << "llvm-objdump: " << Filename << ": " << ec.message() << "\n";
207206 return;
208207 }
209208
210 OwningPtr MachOOF(static_cast(
209 std::unique_ptr MachOOF(static_cast(
211210 ObjectFile::createMachOObjectFile(Buff.release()).get()));
212211
213212 DisassembleInputMachO2(Filename, MachOOF.get());
220219 // GetTarget prints out stuff.
221220 return;
222221 }
223 OwningPtr InstrInfo(TheTarget->createMCInstrInfo());
224 OwningPtr
225 InstrAnalysis(TheTarget->createMCInstrAnalysis(InstrInfo.get()));
222 std::unique_ptr InstrInfo(TheTarget->createMCInstrInfo());
223 std::unique_ptr InstrAnalysis(
224 TheTarget->createMCInstrAnalysis(InstrInfo.get()));
226225
227226 // Set up disassembler.
228 OwningPtr MRI(TheTarget->createMCRegInfo(TripleName));
229 OwningPtr AsmInfo(
227 std::unique_ptr MRI(
228 TheTarget->createMCRegInfo(TripleName));
229 std::unique_ptr AsmInfo(
230230 TheTarget->createMCAsmInfo(*MRI, TripleName));
231 OwningPtr
232 STI(TheTarget->createMCSubtargetInfo(TripleName, "", ""));
233 OwningPtr DisAsm(TheTarget->createMCDisassembler(*STI));
231 std::unique_ptr STI(
232 TheTarget->createMCSubtargetInfo(TripleName, "", ""));
233 std::unique_ptr DisAsm(
234 TheTarget->createMCDisassembler(*STI));
234235 int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
235 OwningPtr
236 IP(TheTarget->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *InstrInfo,
237 *MRI, *STI));
236 std::unique_ptr IP(TheTarget->createMCInstPrinter(
237 AsmPrinterVariant, *AsmInfo, *InstrInfo, *MRI, *STI));
238238
239239 if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) {
240240 errs() << "error: couldn't initialize disassembler for target "
284284 raw_ostream &DebugOut = nulls();
285285 #endif
286286
287 OwningPtr diContext;
287 std::unique_ptr diContext;
288288 ObjectFile *DbgObj = MachOOF;
289289 // Try to find debug info and set up the DIContext for it.
290290 if (UseDbg) {
291291 // A separate DSym file path was specified, parse it as a macho file,
292292 // get the sections and supply it to the section name parsing machinery.
293293 if (!DSYMFile.empty()) {
294 OwningPtr Buf;
294 std::unique_ptr Buf;
295295 if (error_code ec = MemoryBuffer::getFileOrSTDIN(DSYMFile, Buf)) {
296296 errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
297297 return;
1616 //===----------------------------------------------------------------------===//
1717
1818 #include "llvm-objdump.h"
19 #include "llvm/ADT/OwningPtr.h"
2019 #include "llvm/ADT/STLExtras.h"
2120 #include "llvm/ADT/StringExtras.h"
2221 #include "llvm/ADT/Triple.h"
281280 FeaturesStr = Features.getString();
282281 }
283282
284 OwningPtr MRI(TheTarget->createMCRegInfo(TripleName));
283 std::unique_ptr MRI(
284 TheTarget->createMCRegInfo(TripleName));
285285 if (!MRI) {
286286 errs() << "error: no register info for target " << TripleName << "\n";
287287 return;
288288 }
289289
290290 // Set up disassembler.
291 OwningPtr AsmInfo(
292 TheTarget->createMCAsmInfo(*MRI, TripleName));
291 std::unique_ptr AsmInfo(
292 TheTarget->createMCAsmInfo(*MRI, TripleName));
293293 if (!AsmInfo) {
294294 errs() << "error: no assembly info for target " << TripleName << "\n";
295295 return;
296296 }
297297
298 OwningPtr STI(
299 TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr));
298 std::unique_ptr STI(
299 TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr));
300300 if (!STI) {
301301 errs() << "error: no subtarget info for target " << TripleName << "\n";
302302 return;
303303 }
304304
305 OwningPtr MII(TheTarget->createMCInstrInfo());
305 std::unique_ptr MII(TheTarget->createMCInstrInfo());
306306 if (!MII) {
307307 errs() << "error: no instruction info for target " << TripleName << "\n";
308308 return;
309309 }
310310
311 OwningPtr DisAsm(TheTarget->createMCDisassembler(*STI));
311 std::unique_ptr DisAsm(TheTarget->createMCDisassembler(*STI));
312312 if (!DisAsm) {
313313 errs() << "error: no disassembler for target " << TripleName << "\n";
314314 return;
315315 }
316316
317 OwningPtr MOFI;
318 OwningPtr Ctx;
317 std::unique_ptr MOFI;
318 std::unique_ptr Ctx;
319319
320320 if (Symbolize) {
321321 MOFI.reset(new MCObjectFileInfo);
322322 Ctx.reset(new MCContext(AsmInfo.get(), MRI.get(), MOFI.get()));
323 OwningPtr RelInfo(
324 TheTarget->createMCRelocationInfo(TripleName, *Ctx.get()));
323 std::unique_ptr RelInfo(
324 TheTarget->createMCRelocationInfo(TripleName, *Ctx.get()));
325325 if (RelInfo) {
326 OwningPtr Symzer(
327 MCObjectSymbolizer::createObjectSymbolizer(*Ctx.get(), RelInfo, Obj));
326 std::unique_ptr Symzer(
327 MCObjectSymbolizer::createObjectSymbolizer(*Ctx.get(), RelInfo, Obj));
328328 if (Symzer)
329329 DisAsm->setSymbolizer(Symzer);
330330 }
331331 }
332332
333 OwningPtr
334 MIA(TheTarget->createMCInstrAnalysis(MII.get()));
333 std::unique_ptr MIA(
334 TheTarget->createMCInstrAnalysis(MII.get()));
335335
336336 int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
337 OwningPtr IP(TheTarget->createMCInstPrinter(
337 std::unique_ptr IP(TheTarget->createMCInstPrinter(
338338 AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI));
339339 if (!IP) {
340340 errs() << "error: no instruction printer for target " << TripleName
343343 }
344344
345345 if (CFG || !YAMLCFG.empty()) {
346 OwningPtr OD(
347 new MCObjectDisassembler(*Obj, *DisAsm, *MIA));
348 OwningPtr Mod(OD->buildModule(/* withCFG */ true));
346 std::unique_ptr OD(
347 new MCObjectDisassembler(*Obj, *DisAsm, *MIA));
348 std::unique_ptr Mod(OD->buildModule(/* withCFG */ true));
349349 for (MCModule::const_atom_iterator AI = Mod->atom_begin(),
350350 AE = Mod->atom_end();
351351 AI != AE; ++AI) {
813813 static void DumpArchive(const Archive *a) {
814814 for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
815815 ++i) {
816 OwningPtr child;
816 std::unique_ptr child;
817817 if (error_code EC = i->getAsBinary(child)) {
818818 // Ignore non-object files.
819819 if (EC != object_error::invalid_file_type)
848848 errs() << ToolName << ": '" << file << "': " << EC.message() << ".\n";
849849 return;
850850 }
851 OwningPtr binary(BinaryOrErr.get());
851 std::unique_ptr binary(BinaryOrErr.get());
852852
853853 if (Archive *a = dyn_cast(binary.get()))
854854 DumpArchive(a);
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/ADT/StringRef.h"
1514 #include "llvm/Support/CommandLine.h"
1615 #include "llvm/Support/ManagedStatic.h"
10099
101100 cl::ParseCommandLineOptions(argc, argv, "LLVM profile data merger\n");
102101
103 OwningPtr File1;
104 OwningPtr File2;
102 std::unique_ptr File1;
103 std::unique_ptr File2;
105104 if (error_code ec = MemoryBuffer::getFile(Filename1, File1))
106105 exitWithError(ec.message(), Filename1);
107106 if (error_code ec = MemoryBuffer::getFile(Filename2, File2))
103103
104104 namespace llvm {
105105
106 error_code createCOFFDumper(const object::ObjectFile *Obj,
107 StreamWriter& Writer,
108 OwningPtr &Result) {
106 error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
107 std::unique_ptr &Result) {
109108 const COFFObjectFile *COFFObj = dyn_cast(Obj);
110109 if (!COFFObj)
111110 return readobj_error::unsupported_obj_file_format;
8282 template
8383 static error_code createELFDumper(const ELFFile *Obj,
8484 StreamWriter &Writer,
85 OwningPtr &Result) {
85 std::unique_ptr &Result) {
8686 Result.reset(new ELFDumper(Obj, Writer));
8787 return readobj_error::success;
8888 }
8989
90 error_code createELFDumper(const object::ObjectFile *Obj,
91 StreamWriter& Writer,
92 OwningPtr &Result) {
90 error_code createELFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
91 std::unique_ptr &Result) {
9392 // Little-endian 32-bit
9493 if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj))
9594 return createELFDumper(ELFObj->getELFFile(), Writer, Result);
5555 namespace llvm {
5656
5757 error_code createMachODumper(const object::ObjectFile *Obj,
58 StreamWriter& Writer,
59 OwningPtr &Result) {
58 StreamWriter &Writer,
59 std::unique_ptr &Result) {
6060 const MachOObjectFile *MachOObj = dyn_cast(Obj);
6161 if (!MachOObj)
6262 return readobj_error::unsupported_obj_file_format;
99 #ifndef LLVM_READOBJ_OBJDUMPER_H
1010 #define LLVM_READOBJ_OBJDUMPER_H
1111
12 #include
13
1214 namespace llvm {
1315
1416 namespace object {
1618 }
1719
1820 class error_code;
19
20 template
21 class OwningPtr;
2221
2322 class StreamWriter;
2423
4645 StreamWriter& W;
4746 };
4847
49 error_code createCOFFDumper(const object::ObjectFile *Obj,
50 StreamWriter& Writer,
51 OwningPtr &Result);
48 error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
49 std::unique_ptr &Result);
5250
53 error_code createELFDumper(const object::ObjectFile *Obj,
54 StreamWriter& Writer,
55 OwningPtr &Result);
51 error_code createELFDumper(const object::ObjectFile *Obj, StreamWriter &Writer,
52 std::unique_ptr &Result);
5653
5754 error_code createMachODumper(const object::ObjectFile *Obj,
58 StreamWriter& Writer,
59 OwningPtr &Result);
55 StreamWriter &Writer,
56 std::unique_ptr &Result);
6057
6158 } // namespace llvm
6259
178178 }
179179
180180 /// @brief Creates an format-specific object file dumper.
181 static error_code createDumper(const ObjectFile *Obj,
182 StreamWriter &Writer,
183 OwningPtr &Result) {
181 static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer,
182 std::unique_ptr &Result) {
184183 if (!Obj)
185184 return readobj_error::unsupported_file_format;
186185
198197 /// @brief Dumps the specified object file.
199198 static void dumpObject(const ObjectFile *Obj) {
200199 StreamWriter Writer(outs());
201 OwningPtr Dumper;
200 std::unique_ptr Dumper;
202201 if (error_code EC = createDumper(Obj, Writer, Dumper)) {
203202 reportError(Obj->getFileName(), EC);
204203 return;
243242 for (Archive::child_iterator ArcI = Arc->child_begin(),
244243 ArcE = Arc->child_end();
245244 ArcI != ArcE; ++ArcI) {
246 OwningPtr child;
245 std::unique_ptr child;
247246 if (error_code EC = ArcI->getAsBinary(child)) {
248247 // Ignore non-object files.
249248 if (EC != object_error::invalid_file_type)
273272 reportError(File, EC);
274273 return;
275274 }
276 OwningPtr Binary(BinaryOrErr.get());
275 std::unique_ptr Binary(BinaryOrErr.get());
277276
278277 if (Archive *Arc = dyn_cast(Binary.get()))
279278 dumpArchive(Arc);
1010 //
1111 //===----------------------------------------------------------------------===//
1212
13 #include "llvm/ADT/OwningPtr.h"
1413 #include "llvm/ADT/StringMap.h"
1514 #include "llvm/DebugInfo/DIContext.h"
1615 #include "llvm/ExecutionEngine/ObjectBuffer.h"
132131 RuntimeDyld Dyld(&MemMgr);
133132
134133 // Load the input memory buffer.
135 OwningPtr InputBuffer;
136 OwningPtr LoadedObject;
134 std::unique_ptr InputBuffer;
135 std::unique_ptr LoadedObject;
137136 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFileList[i],
138137 InputBuffer))
139138 return Error("unable to read input: '" + ec.message() + "'");
147146 // Resolve all the relocations we can.
148147 Dyld.resolveRelocations();
149148
150 OwningPtr Context(DIContext::getDWARFContext(LoadedObject->getObjectFile()));
149 std::unique_ptr Context(
150 DIContext::getDWARFContext(LoadedObject->getObjectFile()));
151151
152152 // Use symbol info to iterate functions in the object.
153153 for (object::symbol_iterator I = LoadedObject->begin_symbols(),
190190 InputFileList.push_back("-");
191191 for(unsigned i = 0, e = InputFileList.size(); i != e; ++i) {
192192 // Load the input memory buffer.
193 OwningPtr InputBuffer;
194 OwningPtr LoadedObject;
193 std::unique_ptr InputBuffer;
194 std::unique_ptr LoadedObject;
195195 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFileList[i],
196196 InputBuffer))
197197 return Error("unable to read input: '" + ec.message() + "'");
235235 errs() << ToolName << ": " << file << ": " << EC.message() << ".\n";
236236 return;
237237 }
238 OwningPtr binary(BinaryOrErr.get());
238 std::unique_ptr binary(BinaryOrErr.get());
239239
240240 if (Archive *a = dyn_cast(binary.get())) {
241241 // This is an archive. Iterate over each member and display its sizes.
242242 for (object::Archive::child_iterator i = a->child_begin(),
243243 e = a->child_end(); i != e; ++i) {
244 OwningPtr child;
244 std::unique_ptr child;
245245 if (error_code ec = i->getAsBinary(child)) {
246246 errs() << ToolName << ": " << file << ": " << ec.message() << ".\n";
247247 continue;
1010 // different components in LLVM.
1111 //
1212 //===----------------------------------------------------------------------===//
13 #include "llvm/ADT/OwningPtr.h"
13
1414 #include "llvm/Analysis/CallGraphSCCPass.h"
1515 #include "llvm/IR/Constants.h"
1616 #include "llvm/IR/IRPrintingPasses.h"
624624
625625 // List of modifiers which add new random instructions.
626626 std::vector Modifiers;
627 OwningPtr LM(new LoadModifier(BB, &PT, &R));
628 OwningPtr SM(new StoreModifier(BB, &PT, &R));
629 OwningPtr EE(new ExtractElementModifier(BB, &PT, &R));
630 OwningPtr SHM(new ShuffModifier(BB, &PT, &R));
631 OwningPtr IE(new InsertElementModifier(BB, &PT, &R));
632 OwningPtr BM(new BinModifier(BB, &PT, &R));
633 OwningPtr CM(new CastModifier(BB, &PT, &R));
634 OwningPtr SLM(new SelectModifier(BB, &PT, &R));
635 OwningPtr PM(new CmpModifier(BB, &PT, &R));
627 std::unique_ptr LM(new LoadModifier(BB, &PT, &R));
628 std::unique_ptr SM(new StoreModifier(BB, &PT, &R));
629 std::unique_ptr EE(new ExtractElementModifier(BB, &PT, &R));
630 std::unique_ptr SHM(new ShuffModifier(BB, &PT, &R));
631 std::unique_ptr IE(new InsertElementModifier(BB, &PT, &R));
632 std::unique_ptr BM(new BinModifier(BB, &PT, &R));
633 std::unique_ptr CM(new CastModifier(BB, &PT, &R));
634 std::unique_ptr SLM(new SelectModifier(BB, &PT, &R));
635 std::unique_ptr PM(new CmpModifier(BB, &PT, &R));
636636 Modifiers.push_back(LM.get());
637637 Modifiers.push_back(SM.get());
638638 Modifiers.push_back(EE.get());
686686 cl::ParseCommandLineOptions(argc, argv, "llvm codegen stress-tester\n");
687687 llvm_shutdown_obj Y;
688688
689 OwningPtr M(new Module("/tmp/autogen.bc", getGlobalContext()));
689 std::unique_ptr M(new Module("/tmp/autogen.bc", getGlobalContext()));
690690 Function *F = GenEmptyFunction(M.get());
691691
692692 // Pick an initial seed value
697697 IntroduceControlFlow(F, R);
698698
699699 // Figure out what stream we are supposed to write to...
700 OwningPtr Out;
700 std::unique_ptr Out;
701701 // Default to standard output.
702702 if (OutputFilename.empty())
703703 OutputFilename = "-";
230230 }
231231
232232 static bool checkFileCRC(StringRef Path, uint32_t CRCHash) {
233 OwningPtr MB;
233 std::unique_ptr MB;
234234 if (MemoryBuffer::getFileOrSTDIN(Path, MB))
235235 return false;
236236 return !zlib::isAvailable() || CRCHash == zlib::crc32(MB->getBuffer());
312312 Binary *DbgBin = 0;
313313 ErrorOr BinaryOrErr = createBinary(Path);
314314 if (!error(BinaryOrErr.getError())) {
315 OwningPtr ParsedBinary(BinaryOrErr.get());
315 std::unique_ptr ParsedBinary(BinaryOrErr.get());
316316 // Check if it's a universal binary.
317317 Bin = ParsedBinary.release();
318318 ParsedBinariesAndObjects.push_back(Bin);
360360 std::make_pair(UB, ArchName));
361361 if (I != ObjectFileForArch.end())
362362 return I->second;
363 OwningPtr ParsedObj;
363 std::unique_ptr ParsedObj;
364364 if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
365365 Res = ParsedObj.release();
366366 ParsedBinariesAndObjects.push_back(Res);
1212 #ifndef LLVM_SYMBOLIZE_H
1313 #define LLVM_SYMBOLIZE_H
1414
15 #include "llvm/ADT/OwningPtr.h"
1615 #include "llvm/ADT/SmallVector.h"
1716 #include "llvm/DebugInfo/DIContext.h"
1817 #include "llvm/Object/MachOUniversal.h"
103102 uint64_t &Size) const;
104103 void addSymbol(const symbol_iterator &Sym);
105104 ObjectFile *Module;
106 OwningPtr DebugInfoContext;
105 std::unique_ptr DebugInfoContext;
107106
108107 struct SymbolDesc {
109108 uint64_t Addr;
380380 ErrorOr BinaryOrErr = createBinary(InputFile);
381381 if (error_code EC = BinaryOrErr.getError())
382382 return Error("unable to read input: '" + EC.message() + "'");
383 OwningPtr Binary(BinaryOrErr.get());
383 std::unique_ptr Binary(BinaryOrErr.get());
384384
385385 const MachOObjectFile *InputObject = dyn_cast(Binary.get());
386386 if (!InputObject)
77 //===----------------------------------------------------------------------===//
88
99 #include "obj2yaml.h"
10 #include "llvm/ADT/OwningPtr.h"
1110 #include "llvm/Object/Archive.h"
1211 #include "llvm/Object/COFF.h"
1312 #include "llvm/Support/CommandLine.h"
3736 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
3837
3938 // Process the input file
40 OwningPtr buf;
39 std::unique_ptr buf;
4140
4241 // TODO: If this is an archive, then burst it and dump each entry
4342 if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, buf)) {
355355 SMDiagnostic Err;
356356
357357 // Load the input module...
358 OwningPtr M;
358 std::unique_ptr M;
359359 M.reset(ParseIRFile(InputFilename, Err, Context));
360360
361361 if (M.get() == 0) {
368368 M->setTargetTriple(Triple::normalize(TargetTriple));
369369
370370 // Figure out what stream we are supposed to write to...
371 OwningPtr Out;
371 std::unique_ptr Out;
372372 if (NoOutput) {
373373 if (!OutputFilename.empty())
374374 errs() << "WARNING: The -o (output filename) option is ignored when\n"
441441 TargetMachine *Machine = 0;
442442 if (ModuleTriple.getArch())
443443 Machine = GetTargetMachine(Triple(ModuleTriple));
444 OwningPtr TM(Machine);
444 std::unique_ptr TM(Machine);
445445
446446 // Add internal analysis passes from the target machine.
447447 if (TM.get())
448448 TM->addAnalysisPasses(Passes);
449449
450 OwningPtr FPasses;
450 std::unique_ptr FPasses;
451451 if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
452452 FPasses.reset(new FunctionPassManager(M.get()));
453453 if (DL)
1414 //===----------------------------------------------------------------------===//
1515
1616