diff options
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 6ddb316fd08..b1e806add8c 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -48,8 +48,9 @@ void InitOnlyAction::ExecuteAction() { std::unique_ptr<ASTConsumer> ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { - if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile)) - return CreateASTPrinter(OS, CI.getFrontendOpts().ASTDumpFilter); + if (std::unique_ptr<raw_ostream> OS = + CI.createDefaultOutputFile(false, InFile)) + return CreateASTPrinter(std::move(OS), CI.getFrontendOpts().ASTDumpFilter); return nullptr; } @@ -80,7 +81,7 @@ std::unique_ptr<ASTConsumer> GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; std::string OutputFile; - raw_pwrite_stream *OS = + std::unique_ptr<raw_pwrite_stream> OS = ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile); if (!OS) return nullptr; @@ -97,14 +98,16 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { /*IncludeTimestamps*/ +CI.getFrontendOpts().IncludeTimestamps)); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( - CI, InFile, OutputFile, OS, Buffer)); + CI, InFile, OutputFile, std::move(OS), Buffer)); return llvm::make_unique<MultiplexConsumer>(std::move(Consumers)); } -raw_pwrite_stream *GeneratePCHAction::ComputeASTConsumerArguments( - CompilerInstance &CI, StringRef InFile, std::string &Sysroot, - std::string &OutputFile) { +std::unique_ptr<raw_pwrite_stream> +GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, + StringRef InFile, + std::string &Sysroot, + std::string &OutputFile) { Sysroot = CI.getHeaderSearchOpts().Sysroot; if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) { CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot); @@ -114,7 +117,7 @@ raw_pwrite_stream *GeneratePCHAction::ComputeASTConsumerArguments( // We use createOutputFile here because this is exposed via libclang, and we // must disable the RemoveFileOnSignal behavior. // We use a temporary to avoid race conditions. - raw_pwrite_stream *OS = + std::unique_ptr<raw_pwrite_stream> OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true, /*RemoveFileOnSignal=*/false, InFile, /*Extension=*/"", /*useTemporary=*/true); @@ -130,7 +133,7 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; std::string OutputFile; - raw_pwrite_stream *OS = + std::unique_ptr<raw_pwrite_stream> OS = ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile); if (!OS) return nullptr; @@ -145,7 +148,7 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, /*IncludeTimestamps=*/ +CI.getFrontendOpts().BuildingImplicitModule)); Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator( - CI, InFile, OutputFile, OS, Buffer)); + CI, InFile, OutputFile, std::move(OS), Buffer)); return llvm::make_unique<MultiplexConsumer>(std::move(Consumers)); } @@ -378,9 +381,11 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, return true; } -raw_pwrite_stream *GenerateModuleAction::ComputeASTConsumerArguments( - CompilerInstance &CI, StringRef InFile, std::string &Sysroot, - std::string &OutputFile) { +std::unique_ptr<raw_pwrite_stream> +GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI, + StringRef InFile, + std::string &Sysroot, + std::string &OutputFile) { // If no output file was provided, figure out where this module would go // in the module cache. if (CI.getFrontendOpts().OutputFile.empty()) { @@ -393,7 +398,7 @@ raw_pwrite_stream *GenerateModuleAction::ComputeASTConsumerArguments( // We use createOutputFile here because this is exposed via libclang, and we // must disable the RemoveFileOnSignal behavior. // We use a temporary to avoid race conditions. - raw_pwrite_stream *OS = + std::unique_ptr<raw_pwrite_stream> OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true, /*RemoveFileOnSignal=*/false, InFile, /*Extension=*/"", /*useTemporary=*/true, @@ -647,11 +652,12 @@ void DumpTokensAction::ExecuteAction() { void GeneratePTHAction::ExecuteAction() { CompilerInstance &CI = getCompilerInstance(); - raw_pwrite_stream *OS = CI.createDefaultOutputFile(true, getCurrentFile()); + std::unique_ptr<raw_pwrite_stream> OS = + CI.createDefaultOutputFile(true, getCurrentFile()); if (!OS) return; - CacheTokens(CI.getPreprocessor(), OS); + CacheTokens(CI.getPreprocessor(), OS.get()); } void PreprocessOnlyAction::ExecuteAction() { @@ -712,10 +718,11 @@ void PrintPreprocessedAction::ExecuteAction() { } } - raw_ostream *OS = CI.createDefaultOutputFile(BinaryMode, getCurrentFile()); + std::unique_ptr<raw_ostream> OS = + CI.createDefaultOutputFile(BinaryMode, getCurrentFile()); if (!OS) return; - DoPrintPreprocessedInput(CI.getPreprocessor(), OS, + DoPrintPreprocessedInput(CI.getPreprocessor(), OS.get(), CI.getPreprocessorOutputOpts()); } |