diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-15 21:49:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-15 21:49:36 +0000 |
commit | 86b6f742171d94cc23e9773429ed9cc33dde4857 (patch) | |
tree | 3d480aa138f8d81a0c91faf64d45d6acd7dec0ea /clang/lib/Frontend/FrontendActions.cpp | |
parent | b4db660cff42462e3b312eb27923cbe670cc746e (diff) | |
download | llvm-86b6f742171d94cc23e9773429ed9cc33dde4857.zip llvm-86b6f742171d94cc23e9773429ed9cc33dde4857.tar.gz llvm-86b6f742171d94cc23e9773429ed9cc33dde4857.tar.bz2 |
Split GenerateModuleAction into its own action, which will start
differing from GeneratePCHAction fairly soon.
llvm-svn: 144703
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 6f84da9..2fcbc67 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -85,7 +85,7 @@ ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, if (!CI.getFrontendOpts().RelocatablePCH) Sysroot.clear(); - return new PCHGenerator(CI.getPreprocessor(), OutputFile, MakeModule, + return new PCHGenerator(CI.getPreprocessor(), OutputFile, /*Module=*/false, Sysroot, OS); } @@ -113,6 +113,44 @@ bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, return false; } +ASTConsumer *GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) { + std::string Sysroot; + std::string OutputFile; + raw_ostream *OS = 0; + if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS)) + return 0; + + if (!CI.getFrontendOpts().RelocatablePCH) + Sysroot.clear(); + return new PCHGenerator(CI.getPreprocessor(), OutputFile, /*Module=*/true, + Sysroot, OS); +} + +bool GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI, + StringRef InFile, + std::string &Sysroot, + std::string &OutputFile, + raw_ostream *&OS) { + Sysroot = CI.getHeaderSearchOpts().Sysroot; + if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) { + CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot); + return true; + } + + // 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. + OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true, + /*RemoveFileOnSignal=*/false, InFile, + /*Extension=*/"", /*useTemporary=*/true); + if (!OS) + return true; + + OutputFile = CI.getFrontendOpts().OutputFile; + return false; +} + ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { return new ASTConsumer(); |