summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-10 19:56:51 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-10 19:56:51 +0000
commit6beb6aa8f0f6fa20e8c8de7a17f39b101ed0da59 (patch)
tree584157687d5fd851d1afa4ca2e217973ff095555 /clang/lib/Frontend/FrontendActions.cpp
parent4422df6fa321019aad77ea3a1aacff3fcf6d0280 (diff)
downloadbcm5719-llvm-6beb6aa8f0f6fa20e8c8de7a17f39b101ed0da59.tar.gz
bcm5719-llvm-6beb6aa8f0f6fa20e8c8de7a17f39b101ed0da59.zip
Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)
After post-commit review and community discussion, this seems like a reasonable direction to continue, making ownership semantics explicit in the source using the type system. llvm-svn: 215323
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp63
1 files changed, 33 insertions, 30 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 3c247071507..903abe2d61f 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -33,9 +33,9 @@ using namespace clang;
// Custom Actions
//===----------------------------------------------------------------------===//
-ASTConsumer *InitOnlyAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return new ASTConsumer();
+std::unique_ptr<ASTConsumer>
+InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
+ return llvm::make_unique<ASTConsumer>();
}
void InitOnlyAction::ExecuteAction() {
@@ -45,36 +45,37 @@ void InitOnlyAction::ExecuteAction() {
// AST Consumer Actions
//===----------------------------------------------------------------------===//
-ASTConsumer *ASTPrintAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
return CreateASTPrinter(OS, CI.getFrontendOpts().ASTDumpFilter);
return nullptr;
}
-ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
CI.getFrontendOpts().ASTDumpLookups);
}
-ASTConsumer *ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTDeclNodeLister();
}
-ASTConsumer *ASTViewAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+ASTViewAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
return CreateASTViewer();
}
-ASTConsumer *DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
return CreateDeclContextPrinter();
}
-ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::string Sysroot;
std::string OutputFile;
raw_ostream *OS = nullptr;
@@ -83,8 +84,8 @@ ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI,
if (!CI.getFrontendOpts().RelocatablePCH)
Sysroot.clear();
- return new PCHGenerator(CI.getPreprocessor(), OutputFile, nullptr, Sysroot,
- OS);
+ return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
+ nullptr, Sysroot, OS);
}
bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
@@ -111,16 +112,17 @@ bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
return false;
}
-ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
+std::unique_ptr<ASTConsumer>
+GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
std::string Sysroot;
std::string OutputFile;
raw_ostream *OS = nullptr;
if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS))
return nullptr;
- return new PCHGenerator(CI.getPreprocessor(), OutputFile, Module,
- Sysroot, OS);
+ return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(), OutputFile,
+ Module, Sysroot, OS);
}
static SmallVectorImpl<char> &
@@ -365,19 +367,20 @@ bool GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI,
return false;
}
-ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return new ASTConsumer();
+std::unique_ptr<ASTConsumer>
+SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
+ return llvm::make_unique<ASTConsumer>();
}
-ASTConsumer *DumpModuleInfoAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return new ASTConsumer();
+std::unique_ptr<ASTConsumer>
+DumpModuleInfoAction::CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) {
+ return llvm::make_unique<ASTConsumer>();
}
-ASTConsumer *VerifyPCHAction::CreateASTConsumer(CompilerInstance &CI,
- StringRef InFile) {
- return new ASTConsumer();
+std::unique_ptr<ASTConsumer>
+VerifyPCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
+ return llvm::make_unique<ASTConsumer>();
}
void VerifyPCHAction::ExecuteAction() {
OpenPOWER on IntegriCloud