Return a pointer instead of having a pointer outparam and a bool return.
llvm-svn: 234590
This commit is contained in:
@@ -85,11 +85,10 @@ public:
|
|||||||
/// create the PCHGenerator instance returned by CreateASTConsumer.
|
/// create the PCHGenerator instance returned by CreateASTConsumer.
|
||||||
///
|
///
|
||||||
/// \returns true if an error occurred, false otherwise.
|
/// \returns true if an error occurred, false otherwise.
|
||||||
static bool ComputeASTConsumerArguments(CompilerInstance &CI,
|
static raw_ostream *ComputeASTConsumerArguments(CompilerInstance &CI,
|
||||||
StringRef InFile,
|
StringRef InFile,
|
||||||
std::string &Sysroot,
|
std::string &Sysroot,
|
||||||
std::string &OutputFile,
|
std::string &OutputFile);
|
||||||
raw_ostream *&OS);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class GenerateModuleAction : public ASTFrontendAction {
|
class GenerateModuleAction : public ASTFrontendAction {
|
||||||
|
|||||||
@@ -966,9 +966,9 @@ PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
|
|||||||
StringRef InFile) {
|
StringRef InFile) {
|
||||||
std::string Sysroot;
|
std::string Sysroot;
|
||||||
std::string OutputFile;
|
std::string OutputFile;
|
||||||
raw_ostream *OS = nullptr;
|
raw_ostream *OS = GeneratePCHAction::ComputeASTConsumerArguments(
|
||||||
if (GeneratePCHAction::ComputeASTConsumerArguments(CI, InFile, Sysroot,
|
CI, InFile, Sysroot, OutputFile);
|
||||||
OutputFile, OS))
|
if (!OS)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!CI.getFrontendOpts().RelocatablePCH)
|
if (!CI.getFrontendOpts().RelocatablePCH)
|
||||||
|
|||||||
@@ -79,8 +79,9 @@ std::unique_ptr<ASTConsumer>
|
|||||||
GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
|
GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
|
||||||
std::string Sysroot;
|
std::string Sysroot;
|
||||||
std::string OutputFile;
|
std::string OutputFile;
|
||||||
raw_ostream *OS = nullptr;
|
raw_ostream *OS =
|
||||||
if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile, OS))
|
ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile);
|
||||||
|
if (!OS)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (!CI.getFrontendOpts().RelocatablePCH)
|
if (!CI.getFrontendOpts().RelocatablePCH)
|
||||||
@@ -89,28 +90,27 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
|
|||||||
nullptr, Sysroot, OS);
|
nullptr, Sysroot, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI,
|
raw_ostream *GeneratePCHAction::ComputeASTConsumerArguments(
|
||||||
StringRef InFile,
|
CompilerInstance &CI, StringRef InFile, std::string &Sysroot,
|
||||||
std::string &Sysroot,
|
std::string &OutputFile) {
|
||||||
std::string &OutputFile,
|
|
||||||
raw_ostream *&OS) {
|
|
||||||
Sysroot = CI.getHeaderSearchOpts().Sysroot;
|
Sysroot = CI.getHeaderSearchOpts().Sysroot;
|
||||||
if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
|
if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) {
|
||||||
CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
|
CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot);
|
||||||
return true;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use createOutputFile here because this is exposed via libclang, and we
|
// We use createOutputFile here because this is exposed via libclang, and we
|
||||||
// must disable the RemoveFileOnSignal behavior.
|
// must disable the RemoveFileOnSignal behavior.
|
||||||
// We use a temporary to avoid race conditions.
|
// We use a temporary to avoid race conditions.
|
||||||
OS = CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
|
raw_ostream *OS =
|
||||||
/*RemoveFileOnSignal=*/false, InFile,
|
CI.createOutputFile(CI.getFrontendOpts().OutputFile, /*Binary=*/true,
|
||||||
/*Extension=*/"", /*useTemporary=*/true);
|
/*RemoveFileOnSignal=*/false, InFile,
|
||||||
|
/*Extension=*/"", /*useTemporary=*/true);
|
||||||
if (!OS)
|
if (!OS)
|
||||||
return true;
|
return nullptr;
|
||||||
|
|
||||||
OutputFile = CI.getFrontendOpts().OutputFile;
|
OutputFile = CI.getFrontendOpts().OutputFile;
|
||||||
return false;
|
return OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ASTConsumer>
|
std::unique_ptr<ASTConsumer>
|
||||||
|
|||||||
Reference in New Issue
Block a user