diff options
Diffstat (limited to 'tools/libclang/Indexing.cpp')
-rw-r--r-- | tools/libclang/Indexing.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/tools/libclang/Indexing.cpp b/tools/libclang/Indexing.cpp index 58af618..20f4474 100644 --- a/tools/libclang/Indexing.cpp +++ b/tools/libclang/Indexing.cpp @@ -414,8 +414,8 @@ public: : IndexCtx(clientData, indexCallbacks, indexOptions, cxTU), CXTU(cxTU), SKData(skData) { } - ASTConsumer *CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override { + std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override { PreprocessorOptions &PPOpts = CI.getPreprocessorOpts(); if (!PPOpts.ImplicitPCHInclude.empty()) { @@ -425,17 +425,16 @@ public: IndexCtx.setASTContext(CI.getASTContext()); Preprocessor &PP = CI.getPreprocessor(); - PP.addPPCallbacks(new IndexPPCallbacks(PP, IndexCtx)); + PP.addPPCallbacks(llvm::make_unique<IndexPPCallbacks>(PP, IndexCtx)); IndexCtx.setPreprocessor(PP); if (SKData) { - PPConditionalDirectiveRecord * - PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager()); - PP.addPPCallbacks(PPRec); - SKCtrl.reset(new TUSkipBodyControl(*SKData, *PPRec, PP)); + auto *PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager()); + PP.addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec)); + SKCtrl = llvm::make_unique<TUSkipBodyControl>(*SKData, *PPRec, PP); } - return new IndexingConsumer(IndexCtx, SKCtrl.get()); + return llvm::make_unique<IndexingConsumer>(IndexCtx, SKCtrl.get()); } void EndSourceFileAction() override { @@ -576,10 +575,10 @@ static void clang_indexSourceFile_Impl(void *UserData) { BufOwner.get()); for (auto &UF : ITUI->unsaved_files) { - llvm::MemoryBuffer *MB = + std::unique_ptr<llvm::MemoryBuffer> MB = llvm::MemoryBuffer::getMemBufferCopy(getContents(UF), UF.Filename); - BufOwner->push_back(std::unique_ptr<llvm::MemoryBuffer>(MB)); - CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB); + CInvok->getPreprocessorOpts().addRemappedFile(UF.Filename, MB.get()); + BufOwner->push_back(std::move(MB)); } // Since libclang is primarily used by batch tools dealing with |