diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-07-17 20:40:36 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-07-17 20:40:36 +0000 |
| commit | a51666a4d624a745df90e1c84777fb7a644ff80b (patch) | |
| tree | 27a6715358a552387f3e0fd041de88a3095d0a35 /clang/tools | |
| parent | fa59e620126114e35477299dbb726c4e85195276 (diff) | |
| download | bcm5719-llvm-a51666a4d624a745df90e1c84777fb7a644ff80b.tar.gz bcm5719-llvm-a51666a4d624a745df90e1c84777fb7a644ff80b.zip | |
unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)
llvm-svn: 213307
Diffstat (limited to 'clang/tools')
| -rw-r--r-- | clang/tools/clang-check/ClangCheck.cpp | 5 | ||||
| -rw-r--r-- | clang/tools/libclang/Indexing.cpp | 11 |
2 files changed, 8 insertions, 8 deletions
diff --git a/clang/tools/clang-check/ClangCheck.cpp b/clang/tools/clang-check/ClangCheck.cpp index cc8d43cec22..df3b4e0d950 100644 --- a/clang/tools/clang-check/ClangCheck.cpp +++ b/clang/tools/clang-check/ClangCheck.cpp @@ -28,6 +28,7 @@ #include "llvm/Option/OptTable.h" #include "llvm/Support/Path.h" #include "llvm/Support/Signals.h" +#include "llvm/ADT/STLExtras.h" using namespace clang::driver; using namespace clang::tooling; @@ -179,14 +180,14 @@ private: namespace clang_check { class ClangCheckActionFactory { public: - clang::ASTConsumer *newASTConsumer() { + std::unique_ptr<clang::ASTConsumer> newASTConsumer() { if (ASTList) return clang::CreateASTDeclNodeLister(); if (ASTDump) return clang::CreateASTDumper(ASTDumpFilter); if (ASTPrint) return clang::CreateASTPrinter(&llvm::outs(), ASTDumpFilter); - return new clang::ASTConsumer(); + return llvm::make_unique<clang::ASTConsumer>(); } }; } diff --git a/clang/tools/libclang/Indexing.cpp b/clang/tools/libclang/Indexing.cpp index 58af61811bf..f347f9f3454 100644 --- a/clang/tools/libclang/Indexing.cpp +++ b/clang/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()) { @@ -429,13 +429,12 @@ public: IndexCtx.setPreprocessor(PP); if (SKData) { - PPConditionalDirectiveRecord * - PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager()); + auto *PPRec = new PPConditionalDirectiveRecord(PP.getSourceManager()); PP.addPPCallbacks(PPRec); - SKCtrl.reset(new TUSkipBodyControl(*SKData, *PPRec, PP)); + 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 { |

