diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-07-17 22:34:12 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-07-17 22:34:12 +0000 |
commit | 62a56f39b7c5587a1b2144880500689bea5f32e4 (patch) | |
tree | c6f21dd30c4dfd02f50e4ca54712b24f2022a6f4 /clang/lib/Frontend/FrontendAction.cpp | |
parent | 5bae2c87d5946ee72ad31d88033ed5ecbd01ada2 (diff) | |
download | bcm5719-llvm-62a56f39b7c5587a1b2144880500689bea5f32e4.tar.gz bcm5719-llvm-62a56f39b7c5587a1b2144880500689bea5f32e4.zip |
Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307.
Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.
llvm-svn: 213325
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 3535276e6e9..791017924d6 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -134,10 +134,9 @@ void FrontendAction::setCurrentInput(const FrontendInputFile &CurrentInput, CurrentASTUnit.reset(AST); } -std::unique_ptr<ASTConsumer> -FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, - StringRef InFile) { - std::unique_ptr<ASTConsumer> Consumer = CreateASTConsumer(CI, InFile); +ASTConsumer* FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, + StringRef InFile) { + ASTConsumer* Consumer = CreateASTConsumer(CI, InFile); if (!Consumer) return nullptr; @@ -146,8 +145,7 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, // Make sure the non-plugin consumer is first, so that plugins can't // modifiy the AST. - std::vector<std::unique_ptr<ASTConsumer>> Consumers; - Consumers.push_back(std::move(Consumer)); + std::vector<ASTConsumer*> Consumers(1, Consumer); for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size(); i != e; ++i) { @@ -157,15 +155,16 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI, it = FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end(); it != ie; ++it) { - if (it->getName() != CI.getFrontendOpts().AddPluginActions[i]) - continue; - std::unique_ptr<PluginASTAction> P = it->instantiate(); - if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i])) - Consumers.push_back(P->CreateASTConsumer(CI, InFile)); + if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) { + std::unique_ptr<PluginASTAction> P(it->instantiate()); + FrontendAction* c = P.get(); + if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i])) + Consumers.push_back(c->CreateASTConsumer(CI, InFile)); + } } } - return llvm::make_unique<MultiplexConsumer>(std::move(Consumers)); + return new MultiplexConsumer(Consumers); } bool FrontendAction::BeginSourceFile(CompilerInstance &CI, @@ -308,8 +307,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!usesPreprocessorOnly()) { CI.createASTContext(); - std::unique_ptr<ASTConsumer> Consumer = - CreateWrappedASTConsumer(CI, InputFile); + std::unique_ptr<ASTConsumer> Consumer( + CreateWrappedASTConsumer(CI, InputFile)); if (!Consumer) goto failure; @@ -350,7 +349,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, goto failure; } - CI.setASTConsumer(std::move(Consumer)); + CI.setASTConsumer(Consumer.release()); if (!CI.hasASTConsumer()) goto failure; } @@ -445,7 +444,7 @@ void FrontendAction::EndSourceFile() { CI.resetAndLeakSema(); CI.resetAndLeakASTContext(); } - BuryPointer(CI.takeASTConsumer().get()); + BuryPointer(CI.takeASTConsumer()); } else { if (!isCurrentFileAST()) { CI.setSema(nullptr); @@ -517,15 +516,14 @@ void ASTFrontendAction::ExecuteAction() { void PluginASTAction::anchor() { } -std::unique_ptr<ASTConsumer> +ASTConsumer * PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { llvm_unreachable("Invalid CreateASTConsumer on preprocessor action!"); } -std::unique_ptr<ASTConsumer> -WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { +ASTConsumer *WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) { return WrappedAction->CreateASTConsumer(CI, InFile); } bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) { |